public void setProps(PCLSkeleton skel, Transform lookAtTarget, string text, float time, int jointIndex, Vector3 dir, float fontSize, float posSmooth, float circleSize) { this.skel = skel; this.lookAtTarget = lookAtTarget; this.jointIndex = jointIndex; this.text = text; this.posSmooth = posSmooth; Invoke("kill", time); // Create the LineWorks Components and Scriptable Objects. linework = GetComponent <LW_Canvas>(); linework.segmentation = 20; linework.featureMode = FeatureMode.Advanced; linework.strokeDrawMode = StrokeDrawMode.Draw3D; linework.joinsAndCapsMode = JoinsAndCapsMode.Shader; circle = LW_Circle.Create(Vector2.zero, .15f / transform.localScale.x); circleStroke = LW_Stroke.Create(Color.white, .2f); circleStroke.linejoin = Linejoin.Round; circle.styles.Add(circleStroke); linework.graphic.Add(circle); Vector3[] points = new Vector3[3]; points[0] = Vector3.zero; points[1] = Vector3.Scale(Vector3.one, dir) / transform.localScale.x; points[2] = points[1] + (Vector3.right * dir.x * lineSizeFactor) / transform.localScale.x; line = LW_Polyline3D.Create(points); lineStroke = LW_Stroke.Create(Color.white, .2f); line.styles.Add(lineStroke); linework.graphic.Add(line); line.isVisible = false; tm.transform.localPosition = points[2]; tm.anchor = dir.x > 0 ? TextAnchor.LowerRight : TextAnchor.LowerLeft; tm.alignment = dir.x > 0 ? TextAlignment.Right : TextAlignment.Left; tm.characterSize = fontSize / 100; text = "Super cool dis-donc"; seq = DOTween.Sequence(); //seq.Pause(); //blink circle seq.AppendCallback(() => blinkShape(circle, .5f)).AppendInterval(.3f); // reduce circle seq.AppendCallback(() => reduceCircle(circleSize / transform.localScale.x)).AppendInterval(.2f); //reveal line seq.AppendCallback(() => blinkShape(line, .5f)).AppendInterval(.3f); seq.AppendCallback(() => revealText(1)); if (skel != null) { transform.position = skel.joints[jointIndex]; } transform.LookAt(lookAtTarget.position); }
void CreateRing(Vector3 point) { if (linework != null) { LW_Circle circle = LW_Circle.Create(point, 0.01f); LW_Stroke stroke = masterStroke.Copy() as LW_Stroke; stroke.gradientStart = point; stroke.gradientEnd = point + Vector3.right * ringMaxRadius; linework.graphic.Add(circle); circle.styles.Add(stroke); StartCoroutine(DrawRing(circle, stroke)); } }
private LW_Canvas CreateControlPointDot(int pointIndex, int handleIndex) { LW_Point2D point = points[pointIndex]; Vector3 position = (vectorCanvas.transform.localToWorldMatrix * vectorCanvas.scaler).MultiplyPoint3x4(point.position); float radius = 6f; Color color = Color.white; if (handleIndex < 0) { position += (vectorCanvas.scaler).MultiplyVector(point.handleIn); radius = 4f; color = Color.gray; } else if (handleIndex > 0) { position += (vectorCanvas.scaler).MultiplyVector(point.handleOut); radius = 4f; color = Color.gray; } //GameObject controlPointGO = new GameObject("ControlPoint " + pointIndex + " : " + handleIndex); //controlPointGO.transform.SetParent(vectorCanvas.transform); LW_Canvas canvas = LW_Canvas.Create(vectorCanvas.gameObject, "ControlPoint"); LW_Circle circle = LW_Circle.Create(Vector3.zero, radius); LW_Fill fill = LW_Fill.Create(color); LW_Stroke stroke = LW_Stroke.Create(Color.black, 2f); circle.styles.Add(fill); circle.styles.Add(stroke); canvas.graphic.Add(circle); canvas.featureMode = FeatureMode.Advanced; canvas.joinsAndCapsMode = JoinsAndCapsMode.Shader; canvas.gradientsMode = GradientsMode.Shader; canvas.antiAliasingMode = AntiAliasingMode.On; canvas.transform.position = position; canvas.viewBox = new Rect(0, 0, 32, 32); canvas.SetRectSizeToViewBox(); ControlPointHandler cpHandler = canvas.gameObject.AddComponent <ControlPointHandler>(); cpHandler.tentacle = this; cpHandler.pointIndex = pointIndex; cpHandler.handleIndex = handleIndex; cpHandler.fillStyle = fill; return(canvas); }
IEnumerator DrawRing(LW_Circle circle, LW_Stroke stroke) { float minRadius = circle.radius; float maxRadius = ringMaxRadius; float lifeSpan = 0; while (lifeSpan < ringLifeSpan) { float t = lifeSpan / ringLifeSpan; circle.radius = Mathf.Lerp(minRadius, maxRadius, t); lifeSpan += Time.deltaTime; yield return(null); } if (linework != null) { linework.graphic.Remove(circle); } }