Exemple #1
0
 void prefabListGUI()
 {
     Edit.Column(() =>
     {
         Edit.Row(() =>
         {
             param.listSize = EditorGUILayout.IntField("Count: ", param.listSize);
             if (GUILayout.Button(" + "))
             {
                 param.listSize++;
             }
             if (GUILayout.Button(" - "))
             {
                 param.listSize--;
             }
         });
         param.spawnedPrefix = EditorGUILayout.TextField("Spawned Prefix", param.spawnedPrefix);
         param.listSize      = Mathf.Max(0, param.listSize);
         togglePrefabs       = Edit.ToggleGroup(togglePrefabs, "Prefabs", 0, () => {
             for (int i = 0; i < param.objects.Count; i++)
             {
                 Edit.Row(() =>
                 {
                     PaintObject.display(param.objects[i], param.editorPrefabVisual);
                 }, "Box");
             }
         });
     }, "Box");
     GUILayout.Space(10);
 }
Exemple #2
0
 void OnGUI()
 {
     Edit.Row(() => {
         windowsTab = GUILayout.SelectionGrid(windowsTab, new string[] { "Spawning", "Paint", "Setting" }, 3, EditorStyles.toolbarButton);
         if (GUILayout.Button("Exit", EditorStyles.toolbarButton, GUILayout.Width(50)))
         {
             this.Close();
         }
     });
     Edit.View(ref scrollView, () => {
         if (windowsTab == 2)
         {
             optionTab();
         }
         else if (windowsTab == 1)
         {
             //dropArea(new Rect(0, 0, this.position.width, this.position.height));
             float tempSize  = param.size;
             int tempDensity = param.density;
             paintTab();
             prefabListGUI();
             datacheck(tempSize, tempDensity);
         }
         else
         {
             SpawnerTab();
         }
     });
 }
 void paintTab()
 {
     Edit.Column(() =>
     {
         param.paintMask = EditorGUILayout.MaskField(new GUIContent("Paint Layer", "on which layer the tool will paint"), param.paintMask, layerNames.ToArray());
         param.size      = EditorGUILayout.FloatField("Size :", param.size);
         param.density   = EditorGUILayout.IntField("Density :", param.density);
         Edit.Row(() =>
         {
             GUILayout.Label("Random Rotation :");
             param.rndRotationX = GUILayout.Toggle(param.rndRotationX, "X");
             param.rndRotationY = GUILayout.Toggle(param.rndRotationY, "Y");
             param.rndRotationZ = GUILayout.Toggle(param.rndRotationZ, "Z");
         });
         Edit.Row(() =>
         {
             param.proximityCheck = EditorGUILayout.Toggle("Proximity Check ", param.proximityCheck);
             if (param.proximityCheck)
             {
                 param.proximityDistance = EditorGUILayout.Slider(param.proximityDistance, 0.1f, param.size);
             }
         });
         Edit.Row(() =>
         {
             EditorGUILayout.LabelField("Mode");
             if (GUILayout.Toggle(param.mode == PaintMode.Auto, "Default", EditorStyles.miniButtonLeft, GUILayout.MaxWidth(100)))
             {
                 param.mode = PaintMode.Auto;
             }
             if (GUILayout.Toggle(param.mode == PaintMode.Forced, "Y-Forced", EditorStyles.miniButtonMid, GUILayout.MaxWidth(100)))
             {
                 param.mode = PaintMode.Forced;
             }
             if (GUILayout.Toggle(param.mode == PaintMode.Snap, "Snap", EditorStyles.miniButtonRight, GUILayout.MaxWidth(100)))
             {
                 param.mode = PaintMode.Snap;
             }
             GUILayout.FlexibleSpace();
         });
         if (param.mode == PaintMode.Auto)
         {
             EditorGUILayout.LabelField("Use the mouse position");
         }
         else if (param.mode == PaintMode.Forced)
         {
             param.heightForced = EditorGUILayout.FloatField("Forced height :", param.heightForced);
         }
         else if (param.mode == PaintMode.Snap)
         {
             Edit.Column(() =>
             {
                 param.maxYPosition = EditorGUILayout.FloatField(new GUIContent("Roof height", "Define the max height needed for the object to spawn"), param.maxYPosition);
             });
         }
     }, "Box");
 }
Exemple #4
0
        void optionTab()
        {
            toggleGroupKeys = Edit.ToggleGroup(toggleGroupKeys, "hotKey", 1, () =>
            {
                EditorGUILayout.LabelField("ctrl + click : Paint");
                EditorGUILayout.LabelField("ctrl + scroll : Change Size");
                EditorGUILayout.LabelField("alt + scroll : Change Density");
                EditorGUILayout.LabelField("ctrl + alt + Z : Cancel Paint");
                EditorGUILayout.LabelField("ctrl + alt + Click : Current height as Forced height");
            }, "Box");
            toggleGroupGizmo = Edit.ToggleGroup(toggleGroupGizmo, "Gizmo", 1, () =>
            {
                enableSceneGizmo = EditorGUILayout.Toggle(new GUIContent("Display Gizmo", "Display the scene UI"), enableSceneGizmo);
                if (enableSceneGizmo)
                {
                    EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

                    param.gizmoSize     = EditorGUILayout.Toggle(new GUIContent("Size", ""), param.gizmoSize);
                    param.gizmoDensity  = EditorGUILayout.Toggle(new GUIContent("Density", ""), param.gizmoDensity);
                    param.gizmoHeight   = EditorGUILayout.Toggle(new GUIContent("Height", ""), param.gizmoHeight);
                    param.gizmoLayer    = EditorGUILayout.Toggle(new GUIContent("Layer", ""), param.gizmoLayer);
                    param.gizmoName     = EditorGUILayout.Toggle(new GUIContent("Name", ""), param.gizmoName);
                    param.gizmoPosition = EditorGUILayout.Toggle(new GUIContent("Position", ""), param.gizmoPosition);
                    param.gizmoCircle   = EditorGUILayout.Toggle(new GUIContent("Circle", ""), param.gizmoCircle);
                    Edit.Row(() =>
                    {
                        param.gizmoNormal = EditorGUILayout.Toggle(new GUIContent("Normal", ""), param.gizmoNormal);
                        if (param.gizmoNormal)
                        {
                            gizmoNormalLenght = EditorGUILayout.FloatField(new GUIContent("Lenght", ""), gizmoNormalLenght);
                        }
                    });
                }
            }, "Box");
            toggleGroupEditor = Edit.ToggleGroup(toggleGroupEditor, "Editor", 1, () =>
            {
                ROOT_PARENT_NAME           = EditorGUILayout.TextField("Root Parent Name:", ROOT_PARENT_NAME);
                GROUP_NAME                 = EditorGUILayout.TextField("Group Name:", GROUP_NAME);
                param.addPrefabNameToGroup = EditorGUILayout.Toggle("Add prefab name to group", param.addPrefabNameToGroup);
                param.editorPrefabVisual   = EditorGUILayout.Toggle(new GUIContent("Show Prefab Preview", ""), param.editorPrefabVisual);
                Edit.Row(() =>
                {
                    EditorGUILayout.LabelField("Clear Data:");
                    if (GUILayout.Button("Prefab list", EditorStyles.miniButtonLeft))
                    {
                        param.listSize = 0;
                        param.objects.Clear();
                    }
                    if (GUILayout.Button("Paint history", EditorStyles.miniButtonRight))
                    {
                        clearMemory();
                    }
                });
            }, "Box");
        }
Exemple #5
0
        void DisplayMeshesSelected()
        {
            param.paintMask = EditorGUILayout.MaskField(new GUIContent("Paint Layer", "on which layer the tool will paint"), param.paintMask, layerNames.ToArray());
            Edit.Row(() =>
            {
                if (GUILayout.Button("Add selection"))
                {
                    GameObject[] objects = Selection.gameObjects;
                    if (objects != null && objects.Length > 0)
                    {
                        foreach (var item in objects)
                        {
                            MeshFilter filter = item.GetComponent <MeshFilter>();
                            if (filter != null && !param.filters.Contains(filter))
                            {
                                param.filters.Add(filter);
                            }
                        }
                    }
                }
                if (GUILayout.Button("Remove Empty"))
                {
                    for (int i = 0; i < param.filters.Count; i++)
                    {
                        if (param.filters[i] == null)
                        {
                            param.filters.RemoveAt(i);
                            i--;
                        }
                    }
                }
            });

            showList = Edit.List("Meshes", showList, param.filters.Count, (int i, int count) =>
            {
                if (param.filters.Count <= i)
                {
                    param.filters.Add(null);
                }
                if (count < param.filters.Count)
                {
                    param.filters.RemoveAt(param.filters.Count - 1);
                }
                param.filters[i] = (MeshFilter)EditorGUILayout.ObjectField("", param.filters[i], typeof(MeshFilter), true);
            });
        }
Exemple #6
0
 public static void display(PaintObject obj, bool displayVisual)
 {
     if (obj == null)
     {
         return;
     }
     Edit.Column(() =>
     {
         obj.isDisplayed = EditorGUILayout.Foldout(obj.isDisplayed, obj.prefab ? obj.prefab.name : "Empty", true);
         if (obj.isDisplayed)
         {
             Edit.Row(() =>
             {
                 Edit.Indent(() =>
                 {
                     if (displayVisual)
                     {
                         GUILayout.Label(AssetPreview.GetAssetPreview(obj.prefab));
                     }
                     Edit.Column(() =>
                     {
                         obj.prefab = (GameObject)EditorGUILayout.ObjectField("Prefab", obj.prefab, typeof(GameObject), true);
                         if (obj.prefab != null)
                         {
                             if (obj.customName.Length == 0 && obj.prefab)
                             {
                                 obj.customName = obj.prefab.name;
                             }
                             obj.customName = EditorGUILayout.TextField("Name", obj.customName);
                             obj.scale      = EditorGUILayout.Vector2Field("Scale Modifier (Min/Max) :", obj.scale);
                         }
                     });
                 }, 1);
             });
         }
     });
 }