void OnGUI()
        {
            if (_managerEditor == null || _managerEditor.GetManager() == null)
            {
                Close();
                return;
            }

            if (dropIcon == null)
            {
                dropIcon = Resources.Load <Texture2D>(GPUInstancerConstants.EDITOR_TEXTURES_PATH +
#if UNITY_PRO_LICENSE
                                                      GPUInstancerEditorConstants.DROP_ICON_PRO
#else
                                                      GPUInstancerEditorConstants.DROP_ICON
#endif
                                                      );
            }

            Rect buttonRect = GUILayoutUtility.GetRect(360, 180, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GPUInstancerEditorConstants.DrawColoredButton(new GUIContent("<size=18>Drop Files Here</size>", dropIcon), Color.clear,
#if UNITY_PRO_LICENSE
                                                          Color.white,
#else
                                                          GPUInstancerEditorConstants.Colors.dimgray,
#endif
                                                          FontStyle.Bold, buttonRect,
                                                          null,
                                                          true, true,
                                                          (o) =>
            {
                _managerEditor.AddPickerObject(o);
            });
        }
Exemplo n.º 2
0
        public void DrawGPUInstancerPrototypeAddButton()
        {
            Rect prototypeRect = GUILayoutUtility.GetRect(PROTOTYPE_RECT_SIZE, PROTOTYPE_RECT_SIZE, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));

            Rect iconRect = new Rect(prototypeRect.position + PROTOTYPE_RECT_PADDING_VECTOR, PROTOTYPE_RECT_SIZE_VECTOR);

            iconRect.height -= 22;

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.add, GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, iconRect,
                                                          () =>
            {
                _pickerOverride = null;
                pickerControlID = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
                ShowObjectPicker();
            },
                                                          true, true,
                                                          (o) =>
            {
                AddPickerObject(o);
            });

            iconRect.y     += iconRect.height;
            iconRect.height = 22;

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.addMulti, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, iconRect,
                                                          () =>
            {
                GPUInstancerMultiAddWindow.ShowWindow(GUIUtility.GUIToScreenPoint(iconRect.position), this);
            },
                                                          true, true,
                                                          (o) =>
            {
                AddPickerObject(o);
            });
        }
Exemplo n.º 3
0
        public override void DrawGPUInstancerPrototypeActions()
        {
            if (Application.isPlaying)
            {
                return;
            }

            GUILayout.Space(10);

            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_actions, GPUInstancerEditorConstants.Styles.boldLabel, false);

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.delete, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_deleteConfirmation, GPUInstancerEditorConstants.TEXT_deleteAreYouSure + "\n\"" + _prefabManager.selectedPrototype.ToString() + "\"", GPUInstancerEditorConstants.TEXT_remove, GPUInstancerEditorConstants.TEXT_cancel))
                {
                    if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_deleteConfirmation, GPUInstancerEditorConstants.TEXT_deletePrototypeAreYouSure + "\n\"" + _prefabManager.selectedPrototype.ToString() + "\"", GPUInstancerEditorConstants.TEXT_delete, GPUInstancerEditorConstants.TEXT_keepPrototypeDefinition))
                    {
                        if (((GPUInstancerPrefabPrototype)_prefabManager.selectedPrototype).meshRenderersDisabled)
                        {
                            SetRenderersEnabled((GPUInstancerPrefabPrototype)_prefabManager.selectedPrototype, true);
                        }
                        _prefabManager.DeletePrototype(_prefabManager.selectedPrototype);
                        _prefabManager.selectedPrototype = null;
                    }
                    else
                    {
                        _prefabManager.DeletePrototype(_prefabManager.selectedPrototype, false);
                        _prefabManager.selectedPrototype = null;
                    }
                }
            });
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_delete);
        }
 public static void DrawWikiButton(Rect buttonRect, string hash)
 {
     GPUInstancerEditorConstants.DrawColoredButton(new GUIContent("Wiki"),
                                                   GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, buttonRect,
                                                   () => { Application.OpenURL("https://wiki.gurbu.com/index.php?title=GPU_Instancer:GettingStarted" + hash); }
                                                   );
 }
        public override void DrawGPUInstancerPrototypeActions()
        {
            GUILayout.Space(10);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_actions, GPUInstancerEditorConstants.Styles.boldLabel, false);

            if (!_detailManager.editorDataChanged)
            {
                EditorGUI.BeginDisabledGroup(true);
            }
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.applyChangesToTerrain, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                _detailManager.ApplyEditorDataChanges();
            });
            if (!_detailManager.editorDataChanged)
            {
                EditorGUI.EndDisabledGroup();
            }
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_applyChangesToTerrain);

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.delete, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_deleteConfirmation, GPUInstancerEditorConstants.TEXT_deleteAreYouSure + "\n\"" + _detailManager.selectedPrototype.ToString() + "\"", GPUInstancerEditorConstants.TEXT_delete, GPUInstancerEditorConstants.TEXT_cancel))
                {
                    _detailManager.DeletePrototype(_detailManager.selectedPrototype);
                    _detailManager.selectedPrototype = null;
                }
            });
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_delete);
        }
        public virtual void DrawGPUInstancerPrototypeButton(GPUInstancerPrototype prototype, GUIContent prototypeContent, bool isSelected, UnityAction handleSelect)
        {
            if (prototypeContent.image == null)
            {
                prototypeContent.image = GetPreview(prototype);
            }

            Rect prototypeRect = GUILayoutUtility.GetRect(PROTOTYPE_RECT_SIZE, PROTOTYPE_RECT_SIZE, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));

            Rect iconRect = new Rect(prototypeRect.position + new Vector2(PROTOTYPE_RECT_PADDING, PROTOTYPE_RECT_PADDING),
                                     new Vector2(PROTOTYPE_RECT_SIZE - PROTOTYPE_RECT_PADDING * 2, PROTOTYPE_RECT_SIZE - PROTOTYPE_RECT_PADDING * 2));

            GUI.SetNextControlName(prototypeContent.tooltip);
            if (isSelected)
            {
                GPUInstancerEditorConstants.DrawColoredButton(prototypeContent,
                                                              string.IsNullOrEmpty(prototype.warningText) ? GPUInstancerEditorConstants.Colors.lightGreen : GPUInstancerEditorConstants.Colors.lightred, Color.black,
                                                              FontStyle.Normal, iconRect, null);
            }
            else
            {
                GPUInstancerEditorConstants.DrawColoredButton(prototypeContent,
                                                              string.IsNullOrEmpty(prototype.warningText) ? GUI.backgroundColor : GPUInstancerEditorConstants.Colors.darkred, Color.black,
                                                              FontStyle.Normal, iconRect,
                                                              () =>
                {
                    if (handleSelect != null)
                    {
                        handleSelect();
                    }
                });
            }
        }
        public override void DrawPrototypeBoxButtons()
        {
            if (!Application.isPlaying)
            {
                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.generatePrototypes, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_generatePrototypesConfirmation, GPUInstancerEditorConstants.TEXT_generatePrototypeAreYouSure, GPUInstancerEditorConstants.TEXT_generatePrototypes, GPUInstancerEditorConstants.TEXT_cancel))
                    {
                        _treeManager.GeneratePrototypes(true);
                    }
                });
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_generatePrototypesTree);

                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.regenerateBillboards, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_regenerateBillboardsConfirmation, GPUInstancerEditorConstants.TEXT_regenerateBillboardsAreYouSure, GPUInstancerEditorConstants.TEXT_regenerateBillboards, GPUInstancerEditorConstants.TEXT_cancel))
                    {
                        foreach (GPUInstancerPrototype prototype in _treeManager.prototypeList)
                        {
                            if (prototype.useGeneratedBillboard)
                            {
                                GPUInstancerUtility.GeneratePrototypeBillboard(prototype, true);
                            }
                        }
                    }
                });
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_regenerateBillboards);
            }
        }
        public void DrawMapMagicImportBox()
        {
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_mapMagicImporter, GPUInstancerEditorConstants.Styles.boldLabel);
            _mapMagicIntegration.importDetails = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_mapMagicImportDetails, _mapMagicIntegration.importDetails);
            _mapMagicIntegration.importTrees   = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_mapMagicImportTrees, _mapMagicIntegration.importTrees);

            if (_mapMagicIntegration.prefabs != null && _mapMagicIntegration.prefabs.Count > 0)
            {
                _mapMagicIntegration.importObjects = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_mapMagicImportObjects, _mapMagicIntegration.importObjects);
                if (_mapMagicIntegration.importObjects)
                {
                    EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
                    GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_mapMagicObjectsList, GPUInstancerEditorConstants.Styles.boldLabel);

                    foreach (GameObject prefab in _mapMagicIntegration.prefabs)
                    {
                        bool isPrefabSelected = _mapMagicIntegration.selectedPrefabs.Contains(prefab);
                        bool result           = EditorGUILayout.Toggle(prefab.gameObject.name, isPrefabSelected);
                        if (result && !isPrefabSelected)
                        {
                            _mapMagicIntegration.selectedPrefabs.Add(prefab);
                        }
                        else if (!result && isPrefabSelected)
                        {
                            _mapMagicIntegration.selectedPrefabs.Remove(prefab);
                        }
                    }

                    EditorGUILayout.EndVertical();
                }
            }

            Rect buttonRect = GUILayoutUtility.GetRect(100, 25, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.mapMagicImport, GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, buttonRect,
                                                          () =>
            {
                _mapMagicIntegration.GeneratePrototypes();

                prototypeList = new List <GPUInstancerPrototype>();
                if (_mapMagicIntegration.detailPrototypes != null && _mapMagicIntegration.detailPrototypes.Count > 0)
                {
                    prototypeList.AddRange(_mapMagicIntegration.detailPrototypes);
                }
                if (_mapMagicIntegration.treePrototypes != null && _mapMagicIntegration.treePrototypes.Count > 0)
                {
                    prototypeList.AddRange(_mapMagicIntegration.treePrototypes);
                }
                if (_mapMagicIntegration.prefabPrototypes != null && _mapMagicIntegration.prefabPrototypes.Count > 0)
                {
                    prototypeList.AddRange(_mapMagicIntegration.prefabPrototypes);
                }
                prototypeContents = null;
            });
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 9
0
        public void DrawDebugBox(GPUInstancerEditorSimulator simulator = null)
        {
            if (!Application.isPlaying)
            {
                EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);

                Rect foldoutRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));
                foldoutRect.x += 12;
                showDebugBox   = EditorGUI.Foldout(foldoutRect, showDebugBox, GPUInstancerEditorConstants.TEXT_debug, true, GPUInstancerEditorConstants.Styles.foldout);

                if (showDebugBox)
                {
                    if (simulator != null)
                    {
                        if (simulator.simulateAtEditor)
                        {
                            if (simulator.initializingInstances)
                            {
                                EditorGUI.BeginDisabledGroup(true);
                                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.simulateAtEditorPrep, GPUInstancerEditorConstants.Colors.darkBlue, Color.white,
                                                                              FontStyle.Bold, Rect.zero, null);
                                EditorGUI.EndDisabledGroup();
                            }
                            else
                            {
                                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.simulateAtEditorStop, Color.red, Color.white,
                                                                              FontStyle.Bold, Rect.zero, () =>
                                {
                                    simulator.StopSimulation();
                                });
                            }
                        }
                        else
                        {
                            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.simulateAtEditor, GPUInstancerEditorConstants.Colors.green, Color.white,
                                                                          FontStyle.Bold, Rect.zero, () =>
                            {
                                simulator.StartSimulation();
                            });
                        }
                    }
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_simulator);

                    _manager.keepSimulationLive = EditorGUILayout.Toggle("Keep Simulation Live", _manager.keepSimulationLive);

                    if (_manager.keepSimulationLive)
                    {
                        _manager.updateSimulation = EditorGUILayout.Toggle(new GUIContent("Update Simulation On Change", "Update Simulation On Change"), _manager.updateSimulation);

                        EditorGUILayout.HelpBox("Simulation is kept alive. The simulation might not show every change on terrain details. Changing some prototype settings during the simulation can also cause errors. Please stop and start the simulation again to solve these issues.", MessageType.Warning);
                    }
                }

                EditorGUILayout.EndVertical();
            }
        }
        public override void OnInspectorGUI()
        {
            GPUInstancerTerrainProxy terrainProxy = (GPUInstancerTerrainProxy)target;

            if (terrainProxy.detailManager != null)
            {
                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.goToGPUInstancerDetail, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (terrainProxy.detailManager != null && terrainProxy.detailManager.gameObject != null)
                    {
                        Selection.activeGameObject = terrainProxy.detailManager.gameObject;
                    }
                });
            }
            if (terrainProxy.treeManager != null)
            {
                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.goToGPUInstancerTree, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (terrainProxy.treeManager != null && terrainProxy.treeManager.gameObject != null)
                    {
                        Selection.activeGameObject = terrainProxy.treeManager.gameObject;
                    }
                });
            }
            EditorGUILayout.HelpBox(GPUInstancerEditorConstants.HELPTEXT_terrainProxyWarning, MessageType.Warning);

            // select terrain tool
            if (terrainProxy.terrainSelectedToolIndex > 0)
            {
                try
                {
                    if (terrainInspectorType == null)
                    {
                        terrainInspectorType = Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.TerrainInspector");
                    }
                    PropertyInfo selectedTool = terrainInspectorType.GetProperty("selectedTool", BindingFlags.NonPublic | BindingFlags.Instance);

                    UnityEngine.Object[] terrainInspectors = Resources.FindObjectsOfTypeAll(terrainInspectorType);
                    foreach (UnityEngine.Object terrainInspector in terrainInspectors)
                    {
                        //Debug.Log(selectedTool.GetValue(terrainInspector, new object[0]));
                        selectedTool.SetValue(terrainInspector, terrainProxy.terrainSelectedToolIndex, new object[0]);
                        break;
                    }
                }
                catch (Exception) { };

                terrainProxy.terrainSelectedToolIndex = -1;
            }
        }
Exemplo n.º 11
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 DrawGPUInstancerPrototypeActions()
        {
            GUILayout.Space(10);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_actions, GPUInstancerEditorConstants.Styles.boldLabel, false);

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.delete, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_deleteConfirmation, GPUInstancerEditorConstants.TEXT_deleteAreYouSure + "\n\"" + _treeManager.selectedPrototype.ToString() + "\"", GPUInstancerEditorConstants.TEXT_delete, GPUInstancerEditorConstants.TEXT_cancel))
                {
                    _treeManager.DeletePrototype(_treeManager.selectedPrototype);
                    _treeManager.selectedPrototype = null;
                }
            });
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_delete);
        }
Exemplo n.º 13
0
        public void DrawGPUInstancerPrototypeAddMultiButtonTextMode()
        {
            Rect prototypeRect = GUILayoutUtility.GetRect(PROTOTYPE_TEXT_RECT_SIZE_X, PROTOTYPE_TEXT_RECT_SIZE_Y, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));

            Rect iconRect = new Rect(prototypeRect.position + PROTOTYPE_RECT_PADDING_VECTOR, PROTOTYPE_TEXT_RECT_SIZE_VECTOR);

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.addMultiTextMode, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, iconRect,
                                                          () =>
            {
                GPUInstancerMultiAddWindow.ShowWindow(GUIUtility.GUIToScreenPoint(iconRect.position), this);
            },
                                                          true, true,
                                                          (o) =>
            {
                AddPickerObject(o);
            });
        }
Exemplo n.º 14
0
        public void DrawGPUInstancerPrototypeAddButton()
        {
            Rect prototypeRect = GUILayoutUtility.GetRect(PROTOTYPE_RECT_SIZE, PROTOTYPE_RECT_SIZE, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));

            Rect iconRect = new Rect(prototypeRect.position + PROTOTYPE_RECT_PADDING_VECTOR, PROTOTYPE_RECT_SIZE_VECTOR);

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.add, GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, iconRect,
                                                          () =>
            {
                _manager.pickerControlID = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
                _manager.ShowObjectPicker();
            },
                                                          true, true,
                                                          (o) =>
            {
                _manager.AddPickerObject(o);
            });
        }
        public override void DrawSettingContents()
        {
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            //EditorGUILayout.PropertyField(prop_settings);

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_terrain, _treeManager.terrain, typeof(Terrain), true);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.paintOnTerrain, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (_treeManager.terrain != null)
                {
                    GPUInstancerTerrainProxy proxy = _treeManager.AddProxyToTerrain();
                    Selection.activeGameObject     = _treeManager.terrain.gameObject;

                    proxy.terrainSelectedToolIndex = 4;
                }
            });
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.removeTerrain, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_removeTerrainConfirmation, GPUInstancerEditorConstants.TEXT_removeTerrainAreYouSure, GPUInstancerEditorConstants.TEXT_unset, GPUInstancerEditorConstants.TEXT_cancel))
                {
                    _treeManager.SetupManagerWithTerrain(null);
                }
            });
            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_terrain);

            EditorGUILayout.Space();

            EditorGUI.EndDisabledGroup();

            DrawCameraDataFields();

            DrawCullingSettings(_treeManager.prototypeList);

            DrawFloatingOriginFields();

            DrawLayerMaskFields();
        }
        public void DrawDetailTerrainAddButton()
        {
            GUILayout.Space(10);
            Rect buttonRect = GUILayoutUtility.GetRect(100, 40, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));

            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.setTerrain, GPUInstancerEditorConstants.Colors.lightBlue, Color.black, FontStyle.Bold, buttonRect,
                                                          () =>
            {
                _detailManager.pickerControlID = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
                _detailManager.ShowTerrainPicker();
            },
                                                          true, true,
                                                          (o) =>
            {
                _detailManager.AddTerrainPickerObject(o);
            });
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_setTerrain, true);
            GUILayout.Space(10);
        }
Exemplo n.º 17
0
        public void DrawDebugBox(GPUInstancerEditorSimulator simulator = null)
        {
            if (!Application.isPlaying)
            {
                EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
                GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_debug, GPUInstancerEditorConstants.Styles.boldLabel);

                if (simulator != null)
                {
                    if (simulator.simulateAtEditor)
                    {
                        if (simulator.initializingInstances)
                        {
                            EditorGUI.BeginDisabledGroup(true);
                            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.simulateAtEditorPrep, GPUInstancerEditorConstants.Colors.darkBlue, Color.white,
                                                                          FontStyle.Bold, Rect.zero, null);
                            EditorGUI.EndDisabledGroup();
                        }
                        else
                        {
                            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.simulateAtEditorStop, Color.red, Color.white,
                                                                          FontStyle.Bold, Rect.zero, () =>
                            {
                                simulator.StopSimulation();
                            });
                        }
                    }
                    else
                    {
                        GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.simulateAtEditor, GPUInstancerEditorConstants.Colors.green, Color.white,
                                                                      FontStyle.Bold, Rect.zero, () =>
                        {
                            simulator.StartSimulation();
                        });
                    }
                }
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_simulator);

                EditorGUILayout.EndVertical();
            }
        }
Exemplo n.º 18
0
 public virtual void DrawDeleteButton()
 {
     GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.delete, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                   () =>
     {
         string selectedPrototypesText = "";
         foreach (GPUInstancerPrototype prototype in _manager.selectedPrototypeList)
         {
             selectedPrototypesText += "\n\"" + prototype.ToString() + "\"";
         }
         if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_deleteConfirmation, GPUInstancerEditorConstants.TEXT_deleteAreYouSure + selectedPrototypesText, GPUInstancerEditorConstants.TEXT_delete, GPUInstancerEditorConstants.TEXT_cancel))
         {
             foreach (GPUInstancerPrototype prototype in _manager.selectedPrototypeList)
             {
                 _manager.DeletePrototype(prototype);
             }
             _manager.selectedPrototypeList.Clear();
         }
     });
     DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_delete);
 }
 public override void DrawPrefabField(GPUInstancerPrototype selectedPrototype)
 {
     EditorGUILayout.BeginHorizontal();
     base.DrawPrefabField(selectedPrototype);
     if (!Application.isPlaying)
     {
         Rect prototypeRect = GUILayoutUtility.GetRect(120, 20, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));
         GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.editPrefab, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, prototypeRect,
                                                       () =>
         {
             _pickerOverride = selectedPrototype;
             pickerControlID = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
             ShowObjectPicker();
         },
                                                       true, true,
                                                       (o) =>
         {
             AddPickerObject(o, selectedPrototype);
             prototypeContents = null;
         });
     }
     EditorGUILayout.EndHorizontal();
 }
Exemplo n.º 20
0
        public void DrawRegisterPrefabsBox()
        {
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_registeredPrefabs, GPUInstancerEditorConstants.Styles.boldLabel);
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.registerPrefabsInScene, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                Undo.RecordObject(_prefabManager, "Register prefabs in scene");
                _prefabManager.RegisterPrefabsInScene();
            });
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_registerPrefabsInScene);

            if (!Application.isPlaying && _prefabManager.registeredPrefabs.Count > 0)
            {
                foreach (RegisteredPrefabsData rpd in _prefabManager.registeredPrefabs)
                {
                    GPUInstancerEditorConstants.DrawCustomLabel(rpd.prefabPrototype.ToString() + " Instance Count: " +
                                                                rpd.registeredPrefabs.Count,
                                                                GPUInstancerEditorConstants.Styles.label, false);
                }
            }
            else if (Application.isPlaying && _prefabManager.GetRegisteredPrefabsRuntimeData() != null && _prefabManager.GetRegisteredPrefabsRuntimeData().Count > 0)
            {
                foreach (GPUInstancerPrototype p in _prefabManager.GetRegisteredPrefabsRuntimeData().Keys)
                {
                    GPUInstancerEditorConstants.DrawCustomLabel(p.ToString() + " Instance Count: " +
                                                                _prefabManager.GetRegisteredPrefabsRuntimeData()[p].Count,
                                                                GPUInstancerEditorConstants.Styles.label, false);
                }
            }
            else
            {
                GPUInstancerEditorConstants.DrawCustomLabel("No registered prefabs.", GPUInstancerEditorConstants.Styles.label, false);
            }

            EditorGUILayout.EndVertical();
        }
        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();
                    }
                }
            }
        }
Exemplo n.º 22
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 => prefabManager.AddPickerObject(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();
            EditorGUILayout.EndVertical();

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

            //Selection.activeGameObject = go;
        }
        public virtual void DrawGPUInstancerPrototypeBox(GPUInstancerPrototype selectedPrototype, bool isFrustumCulling, bool isOcclusionCulling,
                                                         GPUInstancerShaderBindings shaderBindings, GPUInstancerBillboardAtlasBindings billboardAtlasBindings)
        {
            if (selectedPrototype == null)
            {
                return;
            }

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

            foldoutRect.x   += 12;
            showPrototypeBox = EditorGUI.Foldout(foldoutRect, showPrototypeBox, selectedPrototype.ToString(), true, GPUInstancerEditorConstants.Styles.foldout);

            if (!showPrototypeBox)
            {
                EditorGUILayout.EndVertical();
                return;
            }

            if (!string.IsNullOrEmpty(selectedPrototype.warningText))
            {
                EditorGUILayout.HelpBox(selectedPrototype.warningText, MessageType.Error);
                if (selectedPrototype.warningText.StartsWith("Can not create instanced version for shader"))
                {
                    GPUInstancerEditorConstants.DrawColoredButton(new GUIContent("Go to Unity Archive"),
                                                                  GPUInstancerEditorConstants.Colors.lightred, Color.white, FontStyle.Bold, Rect.zero,
                                                                  () =>
                    {
                        Application.OpenURL("https://unity3d.com/get-unity/download/archive");
                    });
                    GUILayout.Space(10);
                }
            }

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_prefabObject, selectedPrototype.prefabObject, typeof(GameObject), false);
            EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_prototypeSO, selectedPrototype, typeof(GPUInstancerPrototype), false);
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginChangeCheck();

            #region Shadows
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_shadows, GPUInstancerEditorConstants.Styles.boldLabel);

            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            selectedPrototype.isShadowCasting = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_isShadowCasting, selectedPrototype.isShadowCasting);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_isShadowCasting);
            EditorGUI.EndDisabledGroup();
            if (selectedPrototype.isShadowCasting)
            {
                if (selectedPrototype is GPUInstancerPrefabPrototype)
                {
                    EditorGUI.BeginDisabledGroup(Application.isPlaying);
                    selectedPrototype.useOriginalShaderForShadow = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_useOriginalShaderForShadow, selectedPrototype.useOriginalShaderForShadow);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useOriginalShaderForShadow);
                    EditorGUI.EndDisabledGroup();
                }

                if (!(selectedPrototype is GPUInstancerDetailPrototype))
                {
                    selectedPrototype.useCustomShadowDistance = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_useCustomShadowDistance, selectedPrototype.useCustomShadowDistance);
                    if (selectedPrototype.useCustomShadowDistance)
                    {
                        selectedPrototype.shadowDistance = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_shadowDistance, selectedPrototype.shadowDistance, 0.0f, QualitySettings.shadowDistance);
                    }
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useCustomShadowDistance);
                    if (selectedPrototype.prefabObject != null && selectedPrototype.prefabObject.GetComponent <LODGroup>() != null)
                    {
                        LODGroup          lodGroup    = selectedPrototype.prefabObject.GetComponent <LODGroup>();
                        List <GUIContent> optionsList = GPUInstancerEditorConstants.Contents.LODs.GetRange(0, lodGroup.lodCount);
                        optionsList.Add(GPUInstancerEditorConstants.Contents.LODs[8]);
                        GUIContent[] options = optionsList.ToArray();
                        int          index   = 0;
                        for (int i = 0; i < lodGroup.lodCount; i++)
                        {
                            index = i * 4;
                            if (i >= 4)
                            {
                                index = (i - 4) * 4 + 1;
                            }
                            selectedPrototype.shadowLODMap[index] = EditorGUILayout.Popup(GPUInstancerEditorConstants.Contents.shadowLODs[i], selectedPrototype.shadowLODMap[index],
                                                                                          options);
                        }
                    }

                    selectedPrototype.cullShadows = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_cullShadows, selectedPrototype.cullShadows);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_cullShadows);
                }
            }

            EditorGUILayout.EndVertical();
            #endregion Shadows

            #region Culling
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_culling, GPUInstancerEditorConstants.Styles.boldLabel);

            selectedPrototype.maxDistance = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_maxDistance, selectedPrototype.maxDistance, 0.0f, GetMaxDistance(selectedPrototype));
            DrawHelpText(selectedPrototype is GPUInstancerDetailPrototype ? GPUInstancerEditorConstants.HELPTEXT_maxDistanceDetail : GPUInstancerEditorConstants.HELPTEXT_maxDistance);
            if (isFrustumCulling)
            {
                selectedPrototype.isFrustumCulling = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_isFrustumCulling, selectedPrototype.isFrustumCulling);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_isFrustumCulling);
                selectedPrototype.frustumOffset = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_frustumOffset, selectedPrototype.frustumOffset, 0.0f, 0.5f);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_frustumOffset);
            }

            if (isOcclusionCulling)
            {
                selectedPrototype.isOcclusionCulling = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_isOcclusionCulling, selectedPrototype.isOcclusionCulling);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_isOcclusionCulling);
            }

            if (isFrustumCulling || isOcclusionCulling)
            {
                selectedPrototype.minCullingDistance = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_minCullingDistance, selectedPrototype.minCullingDistance, 0, 100);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_minCullingDistance);
            }

            EditorGUILayout.EndVertical();
            #endregion Culling

            #region LOD
            if (selectedPrototype.prefabObject != null && (selectedPrototype.prefabObject.GetComponent <LODGroup>() != null || selectedPrototype.useGeneratedBillboard))
            {
                EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
                GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_LOD, GPUInstancerEditorConstants.Styles.boldLabel);

                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                selectedPrototype.isLODCrossFade = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_isLODCrossFade, selectedPrototype.isLODCrossFade);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_isLODCrossFade);

                if (selectedPrototype.isLODCrossFade)
                {
                    selectedPrototype.isLODCrossFadeAnimate = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_isLODCrossFadeAnimate, selectedPrototype.isLODCrossFadeAnimate);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_isLODCrossFadeAnimate);

                    if (!selectedPrototype.isLODCrossFadeAnimate)
                    {
                        selectedPrototype.lodFadeTransitionWidth = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_lodFadeTransitionWidth, selectedPrototype.lodFadeTransitionWidth, 0.0f, 1.0f);
                        DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_lodFadeTransitionWidth);
                    }
                }

                selectedPrototype.lodBiasAdjustment = EditorGUILayout.FloatField(GPUInstancerEditorConstants.TEXT_lodBiasAdjustment, selectedPrototype.lodBiasAdjustment);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_lodBiasAdjustment);
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.EndVertical();
            }
            #endregion LOD

            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            DrawGPUInstancerPrototypeInfo(selectedPrototype);

            DrawGPUInstancerPrototypeBillboardSettings(selectedPrototype, shaderBindings, billboardAtlasBindings);

            DrawGPUInstancerPrototypeActions();
            DrawGPUInstancerPrototypeAdvancedActions();

            if (EditorGUI.EndChangeCheck() && selectedPrototype != null)
            {
                EditorUtility.SetDirty(selectedPrototype);
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
        public void DrawGPUInstancerManagerGUILayout()
        {
            int prototypeRowCount = Mathf.FloorToInt((EditorGUIUtility.currentViewWidth - 30f) / PROTOTYPE_RECT_SIZE);

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_prototypes, GPUInstancerEditorConstants.Styles.boldLabel);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prototypes);

            if (!string.IsNullOrEmpty(_detailManager.terrainSettings.warningText))
            {
                EditorGUILayout.HelpBox(_detailManager.terrainSettings.warningText, MessageType.Error);
            }

            if (!Application.isPlaying)
            {
                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.generatePrototypes, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_generatePrototypesConfirmation, GPUInstancerEditorConstants.TEXT_generatePrototypeAreYouSure, GPUInstancerEditorConstants.TEXT_generatePrototypes, GPUInstancerEditorConstants.TEXT_cancel))
                    {
                        _detailManager.GeneratePrototypes(true);
                    }
                });
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_generatePrototypesDetail);
            }

            if (prototypeContents == null || prototypeContents.Length != _detailManager.prototypeList.Count)
            {
                GeneratePrototypeContents();
            }

            int i = 0;

            EditorGUILayout.BeginHorizontal();
            foreach (GPUInstancerPrototype prototype in _detailManager.prototypeList)
            {
                if (prototype == null)
                {
                    continue;
                }
                if (i != 0 && i % prototypeRowCount == 0)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }

                DrawGPUInstancerPrototypeButton(prototype, prototypeContents[i]);
                i++;
            }

            if (i != 0 && i % prototypeRowCount == 0)
            {
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
            }
            if (!Application.isPlaying)
            {
                DrawGPUInstancerPrototypeAddButton();
            }

            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_addprototypedetail);

            DrawGPUInstancerPrototypeBox(_detailManager.selectedPrototype, _detailManager.isFrustumCulling, _detailManager.isOcclusionCulling,
                                         _detailManager.shaderBindings, _detailManager.billboardAtlasBindings);

            EditorGUILayout.EndVertical();
        }
        public virtual void DrawGPUInstancerPrototypeBillboardSettings(GPUInstancerPrototype selectedPrototype,
                                                                       GPUInstancerShaderBindings shaderBindings, GPUInstancerBillboardAtlasBindings billboardAtlasBindings)
        {
            if (selectedPrototype.isBillboardDisabled || (selectedPrototype is GPUInstancerDetailPrototype && !((GPUInstancerDetailPrototype)selectedPrototype).usePrototypeMesh))
            {
                if (selectedPrototype.useGeneratedBillboard)
                {
                    selectedPrototype.useGeneratedBillboard = false;
                }
                if (selectedPrototype.billboard != null)
                {
                    selectedPrototype.billboard = null;
                }
                return;
            }

            if (Event.current.type == EventType.Repaint && !selectedPrototype.checkedForBillboardExtentions)
            {
                selectedPrototype.checkedForBillboardExtentions = true;
                if (CheckForBillboardExtentions(selectedPrototype, billboardAtlasBindings))
                {
                    return;
                }
            }

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);

            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_billboardSettings, GPUInstancerEditorConstants.Styles.boldLabel);

            selectedPrototype.useGeneratedBillboard = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_useGeneratedBillboard, selectedPrototype.useGeneratedBillboard);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useGeneratedBillboard);

            if (selectedPrototype.useGeneratedBillboard && selectedPrototype.billboard == null)
            {
                selectedPrototype.billboard = new GPUInstancerBillboard();
            }
            else if (!selectedPrototype.useGeneratedBillboard && selectedPrototype.billboard != null)
            {
                if (selectedPrototype.billboard.albedoAtlasTexture != null)
                {
                    billboardAtlasBindings.DeleteBillboardTextures(selectedPrototype);
                }
                if (!selectedPrototype.billboard.useCustomBillboard)
                {
                    selectedPrototype.billboard = null;
                }
            }

            if (selectedPrototype.useGeneratedBillboard)
            {
                if (selectedPrototype.treeType != GPUInstancerTreeType.SpeedTree && selectedPrototype.treeType != GPUInstancerTreeType.TreeCreatorTree && selectedPrototype.treeType != GPUInstancerTreeType.SoftOcclusionTree &&
                    !selectedPrototype.billboard.useCustomBillboard)
                {
                    EditorGUILayout.HelpBox(GPUInstancerEditorConstants.HELPTEXT_unsupportedBillboardWarning, MessageType.Warning);
                }

                bool previousUseCustomBillboard = selectedPrototype.billboard.useCustomBillboard;
                selectedPrototype.billboard.useCustomBillboard = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_useCustomBillboard, selectedPrototype.billboard.useCustomBillboard);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useCustomBillboard);

                if (selectedPrototype.billboard.useCustomBillboard)
                {
                    selectedPrototype.billboard.customBillboardMesh = (Mesh)EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_customBillboardMesh,
                                                                                                        selectedPrototype.billboard.customBillboardMesh, typeof(Mesh), false);
                    selectedPrototype.billboard.customBillboardMaterial = (Material)EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_customBillboardMaterial,
                                                                                                                selectedPrototype.billboard.customBillboardMaterial, typeof(Material), false);
                    selectedPrototype.billboard.isBillboardShadowCasting = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_isBillboardShadowCasting,
                                                                                                  selectedPrototype.billboard.isBillboardShadowCasting);

                    if (!previousUseCustomBillboard && selectedPrototype.billboard.albedoAtlasTexture != null)
                    {
                        billboardAtlasBindings.DeleteBillboardTextures(selectedPrototype);
                    }


                    if (shaderBindings != null && selectedPrototype.billboard.customBillboardMaterial != null)
                    {
                        if (!shaderBindings.IsShadersInstancedVersionExists(selectedPrototype.billboard.customBillboardMaterial.shader.name))
                        {
                            Shader instancedShader = GPUInstancerUtility.CreateInstancedShader(selectedPrototype.billboard.customBillboardMaterial.shader, shaderBindings);
                            if (instancedShader != null)
                            {
                                shaderBindings.AddShaderInstance(selectedPrototype.billboard.customBillboardMaterial.shader.name, instancedShader);
                            }
                        }
                    }
                }
                else
                {
                    if (selectedPrototype.billboard.customBillboardInLODGroup)
                    {
                        selectedPrototype.billboard.customBillboardInLODGroup = false;
                    }

                    selectedPrototype.billboard.billboardQuality = (BillboardQuality)EditorGUILayout.Popup(GPUInstancerEditorConstants.TEXT_billboardQuality,
                                                                                                           (int)selectedPrototype.billboard.billboardQuality, GPUInstancerEditorConstants.TEXT_BillboardQualityOptions);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_billboardQuality);

                    switch (selectedPrototype.billboard.billboardQuality)
                    {
                    case BillboardQuality.Low:
                        selectedPrototype.billboard.atlasResolution = 1024;
                        break;

                    case BillboardQuality.Mid:
                        selectedPrototype.billboard.atlasResolution = 2048;
                        break;

                    case BillboardQuality.High:
                        selectedPrototype.billboard.atlasResolution = 4096;
                        break;

                    case BillboardQuality.VeryHigh:
                        selectedPrototype.billboard.atlasResolution = 8192;
                        break;
                    }

                    selectedPrototype.billboard.frameCount = EditorGUILayout.IntSlider(GPUInstancerEditorConstants.TEXT_billboardFrameCount, selectedPrototype.billboard.frameCount, 8, 32);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_billboardFrameCount);
                    selectedPrototype.billboard.frameCount = Mathf.NextPowerOfTwo(selectedPrototype.billboard.frameCount);

                    selectedPrototype.billboard.billboardBrightness = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_billboardBrightness, selectedPrototype.billboard.billboardBrightness, 0.0f, 1.0f);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_billboardBrightness);

                    selectedPrototype.billboard.isOverridingOriginalCutoff = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_overrideOriginalCutoff, selectedPrototype.billboard.isOverridingOriginalCutoff);
                    if (selectedPrototype.billboard.isOverridingOriginalCutoff)
                    {
                        selectedPrototype.billboard.cutoffOverride = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_overrideCutoffAmount, selectedPrototype.billboard.cutoffOverride, 0.01f, 1.0f);
                    }
                    else
                    {
                        selectedPrototype.billboard.cutoffOverride = -1f;
                    }
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_overrideOriginalCutoff);
                }

                if (!selectedPrototype.billboard.customBillboardInLODGroup)
                {
                    bool hasLODGroup        = selectedPrototype.prefabObject.GetComponent <LODGroup>() != null;
                    bool speedTreeBillboard = selectedPrototype.treeType == GPUInstancerTreeType.SpeedTree && hasLODGroup &&
                                              selectedPrototype.prefabObject.GetComponentInChildren <BillboardRenderer>() != null;
                    if (hasLODGroup && !speedTreeBillboard)
                    {
                        selectedPrototype.billboard.replaceLODCullWithBillboard = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_replaceLODCull, selectedPrototype.billboard.replaceLODCullWithBillboard);
                        DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_replaceLODCull);
                    }
                    if ((!hasLODGroup || !selectedPrototype.billboard.replaceLODCullWithBillboard) && !speedTreeBillboard)
                    {
                        selectedPrototype.billboard.billboardDistance = EditorGUILayout.Slider(GPUInstancerEditorConstants.TEXT_generatedBillboardDistance, selectedPrototype.billboard.billboardDistance, 0.01f, 1f);
                        DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_generatedBillboardDistance);
                    }
                }

                if (!selectedPrototype.billboard.useCustomBillboard)
                {
                    selectedPrototype.billboard.billboardFaceCamPos = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_billboardFaceCamPos, selectedPrototype.billboard.billboardFaceCamPos);
                    DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_billboardFaceCamPos);

                    if (selectedPrototype.billboard.albedoAtlasTexture == null)
                    {
                        GPUInstancerUtility.AssignBillboardBinding(selectedPrototype, billboardAtlasBindings);
                    }

                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_billboardAlbedo, selectedPrototype.billboard.albedoAtlasTexture, typeof(GameObject), false);
                    EditorGUILayout.ObjectField(GPUInstancerEditorConstants.TEXT_billboardNormal, selectedPrototype.billboard.normalAtlasTexture, typeof(GameObject), false);
                    EditorGUI.EndDisabledGroup();
                }

                GUILayout.Space(10);

                EditorGUILayout.BeginHorizontal();

                if (!selectedPrototype.billboard.useCustomBillboard)
                {
                    GPUInstancerEditorConstants.DrawColoredButton(selectedPrototype.billboard.albedoAtlasTexture == null ?
                                                                  GPUInstancerEditorConstants.Contents.generateBillboard : GPUInstancerEditorConstants.Contents.regenerateBillboard,
                                                                  GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                                  () =>
                    {
                        GPUInstancerUtility.GeneratePrototypeBillboard(selectedPrototype, billboardAtlasBindings, selectedPrototype.billboard.albedoAtlasTexture != null);
                    });
                }

                if ((!selectedPrototype.billboard.useCustomBillboard && selectedPrototype.billboard.albedoAtlasTexture != null) ||
                    (selectedPrototype.billboard.useCustomBillboard &&
                     selectedPrototype.billboard.customBillboardMesh != null &&
                     selectedPrototype.billboard.customBillboardMaterial != null))
                {
                    GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.showBillboard, GPUInstancerEditorConstants.Colors.lightBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                                  () =>
                    {
                        GPUInstancerUtility.ShowBillboardQuad(selectedPrototype, Vector3.zero);
                    });
                }

                EditorGUILayout.EndHorizontal();

                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_regenerateBillboard);
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_showBillboard);
            }

            if (selectedPrototype.useGeneratedBillboard && selectedPrototype.billboard != null && selectedPrototype.billboard.useCustomBillboard && GPUInstancerDefines.billboardExtentions != null && GPUInstancerDefines.billboardExtentions.Count > 0)
            {
                GUILayout.Space(10);

                EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);

                GPUInstancerEditorConstants.DrawCustomLabel("External Billboard Generators", GPUInstancerEditorConstants.Styles.boldLabel);

                GUILayout.Space(5);

                foreach (Extention.GPUInstancerBillboardExtention billboardExtention in GPUInstancerDefines.billboardExtentions)
                {
                    try
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(billboardExtention.GetTitle(), GPUInstancerEditorConstants.Styles.label);

                        GPUInstancerEditorConstants.DrawColoredButton(new GUIContent(billboardExtention.GetButtonText()), GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                                      () =>
                        {
                            _redirectObject = billboardExtention.GenerateBillboard(selectedPrototype.prefabObject);
                            selectedPrototype.checkedForBillboardExtentions = false;
                        });
                        EditorGUILayout.EndHorizontal();

                        GUILayout.Space(5);
                    }
                    catch (System.Exception e)
                    {
                        EditorUtility.ClearProgressBar();
                        Debug.LogError("Error generating billboard: " + e.Message + " StackTrace:" + e.StackTrace);
                    }
                }

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 26
0
        public virtual void DrawGPUInstancerPrototypesBox()
        {
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);

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

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


            Rect switchRect = GUILayoutUtility.GetRect(80, 20, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));

            GPUInstancerEditorConstants.DrawColoredButton(new GUIContent(_manager.isPrototypeTextMode ? "Icon Mode" : "Text Mode"), GPUInstancerEditorConstants.Colors.green, Color.white,
                                                          FontStyle.Bold, switchRect, () => _manager.isPrototypeTextMode = !_manager.isPrototypeTextMode);
            EditorGUILayout.EndHorizontal();

            if (showPrototypesBox)
            {
                int prototypeRowCount = Mathf.FloorToInt((EditorGUIUtility.currentViewWidth - 30f) / (_manager.isPrototypeTextMode ? PROTOTYPE_TEXT_RECT_SIZE_X : PROTOTYPE_RECT_SIZE));
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prototypes);

                DrawPrototypeBoxButtons();

                if (prototypeContents == null || prototypeContents.Length != _manager.prototypeList.Count)
                {
                    GeneratePrototypeContents();
                }

                int i = 0;
                EditorGUILayout.BeginHorizontal();
                foreach (GPUInstancerPrototype prototype in _manager.prototypeList)
                {
                    if (prototype == null)
                    {
                        continue;
                    }
                    if (i != 0 && i % prototypeRowCount == 0)
                    {
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                    }

                    DrawGPUInstancerPrototypeButton(prototype, prototypeContents[i]);
                    i++;
                }

                if (i != 0 && i % prototypeRowCount == 0)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }
                if (!Application.isPlaying)
                {
                    if (_manager.isPrototypeTextMode)
                    {
                        DrawGPUInstancerPrototypeAddButtonTextMode();
                        i++;
                        if (i != 0 && i % prototypeRowCount == 0)
                        {
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                        }
                        DrawGPUInstancerPrototypeAddMultiButtonTextMode();
                    }
                    else
                    {
                        DrawGPUInstancerPrototypeAddButton();
                    }
                }

                EditorGUILayout.EndHorizontal();
                DrawAddPrototypeHelpText();

                GPUInstancerEditorConstants.DrawCustomLabel("<size=10><i>*Ctrl+Clict to select multiple, Shift+Click to select adjacent items.</i></size>",
                                                            GPUInstancerEditorConstants.Styles.richLabel, false);

                DrawGPUInstancerPrototypeBox(_manager.selectedPrototypeList, _manager.isFrustumCulling, _manager.isOcclusionCulling);
            }
            EditorGUILayout.EndVertical();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (_mapMagicIntegration.cameraData.mainCamera == null)
            {
                _mapMagicIntegration.cameraData.SetCamera(Camera.main);
            }

            base.OnInspectorGUI();
#if MAPMAGIC
            if (_mapMagicIntegration.mapMagicInstance == null)
            {
                // set map magic instance

                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                GUILayout.Space(10);
                Rect buttonRect = GUILayoutUtility.GetRect(100, 40, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));

                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.mapMagicSet, GPUInstancerEditorConstants.Colors.lightBlue, Color.black, FontStyle.Bold, buttonRect,
                                                              () =>
                {
                    _mapMagicIntegration.SetMapMagicInstance();
                });
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_setMapMagic, true);
                GUILayout.Space(10);
                EditorGUI.EndDisabledGroup();
                return;
            }
            else
            {
                // import box
                _mapMagicIntegration.SetUpWithGeneratorsAsset();
                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                DrawMapMagicImportBox();
                EditorGUI.EndDisabledGroup();


                if ((_mapMagicIntegration.detailPrototypes != null && _mapMagicIntegration.detailPrototypes.Count > 0) ||
                    (_mapMagicIntegration.prefabPrototypes != null && _mapMagicIntegration.prefabPrototypes.Count > 0) ||
                    (_mapMagicIntegration.treePrototypes != null && _mapMagicIntegration.treePrototypes.Count > 0)
                    )
                {
                    EditorGUI.BeginDisabledGroup(Application.isPlaying);
                    EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(GPUInstancerEditorConstants.TEXT_sceneSettings, GPUInstancerEditorConstants.Styles.boldLabel);
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    DrawCameraDataFields();
                    DrawCullingSettings(prototypeList);
                    EditorGUI.EndDisabledGroup();

                    EditorGUILayout.EndVertical();

                    int prototypeCount = (_mapMagicIntegration.detailPrototypes != null ? _mapMagicIntegration.detailPrototypes.Count : 0) +
                                         (_mapMagicIntegration.treePrototypes != null ? _mapMagicIntegration.treePrototypes.Count : 0) +
                                         (_mapMagicIntegration.prefabPrototypes != null ? _mapMagicIntegration.prefabPrototypes.Count : 0);

                    if (prototypeContents == null || prototypeContents.Length != prototypeCount)
                    {
                        GeneratePrototypeContents();
                    }

                    // prototypes editor
                    if (_mapMagicIntegration.detailPrototypes != null && _mapMagicIntegration.detailPrototypes.Count > 0)
                    {
                        DrawMapMagicDetailGlobalInfoBox();
                        DrawMapMagicDetailPrototypesBox();
                    }
                    if (_mapMagicIntegration.treePrototypes != null && _mapMagicIntegration.treePrototypes.Count > 0)
                    {
                        DrawMapMagicTreePrototypesBox();
                    }

                    if (_mapMagicIntegration.prefabPrototypes != null && _mapMagicIntegration.prefabPrototypes.Count > 0)
                    {
                        DrawMapMagicPrefabGlobalInfoBox();
                        DrawMapMagicPrefabPrototypesBox();
                    }
                }
            }
#else
            EditorGUILayout.HelpBox("Map Magic is not present!", MessageType.Error);
#endif

            serializedObject.ApplyModifiedProperties();

            base.InspectorGUIEnd();
        }
        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);
            }

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

            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabReplacerIntro, true);

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

            GPUInstancerEditorConstants.DrawColoredButton(new GUIContent("Replace Selection With Prefab"), GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                ReplaceSelectionWithPrefab();
            });

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

            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabReplacerReplaceCancel);

            GUILayout.Space(10);
            selectedPrefab = (GameObject)EditorGUILayout.ObjectField("Prefab", selectedPrefab, typeof(GameObject), false);

#if UNITY_2018_3_OR_NEWER
            if (selectedPrefab != null &&
                PrefabUtility.GetPrefabAssetType(selectedPrefab) != PrefabAssetType.Regular &&
                PrefabUtility.GetPrefabAssetType(selectedPrefab) != PrefabAssetType.Variant)
#else
            if (selectedPrefab != null && PrefabUtility.GetPrefabType(selectedPrefab) != PrefabType.Prefab)
#endif
            { selectedPrefab = null; }
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabReplacerPrefab);

            replaceNames = EditorGUILayout.Toggle("Replace Names", replaceNames);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabReplacerReplaceNames);

            GUILayout.Space(10);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GUILayout.Space(5);
            GPUInstancerEditorConstants.DrawCustomLabel("Selected GameObjects", GPUInstancerEditorConstants.Styles.boldLabel);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prefabReplacerSelectedObjects);
            GUILayout.Space(5);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            EditorGUILayout.BeginVertical();
            foreach (Transform selectedTransform in Selection.transforms)
            {
                EditorGUILayout.LabelField(selectedTransform.name);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
        public void DrawGPUInstancerManagerGUILayout()
        {
            int prototypeRowCount = Mathf.FloorToInt((EditorGUIUtility.currentViewWidth - 30f) / PROTOTYPE_RECT_SIZE);

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_prototypes, GPUInstancerEditorConstants.Styles.boldLabel);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_prototypes);

            if (!Application.isPlaying)
            {
                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.generatePrototypes, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_generatePrototypesConfirmation, GPUInstancerEditorConstants.TEXT_generatePrototypeAreYouSure, GPUInstancerEditorConstants.TEXT_generatePrototypes, GPUInstancerEditorConstants.TEXT_cancel))
                    {
                        _treeManager.GeneratePrototypes(true);
                    }
                });
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_generatePrototypesTree);

                GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.regenerateBillboards, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                              () =>
                {
                    if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_regenerateBillboardsConfirmation, GPUInstancerEditorConstants.TEXT_regenerateBillboardsAreYouSure, GPUInstancerEditorConstants.TEXT_regenerateBillboards, GPUInstancerEditorConstants.TEXT_cancel))
                    {
                        foreach (GPUInstancerPrototype prototype in _treeManager.prototypeList)
                        {
                            if (prototype.useGeneratedBillboard)
                            {
                                GPUInstancerUtility.GeneratePrototypeBillboard(prototype, _treeManager.billboardAtlasBindings, true);
                            }
                        }
                    }
                });
                DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_regenerateBillboards);
            }

            if (prototypeContents == null || prototypeContents.Length != _treeManager.prototypeList.Count)
            {
                GeneratePrototypeContents();
            }

            int i = 0;

            EditorGUILayout.BeginHorizontal();
            foreach (GPUInstancerPrototype prototype in _treeManager.prototypeList)
            {
                if (prototype == null)
                {
                    continue;
                }
                if (i != 0 && i % prototypeRowCount == 0)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }

                DrawGPUInstancerPrototypeButton(prototype, prototypeContents[i]);
                i++;
            }

            if (i != 0 && i % prototypeRowCount == 0)
            {
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
            }
            if (!Application.isPlaying)
            {
                DrawGPUInstancerPrototypeAddButton();
            }

            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_addprototypetree);

            DrawGPUInstancerPrototypeBox(_treeManager.selectedPrototype, prop_isManagerFrustumCulling.boolValue, prop_isManagerOcclusionCulling.boolValue,
                                         _treeManager.shaderBindings, _treeManager.billboardAtlasBindings);

            EditorGUILayout.EndVertical();
        }
        public override void DrawSettingContents()
        {
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            //EditorGUILayout.PropertyField(prop_settings);

            if (Application.isPlaying)
            {
                int index = 1;
                foreach (Terrain terrain in _treeManager.GetTerrains())
                {
                    EditorGUILayout.ObjectField("Terrain " + index, terrain, typeof(Terrain), true);
                    index++;
                }
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("Main " + GPUInstancerEditorConstants.TEXT_terrain, _treeManager.terrain, typeof(Terrain), true);
                EditorGUI.EndDisabledGroup();

                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(prop_additionalTerrains, true);
                EditorGUI.indentLevel--;

                if (prop_additionalTerrains.arraySize > 0)
                {
                    EditorGUILayout.HelpBox("When using Tree Manager with multiple Terrains, it requires every Terrain to have the same Tree prototypes defined on it. Adding Terrains with different tree prototypes might cause incorrect rendering and errors.", MessageType.Warning);
                }
            }

            EditorGUILayout.BeginHorizontal();
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.paintOnTerrain, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (_treeManager.terrain != null)
                {
                    GPUInstancerTerrainProxy proxy = _treeManager.AddProxyToTerrain();
                    Selection.activeGameObject     = _treeManager.terrain.gameObject;

                    proxy.terrainSelectedToolIndex = 4;
                }
            });
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.removeTerrain, Color.red, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                if (EditorUtility.DisplayDialog(GPUInstancerEditorConstants.TEXT_removeTerrainConfirmation, GPUInstancerEditorConstants.TEXT_removeTerrainAreYouSure, GPUInstancerEditorConstants.TEXT_unset, GPUInstancerEditorConstants.TEXT_cancel))
                {
                    _treeManager.SetupManagerWithTerrain(null);
                }
            });
            EditorGUILayout.EndHorizontal();
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_terrain);

            EditorGUILayout.Space();

            EditorGUI.EndDisabledGroup();

            DrawCameraDataFields();

            DrawCullingSettings(_treeManager.prototypeList);

            DrawFloatingOriginFields();

            DrawLayerMaskFields();
        }