Beispiel #1
0
        protected override void RenderContent()
        {
            _scrollViewPosition = EditorGUILayout.BeginScrollView(_scrollViewPosition);
            EditorGUILayout.HelpBox("Please press the fix button if you have been using an Octave3D version prior to 2.2. This will cleanup of the scene " +
                                    "of any stray Octave3D internal module objects (this was a bug in previous versions) and also it is required when uprading " +
                                    "from an earlier version to 2.2 or above.", UnityEditor.MessageType.Info);
            var content = new GUIContent();

            content.text    = "Fix";
            content.tooltip = "Applies necessary fixes.";
            if (GUILayout.Button(content, GUILayout.Width(90.0f)))
            {
                var  scriptableObjectPools = FindObjectsOfType <ScriptableObjectPool>();
                bool foundScriptablePool   = false;
                for (int index = 0; index < scriptableObjectPools.Length; ++index)
                {
                    EditorUtility.DisplayProgressBar("Octave3D Fix", "Cleaning up scriptable object pools...", (float)index / scriptableObjectPools.Length);
                    ScriptableObjectPool pool = scriptableObjectPools[index];
                    if (pool != null && pool.gameObject.GetComponent <Octave3DWorldBuilder>() == null)
                    {
                        GameObject gameObj = pool.gameObject;
                        pool.DestroyAllScriptableObjects();
                        GameObject.DestroyImmediate(pool);
                        GameObject.DestroyImmediate(gameObj);
                        foundScriptablePool = true;
                    }
                }

                var  editorWindowPools     = FindObjectsOfType <EditorWindowPool>();
                bool foundEditorWindowPool = false;
                for (int index = 0; index < editorWindowPools.Length; ++index)
                {
                    EditorUtility.DisplayProgressBar("Octave3D Fix", "Cleaning up editor window pools...", (float)index / editorWindowPools.Length);
                    EditorWindowPool pool = editorWindowPools[index];
                    if (pool != null && pool.gameObject.GetComponent <Octave3DWorldBuilder>() == null)
                    {
                        GameObject gameObj = pool.gameObject;
                        GameObject.DestroyImmediate(pool);
                        GameObject.DestroyImmediate(gameObj);
                        foundEditorWindowPool = true;
                    }
                }
                EditorUtility.ClearProgressBar();

                if (!foundScriptablePool && !foundEditorWindowPool)
                {
                    EditorUtility.DisplayDialog("All fine!", "There were no stray objects left behind in this scene :)", "OK");
                }
                else
                {
                    EditorUtility.DisplayDialog("Done!", "Cleanup successfully completed!", "OK");
                }
            }
            EditorGUILayout.EndScrollView();
        }
        public void RemoveGroupsWithNullParents()
        {
            List <ObjectGroup> groupsWithNullParents = _objectGroups.GetAllEntities();

            groupsWithNullParents = groupsWithNullParents.FindAll(item => item != null && item.GroupObject == null);
            _objectGroups.RemoveWithPredicate(item => item != null && item.GroupObject == null);
            foreach (var group in groupsWithNullParents)
            {
                ScriptableObjectPool.DestroyImmediate(group);
            }

            if (!IsEmpty)
            {
                if (IndexOfActiveGroup < 0 || IndexOfActiveGroup >= NumberOfGroups)
                {
                    SetActiveObjectGroup(GetObjectGroupByIndex(0));
                }
            }
            else
            {
                SetActiveObjectGroup(null);
            }
        }
 private void CreateScriptableObjectPool()
 {
     _scriptableObjectPool           = gameObject.AddComponent <ScriptableObjectPool>();
     _scriptableObjectPool.hideFlags = HideFlags.HideInInspector;
 }
 public void RemoveNullScriptableObjects()
 {
     ScriptableObjectPool.RemoveNullEntries();
 }
 public T CreateScriptableObject <T>() where T : ScriptableObject
 {
     return(ScriptableObjectPool.CreateScriptableObject <T>());
 }