Skip to content

Commit 468f57c

Browse files
author
DESKTOP-F8VO8FK\Austin
committed
[ADDED] color (3 channels) test added
[REMOVED] conditions for mapping that we don't need for these cases
1 parent 1c906e9 commit 468f57c

File tree

2 files changed

+72
-11
lines changed

2 files changed

+72
-11
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,37 +1030,31 @@ public static bool TryGetValue(string unityPropertyName, out FbxPropertyChannelP
10301030
return true;
10311031
}
10321032

1033-
if (unityPropertyName.StartsWith("m_Intensity", ct) || unityPropertyName.EndsWith("T.z", ct))
1033+
if (unityPropertyName.StartsWith("m_Intensity", ct))
10341034
{
10351035
prop = new FbxPropertyChannelPair("Intensity", null);
10361036
return true;
10371037
}
10381038

1039-
if (unityPropertyName.StartsWith("m_SpotAngle", ct) || unityPropertyName.EndsWith("T.z", ct))
1039+
if (unityPropertyName.StartsWith("m_SpotAngle", ct))
10401040
{
10411041
prop = new FbxPropertyChannelPair("OuterAngle", null);
10421042
return true;
10431043
}
10441044

1045-
if (unityPropertyName.StartsWith("m_Color", ct) || unityPropertyName.EndsWith("T.z", ct))
1046-
{
1047-
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR);
1048-
return true;
1049-
}
1050-
1051-
if (unityPropertyName.StartsWith("m_Color.r", ct) || unityPropertyName.EndsWith("T.z", ct))
1045+
if (unityPropertyName.StartsWith("m_Color.r", ct))
10521046
{
10531047
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_RED);
10541048
return true;
10551049
}
10561050

1057-
if (unityPropertyName.StartsWith("m_Color.g", ct) || unityPropertyName.EndsWith("T.z", ct))
1051+
if (unityPropertyName.StartsWith("m_Color.g", ct))
10581052
{
10591053
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_GREEN);
10601054
return true;
10611055
}
10621056

1063-
if (unityPropertyName.StartsWith("m_Color.b", ct) || unityPropertyName.EndsWith("T.z", ct))
1057+
if (unityPropertyName.StartsWith("m_Color.b", ct))
10641058
{
10651059
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_BLUE);
10661060
return true;

Assets/FbxExporters/Editor/UnitTests/FbxLightTest.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,72 @@ public void AnimationWithLightIntensityTest()
136136
Assert.That(exportedCurve.keys[i].value == keys[i].value);
137137
}
138138
}
139+
140+
[Test]
141+
public void AnimationWithLightColorTest()
142+
{
143+
string filename = GetRandomFbxFilePath();
144+
GameObject go = new GameObject();
145+
go.name = "original";
146+
Light light = go.AddComponent(typeof(Light)) as Light;
147+
Animation anim = go.AddComponent(typeof(Animation)) as Animation;
148+
149+
Keyframe[] keys = new Keyframe[3];
150+
keys[0] = new Keyframe(0.0f, 0.0f);
151+
keys[1] = new Keyframe(1.0f, 0.5f);
152+
keys[2] = new Keyframe(2.0f, 1.0f);
153+
154+
AnimationCurve curve = new AnimationCurve(keys);
155+
156+
AnimationClip clip = new AnimationClip();
157+
158+
clip.legacy = true;
159+
160+
clip.SetCurve("", typeof(Light), "m_Color.r", curve);
161+
clip.SetCurve("", typeof(Light), "m_Color.g", curve);
162+
clip.SetCurve("", typeof(Light), "m_Color.b", curve);
163+
164+
anim.AddClip(clip, "test");
165+
166+
//export the object
167+
var exported = FbxExporters.Editor.ModelExporter.ExportObject(filename, go);
168+
169+
Assert.That(exported, Is.EqualTo(filename));
170+
171+
// TODO: Uni-34492 change importer settings of (newly exported model)
172+
// so that it's not resampled and it is legacy animation
173+
{
174+
ModelImporter modelImporter = AssetImporter.GetAtPath(filename) as ModelImporter;
175+
Assert.That(modelImporter, Is.Not.Null);
176+
modelImporter.resampleCurves = false;
177+
AssetDatabase.ImportAsset(filename);
178+
modelImporter.animationType = ModelImporterAnimationType.Legacy;
179+
AssetDatabase.ImportAsset(filename);
180+
}
181+
182+
Object[] objects = AssetDatabase.LoadAllAssetsAtPath(filename);
183+
184+
AnimationClip exportedClip = null;
185+
foreach (Object o in objects)
186+
{
187+
exportedClip = o as AnimationClip;
188+
if (exportedClip != null) break;
189+
}
190+
191+
Assert.IsNotNull(exportedClip);
192+
exportedClip.legacy = true;
193+
194+
EditorCurveBinding exportedEditorCurveBinding = AnimationUtility.GetCurveBindings(exportedClip)[0];
195+
196+
AnimationCurve exportedCurve = AnimationUtility.GetEditorCurve(exportedClip, exportedEditorCurveBinding);
197+
198+
Assert.That(exportedCurve.keys.Length, Is.EqualTo(keys.Length));
199+
200+
for (int i = 0; i < exportedCurve.keys.Length; i++)
201+
{
202+
Assert.That(exportedCurve.keys[i].time == keys[i].time);
203+
Assert.That(exportedCurve.keys[i].value == keys[i].value);
204+
}
205+
}
139206
}
140207
}

0 commit comments

Comments
 (0)