public static void QueueCommit(tk2dCurvedTextMesh curvedTextMesh) { #if UNITY_EDITOR if (!Application.isPlaying) { curvedTextMesh.DoNotUse__CommitInternal(); } else #endif { Instance.QueueCommitInternal(curvedTextMesh); } }
void QueueCommitInternal(tk2dCurvedTextMesh curvedTextMesh) { curvedTextMeshes.Add(curvedTextMesh); }
// Draws the word wrap GUI void DrawWordWrapSceneGUI(tk2dCurvedTextMesh textMesh) { tk2dFontData font = textMesh.font; Transform transform = textMesh.transform; int px = textMesh.wordWrapWidth; Vector3 p0 = transform.position; float width = font.texelSize.x * px * transform.localScale.x; bool drawRightHandle = true; bool drawLeftHandle = false; switch (textMesh.anchor) { case TextAnchor.LowerCenter: case TextAnchor.MiddleCenter: case TextAnchor.UpperCenter: drawLeftHandle = true; p0 -= width * 0.5f * transform.right; break; case TextAnchor.LowerRight: case TextAnchor.MiddleRight: case TextAnchor.UpperRight: drawLeftHandle = true; drawRightHandle = false; p0 -= width * transform.right; break; } Vector3 p1 = p0 + width * transform.right; Handles.color = new Color32(255, 255, 255, 24); float subPin = font.texelSize.y * 2048; Handles.DrawLine(p0, p1); Handles.DrawLine(p0 - subPin * transform.up, p0 + subPin * transform.up); Handles.DrawLine(p1 - subPin * transform.up, p1 + subPin * transform.up); Handles.color = Color.white; Vector3 pin = transform.up * font.texelSize.y * 10.0f; Handles.DrawLine(p0 - pin, p0 + pin); Handles.DrawLine(p1 - pin, p1 + pin); if (drawRightHandle) { Vector3 newp1 = Handles.Slider(p1, transform.right, HandleUtility.GetHandleSize(p1), Handles.ArrowCap, 0.0f); if (newp1 != p1) { tk2dUndo.RecordObject(textMesh, "TextMesh Wrap Length"); int newPx = (int)Mathf.Round((newp1 - p0).magnitude / (font.texelSize.x * transform.localScale.x)); newPx = Mathf.Max(newPx, 0); textMesh.wordWrapWidth = newPx; textMesh.Commit(); } } if (drawLeftHandle) { Vector3 newp0 = Handles.Slider(p0, -transform.right, HandleUtility.GetHandleSize(p0), Handles.ArrowCap, 0.0f); if (newp0 != p0) { tk2dUndo.RecordObject(textMesh, "TextMesh Wrap Length"); int newPx = (int)Mathf.Round((p1 - newp0).magnitude / (font.texelSize.x * transform.localScale.x)); newPx = Mathf.Max(newPx, 0); textMesh.wordWrapWidth = newPx; textMesh.Commit(); } } }