Skip to content

Commit 76677c2

Browse files
author
DESKTOP-F8VO8FK\Austin
committed
Merge branch 'master' into Uni-35058-sprint42-release
2 parents 46ffe88 + bc06dff commit 76677c2

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,12 @@ public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPai
15371537
return true;
15381538
}
15391539

1540+
if (uniPropertyName.StartsWith("field of view", ct))
1541+
{
1542+
prop = new FbxPropertyChannelPair("FieldOfView", null);
1543+
return true;
1544+
}
1545+
15401546
prop = new FbxPropertyChannelPair ();
15411547
return false;
15421548
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using NUnit.Framework;
4+
using System.Collections.Generic;
5+
6+
namespace FbxExporters.UnitTests
7+
{
8+
public class MyKeyComparer : IComparer<Keyframe>
9+
{
10+
public int Compare(Keyframe a, Keyframe b)
11+
{
12+
Debug.Log(string.Format("a.value: {0}, b.value: {1}, a.time: {2}, b.time: {3}", a.value, b.value, a.time, b.time));
13+
return a.time == b.time && a.value == b.value ? 0 : 1;
14+
}
15+
}
16+
17+
public class FbxCameraTest : ExporterTestBase
18+
{
19+
20+
[Test]
21+
public void AnimationWithCameraFOVTest()
22+
{
23+
string filename = GetRandomFbxFilePath();
24+
GameObject go = new GameObject();
25+
go.name = "originalCamera";
26+
Camera camera = go.AddComponent(typeof(Camera)) as Camera;
27+
Animation anim = go.AddComponent(typeof(Animation)) as Animation;
28+
29+
Keyframe[] keys = new Keyframe[3];
30+
keys[0] = new Keyframe(0.0f, 1f);
31+
keys[1] = new Keyframe(1.0f, 2f);
32+
keys[2] = new Keyframe(2.0f, 3f);
33+
34+
AnimationCurve curve = new AnimationCurve(keys);
35+
36+
AnimationClip clip = new AnimationClip();
37+
38+
clip.legacy = true;
39+
40+
clip.SetCurve("", typeof(Camera), "field of view", curve);
41+
42+
anim.AddClip(clip, "test");
43+
44+
//export the object
45+
var exported = FbxExporters.Editor.ModelExporter.ExportObject(filename, go);
46+
47+
Assert.That(exported, Is.EqualTo(filename));
48+
49+
// TODO: Uni-34492 change importer settings of (newly exported model)
50+
// so that it's not resampled and it is legacy animation
51+
{
52+
ModelImporter modelImporter = AssetImporter.GetAtPath(filename) as ModelImporter;
53+
Assert.That(modelImporter, Is.Not.Null);
54+
modelImporter.resampleCurves = false;
55+
AssetDatabase.ImportAsset(filename);
56+
modelImporter.animationType = ModelImporterAnimationType.Legacy;
57+
AssetDatabase.ImportAsset(filename);
58+
}
59+
60+
Object[] objects = AssetDatabase.LoadAllAssetsAtPath(filename);
61+
62+
AnimationClip exportedClip = null;
63+
foreach (Object o in objects)
64+
{
65+
exportedClip = o as AnimationClip;
66+
if (exportedClip != null) break;
67+
}
68+
69+
Assert.IsNotNull(exportedClip);
70+
exportedClip.legacy = true;
71+
72+
EditorCurveBinding exportedEditorCurveBinding = AnimationUtility.GetCurveBindings(exportedClip)[0];
73+
74+
AnimationCurve exportedCurve = AnimationUtility.GetEditorCurve(exportedClip, exportedEditorCurveBinding);
75+
76+
Assert.That(exportedCurve.keys.Length, Is.EqualTo(keys.Length));
77+
78+
//check imported animation against original
79+
Assert.That(exportedCurve.keys, Is.EqualTo(keys).Using<Keyframe>(new MyKeyComparer()), string.Format("key doesn't match"));
80+
}
81+
82+
}
83+
}

0 commit comments

Comments
 (0)