示例#1
0
 override public void Preprocess()
 {
     unityMeshRenderer = unityComponent as MeshRenderer;
     unityMeshFilter   = jeGameObject.unityGameObject.GetComponent <MeshFilter>();
     if (unityMeshFilter == null)
     {
         ExportError.FatalError("MeshRenderer with no MeshFilter");
     }
 }
示例#2
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);
        }
示例#3
0
        public static void QueryComponents(BundleGameObject jgo)
        {
            // for every registered conversion get that component
            bool isQueried = false;

            foreach (KeyValuePair <Type, Type> pair in conversions)
            {
                Component[] components = jgo.unityGameObject.GetComponents(pair.Key);
                if (components.Length > 0)
                {
                    isQueried = true;
                }

                foreach (Component component in components)
                {
                    MeshRenderer meshRenderer = component as MeshRenderer;
                    if (meshRenderer != null && !meshRenderer.enabled)
                    {
                        continue;
                    }

                    var jcomponent = Activator.CreateInstance(pair.Value) as BundleComponent;
                    if (jcomponent == null)
                    {
                        ExportError.FatalError("Export component creation failed");
                    }

                    jcomponent.unityComponent = component;
                    jcomponent.jeGameObject   = jgo;
                    jgo.AddComponent(jcomponent);
                }
            }

            if (!isQueried)
            {
                Debug.LogWarning("Unregistered game object " + jgo.unityGameObject.name);
            }
        }