Esempio n. 1
0
        private void AddTerrainLayerMask(object id)
        {
            TerrainLayerMask m = new TerrainLayerMask();

            m.layerID = (int)id;

            contextMasks.Add(m);
            selectedLayerID = contextMasks.Count - 1;
        }
Esempio n. 2
0
        private void LayerMaskSettings(List <TerrainLayerMask> masks)
        {
            EditorGUILayout.LabelField("Layer masks", EditorStyles.boldLabel);

            if (masks.Count > 0)
            {
                terrainLayerScrollPos = EditorGUILayout.BeginScrollView(terrainLayerScrollPos, EditorStyles.textArea, GUILayout.Height(texThumbSize + 10f));

                using (new EditorGUILayout.HorizontalScope())
                {
                    for (int i = 0; i < masks.Count; i++)
                    {
                        if (i < masks.Count && masks[i] != null)
                        {
                            //Select preview texture
                            if (masks[i] != null)
                            {
                                previewTex = GetLayerMainTex(masks[i].layerID);
                            }

                            if (GUILayout.Button(new GUIContent("", previewTex), (selectedLayerID == masks[i].layerID) ? VegetationSpawnerEditor.PreviewTexSelected : VegetationSpawnerEditor.PreviewTex,
                                                 GUILayout.MaxWidth(texThumbSize), GUILayout.MaxHeight(texThumbSize)))
                            {
                                selectedLayerID = i;
                            }
                        }
                    }
                }

                EditorGUILayout.EndScrollView();

                TerrainLayerMask selected = masks[selectedLayerID];

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

                    if (GUILayout.Button(new GUIContent("Add", VegetationSpawnerEditor.PlusIcon, "Add new item")))
                    {
                        LayerDropDown(masks);
                    }


                    if (GUILayout.Button(new GUIContent("", VegetationSpawnerEditor.TrashIcon, "Remove")))
                    {
                        masks.Remove(selected);
                        selectedLayerID = masks.Count - 1;
                    }
                }

                if (selected != null)
                {
                    EditorGUILayout.LabelField("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);
                }
            }
            else
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button(new GUIContent("Add", EditorGUIUtility.IconContent(EditorGUIUtility.isProSkin ? "d_Toolbar Plus" : "Toolbar Plus").image, "Add new item")))
                    {
                        LayerDropDown(masks);
                    }
                }
            }
        }