コード例 #1
0
        private static void DrawGeometryBrushSettingsGroup(TerrainGenerator instance)
        {
            instance.inspector.isGeometryBrushSettingsGroupExpanded = EditorCommon.GroupFoldout(instance.inspector.isGeometryBrushSettingsGroupExpanded, "Brush");

            if (instance.inspector.isGeometryBrushSettingsGroupExpanded)
            {
                EditorGUI.indentLevel += 1;

                GeometryPainter.ToolsSettings settings = instance.GeometryPainter.Settings;
                EditorGUI.BeginChangeCheck();
                settings.brushMode = (GeometryPainter.BrushMode)EditorGUILayout.EnumPopup("Mode", settings.brushMode);
                if (EditorGUI.EndChangeCheck())
                {
                    instance.GeometryPainter.UpdateHandle();
                }
                settings.brushRadius = EditorGUILayout.FloatField("Radius", settings.brushRadius);
                settings.strength    = EditorGUILayout.FloatField("Strength", settings.strength);
                settings.Validate();

                if (EditorCommon.RightAnchoredButton("Erase All"))
                {
                    ConfirmAndResetElevations(instance);
                }

                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.GetControlRect(GUILayout.Height(1));
        }
コード例 #2
0
        private void OnGUI()
        {
            source = (TextureExporter.Source)EditorGUILayout.EnumPopup("Source", source);
            if (source == TextureExporter.Source.FromMeshFilter)
            {
                targetMeshFilter = EditorGUILayout.ObjectField("Target", targetMeshFilter, typeof(MeshFilter), true) as MeshFilter;
            }
            else
            {
                targetMesh = EditorGUILayout.ObjectField("Target", targetMesh, typeof(Mesh), true) as Mesh;
            }

            fileName    = EditorGUILayout.TextField("File name", fileName);
            size        = EditorGUILayout.IntPopup("Size", size, TextureExporter.textureSizeName, TextureExporter.textureSize);
            fileType    = (ImageFileType)EditorGUILayout.EnumPopup("File type", fileType);
            textureType = (TextureExporter.TextureType)EditorGUILayout.EnumPopup("Texture type", textureType);
            EditorCommon.BrowseFolder("Path", ref path);

            GUI.enabled = CanSave();
            if (EditorCommon.RightAnchoredButton("Save"))
            {
                bool   willSave = false;
                string fullName = string.Format("{0}{1}", fileName, TextureExporter.GetExtension(fileType));
                string fullPath = Path.Combine(path, fullName);
                if (System.IO.File.Exists(fullPath))
                {
                    if (EditorUtility.DisplayDialog(
                            "File existed",
                            "The file at specified path is already existed.\nWould you like to overwrite it?",
                            "Yes",
                            "No"))
                    {
                        willSave = true;
                    }
                }
                else
                {
                    willSave = true;
                }

                if (willSave)
                {
                    if (source == TextureExporter.Source.FromMeshFilter)
                    {
                        TextureExporter.Export(targetMeshFilter, path, fileName, size, fileType, textureType);
                    }
                    else
                    {
                        TextureExporter.Export(targetMesh, path, fileName, size, fileType, textureType);
                    }
                }
            }
            GUI.enabled = true;
        }
コード例 #3
0
        private void OnGUI()
        {
            EditorGUILayout.LabelField("Prefab", prefab.name);
            EditorGUI.BeginChangeCheck();
            Texture2D t          = EditorGUILayout.ObjectField("Distribution Map", map, typeof(Texture2D), false) as Texture2D;
            bool      hasChanged = EditorGUI.EndChangeCheck();

            if (hasChanged && t != null)
            {
                try
                {
                    t.GetPixel(0, 0);
                    validTexture = true;
                    map          = t;
                }
                catch
                {
                    validTexture = false;
                    map          = null;
                }
            }
            if (!validTexture)
            {
                EditorGUILayout.HelpBox("Please assign a Read/Write Enabled texture!", MessageType.None, false);
            }

            density           = EditorGUILayout.IntSlider("Density", density, 1, 100);
            densityMultiplier = EditorGUILayout.Slider("Density Multiplier", densityMultiplier, 0f, 1f);
            scaleMin          = EditorGUILayout.FloatField("Scale Min", scaleMin);
            scaleMax          = EditorGUILayout.FloatField("Scale Max", scaleMax);
            maxRotation       = EditorGUILayout.FloatField("Max Rotation", maxRotation);
            followNormals     = EditorGUILayout.Toggle("Follow Normals", followNormals);
            keepOldObjects    = EditorGUILayout.Toggle("Keep Old Objects", keepOldObjects);

            if (EditorCommon.RightAnchoredButton("OK"))
            {
                if (painter == null)
                {
                    painter = terrain.EnvironmentalPainter;
                }
                EnvironmentalPainter.MassPlacementProcessor massPlacementProcessor = new EnvironmentalPainter.MassPlacementProcessor(
                    painter.Terrain, map, density, densityMultiplier, scaleMin, scaleMax, maxRotation, followNormals);
                Matrix4x4[] matrices = massPlacementProcessor.CalculatePlacementData();
                painter.MassPlacing(prefabIndex, matrices, keepOldObjects);
            }
            GUI.enabled = true;
        }
コード例 #4
0
        public void OnGUI()
        {
            bool willClose = false;

            EditorGUILayout.Space();
            GUI.SetNextControlName(BRUSH_NAME_TEXT_BOX_NAME);
            NewBrushName = EditorGUILayout.TextField("Brush Name", NewBrushName);
            GUI.enabled  = !string.IsNullOrEmpty(newBrushName) && painter != null;
            if (EditorCommon.RightAnchoredButton("OK"))
            {
                painter.AddCurrentSettingsAsNewBrush(NewBrushName);
                GUI.enabled = true;
                willClose   = true;
            }
            GUI.enabled = true;

            if (focusedWindow != this || willClose)
            {
                Close();
            }
        }
コード例 #5
0
        private void OnGUI()
        {
            EditorGUILayout.LabelField("Prefab", prefab.name);
            fileName = EditorGUILayout.TextField("File name", fileName);
            spread   = EditorGUILayout.IntSlider("Spread", spread, 1, 100);
            size     = EditorGUILayout.IntPopup("Size", size, TextureExporter.textureSizeName, TextureExporter.textureSize);
            fileType = (ImageFileType)EditorGUILayout.EnumPopup("File type", fileType);
            EditorCommon.BrowseFolder("Path", ref path);

            GUI.enabled = CanSave();
            if (EditorCommon.RightAnchoredButton("Export"))
            {
                bool   willSave = false;
                string fullName = string.Format("{0}{1}", fileName, TextureExporter.GetExtension(fileType));
                string fullPath = Path.Combine(path, fullName);
                if (System.IO.File.Exists(fullPath))
                {
                    if (EditorUtility.DisplayDialog(
                            "File existed",
                            "The file at specified path is already existed.\nWould you like to overwrite it?",
                            "Yes",
                            "No"))
                    {
                        willSave = true;
                    }
                }
                else
                {
                    willSave = true;
                }

                if (willSave)
                {
                    Save();
                }
            }
            GUI.enabled = true;
        }
コード例 #6
0
 private void OnGUI()
 {
     target   = EditorGUILayout.ObjectField("Target", target, typeof(MeshFilter), true) as MeshFilter;
     meshName = EditorGUILayout.TextField("Mesh name", meshName);
     fileType = (MeshSaver.FileType)EditorGUILayout.EnumPopup("File type", fileType);
     EditorCommon.BrowseFolder("Path", ref path);
     GUI.enabled =
         target != null &&
         target.sharedMesh != null &&
         !string.IsNullOrEmpty(meshName) &&
         !string.IsNullOrEmpty(path);
     if (EditorCommon.RightAnchoredButton("Save"))
     {
         Material     mat = null;
         MeshRenderer mr  = target.GetComponent <MeshRenderer>();
         if (mr != null)
         {
             mat = mr.sharedMaterial;
         }
         MeshSaver.Save(target.sharedMesh, mat, path, meshName, fileType);
     }
     GUI.enabled = true;
 }
コード例 #7
0
        public void OnGUI()
        {
            bool willClose = false;

            EditorGUILayout.Space();

            brush.name        = EditorGUILayout.TextField("Name", brush.name);
            brush.brushRadius = EditorGUILayout.FloatField("Radius", brush.brushRadius);
            brush.strength    = EditorGUILayout.Slider("Strength", brush.strength, 0f, 1f);
            brush.color       = EditorGUILayout.ColorField("Color", brush.color);

            GUI.enabled = !string.IsNullOrEmpty(brush.name) && painter != null;
            if (EditorCommon.RightAnchoredButton("OK"))
            {
                painter.SetBrushAtIndex(index, brush);
                GUI.enabled = true;
                willClose   = true;
            }
            GUI.enabled = true;
            if (willClose)
            {
                Close();
            }
        }