Beispiel #1
0
        private void AddTerrainLayerMask(object id)
        {
            SpawnerBase.TerrainLayerMask m = new SpawnerBase.TerrainLayerMask();
            m.layerID = (int)id;
            m.name    = spawner.terrains[0].terrainData.terrainLayers[m.layerID].name;

            contextMasks.Add(m);
            selectedLayerID = contextMasks.Count - 1;
        }
Beispiel #2
0
        private void LayerMaskSettings(List <SpawnerBase.TerrainLayerMask> masks)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Layer masks", "Masks can be used to only spawn items on specific terrain layers"), EditorStyles.boldLabel);

            selectedLayerID = Mathf.Clamp(selectedLayerID, 0, masks.Count - 1);

            terrainLayerScrollPos = EditorGUILayout.BeginScrollView(terrainLayerScrollPos, EditorStyles.textArea, GUILayout.MaxHeight(masks.Count > 0 ? texThumbSize + 17f : 17f));
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    for (int i = 0; i < masks.Count; i++)
                    {
                        //Select preview texture
                        previewTex = GetLayerMainTex(masks[i].layerID);

                        if (GUILayout.Button(new GUIContent(previewTex), (selectedLayerID == i) ? VegetationSpawnerEditor.PreviewTexSelected : VegetationSpawnerEditor.PreviewTex,
                                             GUILayout.Width(texThumbSize), GUILayout.MaxHeight(texThumbSize)))
                        {
                            selectedLayerID = i;
                        }
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            SpawnerBase.TerrainLayerMask selected = masks.Count > 0 && selectedLayerID >= 0 ? masks[selectedLayerID] : null;

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(new GUIContent("Add", VegetationSpawnerEditor.PlusIcon, "Add new layer mask"), EditorStyles.miniButtonLeft, GUILayout.Width(60f)))
                {
                    LayerDropDown(masks);
                }

                using (new EditorGUI.DisabledScope(selected == null))
                {
                    if (GUILayout.Button(new GUIContent("", VegetationSpawnerEditor.TrashIcon, "Remove"), EditorStyles.miniButtonRight))
                    {
                        masks.Remove(selected);
                        selectedLayerID = masks.Count - 1;
                    }
                }
            }

            if (selected != null)
            {
                EditorGUILayout.LabelField(selected.name + " settings", EditorStyles.boldLabel);

                selected.threshold = EditorGUILayout.Slider(new GUIContent("Minimum strength", "The minimum strength the material must have underneath the item, before it will spawn"), selected.threshold, 0f, 1f);
            }
        }