public override void PrepareForExport() { base.PrepareForExport(); if (_submeshIndex == 0 && _mesh.SubMeshCount > 1) { for (int i = 1; i < _mesh.SubMeshCount; ++i) { var dummyObject = new GameObject("Submesh#" + i); dummyObject.transform.parent = mComponent.transform; var submeshObject = new GLexGameObject(dummyObject, _glexGameObject.GlexData); _glexGameObject.GlexData.AddGameObject(submeshObject); var submeshRenderer = new GLexMeshRenderer(this, i); submeshObject.AddComponent(submeshRenderer); _glexGameObject.GlexData.AddComponent(submeshRenderer); GooExporter.RemoveAfterExport(dummyObject); } } }
public override void PrepareForExport() { base.PrepareForExport(); if (_submeshIndex == 0 && mMesh.SubMeshCount > 1) { for (int i = 1; i < mMesh.SubMeshCount; ++i) { var dummyObject = new GameObject("Submesh#" + i); dummyObject.transform.parent = mComponent.transform; var submeshObject = new GLexGameObject(dummyObject, _glexGameObject.GlexData); _glexGameObject.GlexData.AddGameObject(submeshObject); var submeshRenderer = (GLexSkinnedMeshRenderer)System.Activator.CreateInstance(GetType()); submeshRenderer.SetupSubmeshRenderer(this, i); submeshObject.AddComponent(submeshRenderer); _glexGameObject.GlexData.AddComponent(submeshRenderer); GooExporter.RemoveAfterExport(dummyObject); } } }
public void AddGameObject(GLexGameObject converter) { mGLexGameObjects.Add(converter); Debug.Log("Added game object: " + converter.Name); }
private bool RecurseSceneGraph(Transform transform, Transform parent) { if (_canceled) { return false; } if (EditorUtility.DisplayCancelableProgressBar("Collecting Objects", transform.name, 0)) { Debug.LogError("User cancelled export"); _canceled = true; return false; } bool active = GLexConfig.GetOption(GLexConfig.RECURSEINACTIVESCHILDREN) ? transform.gameObject.activeSelf : transform.gameObject.activeInHierarchy; if (!GLexConfig.ExportLeafWithOnlyTransform && transform.GetComponents<Component>().Length == 1 && transform.childCount == 0) { active = false; } if (transform.GetComponent<GLexGameObjectSettings>() != null && transform.GetComponent<GLexGameObjectSettings>().export == false) { active = false; } if (active) { GLexGameObject gameObject = new GLexGameObject(transform.gameObject, mData); mData.AddGameObject(gameObject); foreach (KeyValuePair<string,string> componentAndConverters in GLexConfig.Converters) { var unityComponent = transform.GetComponent(componentAndConverters.Key); if (unityComponent != null) { Type coConverterType = Type.GetType(componentAndConverters.Value, true); GLexComponent component = Activator.CreateInstance(coConverterType) as GLexComponent; component.AssociateWithGameObject(transform.gameObject); component.AssociateWithComponent(unityComponent); mData.AddComponent(component); gameObject.AddComponent(component); } } } // traverse children if (active || GLexConfig.GetOption(GLexConfig.RECURSEINACTIVESCHILDREN)) { for (int c = 0; c < transform.childCount; c++) { RecurseSceneGraph(transform.GetChild(c), transform); } } return true; }
private bool RecurseSceneGraph(Transform transform, Transform parent) { if (_canceled) { return(false); } if (EditorUtility.DisplayCancelableProgressBar("Collecting Objects", transform.name, 0)) { Debug.LogError("User cancelled export"); _canceled = true; return(false); } bool active = GLexConfig.GetOption(GLexConfig.RECURSEINACTIVESCHILDREN) ? transform.gameObject.activeSelf : transform.gameObject.activeInHierarchy; if (!GLexConfig.ExportLeafWithOnlyTransform && transform.GetComponents <Component>().Length == 1 && transform.childCount == 0) { active = false; } if (transform.GetComponent <GLexGameObjectSettings>() != null && transform.GetComponent <GLexGameObjectSettings>().export == false) { active = false; } if (active) { GLexGameObject gameObject = new GLexGameObject(transform.gameObject, mData); mData.AddGameObject(gameObject); foreach (KeyValuePair <string, string> componentAndConverters in GLexConfig.Converters) { var unityComponent = transform.GetComponent(componentAndConverters.Key); if (unityComponent != null) { Type coConverterType = Type.GetType(componentAndConverters.Value, true); GLexComponent component = Activator.CreateInstance(coConverterType) as GLexComponent; component.AssociateWithGameObject(transform.gameObject); component.AssociateWithComponent(unityComponent); mData.AddComponent(component); gameObject.AddComponent(component); } } } // traverse children if (active || GLexConfig.GetOption(GLexConfig.RECURSEINACTIVESCHILDREN)) { for (int c = 0; c < transform.childCount; c++) { RecurseSceneGraph(transform.GetChild(c), transform); } } return(true); }