// 创建绘制对象 private VectorObject2D createRectangle(int x, int y, int width, int height, float lineWidth, Color color) { GameObject obj = new GameObject(); obj.AddComponent <VectorObject2D>(); VectorObject2D comp = obj.GetComponent <VectorObject2D>(); comp.vectorLine = null; return(comp); }
private void OnEnable() { vobject = (target as VectorObject2D); vline = vobject.vectorLine; smoothWidth = vline.smoothWidth; smoothColor = vline.smoothColor; color = vline.color; texture = vline.texture; capLength = vline.capLength; lineWidth = vline.lineWidth; joins = vline.joins; lineType = vline.lineType; drawStart = vline.drawStart; drawEnd = vline.drawEnd; textureScale = vline.textureScale; textureOffset = vline.textureOffset; collider = vline.collider; showPointCoords = oldShowPointCoords = EditorPrefs.GetBool("VectrosityShowPointCoords", false); scenePointSize = oldScenePointSize = EditorPrefs.GetFloat("VectrosityScenePointSize", 15.0f); useTextureScale = oldUseTextureScale = (vline.textureScale > 0.0f); if (useTextureScale) { storedTextureScale = vline.textureScale; } if (vline.is2D) { int pointCount = vline.points2.Count; usePartialLine = (drawStart > 0 || drawEnd < pointCount - 1); points = new List <Point>(pointCount); for (int i = 0; i < pointCount; i++) { points.Add(new Point(vline.points2[i].x, vline.points2[i].y)); } } else { int pointCount = vline.points3.Count; usePartialLine = (drawStart > 0 || drawEnd < pointCount - 1); points3 = new List <Point3>(pointCount); for (int i = 0; i < pointCount; i++) { points3.Add(new Point3(vline.points3[i].x, vline.points3[i].y, vline.points3[i].z)); } } SetSegmentLists(); nameString = vline.name + ":"; showWarning = false; var canvas = vobject.rectTransform.root.GetComponent <Canvas>(); if (canvas != null) { if (canvas.renderMode != RenderMode.ScreenSpaceOverlay) { SetWarning("Only canvases using Screen Space Overlay are supported"); } canvasTransform = canvas.transform; } else { SetWarning("Line must be attached to a canvas"); } }