5 using System.Collections.Generic;
16 [Tooltip(
"The ring or outer element")]
19 [Tooltip(
"Inner cursor element")]
20 public GameObject
Dot;
22 [Tooltip(
"Point light")]
25 [Tooltip(
"The scale factor to soften the distance scaling, we want the cursor to scale in the distance, but not disappear.")]
26 public float DistanceScaleFactor = 0.3f;
28 [Tooltip(
"The scale both elements will be at their default state")]
29 public float DefaultScale = 0.75f;
31 [Tooltip(
"The scale both elements will when pressed")]
32 public float DownScale = 0.5f;
34 [Tooltip(
"The scale both elements will a hand is visible")]
35 public float UpScale = 1;
37 [Tooltip(
"Time to scale between states")]
38 public float ScaleTime = 0.5f;
43 private float mTimer = 0;
45 private bool mHasHover =
false;
46 private bool mHasHand =
false;
47 private bool mIsDown =
false;
48 private Vector3 mBaseScale =
new Vector3(1, 1, 1);
49 private Vector3 mTargetScale;
50 private bool mIsVisible =
true;
52 private Vector3 mAwakeScale;
58 mAwakeScale = transform.localScale;
67 base.OnCursorStateChange(state);
70 if (mHasHand != this.IsHandVisible || mIsDown != this.IsInputSourceDown || mHasHover != (this.TargetedObject != null))
75 mHasHand = this.IsHandVisible;
76 mIsDown = this.IsInputSourceDown;
77 mHasHover = this.TargetedObject != null;
79 mTargetScale = mBaseScale * DefaultScale;
80 bool showRing =
false;
93 mTargetScale = mBaseScale * DownScale;
97 mTargetScale = mBaseScale * UpScale;
100 mTargetScale = mBaseScale * UpScale;
115 Ring.SetActive(showRing);
116 Dot.SetActive(!showRing);
119 if (TargetedCursorModifier != null && mHasHover)
121 ElementVisibility(!TargetedCursorModifier.GetCursorVisibility());
130 base.UpdateCursorTransform();
133 if (mTimer < ScaleTime)
135 mTimer += Time.deltaTime;
136 if (mTimer > ScaleTime)
141 Ring.transform.localScale = Vector3.Lerp(mBaseScale * DefaultScale, mTargetScale, mTimer/ScaleTime);
142 Dot.transform.localScale = Vector3.Lerp(mBaseScale * DefaultScale, mTargetScale, mTimer / ScaleTime);
147 float smoothscaling = 1 - DefaultCursorDistance * DistanceScaleFactor;
148 transform.localScale = mAwakeScale * (distance * DistanceScaleFactor + smoothscaling);
157 base.SetVisibility(visible);
159 mIsVisible = visible;
160 ElementVisibility(visible);
164 OnCursorStateChange(CursorState);
172 private void ElementVisibility(
bool visible)
176 Ring.SetActive(visible);
181 Dot.SetActive(visible);
186 Light.SetActive(visible);