Skip to content

Commit 02a0358

Browse files
authored
Merge pull request #404 from Unity-Technologies/UNI-47629-Fixing_obsolete_APIs
UNI-47629 Fixed obsolete API calls
2 parents e43ccfe + 1d2fc7a commit 02a0358

File tree

5 files changed

+9
-67
lines changed

5 files changed

+9
-67
lines changed

Assets/com.unity.formats.fbx.tests/FbxAnimationTest.cs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ public static IEnumerable ContinuousRotationTestCases {
7474
}
7575
}
7676

77-
// test key tangents
78-
public static IEnumerable KeyTangentsTestCases {
79-
get {
80-
yield return new TestCaseData (new float [3] { 0f, 4f, 5f }, new Vector3 [3] { new Vector3 (-100, 100, 0), new Vector3 (0f, 0.0f, 0f), new Vector3 (25f, 0f, 0f) }, new Vector3 [3] { new Vector3 (0, 0, 0), new Vector3 (0f, 0f, 16.9f), new Vector3 (0f, 0f, 0f) }).Returns (6);
81-
}
82-
}
83-
8477
public static IEnumerable SkinnedMeshTestCases {
8578
get {
8679
yield return "Models/DefaultMale/Male_DyingHitFromBack_Blend_T3_Cut01_James.fbx";
@@ -303,33 +296,6 @@ public virtual int Compare(Keyframe a, Keyframe b)
303296
}
304297
}
305298

306-
public class KeyTangentComparer : IComparer<Keyframe>
307-
{
308-
public int CompareKeyTangents(Keyframe a, Keyframe b)
309-
{
310-
bool result = true;
311-
312-
result &= a.time.Equals(b.time);
313-
#if DEBUG_UNITTEST
314-
Debug.Log(string.Format("{2} a.time: {0}, b.time: {1}", a.time, b.time,result));
315-
#endif
316-
// TODO : use AnimationUtility.GetLeftTangentMode
317-
// requires reference to AnimationCurve and keyindex
318-
result &= (a.tangentMode == b.tangentMode);
319-
#if DEBUG_UNITTEST
320-
Debug.Log(string.Format("{2} a.tangentMode={0} b.tangentMode={1}",
321-
((AnimationUtility.TangentMode)a.tangentMode).ToString(),
322-
((AnimationUtility.TangentMode)b.tangentMode).ToString(),result));
323-
#endif
324-
return result ? 0 : 1;
325-
}
326-
327-
public int Compare(Keyframe a, Keyframe b)
328-
{
329-
return CompareKeyTangents(a,b);
330-
}
331-
}
332-
333299
public class AnimTester
334300
{
335301
public FbxAnimationTest.KeyData keyData;
@@ -754,30 +720,6 @@ public int ContinuousRotationAnimTest (RotationCurveType rotCurveType, float []
754720
return tester.DoIt();
755721
}
756722

757-
[Description("Uni-35935 key tangents")]
758-
[Test, TestCaseSource (typeof (AnimationTestDataClass), "KeyTangentsTestCases")]
759-
public int KeyTangentsAnimTest (float [] keyTimesInSeconds, Vector3 [] keyPosValues, Vector3 [] keyRotValues)
760-
{
761-
System.Type componentType = typeof(Transform);
762-
763-
if (keyRotValues == null)
764-
{
765-
keyRotValues = new Vector3[keyPosValues.Length];
766-
}
767-
768-
string[] propertyNames = null;
769-
string testName = componentType.ToString () + "_KeyTangents";
770-
RotationCurveType rotCurveType = RotationCurveType.kEuler;
771-
772-
testName += "_Euler";
773-
propertyNames = AnimationTestDataClass.m_rotationEulerNames.Concat(AnimationTestDataClass.m_translationNames).ToArray();
774-
775-
KeyData keyData = new TransformKeyData { RotationType = rotCurveType, propertyNames = propertyNames, componentType = componentType, keyTimes = keyTimesInSeconds, keyPosValues = keyPosValues, keyEulerValues = keyRotValues };
776-
777-
var tester = new AnimTester {keyData=keyData, testName=testName, path=GetRandomFbxFilePath (), keyComparer=new KeyTangentComparer()};
778-
return tester.DoIt();
779-
}
780-
781723
[Test, TestCaseSource (typeof (AnimationTestDataClass), "ComponentTestCases")]
782724
public int ComponentAnimTest (System.Type componentType)
783725
{

Packages/com.unity.formats.fbx/Editor/Scripts/ConvertToModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public static GameObject ApplyOrCreatePrefab(GameObject instance,
316316
string prefabFullPath = null)
317317
{
318318
if(PrefabUtility.GetPrefabType(instance) == PrefabType.PrefabInstance) {
319-
return PrefabUtility.ReplacePrefab(instance, PrefabUtility.GetPrefabParent(instance));
319+
return PrefabUtility.ReplacePrefab(instance, PrefabUtility.GetCorrespondingObjectFromSource(instance));
320320
}
321321

322322
// Otherwise, create a new prefab. First choose its filename/path.
@@ -388,7 +388,7 @@ public static GameObject GetFbxAssetOrNull(GameObject go) {
388388
switch(unityPrefabType) {
389389
case PrefabType.ModelPrefabInstance:
390390
if (go.Equals(PrefabUtility.FindPrefabRoot (go))) {
391-
return PrefabUtility.GetPrefabParent(go) as GameObject;
391+
return PrefabUtility.GetCorrespondingObjectFromSource(go) as GameObject;
392392
} else {
393393
return null;
394394
}

Packages/com.unity.formats.fbx/Editor/Scripts/FbxExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ protected bool ExportInstance (GameObject unityGo, FbxNode fbxNode, FbxScene fbx
12881288
if (unityPrefabType != PrefabType.PrefabInstance &&
12891289
unityPrefabType != PrefabType.ModelPrefabInstance) return false;
12901290

1291-
Object unityPrefabParent = PrefabUtility.GetPrefabParent (unityGo);
1291+
Object unityPrefabParent = PrefabUtility.GetCorrespondingObjectFromSource(unityGo);
12921292

12931293
if (Verbose)
12941294
Debug.Log (string.Format ("exporting instance {0}({1})", unityGo.name, unityPrefabParent.name));

Packages/com.unity.formats.fbx/Editor/Scripts/FbxPrefabAutoUpdater.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public static bool OnValidateMenuItem()
257257
bool containsLinkedPrefab = false;
258258
foreach (GameObject selectedObject in selection)
259259
{
260-
GameObject prefab = UnityEditor.PrefabUtility.GetPrefabParent(selectedObject) as GameObject;
260+
GameObject prefab = UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(selectedObject) as GameObject;
261261
if (prefab && prefab.GetComponentInChildren<FbxPrefab>())
262262
{
263263
containsLinkedPrefab = true;
@@ -281,7 +281,7 @@ public static void UpdateLinkedPrefab(GameObject prefabOrInstance)
281281
prefab = prefabOrInstance;
282282
break;
283283
case PrefabType.PrefabInstance:
284-
prefab = PrefabUtility.GetPrefabParent(prefabOrInstance) as GameObject;
284+
prefab = PrefabUtility.GetCorrespondingObjectFromSource(prefabOrInstance) as GameObject;
285285
break;
286286
default:
287287
return;
@@ -1407,7 +1407,7 @@ void CompareAndUpdate()
14071407
m_fbxPrefab.gameObject));
14081408
}
14091409
var fbxPrefabInstance = prefabInstanceRoot.GetComponentsInChildren<FbxPrefab>().FirstOrDefault(
1410-
fbxPrefab => UnityEditor.PrefabUtility.GetPrefabParent(fbxPrefab) == m_fbxPrefab);
1410+
fbxPrefab => UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(fbxPrefab) == m_fbxPrefab);
14111411
if (!fbxPrefabInstance) {
14121412
throw new System.Exception(string.Format("Internal error: couldn't find the right FbxPrefab after instantiating."));
14131413
}

Packages/com.unity.formats.fbx/Editor/Scripts/ReviewLastSavedModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ public static UnityEditor.EditorWindow GetMainGameView()
300300
private static void SubscribeToEvents ()
301301
{
302302
// ensure we only subscribe once
303-
UnityEditor.EditorApplication.hierarchyWindowChanged -= UpdateLastSavedModel;
304-
UnityEditor.EditorApplication.hierarchyWindowChanged += UpdateLastSavedModel;
303+
UnityEditor.EditorApplication.hierarchyChanged -= UpdateLastSavedModel;
304+
UnityEditor.EditorApplication.hierarchyChanged += UpdateLastSavedModel;
305305
}
306306

307307
private static void UnsubscribeFromEvents ()
@@ -311,7 +311,7 @@ private static void UnsubscribeFromEvents ()
311311
LastModel = null;
312312
LastFilePath = null;
313313

314-
UnityEditor.EditorApplication.hierarchyWindowChanged -= UpdateLastSavedModel;
314+
UnityEditor.EditorApplication.hierarchyChanged -= UpdateLastSavedModel;
315315
}
316316

317317
private static bool AutoUpdateEnabled ()

0 commit comments

Comments
 (0)