Пример #1
0
        static void reset()
        {
            BundleResource.Reset();
            BundleComponent.Reset();
            BundleScene.Reset();
            BundleGameObject.Reset();
            BundleComponent.RegisterStandardComponents();

            MeshExporter.Reset();
            MaterialExporter.Reset();
        }
Пример #2
0
        public static SceneData GenerateSceneData(bool onlySelected)
        {
            // reset the exporter in case there was an error, Unity doesn't cleanly load/unload editor assemblies
            reset();

            BundleScene.sceneName = Path.GetFileNameWithoutExtension(EditorSceneManager.GetActiveScene().name);
            BundleScene scene = BundleScene.TraverseScene(onlySelected);

            scene.Preprocess();
            scene.Process();
            scene.PostProcess();

            SceneData sceneData = scene.GetSceneData() as SceneData;

            reset();
            return(sceneData);
        }
Пример #3
0
        public static BundleScene TraverseScene(bool onlySelected)
        {
            var scene = new BundleScene();
            List <GameObject> root = new List <GameObject>();

            if (onlySelected)
            {
                object[] objects = Selection.objects;
                foreach (object o in objects)
                {
                    GameObject go = o as GameObject;
                    if (go != null)
                    {
                        root.Add(go);
                    }
                }
            }
            else
            {
                // Unity has no root object, so collect root game objects this way
                object[] objects = GameObject.FindObjectsOfType(typeof(GameObject));
                foreach (object o in objects)
                {
                    GameObject go = (GameObject)o;
                    if (go.transform.parent == null)
                    {
                        root.Add(go);
                    }
                }
            }

            if (root.Count == 0)
            {
                ExportError.FatalError("Cannot Export Empty Scene");
            }

            // traverse the "root" game objects, collecting child game objects and components
            Debug.Log(root.Count + " root game objects to export");
            foreach (var go in root)
            {
                scene.rootGameObjects.Add(Traverse(go));
            }
            return(scene);
        }