private static void CenterToLevel(PWater water) { PWaterQuickSetupConfig config = PWaterQuickSetupConfig.Instance; Bounds levelBounds = GCommon.GetLevelBounds(); water.transform.position = new Vector3(levelBounds.center.x, config.WaterLevel, levelBounds.center.z); }
private static void InitDefaultConfigs() { PWaterQuickSetupConfig config = PWaterQuickSetupConfig.Instance; config.WaterLevel = 1; config.MeshResolution = 100; config.MeshNoise = 0; Bounds levelBounds = GCommon.GetLevelBounds(); config.ApproximateSizeX = levelBounds.size.x; config.ApproximateSizeZ = levelBounds.size.z; config.TileSize = Vector2.one * 100; }
private void DrawActionGUI() { string label = "Actions"; string id = "actions" + instance.GetInstanceID().ToString(); GEditorCommon.Foldout(label, true, id, () => { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Snap To Terrain")) { IEnumerator <GStylizedTerrain> terrains = GStylizedTerrain.ActiveTerrains.GetEnumerator(); while (terrains.MoveNext()) { GStylizedTerrain t = terrains.Current; Bounds b = t.Bounds; Rect r = new Rect(new Vector2(b.min.x, b.min.z), new Vector2(b.size.x, b.size.z)); Vector2 p = new Vector2(instance.Position.x, instance.Position.z); if (r.Contains(p)) { instance.Position = new Vector3(r.center.x, b.min.y, r.center.y); instance.Rotation = Quaternion.identity; instance.Scale = new Vector3(b.size.x, b.size.y, b.size.z); break; } } } if (GUILayout.Button("Snap To Level Bounds")) { Bounds b = GCommon.GetLevelBounds(); instance.Position = new Vector3(b.center.x, b.min.y, b.center.z); instance.Rotation = Quaternion.identity; instance.Scale = new Vector3(b.size.x, b.size.y, b.size.z); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Clear Objects")) { instance.ClearObjects(); Event.current.Use(); } if (GUILayout.Button("Apply")) { GAnalytics.Record(GAnalytics.STAMPER_OBJECT); ApplyStamp(); EditorGUIUtility.ExitGUI(); } }); }
private static void DrawWaterConfigGUI(PWater water) { DrawTemplateSelectionGUI(water); PWaterQuickSetupConfig config = PWaterQuickSetupConfig.Instance; bool changed = false; bool meshChanged = false; EditorGUI.BeginChangeCheck(); config.WaterLevel = EditorGUILayout.FloatField("Water Level", config.WaterLevel); if (EditorGUI.EndChangeCheck()) { changed = true; } EditorGUI.BeginChangeCheck(); config.MeshResolution = EditorGUILayout.DelayedIntField("Resolution", config.MeshResolution); if (EditorGUI.EndChangeCheck()) { meshChanged = true; } EditorGUI.BeginChangeCheck(); config.MeshNoise = EditorGUILayout.FloatField("Noise", config.MeshNoise); config.ApproximateSizeX = EditorGUILayout.FloatField("Approx. Size X", config.ApproximateSizeX); config.ApproximateSizeZ = EditorGUILayout.FloatField("Approx. Size Z", config.ApproximateSizeZ); config.TileSize = PEditorCommon.InlineVector2Field("Tile Size", config.TileSize); if (EditorGUI.EndChangeCheck()) { changed = true; } if (meshChanged) { water.GeneratePlaneMesh(); } if (changed || meshChanged) { water.MeshNoise = config.MeshNoise; water.TileSize = config.TileSize; water.UpdateMaterial(); MatchWaterLevel(water); MatchWaterSize(water); } EditorUtility.SetDirty(config); GEditorCommon.Separator(); if (GUILayout.Button("Center To Level Bounds")) { CenterToLevel(water); } if (GUILayout.Button("Fill Level Bounds")) { Bounds levelBounds = GCommon.GetLevelBounds(); config.ApproximateSizeX = levelBounds.size.x; config.ApproximateSizeZ = levelBounds.size.z; CenterToLevel(water); MatchWaterSize(water); } if (GUILayout.Button("Done")) { Done(water); } }