public bool Apply(Transform src) { GameObject prefab = PrefabUtility.GetPrefabParent(src.gameObject) as GameObject; if (prefab != null && PrefabUtility.GetPrefabType(src.gameObject) == PrefabType.PrefabInstance && !prefabSet.Contains(prefab)) { prefabSet.Add(prefab); GameObject newObj = new GameObject(src.name); Transform dst = newObj.transform; dst.parent = src.parent; dst.localPosition = src.localPosition; dst.localScale = src.localScale; dst.localRotation = src.localRotation; NestedPrefab s = newObj.AddComponent <NestedPrefab>(); s.Link(prefab); destroy.Add(src.gameObject); Debug.Log(AssetDatabase.GetAssetPath(prefab)); } else { NestedPrefab s = src.gameObject.GetComponent <NestedPrefab>(); if (s != null && !s.IsLinked()) { s.Link(null); } } return(true); }
public bool Apply(Transform target) { NestedPrefab s = target.GetComponent <NestedPrefab>(); if (s != null) { if (s.IsLinked() && s.GetPrefab() != null) { GameObject instance = PrefabUtility.InstantiatePrefab(s.GetPrefab()) as GameObject; Transform src = s.transform; Transform dst = instance.transform; dst.parent = s.transform.parent; dst.localPosition = src.localPosition; dst.localScale = src.localScale; dst.localRotation = src.localRotation; destroy.Add(s.gameObject); Debug.Log(AssetDatabase.GetAssetPath(s.GetPrefab())); } s.ClearLink(); } return(true); }
void OnEnable() { nestedPrefab = target as NestedPrefab; }