public void DrawMapMagicPrefabGlobalInfoBox()
        {
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_prefabGlobal, GPUInstancerEditorConstants.Styles.boldLabel);

            EditorGUILayout.PropertyField(prop_prefabSingleton, GPUInstancerEditorConstants.Contents.useSinglePrefabManager);

            bool disableMeshRenderers = prop_prefabDisableMR.boolValue;

            EditorGUILayout.PropertyField(prop_prefabDisableMR, GPUInstancerEditorConstants.Contents.disableMeshRenderers);

            if (prop_prefabDisableMR.boolValue && prop_prefabSingleton.boolValue)
            {
                EditorGUILayout.PropertyField(prop_prefabRunInThreads, GPUInstancerEditorConstants.Contents.runInThreads);
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.PropertyField(prop_prefabRunInThreads, GPUInstancerEditorConstants.Contents.runInThreads);
                EditorGUI.EndDisabledGroup();
                prop_prefabRunInThreads.boolValue = false;
            }

            foreach (GPUInstancerPrefabPrototype prefabPrototype in _mapMagicIntegration.prefabPrototypes)
            {
                if (disableMeshRenderers != prop_prefabDisableMR.boolValue)
                {
                    GPUInstancerPrefabManagerEditor.SetRenderersEnabled(prefabPrototype, disableMeshRenderers);
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUI.EndDisabledGroup();
        }
Esempio n. 2
0
        public override void DrawGPUInstancerPrototypeAdvancedActions()
        {
            if (Application.isPlaying)
            {
                return;
            }

            GUILayout.Space(10);

            EditorGUILayout.BeginVertical();
            // title
            Rect foldoutRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));

            foldoutRect.x  += 12;
            showAdvancedBox = EditorGUI.Foldout(foldoutRect, showAdvancedBox, GPUInstancerEditorConstants.TEXT_advancedActions, true, GPUInstancerEditorConstants.Styles.foldout);

            //GUILayout.Space(10);

            if (showAdvancedBox)
            {
                EditorGUILayout.HelpBox(GPUInstancerEditorConstants.HELPTEXT_advancedActions, MessageType.Warning);

                GPUInstancerPrefabPrototype prefabPrototype = (GPUInstancerPrefabPrototype)_prefabManager.selectedPrototype;

                if (prefabPrototype != null)
                {
                    if (prefabPrototype.meshRenderersDisabled)
                    {
                        GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.enableMeshRenderers, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                                      () =>
                        {
                            GPUInstancerPrefabManagerEditor.SetRenderersEnabled(prefabPrototype, true);
                        });
                    }
                    else
                    {
                        GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.disableMeshRenderers, GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                                      () =>
                        {
                            if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_disableMeshRenderers, GPUInstancerEditorConstants.TEXT_disableMeshRenderersAreYouSure, "Yes", "No"))
                            {
                                GPUInstancerPrefabManagerEditor.SetRenderersEnabled(prefabPrototype, false);
                            }
                        });
                    }
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_disableMeshRenderers);
                }
            }

            EditorGUILayout.EndVertical();
        }
 public override void DrawGPUInstancerPrototypeInfo(GPUInstancerPrototype selectedPrototype)
 {
     if (selectedPrototype is GPUInstancerDetailPrototype)
     {
         GPUInstancerDetailManagerEditor.DrawGPUInstancerPrototypeInfo(selectedPrototype, (string t) => { DrawHelpText(t); }, _mapMagicIntegration, null, _mapMagicIntegration.shaderBindings,
                                                                       null, _mapMagicIntegration.terrainSettings, _mapMagicIntegration.detailLayer);
     }
     else if (selectedPrototype is GPUInstancerTreePrototype)
     {
         GPUInstancerTreeManagerEditor.DrawGPUInstancerPrototypeInfo(selectedPrototype, (string t) => { DrawHelpText(t); }, _mapMagicIntegration, null, _mapMagicIntegration.shaderBindings,
                                                                     null, _mapMagicIntegration.terrainSettings);
     }
     else
     {
         GPUInstancerPrefabManagerEditor.DrawGPUInstancerPrototypeInfo(selectedPrototype, (string t) => { DrawHelpText(t); });
     }
 }
        public override void OnInspectorGUI()
        {
            if (_prefabScripts != null)
            {
                if (_prefabScripts.Length >= 1 && _prefabScripts[0] != null && _prefabScripts[0].prefabPrototype != null)
                {
                    bool isPrefab = _prefabScripts[0].prefabPrototype.prefabObject == _prefabScripts[0].gameObject;

                    if (_prefabScripts.Length == 1)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_prototypeSO, _prefabScripts[0].prefabPrototype, typeof(GPUInstancerPrefabPrototype), false);
                        EditorGUI.EndDisabledGroup();

                        if (!isPrefab)
                        {
                            if (Application.isPlaying)
                            {
                                if (_prefabScripts[0].state == PrefabInstancingState.Instanced)
                                {
                                    GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_prefabInstancingActive + _prefabScripts[0].gpuInstancerID, GPUInstancerEditorConstants.Styles.boldLabel);
                                }
                                else if (_prefabScripts[0].state == PrefabInstancingState.Disabled)
                                {
                                    GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_prefabInstancingDisabled + _prefabScripts[0].gpuInstancerID, GPUInstancerEditorConstants.Styles.boldLabel);
                                }
                                else
                                {
                                    GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_prefabInstancingNone, GPUInstancerEditorConstants.Styles.boldLabel);
                                }
                            }
                        }
                    }

                    if (isPrefab && !Application.isPlaying)
                    {
                        foreach (GPUInstancerPrefab prefabScript in _prefabScripts)
                        {
                            if (prefabScript != null && prefabScript.prefabPrototype != null)
                            {
                                GPUInstancerPrefabManagerEditor.CheckPrefabRigidbodies(prefabScript.prefabPrototype);
                            }
                        }

                        EditorGUILayout.BeginHorizontal();
                        if (_prefabScripts[0].prefabPrototype.meshRenderersDisabled)
                        {
                            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.enableMeshRenderers, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                                          () =>
                            {
                                foreach (GPUInstancerPrefab prefabScript in _prefabScripts)
                                {
                                    if (prefabScript != null && prefabScript.prefabPrototype != null)
                                    {
                                        GPUInstancerPrefabManagerEditor.SetRenderersEnabled(prefabScript.prefabPrototype, true);
                                    }
                                }
                            });
                        }
                        //if (!_prefabScripts[0].prefabPrototype.meshRenderersDisabled)
                        //{
                        //    GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.disableMeshRenderers, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                        //    () =>
                        //    {
                        //        if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_disableMeshRenderers, GPUInstancerEditorConstants.TEXT_disableMeshRenderersAreYouSure, "Yes", "No"))
                        //        {
                        //            foreach (GPUInstancerPrefab prefabScript in _prefabScripts)
                        //            {
                        //                if (prefabScript != null && prefabScript.prefabPrototype != null)
                        //                {
                        //                    GPUInstancerPrefabManagerEditor.SetRenderersEnabled(prefabScript.prefabPrototype, false);
                        //                }
                        //            }
                        //        }
                        //    });
                        //}
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
        }
Esempio n. 5
0
        void OnGUI()
        {
            if (helpIcon == null)
            {
                helpIcon = Resources.Load <Texture2D>(GPUInstancerConstants.EDITOR_TEXTURES_PATH + GPUInstancerEditorConstants.HELP_ICON);
            }
            if (helpIconActive == null)
            {
                helpIconActive = Resources.Load <Texture2D>(GPUInstancerConstants.EDITOR_TEXTURES_PATH + GPUInstancerEditorConstants.HELP_ICON_ACTIVE);
            }

            if (prefabList == null || prefabList.Count == 0)
            {
                this.Close();
            }

            EditorGUILayout.BeginHorizontal(GPUInstancerEditorConstants.Styles.box);
            EditorGUILayout.LabelField(GPUInstancerEditorConstants.GPUI_VERSION, GPUInstancerEditorConstants.Styles.boldLabel);
            GUILayout.FlexibleSpace();
            GPUInstancerEditor.DrawWikiButton(GUILayoutUtility.GetRect(40, 20), "#Scene_Prefab_Importer");
            GUILayout.Space(10);
            DrawHelpButton(GUILayoutUtility.GetRect(20, 20), showHelpText);
            EditorGUILayout.EndHorizontal();

            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabImporterIntro, true);

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.importSelectedPrefabs, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                List <GameObject> selectedPrefabs = new List <GameObject>();
                for (int i = 0; i < prefabList.Count; i++)
                {
                    if (isEnabledArray[i])
                    {
                        selectedPrefabs.Add(prefabList[i]);
                    }
                }

                if (selectedPrefabs.Count > 0)
                {
                    GameObject go = new GameObject("GPUI Prefab Manager");
                    GPUInstancerPrefabManager prefabManager = go.AddComponent <GPUInstancerPrefabManager>();
                    selectedPrefabs.ForEach(p => GPUInstancerPrefabManagerEditor.AddPickerObject(prefabManager, p));
                    this.Close();
                    Selection.activeGameObject = go;
                }
                else
                {
                    EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_info, GPUInstancerEditorConstants.TEXT_noPrefabInstanceSelected, GPUInstancerEditorConstants.TEXT_close);
                }
            });

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.cancel, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                this.Close();
            });

            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabImporterImportCancel);
            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Select All"))
            {
                for (int i = 0; i < prefabList.Count; i++)
                {
                    isEnabledArray[i] = true;
                }
            }
            if (GUILayout.Button("Select None"))
            {
                for (int i = 0; i < prefabList.Count; i++)
                {
                    isEnabledArray[i] = false;
                }
            }
            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabImporterSelectAllNone);

            EditorGUILayout.BeginHorizontal();
            instanceCountToSelect = EditorGUILayout.IntSlider(instanceCountToSelect, 0, maxInstanceCount);
            if (GUILayout.Button("Select Min. Instance Count"))
            {
                for (int i = 0; i < prefabList.Count; i++)
                {
                    isEnabledArray[i] = instanceCountToSelect <= instanceCountArray[i];
                }
            }
            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabImporterSelectOverCount);
            GUILayout.Space(5);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);

            GUILayout.Space(5);
            GPUInstancerEditorConstants.DrawCustomLabel("Prefab Instances", GPUInstancerEditorConstants.Styles.boldLabel);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabImporterInstanceList);
            GUILayout.Space(5);

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            EditorGUILayout.BeginVertical();
            if (prefabList != null)
            {
                for (int i = 0; i < prefabList.Count; i++)
                {
                    isEnabledArray[i] = EditorGUILayout.BeginToggleGroup(prefabList[i].name + " (Instance Count: " + instanceCountArray[i] + ")", isEnabledArray[i]);
                    EditorGUILayout.EndToggleGroup();
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            GUILayout.Space(5);
            EditorGUILayout.HelpBox(GPUInstancerEditorConstants.WARNINGTEXT_instanceCounts, MessageType.Warning);
            EditorGUILayout.EndVertical();

            //GameObject go = new GameObject("GPUI Prefab Manager");
            //GPUInstancerPrefabManager prefabManager = go.AddComponent<GPUInstancerPrefabManager>();

            //Selection.activeGameObject = go;
        }