Skip to content

Commit 3ab9e76

Browse files
committed
generalize testing of multiple components
1 parent d807261 commit 3ab9e76

File tree

2 files changed

+202
-100
lines changed

2 files changed

+202
-100
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,56 @@ static ModelExporter Create ()
125125
return new ModelExporter ();
126126
}
127127

128+
/// <summary>
129+
/// Which components map from Unity Object to Fbx Object
130+
/// </summary>
131+
///
132+
public enum FbxNodeRelationType
133+
{
134+
NodeAttribute,
135+
Property,
136+
Material
137+
}
138+
139+
public static Dictionary<System.Type, KeyValuePair<System.Type,FbxNodeRelationType>> MapsToFbxObject = new Dictionary<System.Type, KeyValuePair<System.Type,FbxNodeRelationType>> ()
140+
{
141+
{ typeof(Transform), new KeyValuePair<System.Type, FbxNodeRelationType>(typeof(FbxProperty), FbxNodeRelationType.Property) },
142+
{ typeof(MeshFilter), new KeyValuePair<System.Type, FbxNodeRelationType>(typeof(FbxMesh), FbxNodeRelationType.NodeAttribute) },
143+
{ typeof(SkinnedMeshRenderer), new KeyValuePair<System.Type, FbxNodeRelationType>(typeof(FbxMesh), FbxNodeRelationType.NodeAttribute) },
144+
{ typeof(Light), new KeyValuePair<System.Type, FbxNodeRelationType>(typeof(FbxLight), FbxNodeRelationType.NodeAttribute) },
145+
{ typeof(Camera), new KeyValuePair<System.Type, FbxNodeRelationType>(typeof(FbxCamera), FbxNodeRelationType.NodeAttribute) },
146+
{ typeof(Material), new KeyValuePair<System.Type, FbxNodeRelationType>(typeof(FbxSurfaceMaterial), FbxNodeRelationType.Material) },
147+
};
148+
149+
/// <summary>
150+
/// Return True is Unity component is animatable
151+
///
152+
public static bool IsAnimatable (System.Type componentType) { return GetAnimatableProperties (componentType).Any (); }
153+
154+
private static HashSet<System.Type> m_animatableTypes = new HashSet<System.Type> () { typeof (System.Single) };
155+
156+
public static IEnumerable<System.Reflection.PropertyInfo> GetAnimatableProperties (System.Type componentType)
157+
{
158+
return from p in componentType.GetProperties ()
159+
where IsAnimatableProperty (p)
160+
select p;
161+
}
162+
163+
private static bool IsAnimatableProperty (System.Reflection.PropertyInfo p)
164+
{
165+
// assume any custom attribute is System.ObsoleteAttribute
166+
return m_animatableTypes.Contains (p.PropertyType) &&
167+
!p.GetCustomAttributes (true).Any ();
168+
}
169+
170+
/// <summary>
171+
/// Which components map to FbxProperty
172+
/// </summary>
173+
public static HashSet<System.Type> MapsToFbxProperty = new HashSet<System.Type> ()
174+
{
175+
typeof(Transform),
176+
};
177+
128178
/// <summary>
129179
/// Map Unity material name to FBX material object
130180
/// </summary>
@@ -2273,7 +2323,7 @@ public void Dispose ()
22732323
{
22742324
}
22752325

2276-
public bool Verbose { private set {;} get { return false; } }
2326+
public bool Verbose { private set {;} get { return true; } }
22772327

22782328
/// <summary>
22792329
/// manage the selection of a filename

0 commit comments

Comments
 (0)