Exemplo n.º 1
0
        public static bool DrawListHeader(Rect rect, bool currentFoldOutState, bool currentToggleAllState, List <AutoSpawner> spawnerList, EditorUtils editorUtils, ref GaiaConstants.AutoSpawnerArea autoSpawnerArea)
        {
            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            //rect.xMin += 0f;


            Rect dropdownRect = new Rect(rect);

            dropdownRect.width  = 50;
            dropdownRect.height = 15;
            dropdownRect.y     += 2;
            dropdownRect.x      = rect.x + rect.width - 2 - dropdownRect.width;

            GUIStyle dropdownStyle = new GUIStyle(GUI.skin.button);

            dropdownStyle.fixedHeight = 15;

            Rect label2Rect = new Rect(rect);

            label2Rect.width = 30;
            label2Rect.x     = dropdownRect.x - 5 - label2Rect.width;


            Rect label1Rect = new Rect(rect);

            label1Rect.x    += 35;
            label1Rect.width = rect.width - label2Rect.width - 35 - dropdownRect.width - 5 - 10;


            Rect toggleAllRect = new Rect(rect);

            toggleAllRect.x    += 15;
            toggleAllRect.width = 12;

            bool oldToggleOldState = currentToggleAllState;

            currentToggleAllState = EditorGUI.Toggle(toggleAllRect, currentToggleAllState);
            EditorGUI.LabelField(toggleAllRect, editorUtils.GetContent("AutoToggleAllTooltip"));

            if (currentToggleAllState != oldToggleOldState)
            {
                foreach (AutoSpawner entry in spawnerList)
                {
                    entry.isActive = currentToggleAllState;
                }
            }

            EditorGUI.LabelField(label1Rect, editorUtils.GetContent("AutoSpawnerHeader"));
            EditorGUI.LabelField(label2Rect, editorUtils.GetContent("AutoSpawnerAreaLabel"));

            autoSpawnerArea = (GaiaConstants.AutoSpawnerArea)EditorGUI.EnumPopup(dropdownRect, autoSpawnerArea, dropdownStyle);
            EditorGUI.LabelField(dropdownRect, editorUtils.GetContent("AutoSpawnerAreaTooltip"));

            //bool newFoldOutState = EditorGUI.Foldout(rect, currentFoldOutState, PropertyCount("SpawnerAdded", spawnerList, editorUtils), true);
            EditorGUI.indentLevel = oldIndent;
            //return newFoldOutState;


            return(currentToggleAllState);
        }
Exemplo n.º 2
0
        public static GUIContent PropertyCount(string key, List <BiomeSpawnerListEntry> list, EditorUtils editorUtils)
        {
            GUIContent content = editorUtils.GetContent(key);

            content.text += " [" + list.Count + "]";
            return(content);
        }
Exemplo n.º 3
0
        public static void DrawListHeader(Rect rect, bool currentFoldOutState, List <BiomeSpawnerListEntry> spawnerList, EditorUtils editorUtils, string headerKey)
        {
            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            //rect.xMin += 0f;
            EditorGUI.LabelField(rect, editorUtils.GetContent(headerKey));
            //bool newFoldOutState = EditorGUI.Foldout(rect, currentFoldOutState, PropertyCount("SpawnerAdded", spawnerList, editorUtils), true);
            EditorGUI.indentLevel = oldIndent;
            //return newFoldOutState;
        }
Exemplo n.º 4
0
        public static void DrawListElementInBiome(Rect rect, BiomeSpawnerListEntry listEntry, EditorUtils m_editorUtils)
        {
            int  oldIndent   = EditorGUI.indentLevel;
            Rect controlRect = new Rect(rect);

            controlRect.width     = 40;
            controlRect.height    = EditorGUIUtility.singleLineHeight;
            EditorGUI.indentLevel = 0;
            EditorGUI.LabelField(controlRect, "Active");
            controlRect.x               = rect.x + 40;
            controlRect.width           = 10;
            listEntry.m_isActiveInBiome = EditorGUI.Toggle(controlRect, listEntry.m_isActiveInBiome);
            controlRect.width           = rect.width - 70;
            controlRect.x               = rect.x + 70;
            listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUI.ObjectField(controlRect, listEntry.m_spawnerSettings, typeof(SpawnerSettings), false);
            EditorGUI.indentLevel       = oldIndent;
        }
Exemplo n.º 5
0
        public static void DrawListElement_AdvancedTab(Rect rect, BiomeSpawnerListEntry listEntry, EditorUtils m_editorUtils)
        {
            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            Rect labelRect = rect;

            //260 is the total width of the controls at the end of each row
            labelRect.width  = rect.width - 280;
            labelRect.height = EditorGUIUtility.singleLineHeight;

            EditorGUI.LabelField(labelRect, listEntry.m_spawnerSettings.name);

            EditorGUIUtility.AddCursorRect(labelRect, MouseCursor.Zoom);
            if (labelRect.Contains(Event.current.mousePosition) && Event.current.clickCount > 0)
            {
                Selection.activeObject = listEntry.m_spawnerSettings;
                EditorGUIUtility.PingObject(Selection.activeObject);
            }

            labelRect.x     = rect.width - 230;
            labelRect.width = 110f;

            EditorGUI.LabelField(labelRect, m_editorUtils.GetContent("SpawnerListAutoAssignPrototypes"));

            labelRect.x     = rect.width - 130f;
            labelRect.width = 20f;

            listEntry.m_autoAssignPrototypes = EditorGUI.Toggle(labelRect, listEntry.m_autoAssignPrototypes);

            labelRect.x     = rect.width - 80f;
            labelRect.width = 100f;
            if (GUI.Button(labelRect, m_editorUtils.GetContent("AdvancedTabAddSpawner")))
            {
                Spawner newSpawner = listEntry.m_spawnerSettings.CreateSpawner(listEntry.m_autoAssignPrototypes);
                Selection.activeGameObject = newSpawner.gameObject;
            }


            EditorGUI.indentLevel = oldIndent;
        }
Exemplo n.º 6
0
        //public static void DrawListElement_GaiaManager(Rect rect, BiomeSpawnerListEntry listEntry, EditorUtils m_editorUtils, EditorWindow window = null)
        //{
        //    int oldIndent = EditorGUI.indentLevel;
        //    Rect controlRect = new Rect(rect);
        //    controlRect.width = 40;
        //    controlRect.height = EditorGUIUtility.singleLineHeight;
        //    EditorGUI.indentLevel = 0;
        //    EditorGUI.LabelField(controlRect, m_editorUtils.GetContent("SpawnerListActive"));
        //    controlRect.x = rect.x + 40;
        //    controlRect.width = 10;
        //    listEntry.m_isActiveInStamper = EditorGUI.Toggle(controlRect, listEntry.m_isActiveInStamper);
        //    controlRect.width = 40;
        //    EditorGUI.LabelField(controlRect, m_editorUtils.GetContent("BiomeActive"));
        //    controlRect.x = rect.x + 40;
        //    controlRect.width = 10;
        //    listEntry.m_isActiveInBiome = EditorGUI.Toggle(controlRect, listEntry.m_isActiveInBiome);
        //    controlRect.x = rect.x + 60;
        //    controlRect.width = 70;
        //    controlRect.height = EditorGUIUtility.singleLineHeight;
        //    EditorGUI.LabelField(controlRect, m_editorUtils.GetContent("SpawnerListAutoAssignPrototypes"));
        //    controlRect.x = rect.x + 125;
        //    controlRect.width = 10;
        //    listEntry.m_autoAssignPrototypes = EditorGUI.Toggle(controlRect, listEntry.m_autoAssignPrototypes);
        //    controlRect.width = 26;
        //    controlRect.x = rect.x + rect.width - 30;
        //    int controlID = EditorGUIUtility.GetControlID(FocusType.Passive);
        //    if (GUI.Button(controlRect, " "))
        //    {
        //        EditorGUIUtility.ShowObjectPicker<SpawnerSettings>(listEntry.m_spawnerSettings, false, "l:GaiaManagerSpawner", controlID);
        //    }
        //    controlRect.width = rect.width - 160;
        //    controlRect.x = rect.x + 150;
        //    listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUI.ObjectField(controlRect, listEntry.m_spawnerSettings, typeof(SpawnerSettings), false);

        //    string commandName = Event.current.commandName;
        //    if (commandName == "ObjectSelectorUpdated")
        //    {
        //        if (controlID == EditorGUIUtility.GetObjectPickerControlID())
        //        {
        //            listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUIUtility.GetObjectPickerObject();
        //            if (window != null)
        //            {
        //                window.Repaint();
        //            }
        //        }
        //    }
        //    else if (commandName == "ObjectSelectorClosed")
        //    {
        //        if (controlID == EditorGUIUtility.GetObjectPickerControlID())
        //        {
        //            listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUIUtility.GetObjectPickerObject();
        //        }
        //    }

        //    EditorGUI.indentLevel = oldIndent;
        //}

        public static void DrawListElement(Rect rect, BiomeSpawnerListEntry listEntry, EditorUtils m_editorUtils, EditorWindow window = null)
        {
            int  oldIndent   = EditorGUI.indentLevel;
            Rect controlRect = new Rect(rect);

            EditorGUI.indentLevel = 0;
            controlRect.height    = EditorGUIUtility.singleLineHeight;
            controlRect.width     = 12;
            EditorGUI.LabelField(controlRect, m_editorUtils.GetContent("StamperActive"));
            controlRect.x                 = rect.x + 12;
            controlRect.width             = 20;
            listEntry.m_isActiveInStamper = EditorGUI.Toggle(controlRect, listEntry.m_isActiveInStamper);
            controlRect.x                 = controlRect.x + 20;
            controlRect.width             = 12;
            EditorGUI.LabelField(controlRect, m_editorUtils.GetContent("BiomeActive"));
            controlRect.x               = controlRect.x + 12;
            controlRect.width           = 15;
            listEntry.m_isActiveInBiome = EditorGUI.Toggle(controlRect, listEntry.m_isActiveInBiome);
            controlRect.x               = controlRect.x + 20;
            controlRect.width           = 12;
            EditorGUI.LabelField(controlRect, m_editorUtils.GetContent("AutoAssignPrototypes"));
            controlRect.x     = controlRect.x + 12;
            controlRect.width = 15;
            listEntry.m_autoAssignPrototypes = EditorGUI.Toggle(controlRect, listEntry.m_autoAssignPrototypes);
            controlRect.x     = rect.x + 10;
            controlRect.width = 20;
            controlRect.x     = rect.x + rect.width - 20;
            int controlID = EditorGUIUtility.GetControlID(FocusType.Passive);

            if (GUI.Button(controlRect, " "))
            {
                EditorGUIUtility.ShowObjectPicker <SpawnerSettings>(listEntry.m_spawnerSettings, false, "l:" + GaiaConstants.gaiaManagerSpawnerLabel, controlID);
            }
            controlRect.width = rect.width - 100;
            controlRect.x     = rect.x + 100;

            EditorGUI.BeginChangeCheck();
            listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUI.ObjectField(controlRect, listEntry.m_spawnerSettings, typeof(SpawnerSettings), false);

            string commandName = Event.current.commandName;

            if (commandName == "ObjectSelectorUpdated")
            {
                if (controlID == EditorGUIUtility.GetObjectPickerControlID())
                {
                    //Triggers when the custom picker object was updated
                    listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUIUtility.GetObjectPickerObject();
                    listEntry.m_spawnerSettings.RefreshGUID();
                    if (window != null)
                    {
                        window.Repaint();
                    }
                }
            }
            else if (commandName == "ObjectSelectorClosed")
            {
                if (controlID == EditorGUIUtility.GetObjectPickerControlID())
                {
                    //Triggers when the custom picker object was closed
                    listEntry.m_spawnerSettings = (SpawnerSettings)EditorGUIUtility.GetObjectPickerObject();
                    listEntry.m_spawnerSettings.RefreshGUID();
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                //Triggers when the user drags and drops a spawner settings file into the slot
                listEntry.m_spawnerSettings.RefreshGUID();
            }

            EditorGUI.indentLevel = oldIndent;
        }
Exemplo n.º 7
0
        public static void DrawMaskListElement(Rect rect, int index, CollisionMask collisionMask, EditorUtils m_editorUtils, Terrain currentTerrain, GaiaConstants.FeatureOperation operation)
        {
            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            //Active Label
            Rect fieldRect = new Rect(rect.x, rect.y, rect.width * 0.1f, EditorGUIUtility.singleLineHeight);

            EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("MaskActive"));
            //Active Checkbox
            fieldRect.x           += rect.width * 0.1f;
            fieldRect.width        = rect.width * 0.05f;
            collisionMask.m_active = EditorGUI.Toggle(fieldRect, collisionMask.m_active);
            //Invert Label
            fieldRect.x    += rect.width * 0.05f;
            fieldRect.width = rect.width * 0.1f;
            EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("MaskInvert"));
            //Invert Checkbox
            fieldRect.x           += rect.width * 0.1f;
            fieldRect.width        = rect.width * 0.05f;
            collisionMask.m_invert = EditorGUI.Toggle(fieldRect, collisionMask.m_invert);
            //Type dropdown
            fieldRect.x    += rect.width * 0.05f;
            fieldRect.width = rect.width * 0.2f;
            BakedMaskType oldType = collisionMask.m_type;

            collisionMask.m_type = (BakedMaskType)EditorGUI.EnumPopup(fieldRect, collisionMask.m_type);
            EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskTypeTooltip"));
            switch (collisionMask.m_type)
            {
            case BakedMaskType.RadiusTree:
                //Tree dropdown
                string oldTreeId = collisionMask.m_treeSpawnRuleGUID;
                fieldRect.x += rect.width * 0.2f;
                int selectedGUIDIndex = 0;
                if (collisionMask.m_treeSpawnRuleGUID != "")
                {
                    SpawnRule selectedRule = CollisionMask.m_allTreeSpawnRules.FirstOrDefault(x => x.GUID == collisionMask.m_treeSpawnRuleGUID);
                    if (selectedRule != null)
                    {
                        selectedGUIDIndex = Array.IndexOf(CollisionMask.m_allTreeSpawnRules, selectedRule);
                    }
                }
                selectedGUIDIndex = EditorGUI.IntPopup(fieldRect, selectedGUIDIndex, CollisionMask.m_allTreeSpawnRuleNames, CollisionMask.m_allTreeSpawnRuleIndices);
                if (selectedGUIDIndex >= 0 && selectedGUIDIndex < CollisionMask.m_allTreeSpawnRules.Length)
                {
                    collisionMask.m_treeSpawnRuleGUID = CollisionMask.m_allTreeSpawnRules[selectedGUIDIndex].GUID;
                }
                if (oldType != collisionMask.m_type || oldTreeId != collisionMask.m_treeSpawnRuleGUID)
                {
                    SpawnRule selectedRule = CollisionMask.m_allTreeSpawnRules.FirstOrDefault(x => x.GUID == collisionMask.m_treeSpawnRuleGUID);
                    if (selectedRule != null)
                    {
                        Spawner spawner = CollisionMask.m_allTreeSpawners.FirstOrDefault(x => x.m_settings.m_spawnerRules.Contains(selectedRule));
                        if (spawner != null)
                        {
                            GameObject treePrefab = spawner.m_settings.m_resources.m_treePrototypes[selectedRule.m_resourceIdx].m_desktopPrefab;
                            collisionMask.m_Radius = GaiaUtils.GetTreeRadius(treePrefab);
                        }
                    }
                }

                fieldRect.x           += rect.width * 0.2f;
                fieldRect.width        = rect.width * 0.1f;
                collisionMask.m_Radius = EditorGUI.FloatField(fieldRect, collisionMask.m_Radius);
                fieldRect.x           += rect.width * 0.1f;
                fieldRect.width        = rect.width * 0.2f;
                break;

            case BakedMaskType.RadiusTag:
                //Tree dropdown
                fieldRect.x += rect.width * 0.2f;
                ////Building up a value array of incrementing ints of the size of the available tags this array will then match the displayed string selection in the popup
                //int[] tagValueArray = Enumerable
                //                    .Repeat(0, (int)((currentTerrain.terrainData.treePrototypes.Length - 0) / 1) + 1)
                //                    .Select((tr, ti) => tr + (1 * ti))
                //                    .ToArray();
                string oldTag = collisionMask.m_tag;
                collisionMask.m_tag = EditorGUI.TagField(fieldRect, collisionMask.m_tag);

                if (oldType != collisionMask.m_type || oldTag != collisionMask.m_tag)
                {
                    collisionMask.m_Radius = GaiaUtils.GetBoundsForTaggedObject(collisionMask.m_tag);
                }


                fieldRect.x           += rect.width * 0.2f;
                fieldRect.width        = rect.width * 0.1f;
                collisionMask.m_Radius = EditorGUI.FloatField(fieldRect, collisionMask.m_Radius);
                fieldRect.x           += rect.width * 0.1f;
                fieldRect.width        = rect.width * 0.2f;
                break;

            case (BakedMaskType.LayerGameObject):
                //Layer mask selection
                fieldRect.x += rect.width * 0.2f;
                EditorGUI.BeginChangeCheck();
                collisionMask.m_layerMask = GaiaEditorUtils.LayerMaskFieldRect(fieldRect, new GUIContent(""), collisionMask.m_layerMask);
                if (EditorGUI.EndChangeCheck())
                {
                    collisionMask.m_layerMaskLayerNames = GaiaUtils.LayerMaskToString(collisionMask.m_layerMask);
                }
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskLayerSelectionTooltip"));
                fieldRect.x    += rect.width * 0.2f;
                fieldRect.width = rect.width * 0.1f;
                collisionMask.m_growShrinkDistance = EditorGUI.FloatField(fieldRect, collisionMask.m_growShrinkDistance);
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskGrowShrinkDistanceTooltip"));
                fieldRect.x    += rect.width * 0.1f;
                fieldRect.width = rect.width * 0.2f;

                break;

            case (BakedMaskType.LayerTree):
                //Layer mask selection
                fieldRect.x += rect.width * 0.2f;
                EditorGUI.BeginChangeCheck();
                collisionMask.m_layerMask = GaiaEditorUtils.LayerMaskFieldRect(fieldRect, new GUIContent(""), collisionMask.m_layerMask);
                if (EditorGUI.EndChangeCheck())
                {
                    collisionMask.m_layerMaskLayerNames = GaiaUtils.LayerMaskToString(collisionMask.m_layerMask);
                }
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskLayerSelectionTooltip"));
                fieldRect.x    += rect.width * 0.2f;
                fieldRect.width = rect.width * 0.1f;
                collisionMask.m_growShrinkDistance = EditorGUI.FloatField(fieldRect, collisionMask.m_growShrinkDistance);
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskGrowShrinkDistanceTooltip"));
                fieldRect.x    += rect.width * 0.1f;
                fieldRect.width = rect.width * 0.2f;

                break;
            }

            if (GUI.Button(fieldRect, m_editorUtils.GetContent("MaskCollisionBake")))
            {
                switch (collisionMask.m_type)
                {
                case BakedMaskType.RadiusTree:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllTreeCollisions(collisionMask.m_treeSpawnRuleGUID, collisionMask.m_Radius);
                    break;

                case BakedMaskType.RadiusTag:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllTagCollisions(collisionMask.m_tag, collisionMask.m_Radius);
                    break;

                case BakedMaskType.LayerGameObject:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllLayerGameObjectCollisions(collisionMask.m_layerMask, collisionMask.m_growShrinkDistance);     //, collisionMask.m_Radius);
                    break;

                case BakedMaskType.LayerTree:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllLayerTreeCollisions(collisionMask.m_layerMask, collisionMask.m_growShrinkDistance);     //, collisionMask.m_Radius);
                    break;
                }
            }
            EditorGUI.indentLevel = oldIndent;
        }
Exemplo n.º 8
0
        public static bool DrawFilterListHeader(Rect rect, bool currentFoldOutState, CollisionMask[] maskList, EditorUtils editorUtils)
        {
            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            rect.xMin            += 8f;
            bool newFoldOutState = EditorGUI.Foldout(rect, currentFoldOutState, PropertyCount("MaskRespectedCollisions", maskList, editorUtils), true);

            EditorGUI.indentLevel = oldIndent;
            return(newFoldOutState);
        }