/* * @author Valentin Simonov / http://va.lent.in/ */ using System.Text; using TouchScript.Pointers; using UnityEngine; namespace TouchScript.Behaviors.Cursors { /// /// Cursor for touch pointers. /// [HelpURL("http://touchscript.github.io/docs/html/T_TouchScript_Behaviors_Cursors_TouchCursor.htm")] public class TouchCursor : TextPointerCursor { #region Public properties /// /// Should the value of be shown on the cursor. /// public bool ShowPressure = false; /// /// Should the value of be shown on the cursor. /// public bool ShowRotation = false; #endregion #region Protected methods /// protected override void generateText(TouchPointer pointer, StringBuilder str) { base.generateText(pointer, str); if (ShowPressure) { if (str.Length > 0) str.Append("\n"); str.Append("Pressure: "); str.AppendFormat("{0:0.000}", pointer.Pressure); } if (ShowRotation) { if (str.Length > 0) str.Append("\n"); str.Append("Rotation: "); str.Append(pointer.Rotation); } } /// protected override bool textIsVisible() { return base.textIsVisible() || ShowPressure || ShowRotation; } /// protected override uint gethash(TouchPointer pointer) { var hash = base.gethash(pointer); if (ShowPressure) hash += (uint) (pointer.Pressure * 1024) << 8; if (ShowRotation) hash += (uint) (pointer.Rotation * 1024) << 16; return hash; } #endregion } }