/* * @author Valentin Simonov / http://va.lent.in/ */ using System.Text; using TouchScript.Pointers; using UnityEngine; namespace TouchScript.Behaviors.Cursors { /// /// Cursor for object pointers. /// [HelpURL("http://touchscript.github.io/docs/html/T_TouchScript_Behaviors_Cursors_ObjectCursor.htm")] public class ObjectCursor : TextPointerCursor { #region Public properties /// /// Should the value of be shown on the cursor. /// public bool ShowObjectId = false; /// /// Should the values of and be shown on the cursor. /// public bool ShowSize = false; /// /// Should the value of be shown on the cursor. /// public bool ShowAngle = false; #endregion #region Protected methods /// protected override void generateText(ObjectPointer pointer, StringBuilder str) { base.generateText(pointer, str); if (ShowObjectId) { if (str.Length > 0) str.Append("\n"); str.Append("ObjectId: "); str.Append(pointer.ObjectId); } if (ShowSize) { if (str.Length > 0) str.Append("\n"); str.Append("Size: "); str.Append(pointer.Width); str.Append("x"); str.Append(pointer.Height); } if (ShowAngle) { if (str.Length > 0) str.Append("\n"); str.Append("Angle: "); str.Append(pointer.Angle); } } /// protected override bool textIsVisible() { return base.textIsVisible() || ShowObjectId || ShowSize || ShowAngle; } /// protected override uint gethash(ObjectPointer pointer) { var hash = base.gethash(pointer); if (ShowSize) hash += (uint) (pointer.Width * 1024 + pointer.Height * 1024 * 1024) << 8; if (ShowAngle) hash += (uint) (pointer.Angle * 1024) << 24; return hash; } #endregion } }