Exemple #1
0
 void Do()
 {
     for (int i = 0; i < replace.Length; i++)
     {
         Transform trs   = replace[i];
         Transform clone = PrefabUtilityExtensions.ClonePrefabInstance(prefab.gameObject).GetComponent <Transform>();
         clone.position = trs.position;
         clone.rotation = trs.rotation;
         clone.SetParent(trs.parent);
         clone.localScale = trs.localScale;
         if (copyMesh)
         {
             MeshFilter meshFilter = trs.GetComponent <MeshFilter>();
             if (meshFilter != null)
             {
                 MeshFilter cloneMeshFilter = clone.GetComponent <MeshFilter>();
                 if (cloneMeshFilter != null)
                 {
                     cloneMeshFilter.mesh = meshFilter.mesh;
                 }
             }
         }
         DestroyImmediate(trs.gameObject);
     }
 }
Exemple #2
0
 public static void PrefabUpdated(GameObject go)
 {
     if (go)
     {
         if (go.activeSelf)
         {
             // Debug.LogError("Set prefab: {0} was left active on last \"Apply\", be sure to set the active flag to false (Sets are always marked inactive)".Fmt(setCom.GetType().Name));
             /// Eventually we want this, but there are some gotchas with writing out a prefab
             /// e.g. if the set gets parented to a blank gameobject and then applied, we would end up writing out that prefab
             Debug.LogError("Set prefab: {0} was left active on last \"Apply\", auto-correcting the active flag to false (Sets are always marked inactive)".Fmt(GetType().Name));
             // TODO: Make sure the correct object is written out and not just simply the root prefab
             go.SetActive(false);
             PrefabUtilityExtensions.WritePrefabToDisk(go);
         }
     }
 }