Beispiel #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 CreateObjectStamper(MenuCommand menuCmd)
        {
            GameObject objectStamperGO = new GameObject("Object Stamper");

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

            objectStamper.GroupId = -1;

            Selection.activeGameObject = objectStamperGO;
            Undo.RegisterCreatedObjectUndo(objectStamperGO, "Creating Object Stampers");
        }
        public static GObjectStamper CreateObjectStamper()
        {
            GameObject root = GetTerrainToolsRoot();

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

            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;

            GObjectStamper stamper = g.AddComponent <GObjectStamper>();

            return(stamper);
        }