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

Commit

Permalink
Fixed scaling with the word-wrap zone indicator (bis)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chman committed Aug 14, 2014
1 parent bd9f73a commit fc505c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Binary file modified Typogenic.unitypackage
Binary file not shown.
14 changes: 7 additions & 7 deletions Typogenic/Editor/TypogenicTextEditor.cs
Expand Up @@ -101,15 +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 * localScale.x, 0f, 0f);
if (src.Alignment == TTextAlignment.Right) alignmentOffset = new Vector3(-src.WordWrap * localScale.x, 0f, 0f);
if (src.Alignment == TTextAlignment.Center) alignmentOffset = new Vector3(-src.WordWrap * 0.5f, 0f, 0f);
else if (src.Alignment == TTextAlignment.Right) alignmentOffset = new Vector3(-src.WordWrap, 0f, 0f);

Vector3 v1 = src.transform.TransformPoint(alignmentOffset);
Vector3 v2 = src.transform.TransformPoint(alignmentOffset + new Vector3(src.WordWrap, 0f, 0f));
Vector3 v3 = src.transform.TransformPoint(alignmentOffset + new Vector3(0f, -src.Height, 0f));
Vector3 v4 = src.transform.TransformPoint(alignmentOffset + new Vector3(src.WordWrap, -src.Height, 0f));

Vector3 v1 = src.transform.position + alignmentOffset; // top left
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 fc505c1

Please sign in to comment.