Skip to content

Commit 296b52e

Browse files
committed
commit auto updated code
- Unity automatically updated these functions
1 parent 1db7c4f commit 296b52e

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

Assets/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
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static bool OnValidateMenuItem()
231231
bool containsLinkedPrefab = false;
232232
foreach (GameObject selectedObject in selection)
233233
{
234-
GameObject prefab = UnityEditor.PrefabUtility.GetPrefabParent(selectedObject) as GameObject;
234+
GameObject prefab = UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(selectedObject) as GameObject;
235235
if (prefab && prefab.GetComponentInChildren<FbxPrefab>())
236236
{
237237
containsLinkedPrefab = true;
@@ -255,7 +255,7 @@ public static void UpdateLinkedPrefab(GameObject prefabOrInstance)
255255
prefab = prefabOrInstance;
256256
break;
257257
case PrefabType.PrefabInstance:
258-
prefab = PrefabUtility.GetPrefabParent(prefabOrInstance) as GameObject;
258+
prefab = PrefabUtility.GetCorrespondingObjectFromSource(prefabOrInstance) as GameObject;
259259
break;
260260
default:
261261
return;
@@ -1381,7 +1381,7 @@ void CompareAndUpdate()
13811381
m_fbxPrefab.gameObject));
13821382
}
13831383
var fbxPrefabInstance = prefabInstanceRoot.GetComponentsInChildren<FbxPrefab>().FirstOrDefault(
1384-
fbxPrefab => UnityEditor.PrefabUtility.GetPrefabParent(fbxPrefab) == m_fbxPrefab);
1384+
fbxPrefab => UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(fbxPrefab) == m_fbxPrefab);
13851385
if (!fbxPrefabInstance) {
13861386
throw new System.Exception(string.Format("Internal error: couldn't find the right FbxPrefab after instantiating."));
13871387
}

Assets/com.unity.formats.fbx/EditorTests/ConvertToModelTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ public void TestStaticHelpers()
9393
var aFbx = ConvertToModel.GetOrCreateFbxAsset(a, fbxFullPath: GetRandomFbxFilePath());
9494
var bFbx = ConvertToModel.GetOrCreateInstance(aFbx);
9595
Assert.AreNotEqual(aFbx, bFbx);
96-
Assert.AreEqual(aFbx, PrefabUtility.GetPrefabParent(bFbx));
96+
Assert.AreEqual(aFbx, PrefabUtility.GetCorrespondingObjectFromSource(bFbx));
9797

9898
// Test on an prefab asset
9999
var aPrefab = PrefabUtility.CreatePrefab(GetRandomPrefabAssetPath(), a);
100100
var bPrefab = ConvertToModel.GetOrCreateInstance(aPrefab);
101101
Assert.AreNotEqual(aPrefab, bPrefab);
102-
Assert.AreEqual(aPrefab, PrefabUtility.GetPrefabParent(bPrefab));
102+
Assert.AreEqual(aPrefab, PrefabUtility.GetCorrespondingObjectFromSource(bPrefab));
103103
}
104104

105105
// Test SetupFbxPrefab
@@ -122,13 +122,13 @@ public void TestStaticHelpers()
122122

123123
var aPath = GetRandomPrefabAssetPath();
124124
var aPrefab = ConvertToModel.ApplyOrCreatePrefab(a, prefabFullPath: aPath);
125-
Assert.AreEqual(aPrefab, PrefabUtility.GetPrefabParent(a));
125+
Assert.AreEqual(aPrefab, PrefabUtility.GetCorrespondingObjectFromSource(a));
126126

127127
// Now apply it again (replacing aPrefab). Make sure we use the
128128
// same file rather than creating a new one.
129129
var bPath = GetRandomPrefabAssetPath();
130130
var bPrefab = ConvertToModel.ApplyOrCreatePrefab(a, prefabFullPath: bPath);
131-
Assert.AreEqual(bPrefab, PrefabUtility.GetPrefabParent(a));
131+
Assert.AreEqual(bPrefab, PrefabUtility.GetCorrespondingObjectFromSource(a));
132132
Assert.AreEqual(aPath, AssetDatabase.GetAssetPath(bPrefab));
133133
}
134134

@@ -227,7 +227,7 @@ public void BasicTest()
227227
Assert.That(cube); // we kept the original
228228
Assert.That(cubePrefab); // we got the new
229229
Assert.AreEqual("Cube", cubePrefab.name); // it has the right name
230-
Assert.AreSame(PrefabUtility.GetPrefabParent(cube), cubePrefab); // the original and new are the same
230+
Assert.AreSame(PrefabUtility.GetCorrespondingObjectFromSource(cube), cubePrefab); // the original and new are the same
231231
Assert.That(!EditorUtility.IsPersistent(cube));
232232
Assert.That(EditorUtility.IsPersistent(cubePrefab));
233233

@@ -265,7 +265,7 @@ public void ExhaustiveTests() {
265265
{
266266
var a = CreateHierarchy();
267267
var aConvert = ConvertToModel.Convert(a, fbxFullPath: GetRandomFbxFilePath(), prefabFullPath: GetRandomPrefabAssetPath());
268-
Assert.AreEqual(aConvert, PrefabUtility.GetPrefabParent(a));
268+
Assert.AreEqual(aConvert, PrefabUtility.GetCorrespondingObjectFromSource(a));
269269
}
270270

271271
// Test Convert on a prefab asset.
@@ -295,7 +295,7 @@ public void ExhaustiveTests() {
295295
var aPrefab = PrefabUtility.CreatePrefab(aPrefabPath, a);
296296
var bPrefabPath = GetRandomPrefabAssetPath();
297297
var aConvert = ConvertToModel.Convert(a, fbxFullPath: GetRandomFbxFilePath(), prefabFullPath: bPrefabPath);
298-
Assert.AreEqual(aConvert, PrefabUtility.GetPrefabParent(a));
298+
Assert.AreEqual(aConvert, PrefabUtility.GetCorrespondingObjectFromSource(a));
299299
Assert.AreEqual(bPrefabPath, AssetDatabase.GetAssetPath(aConvert));
300300
Assert.AreEqual(aPrefabPath, AssetDatabase.GetAssetPath(aPrefab));
301301
Assert.AreNotEqual(aPrefabPath, AssetDatabase.GetAssetPath(aConvert));
@@ -437,7 +437,7 @@ public void TestInstanceNameMatchesFilename()
437437

438438
Assert.That (cube);
439439
Assert.That (cubePrefab);
440-
Assert.AreSame (cubePrefab, PrefabUtility.GetPrefabParent(cube));
440+
Assert.AreSame (cubePrefab, PrefabUtility.GetCorrespondingObjectFromSource(cube));
441441

442442
Assert.AreEqual (Path.GetFileNameWithoutExtension (path), cube.name);
443443
}
@@ -476,7 +476,7 @@ public void TestConvertModelInstance()
476476
GameObject converted = ConvertToModel.Convert (fbxInstance,
477477
fbxFullPath: GetRandomFbxFilePath(),
478478
prefabFullPath: GetRandomPrefabAssetPath());
479-
Assert.That (converted, Is.EqualTo (PrefabUtility.GetPrefabParent(fbxInstance)));
479+
Assert.That (converted, Is.EqualTo (PrefabUtility.GetCorrespondingObjectFromSource(fbxInstance)));
480480

481481
// check meshes link to original fbx
482482
var prefabCubeMesh = fbxInstance.GetComponent<MeshFilter>().sharedMesh;

0 commit comments

Comments
 (0)