public HighlightManager(Layer layer) { mOverlaySolidRectangle = new SolidRectangle(); mOverlaySolidRectangle.Name = "Overlay SolidRectangle"; mOverlaySolidRectangle.Color = Color.LightGreen; mOverlaySolidRectangle.Color.A = 100; mOverlaySolidRectangle.Visible = false; ShapeManager.Self.Add(mOverlaySolidRectangle, layer); mOverlaySprite = new Sprite(null); mOverlaySprite.Name = "Overlay Sprite"; mOverlaySprite.BlendState = BlendState.Additive; mOverlaySprite.Visible = false; SpriteManager.Self.Add(mOverlaySprite, layer); mOverlayNineSlice = new NineSlice(); mOverlayNineSlice.Name = "Overlay NineSlice"; mOverlayNineSlice.BlendState = BlendState.Additive; mOverlayNineSlice.Visible = false; SpriteManager.Self.Add(mOverlayNineSlice, layer); mOverlayLinePolygon = new LinePolygon(); mOverlayLinePolygon.Name = "Overly LinePolygon"; // polys are white by default so let's make it dark mOverlayLinePolygon.Color = Color.DarkGreen; mOverlayLinePolygon.IsDotted = true; mOverlayLinePolygon.Visible = false; ShapeManager.Self.Add(mOverlayLinePolygon, layer); }
void CreateLine(Vector2[] points) { var _object = new GameObject("PolygonLine"); var meshFilter = _object.AddComponent <MeshFilter>(); var meshRenderer = _object.AddComponent <MeshRenderer>(); meshFilter.sharedMesh = LinePolygon.CreateMesh(points, 1f); meshRenderer.material = this.Mateiral; }
void CreateLine(Vector2[] points) { var _object = new GameObject("PolygonLine"); var meshFilter = _object.AddComponent <MeshFilter>(); var meshRenderer = _object.AddComponent <MeshRenderer>(); meshFilter.sharedMesh = LinePolygon.CreateMesh(points, 0.01f); meshRenderer.material = this.Material; _object.transform.SetParent(this.transform); }
private void UpdatePointNodes() { var neededNumberOfPointCircles = 0; LinePolygon linePolygon = SelectedLinePolygon; if (linePolygon != null) { neededNumberOfPointCircles = linePolygon.PointCount; } // create needed circles while (pointNodes.Count < neededNumberOfPointCircles) { var rectangle = new SolidRectangle(); rectangle.Width = NodeDisplayWidth; rectangle.Height = NodeDisplayWidth; ShapeManager.Self.Add(rectangle, layer); pointNodes.Add(rectangle); } // destroy excess circles while (pointNodes.Count > neededNumberOfPointCircles) { var node = pointNodes.Last(); ShapeManager.Self.Remove(node); pointNodes.Remove(node); } if (linePolygon != null) { var nodeDimension = NodeDisplayWidth; var linePolygonXY = new Vector2(linePolygon.GetAbsoluteX(), linePolygon.GetAbsoluteY()); // position circles for (int i = 0; i < linePolygon.PointCount; i++) { var worldPositionPoint = linePolygon.PointAt(i) + linePolygonXY; pointNodes[i].X = worldPositionPoint.X - nodeDimension / 2; pointNodes[i].Y = worldPositionPoint.Y - nodeDimension / 2; pointNodes[i].Width = nodeDimension; pointNodes[i].Height = nodeDimension; } } }
internal static bool TryHandleAsBaseType(string baseType, SystemManagers systemManagers, out IRenderable containedObject) { bool handledAsBaseType = true; containedObject = null; switch (baseType) { case "Container": if (GraphicalUiElement.ShowLineRectangles) { LineRectangle lineRectangle = new LineRectangle(systemManagers); containedObject = lineRectangle; } else { containedObject = new InvisibleRenderable(); } break; case "Rectangle": LineRectangle rectangle = new LineRectangle(systemManagers); rectangle.IsDotted = false; containedObject = rectangle; break; case "Circle": LineCircle circle = new LineCircle(systemManagers); circle.CircleOrigin = CircleOrigin.TopLeft; containedObject = circle; break; case "Polygon": LinePolygon polygon = new LinePolygon(systemManagers); containedObject = polygon; break; case "ColoredRectangle": SolidRectangle solidRectangle = new SolidRectangle(); containedObject = solidRectangle; break; case "Sprite": Texture2D texture = null; Sprite sprite = new Sprite(texture); containedObject = sprite; break; case "NineSlice": { NineSlice nineSlice = new NineSlice(); containedObject = nineSlice; } break; case "Text": { Text text = new Text(systemManagers, ""); containedObject = text; } break; default: handledAsBaseType = false; break; } return(handledAsBaseType); }
internal static bool TryHandleAsBaseType(string baseType, SystemManagers systemManagers, out IRenderable containedObject) { bool handledAsBaseType = true; containedObject = null; #if MONOGAME switch (baseType) { case "Container": case "Component": // this should never be set in Gum, but there could be XML errors or someone could have used an old Gum... if (GraphicalUiElement.ShowLineRectangles) { LineRectangle lineRectangle = new LineRectangle(systemManagers); containedObject = lineRectangle; } else { containedObject = new InvisibleRenderable(); } break; case "Rectangle": LineRectangle rectangle = new LineRectangle(systemManagers); rectangle.IsDotted = false; containedObject = rectangle; break; case "Circle": LineCircle circle = new LineCircle(systemManagers); circle.CircleOrigin = CircleOrigin.TopLeft; containedObject = circle; break; case "Polygon": LinePolygon polygon = new LinePolygon(systemManagers); containedObject = polygon; break; case "ColoredRectangle": SolidRectangle solidRectangle = new SolidRectangle(); containedObject = solidRectangle; break; case "Sprite": Texture2D texture = null; Sprite sprite = new Sprite(texture); containedObject = sprite; break; case "NineSlice": { NineSlice nineSlice = new NineSlice(); containedObject = nineSlice; } break; case "Text": { Text text = new Text(systemManagers, ""); containedObject = text; } break; default: handledAsBaseType = false; break; } #endif return(handledAsBaseType); }