public void PrepareForExport() { if (GLexConfig.GetOption(GLexConfig.SETUNIQUENAMES)) { Dictionary <string, int> uniqueNames = new Dictionary <string, int>(); foreach (GLexGameObject gameObject in mGLexGameObjects) { if (gameObject.Settings == null) { _addedSettingsTo.Add(gameObject); gameObject.AddSettings(); } else { gameObject.ResetSettingsExportName(); } } foreach (GLexGameObject gameObject in mGLexGameObjects) { if (uniqueNames.ContainsKey(gameObject.Settings.UniqueName)) { gameObject.Settings.UniqueName = gameObject.Settings.UniqueName + (++uniqueNames[gameObject.Settings.UniqueName]).ToString(); } else { uniqueNames.Add(gameObject.Settings.UniqueName, 0); } } } // Keep preparing objects while new ones are being added int prevGameObjectCount = 0, prevComponentCount = 0; while (prevGameObjectCount < mGLexGameObjects.Count || prevComponentCount < mGLexComponents.Count) { int goStart = prevGameObjectCount; int gcStart = prevComponentCount; prevGameObjectCount = mGLexGameObjects.Count; prevComponentCount = mGLexComponents.Count; for (int i = goStart; i < prevGameObjectCount; ++i) { mGLexGameObjects[i].PrepareForExport(); } for (int i = gcStart; i < prevComponentCount; ++i) { mGLexComponents[i].PrepareForExport(); } } // find top objects foreach (GLexGameObject gameObject in mGLexGameObjects) { if (!gameObject.HasParent) { mGLexTopGameObjects.Add(gameObject); } } GLexMaterial.PrepareForExport(); GLexMesh.PrepareForExport(); GLexTexture.PrepareForExport(); GLexShader.PrepareForExport(); GLexSkinnedMeshRenderer.StaticPrepareForExport(); GLexBone.PrepareForExport(); // GLexAnimation .PrepareForExport(); // GLexAnimationClip .PrepareForExport(); mGLexGameObjectsAsArray = mGLexGameObjects.ToArray(); mGLexTopGameObjectsAsArray = mGLexTopGameObjects.ToArray(); mGLexComponentsAsArray = mGLexComponents.ToArray(); mScene.PrepareForExport(); }