Пример #1
0
 public static void AttachSounds()
 {
     foreach(GameObject compact in EditorHelpers.ProcessPrefabList<GameObject>( Prefs.CompactPrefab("*") )) {
         using(TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(compact)) {
             if (SetupSound( tmp.Instance as GameObject )) {
                 tmp.Commit();
             }
         }
     }
 }
 void Test_LoadByPath()
 {
     GameObject obj;
     using(TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(tmpPrefabPath)) {
         obj = tmp.Instance as GameObject;
         Assert_True(obj != null);
         Assert_True(obj);
         Assert_Equal("TestPrefab", obj.name);
     }
     Assert_False(obj);
     Assert_True( GameObject.Find("TestPrefab") == null );
 }
 void Test_LoadFromPrefabInstance()
 {
     GameObject obj;
     GameObject prefab = AssetDatabase.LoadAssetAtPath(tmpPrefabPath, typeof(GameObject)) as GameObject;
     Assert_True( prefab != null );
     Assert_True( prefab );
     GameObject instance = EditorUtility.InstantiatePrefab( prefab ) as GameObject;
     using(TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(instance)) {
         obj = tmp.Instance as GameObject;
         Assert_True(obj != null);
         Assert_True(obj);
         Assert_Equal("TestPrefab", obj.name);
     }
     Assert_False(obj);
     Object.DestroyImmediate( instance );
     Assert_True( GameObject.Find("TestPrefab") == null );
 }
Пример #4
0
    CloudCompactor(ImportedCloud cloud)
    {
        using(TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(cloud)) {
            base_name = tmp.Instance.name;

            string targetFName = Prefs.CompactPrefab(base_name + "--loc");
            if (File.Exists( targetFName )) {
                Debug.LogWarning(string.Format("{0} is in the way when compacting the cloud. Remove to recompact",
                                        targetFName), AssetDatabase.LoadMainAssetAtPath(targetFName));
                return;
            }

            Debug.Log(string.Format("Compacting {0}", base_name));

            EnsureCutBoxes( tmp.Instance as GameObject );
            if (cutBoxHelpers != null && shadowBoxHelpers != null)
                CutToBoxes( tmp.Instance as GameObject );
            /*
             * - requires post-shuffle of the cut-bins
             * - shadows are separate BinMesh'es with their own bin
             *
             * Prefab:
             * - After cutting  need to create a prefab
             * - Look for the sound then as well
             *
             */

            foreach(Transform box in cutBoxes)
                ShuffleBin( Prefs.BoxBin(cloud.name, box.name));
            foreach(Transform box in shadowBoxes)
                ShuffleBin( Prefs.BoxBin(cloud.name, box.name));

            CreateCompactPrefab(cutBoxes, shadowBoxes, tmp.Instance as GameObject);
            // don't commit, any changes to tmp.Instance are interim, only for compaction to work
        }
    }
 void Test_LoadFromPrefabObjectComponent()
 {
     GameObject obj;
     GameObject prefab = AssetDatabase.LoadAssetAtPath(tmpPrefabPath, typeof(GameObject)) as GameObject;
     Assert_True( prefab != null );
     Assert_True( prefab );
     using(TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(prefab.transform)) {
         obj = tmp.Instance as GameObject;
         Assert_True(obj != null);
         Assert_True(obj);
         Assert_Equal("TestPrefab", obj.name);
     }
     Assert_False(obj);
     Assert_True( GameObject.Find("TestPrefab") == null );
 }
Пример #6
0
    static void FindPrefabAndLookForSound(MenuCommand command)
    {
        Object compactFragment = command.context as SlideShow;
        using(TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(compactFragment)) {
            GameObject root = tmp.Instance as GameObject;

            if (SetupSound(root))
                tmp.Commit();
        }
    }
Пример #7
0
    static void CopyBoxes()
    {
        foreach(Object o in Selection.objects) {
            ImportedCloud ic = null;
            Component comp = o as Component;
            GameObject go = o as GameObject;
            if (comp != null)
                ic = comp.GetComponent<ImportedCloud>();
            else if (go != null)
                ic = go.GetComponent<ImportedCloud>();

            if (ic == null)
                continue;

            Transform oldBoxes = ic.transform.FindChild("CutBoxes");

            if (oldBoxes != null && oldBoxes.childCount > 0) {
                // see if there is a new original without children...
                string newPath = Prefs.ImportedCloudPrefab( ic.name );
                if (File.Exists(newPath)) {
                    using( TemporaryPrefabInstance tmp = new TemporaryPrefabInstance(newPath) ) {
                        GameObject newGo = tmp.Instance as GameObject;
                        Transform newBoxes = newGo.transform.FindChild("CutBoxes");
                        if (newBoxes != null && newBoxes.childCount == 0) {
                            // clone the original boxes...
                            GameObject boxNodeClone = GameObject.Instantiate(oldBoxes.gameObject) as GameObject;
                            ProceduralUtils.InsertAtOrigin(boxNodeClone, newGo);
                            Object.DestroyImmediate(newBoxes.gameObject);
                            boxNodeClone.name = "CutBoxes"; // remove "(clone)" suffix
                            tmp.Commit();
                        }
                    }
                }
            }
        }
    }