Skip to content

Commit

Permalink
Fix naming on creating new instance
Browse files Browse the repository at this point in the history
  • Loading branch information
JLChnToZ committed Nov 5, 2023
1 parent f3297d8 commit cc2bde9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Packages/idv.jlchntoz.vvmw/Editor/VVMW/MenuUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ static GameObject SpawnPrefab(string path, bool spawnOnRoot = false) {
Debug.LogError($"Cannot find prefab at {path}");
return null;
}
var go = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
var instanceName = GameObjectUtility.GetUniqueNameForSibling(parent, prefab.name);
var go = PrefabUtility.InstantiatePrefab(prefab, parent) as GameObject;
if (go == null) {
Debug.LogError($"Cannot instantiate prefab at {path}");
return null;
}
if (parent != null) go.transform.SetParent(parent, false);
go.name = instanceName;
foreach (var component in go.GetComponentsInChildren<MonoBehaviour>(true)) {
if (component is Core) {
LocatableAttributeDrawer.Locate(component, GetField(typeof(Core), "audioLink"), false, true);
Expand Down

0 comments on commit cc2bde9

Please sign in to comment.