コード例 #1
0
ファイル: Operations.cs プロジェクト: z3nth10n/unity-themes
 //====================================
 // Replace
 //====================================
 public void PerformReplace()
 {
     if (this.optionA.type == ReplaceOption.Prefab)
     {
         ProxyEditor.RegisterSceneUndo(this, "Replace Operation");
         Object prefab = ProxyEditor.CreateEmptyPrefab(null, this.optionA.targetPath);
         ProxyEditor.ApplyPrefab(this.optionB.found.First(), prefab);
     }
     if (this.optionA.type == ReplaceOption.GameObject)
     {
         foreach (GameObject current in new List <GameObject>(this.optionA.found))
         {
             GameObject newObject = (GameObject)ProxyEditor.InstantiatePrefab(this.optionB.found.First());
             newObject.transform.parent   = current.transform.parent;
             newObject.transform.position = current.transform.position;
             newObject.transform.rotation = current.transform.rotation;
             if (this.preserveScale)
             {
                 newObject.transform.localScale = current.transform.localScale;
             }
             DestroyImmediate(current);
         }
     }
 }