コード例 #1
0
        protected override void OnBeginDrawEditors()
        {
            OdinMenuTreeSelection selected = MenuTree.Selection;

            if (selected.SelectedValue != null)
            {
                SirenixEditorGUI.BeginHorizontalToolbar();

                GUILayout.Label(MenuTree.Selection.FirstOrDefault().Name);

                if (selected.SelectedValue.GetType() == typeof(SceneEssentialObjects))
                {
                    GUILayout.FlexibleSpace();
                    if (SirenixEditorGUI.ToolbarButton("Delete Current"))
                    {
                        SceneEssentialObjects asset = selected.SelectedValue as SceneEssentialObjects;
                        var path = AssetDatabase.GetAssetPath(asset);
                        AssetDatabase.DeleteAsset(path);
                        AssetDatabase.SaveAssets();
                    }
                }

                SirenixEditorGUI.EndHorizontalToolbar();
            }
        }
コード例 #2
0
        private void CheckScene(SceneEssentialObjects asset)
        {
            var objectsInScene = FindObjectsOfType <GameObject>();

            if (_missingGameObjects != null)
            {
                _missingGameObjects = null;
            }

            _missingGameObjects = new List <GameObject>();

            foreach (GameObject assetObj in asset.Prefabs)
            {
                var objectExists = false;
                foreach (GameObject sceneObj in objectsInScene)
                {
                    if (PrefabUtility.GetCorrespondingObjectFromSource(sceneObj) == assetObj)
                    {
                        objectExists = true;
                    }
                }

                if (!objectExists)
                {
                    _missingGameObjects.Add(assetObj);
                }
            }

            if (_missingGameObjects.Count == 0)
            {
                _missingGameObjects = null;
            }
        }
コード例 #3
0
            private void CreateNewSceneType()
            {
                AssetDatabase.CreateAsset(EssentialObjects,
                                          "Assets/Editor/Tools/SceneEssentials/" + EssentialsName + ".asset");
                AssetDatabase.SaveAssets();

                // Create new Instance of the Scriptable Object
                EssentialObjects         = CreateInstance <SceneEssentialObjects>();
                EssentialObjects.Prefabs = new List <GameObject>();
                EssentialsName           = null;
            }
コード例 #4
0
        protected override void OnEndDrawEditors()
        {
            OdinMenuTreeSelection selected = MenuTree.Selection;

            if (selected.SelectedValue != null)
            {
                if (selected.SelectedValue.GetType() == typeof(SceneEssentialObjects))
                {
                    SceneEssentialObjects asset = selected.SelectedValue as SceneEssentialObjects;

                    if (_missingGameObjects != null)
                    {
                        foreach (GameObject obj in _missingGameObjects)
                        {
                            SirenixEditorGUI.WarningMessageBox("Missing -" + obj.name + "- Prefab.");
                        }
                    }
                    else
                    {
                        if (asset.HasBeenChecked)
                        {
                            SirenixEditorGUI.InfoMessageBox("No missing Objects.");
                        }
                        else
                        {
                            SirenixEditorGUI.InfoMessageBox("Not Checked Yet.");
                        }
                    }

                    GUILayout.FlexibleSpace();
                    SirenixEditorGUI.BeginHorizontalToolbar();
                    {
                        GUILayout.FlexibleSpace();
                        if (_missingGameObjects != null)
                        {
                            if (SirenixEditorGUI.ToolbarButton("Add Missing Objects"))
                            {
                                AddMissing();
                            }
                        }

                        if (SirenixEditorGUI.ToolbarButton("Check Scene"))
                        {
                            CheckScene(asset);
                            asset.HasBeenChecked = true;
                        }
                    }
                    SirenixEditorGUI.EndHorizontalToolbar();
                }
            }
        }
コード例 #5
0
 public CreateNewSceneEssentials()
 {
     EssentialObjects         = CreateInstance <SceneEssentialObjects>();
     EssentialObjects.Prefabs = new List <GameObject>();
     EssentialsName           = null;
 }