Skip to content
This repository has been archived by the owner on Nov 7, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed scaling with the word-wrap zone indicator
  • Loading branch information
Chman committed Aug 14, 2014
1 parent 9438b13 commit bd9f73a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Binary file modified Typogenic.unitypackage
Binary file not shown.
11 changes: 6 additions & 5 deletions Typogenic/Editor/TypogenicTextEditor.cs
Expand Up @@ -101,14 +101,15 @@ void OnSceneGUI()

if (src.WordWrap > 0f)
{
Vector3 localScale = src.transform.localScale;
Vector3 alignmentOffset = Vector3.zero;
if (src.Alignment == TTextAlignment.Center) alignmentOffset = new Vector3(-src.WordWrap * 0.5f, 0f, 0f);
if (src.Alignment == TTextAlignment.Right) alignmentOffset = new Vector3(-src.WordWrap, 0f, 0f);
if (src.Alignment == TTextAlignment.Center) alignmentOffset = new Vector3(-src.WordWrap * 0.5f * localScale.x, 0f, 0f);
if (src.Alignment == TTextAlignment.Right) alignmentOffset = new Vector3(-src.WordWrap * localScale.x, 0f, 0f);

Vector3 v1 = src.transform.position + alignmentOffset; // top left
Vector3 v2 = v1 + src.transform.rotation * new Vector3(src.WordWrap, 0f, 0f); // top right
Vector3 v3 = v1 + src.transform.rotation * new Vector3(0f, -src.Height, 0f); // bottom left
Vector3 v4 = v3 + src.transform.rotation * new Vector3(src.WordWrap, 0f, 0f); // bottom right
Vector3 v2 = v1 + src.transform.rotation * new Vector3(localScale.x * src.WordWrap, 0f, 0f); // top right
Vector3 v3 = v1 + src.transform.rotation * new Vector3(0f, -src.Height * localScale.y, 0f); // bottom left
Vector3 v4 = v3 + src.transform.rotation * new Vector3(src.WordWrap * localScale.x, 0f, 0f); // bottom right
Handles.color = Color.yellow;
Handles.DrawLine(v1, v2);
Handles.DrawLine(v1, v3);
Expand Down

0 comments on commit bd9f73a

Please sign in to comment.