public RectangularQuadGrid ResetSurface(RectangularQuadGrid surface, Vector3 origin, Quaternion orientation, bool suppressWrap, IntVector2 size) { return(surface.Reset(axis0, axis1, origin, orientation, isAxis0Wrapped && !suppressWrap, isAxis1Wrapped && !suppressWrap, size)); }
protected override void OnPropertiesGUI() { var generator = (PlanarManifoldGenerator)target; EditorGUILayout.PropertyField(_serializedGenerator.FindProperty("size"), new GUIContent("Size")); EditorGUILayout.Space(); generator.tileType = (PlanarManifoldGenerator.TileTypes)EditorGUILayout.EnumPopup("Tile Type", generator.tileType); switch (generator.tileType) { case PlanarManifoldGenerator.TileTypes.Quadrilateral: { generator.SetQuadTileShape((PlanarManifoldGenerator.QuadTileShapes)EditorGUILayout.EnumPopup("Tile Shape", generator.quadTileShape)); bool canGenerate = generator.canGenerate; RectangularQuadGrid surface = null; Topology topology = null; Vector3[] vertexPositions = null; if (canGenerate && Event.current.type == EventType.Repaint) { surface = generator.ResetSurface(CreateInstance <RectangularQuadGrid>(), Vector3.zero, Quaternion.identity, true, new Numerics.IntVector2(3, 3)); topology = surface.CreateManifold(out vertexPositions); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.Space(); float previewSize = 128f; var previewRect = GUILayoutUtility.GetRect(previewSize, previewSize + _previewStyle.margin.top + _previewStyle.margin.bottom, _previewStyle, GUILayout.ExpandWidth(false)); if (canGenerate && Event.current.type == EventType.Repaint) { DrawQuadTilePreview(generator, previewRect.min, previewSize); } EditorGUILayout.Space(); previewRect = GUILayoutUtility.GetRect(previewSize, previewSize + _previewStyle.margin.top + _previewStyle.margin.bottom, _previewStyle, GUILayout.ExpandWidth(false)); if (canGenerate && Event.current.type == EventType.Repaint) { DrawQuadTile3x3Preview(generator, topology, vertexPositions, previewRect.min, previewSize); } EditorGUILayout.Space(); } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); generator.axis0 = EditorGUILayout.Vector2Field("Axis 0", generator.axis0); generator.axis1 = EditorGUILayout.Vector2Field("Axis 1", generator.axis1); if (EditorGUI.EndChangeCheck()) { generator.SetQuadTileShape(PlanarManifoldGenerator.QuadTileShapes.Custom); } break; } case PlanarManifoldGenerator.TileTypes.Hexagonal: { generator.SetHexTileShape((PlanarManifoldGenerator.HexTileShapes)EditorGUILayout.EnumPopup("Tile Shape", generator.hexTileShape)); bool canGenerate = generator.canGenerate; RectangularHexGrid surface = null; Topology topology = null; Vector3[] vertexPositions = null; if (canGenerate && Event.current.type == EventType.Repaint) { surface = generator.ResetSurface(CreateInstance <RectangularHexGrid>(), Vector3.zero, Quaternion.identity, true, new Numerics.IntVector2(3, 3)); topology = surface.CreateManifold(out vertexPositions); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.Space(); float previewSize = 128f; var previewRect = GUILayoutUtility.GetRect(previewSize, previewSize + _previewStyle.margin.top + _previewStyle.margin.bottom, _previewStyle, GUILayout.ExpandWidth(false)); if (canGenerate && Event.current.type == EventType.Repaint) { DrawHexTilePreview(generator, surface, topology, vertexPositions, previewRect.min, previewSize); } EditorGUILayout.Space(); previewRect = GUILayoutUtility.GetRect(previewSize, previewSize + _previewStyle.margin.top + _previewStyle.margin.bottom, _previewStyle, GUILayout.ExpandWidth(false)); if (canGenerate && Event.current.type == EventType.Repaint) { DrawHexTile3x3Preview(generator, surface, topology, vertexPositions, previewRect.min, previewSize); } EditorGUILayout.Space(); } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); generator.midpoint = EditorGUILayout.Vector2Field("Midpoint", generator.midpoint); generator.majorCorner = EditorGUILayout.Vector2Field("Major Corner", generator.majorCorner); generator.minorCorner = EditorGUILayout.Vector2Field("Minor Corner", generator.minorCorner); generator.hexGridAxisStyle = (HexGridAxisStyles)EditorGUILayout.EnumPopup("Axis Style", generator.hexGridAxisStyle); generator.swapAxes = EditorGUILayout.Toggle("Swap Axes", generator.swapAxes); if (EditorGUI.EndChangeCheck()) { generator.SetHexTileShape(PlanarManifoldGenerator.HexTileShapes.Custom); } break; } default: throw new System.NotImplementedException(); } generator.isAxis0Wrapped = EditorGUILayout.Toggle("Axis 0 Wraps", generator.isAxis0Wrapped, GUILayout.ExpandWidth(false)); generator.isAxis1Wrapped = EditorGUILayout.Toggle("Axis 1 Wraps", generator.isAxis1Wrapped, GUILayout.ExpandWidth(false)); EditorGUILayout.Space(); generator.origin = EditorGUILayout.Vector3Field("Origin", generator.origin); generator.rotation = EditorGUILayout.Vector3Field("Rotation", generator.rotation); }