public override void Do() { if (this.backupLink == null) { this.backupLink = new PrefabLink[this.targetObj.Length]; for (int i = 0; i < this.backupLink.Length; i++) { PrefabLink link = this.targetObj[i].AffectedByPrefabLink; this.backupLink[i] = link.DeepClone(BackupCloneContext); } } // Destroy all PrefabLinks foreach (GameObject o in this.targetObj) { o.BreakPrefabLink(); } DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(this.targetObj), ReflectionInfo.Property_GameObject_PrefabLink); }
public override void Do() { if (this.backupPrefab == null) { this.backupPrefab = new Prefab[this.targetObj.Length]; this.backupLink = new PrefabLink[this.targetObj.Length]; for (int i = 0; i < this.backupPrefab.Length; i++) { PrefabLink link = this.targetObj[i].PrefabLink; Prefab prefab = this.targetPrefab[i].Res; this.backupPrefab[i] = prefab.DeepClone(BackupCloneContext); this.backupLink[i] = link.DeepClone(BackupCloneContext); } } List <Prefab> prefabs = new List <Prefab>(); List <GameObject> linkedObj = new List <GameObject>(); for (int i = 0; i < this.targetObj.Length; i++) { GameObject obj = this.targetObj[i]; Prefab prefab = this.targetPrefab[i].Res; if (prefab == null) { continue; } prefab.Inject(obj); if (obj.PrefabLink == null) { obj.LinkToPrefab(prefab); linkedObj.Add(obj); } prefabs.Add(prefab); } DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(prefabs)); DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(linkedObj), ReflectionInfo.Property_GameObject_PrefabLink); }
public override void Do() { if (this.backupObj == null) { this.backupObj = new Component[this.targetObj.Count]; this.backupLink = new PrefabLink[this.targetObj.Count]; for (int i = 0; i < this.backupObj.Length; i++) { PrefabLink link = this.targetObj[i].GameObj.AffectedByPrefabLink; this.backupObj[i] = this.targetObj[i].DeepClone(BackupCloneContext); this.backupLink[i] = link.DeepClone(BackupCloneContext); } } List <PrefabLink> affectedLinks = new List <PrefabLink>(); foreach (Component component in this.targetObj) { Type cmpType = component.GetType(); TypeInfo cmpTypeInfo = cmpType.GetTypeInfo(); PrefabLink link = component.GameObj.AffectedByPrefabLink; if (link != null) { if (link.Prefab.IsAvailable) { link.Prefab.Res.CopyTo(link.Obj.IndexPathOfChild(component.GameObj), component); } link.ClearChanges(component.GameObj, cmpTypeInfo, null); affectedLinks.Add(link); } else { Component resetBase = cmpTypeInfo.CreateInstanceOf() as Component; resetBase.CopyTo(component); } } DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(this.targetObj)); }
public override void Do() { if (this.backupObj == null) { this.backupObj = new GameObject[this.targetObj.Length]; this.backupLink = new PrefabLink[this.targetObj.Length]; for (int i = 0; i < this.backupObj.Length; i++) { PrefabLink link = this.targetObj[i].AffectedByPrefabLink; this.backupObj[i] = this.targetObj[i].DeepClone(BackupCloneContext); this.backupLink[i] = link.DeepClone(BackupCloneContext); } } // Clear all changes and re-apply Prefabs foreach (GameObject o in this.targetObj) { o.PrefabLink.ClearChanges(); } Duality.Resources.PrefabLink.ApplyAllLinks(this.targetObj); DualityEditorApp.NotifyObjPrefabApplied(this, new ObjectSelection(this.targetObj)); }