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 CreateFoliageStamper(MenuCommand menuCmd) { GameObject foliageStamperGO = new GameObject("Foliage Stamper"); if (menuCmd != null) { GameObjectUtility.SetParentAndAlign(foliageStamperGO, menuCmd.context as GameObject); } foliageStamperGO.transform.localPosition = Vector3.zero; foliageStamperGO.transform.hideFlags = HideFlags.HideInInspector; GFoliageStamper foliageStamper = foliageStamperGO.AddComponent <GFoliageStamper>(); foliageStamper.GroupId = -1; Selection.activeGameObject = foliageStamperGO; Undo.RegisterCreatedObjectUndo(foliageStamperGO, "Creating Foliage Stampers"); }
public static GFoliageStamper CreateFoliageStamper() { GameObject root = GetTerrainToolsRoot(); if (root == null) { root = CreateTerrainToolsRoot(); } GameObject g = new GameObject("Foliage 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; GFoliageStamper stamper = g.AddComponent <GFoliageStamper>(); return(stamper); }