Exemplo n.º 1
0
        private static void DrawFoliageAndObjectSpawningGUI()
        {
            string label = "5. Foliage & Object Spawning";
            string id    = "wizard-foliage-object-spawning";

            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUILayout.LabelField("Select the workflow you prefer.", GEditorCommon.WordWrapLeftLabel);

                GEditorCommon.Header("Painting");
                EditorGUILayout.LabelField("Place trees, grasses and game objects by painting.", GEditorCommon.WordWrapLeftLabel);
                if (GUILayout.Button("Create Foliage Painter & Object Painter"))
                {
                    GFoliagePainter fPainter = GWizard.CreateFoliagePainter();
                    GObjectPainter oPainter  = GWizard.CreateObjectPainter();
                    EditorGUIUtility.PingObject(fPainter);
                    Selection.objects          = new GameObject[] { fPainter.gameObject, oPainter.gameObject };
                    Selection.activeGameObject = fPainter.gameObject;
                }

                GEditorCommon.Header("Stamping");
                EditorGUILayout.LabelField("Procedurally spawn trees, grasses and game objects using some rules such as height, normal vector and noise.", GEditorCommon.WordWrapLeftLabel);
                if (GUILayout.Button("Create Foliage Stamper & Object Stamper"))
                {
                    GFoliageStamper fStamper = GWizard.CreateFoliageStamper();
                    GObjectStamper oStamper  = GWizard.CreateObjectStamper();
                    EditorGUIUtility.PingObject(fStamper);
                    Selection.objects          = new GameObject[] { fStamper.gameObject, oStamper.gameObject };
                    Selection.activeGameObject = fStamper.gameObject;
                }
            });
        }
        public static void CreateObjectPainter(MenuCommand menuCmd)
        {
            GameObject g = new GameObject("Object Painter");

            if (menuCmd != null)
            {
                GameObjectUtility.SetParentAndAlign(g, menuCmd.context as GameObject);
            }
            g.transform.localPosition = Vector3.zero;
            g.transform.hideFlags     = HideFlags.HideInInspector;
            GObjectPainter painter = g.AddComponent <GObjectPainter>();

            painter.GroupId = -1;
            painter.gameObject.AddComponent <GRotationRandomizeFilter>();
            painter.gameObject.AddComponent <GScaleRandomizeFilter>();

            Selection.activeGameObject = g;
            Undo.RegisterCreatedObjectUndo(g, "Creating Object Painter");
        }
        public static GObjectPainter CreateObjectPainter()
        {
            GameObject root = GetTerrainToolsRoot();

            if (root == null)
            {
                root = CreateTerrainToolsRoot();
            }
            GameObject g = new GameObject("Object Painter");

            g.transform.parent     = root.transform;
            g.transform.position   = Vector3.zero;
            g.transform.rotation   = Quaternion.identity;
            g.transform.localScale = Vector3.one;
            g.transform.hideFlags  = HideFlags.HideInInspector;

            GObjectPainter painter = g.AddComponent <GObjectPainter>();

            g.AddComponent <GRotationRandomizeFilter>();
            g.AddComponent <GScaleRandomizeFilter>();
            return(painter);
        }
        public static void CreateTerrainTools(MenuCommand menuCmd)
        {
            GameObject g = new GameObject("Polaris V2 Tools");

            if (menuCmd != null)
            {
                GameObjectUtility.SetParentAndAlign(g, menuCmd.context as GameObject);
            }
            g.transform.localPosition = Vector3.zero;
            g.transform.localRotation = Quaternion.identity;
            g.transform.localScale    = Vector3.one;
            g.transform.hideFlags     = HideFlags.HideInInspector;

            GTerrainTools tools = g.AddComponent <GTerrainTools>();

            tools.hideFlags = HideFlags.HideInInspector;

            GameObject terrainGroup = new GameObject("Terrain Group");

            GUtilities.ResetTransform(terrainGroup.transform, g.transform);
            terrainGroup.transform.hideFlags = HideFlags.HideInInspector;
            GTerrainGroup group = terrainGroup.AddComponent <GTerrainGroup>();

            group.GroupId = -1;

            GameObject texturePainter = new GameObject("Geometry & Texture Painter");

            GUtilities.ResetTransform(texturePainter.transform, g.transform);
            texturePainter.transform.hideFlags = HideFlags.HideInInspector;
            GTerrainTexturePainter texturePainterComponent = texturePainter.AddComponent <GTerrainTexturePainter>();

            texturePainterComponent.GroupId = -1;

            GameObject foliagePainter = new GameObject("Foliage Painter");

            GUtilities.ResetTransform(foliagePainter.transform, g.transform);
            foliagePainter.transform.hideFlags = HideFlags.HideInInspector;
            GFoliagePainter foliagePainterComponent = foliagePainter.AddComponent <GFoliagePainter>();

            foliagePainterComponent.GroupId = -1;
            foliagePainterComponent.gameObject.AddComponent <GRotationRandomizeFilter>();
            foliagePainterComponent.gameObject.AddComponent <GScaleRandomizeFilter>();

            GameObject objectPainter = new GameObject("Object Painter");

            GUtilities.ResetTransform(objectPainter.transform, g.transform);
            objectPainter.transform.hideFlags = HideFlags.HideInInspector;
            GObjectPainter objectPainterComponent = objectPainter.AddComponent <GObjectPainter>();

            objectPainterComponent.GroupId = -1;
            objectPainterComponent.gameObject.AddComponent <GRotationRandomizeFilter>();
            objectPainterComponent.gameObject.AddComponent <GScaleRandomizeFilter>();

            GameObject assetExplorer = new GameObject("Asset Explorer");

            GUtilities.ResetTransform(assetExplorer.transform, g.transform);
            assetExplorer.transform.hideFlags = HideFlags.HideInInspector;
            assetExplorer.AddComponent <GAssetExplorer>();

            GameObject helpTool = new GameObject("Help");

            GUtilities.ResetTransform(helpTool.transform, g.transform);
            helpTool.transform.hideFlags = HideFlags.HideInInspector;
            helpTool.AddComponent <GHelpComponent>();

            Selection.activeGameObject = terrainGroup;
            Undo.RegisterCreatedObjectUndo(g, "Creating Terrain Tools");
        }