123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- using System;
- using UnityEngine;
- using wf;
- public class MouseExposition : MonoBehaviour
- {
- public static MouseExposition GetObject()
- {
- if (GameObject.Find("UI Root/MouseExposition") != null)
- {
- return GameObject.Find("UI Root/MouseExposition").GetComponent<MouseExposition>();
- }
- GameObject gameObject = Utility.CreatePrefab(GameObject.Find("UI Root"), "System/Prefab/MouseExposition", true);
- gameObject.name = gameObject.name.Replace("(Clone)", string.Empty);
- MouseExposition component = gameObject.GetComponent<MouseExposition>();
- component.text = string.Empty;
- component.visible = true;
- GameObject gameObject2 = new GameObject();
- gameObject2.transform.SetParent(gameObject.transform);
- component.dummy_object_ = gameObject2;
- return gameObject.GetComponent<MouseExposition>();
- }
- private void Awake()
- {
- if (this.sprite_ != null)
- {
- return;
- }
- this.camera_ = GameObject.Find("UI Root/Camera").GetComponent<Camera>();
- this.sprite_ = base.GetComponentInChildren<UISprite>();
- this.label_ = base.GetComponentInChildren<UILabel>();
- this.visible_ = true;
- this.UpdateAlpha(0f);
- }
- public void Update()
- {
- if (!GameMain.Instance.VRMode)
- {
- Vector3 vector = this.camera_.ScreenToWorldPoint(Input.mousePosition);
- vector = base.transform.parent.InverseTransformPoint(vector);
- vector.z = 0f;
- vector.y -= (float)(this.sprite_.height + 15);
- vector.x += 10f;
- base.transform.localPosition = vector;
- }
- else
- {
- base.transform.localPosition = Vector3.zero;
- }
- if (!string.IsNullOrEmpty(this.label_.text) && this.sprite_.alpha < 1f)
- {
- if (base.GetComponent<iTween>() == null)
- {
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- this.sprite_.alpha,
- "to",
- 1,
- "time",
- MouseExposition.kFadeTime,
- "onupdate",
- "UpdateAlpha"
- }));
- }
- }
- else if (string.IsNullOrEmpty(this.label_.text) && 0f < this.sprite_.alpha && base.GetComponent<iTween>() == null)
- {
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- this.sprite_.alpha,
- "to",
- 0,
- "time",
- MouseExposition.kFadeTime,
- "onupdate",
- "UpdateAlpha"
- }));
- }
- }
- public void SetText(string draw_text, float time)
- {
- this.text = draw_text;
- if (!string.IsNullOrEmpty(this.label_.text) && this.sprite_.alpha < 1f)
- {
- if (base.GetComponent<iTween>() == null)
- {
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- this.sprite_.alpha,
- "to",
- 1,
- "time",
- MouseExposition.kFadeTime,
- "onupdate",
- "UpdateAlpha"
- }));
- }
- }
- else if (string.IsNullOrEmpty(this.label_.text) && 0f < this.sprite_.alpha && base.GetComponent<iTween>() == null)
- {
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- this.sprite_.alpha,
- "to",
- 0,
- "time",
- MouseExposition.kFadeTime,
- "onupdate",
- "UpdateAlpha"
- }));
- }
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.linear,
- "from",
- 0,
- "to",
- 1,
- "time",
- time,
- "onUpdate",
- "OnUpdateDummy",
- "onComplete",
- "OnComplete"
- }));
- }
- public void OnUpdateDummy()
- {
- }
- public void OnComplete()
- {
- this.text = string.Empty;
- }
- public string text
- {
- get
- {
- return this.label_.text;
- }
- set
- {
- this.label_.text = value;
- this.label_.width = 0;
- this.label_.MakePixelPerfect();
- this.sprite_.width = this.label_.width + 15;
- if (!this.visible_)
- {
- return;
- }
- iTween.Stop(base.gameObject);
- iTween[] components = base.GetComponents<iTween>();
- for (int i = 0; i < components.Length; i++)
- {
- UnityEngine.Object.DestroyImmediate(components[i]);
- }
- }
- }
- public bool visible
- {
- get
- {
- return base.gameObject.activeSelf;
- }
- set
- {
- this.visible_ = value;
- if (!this.visible_)
- {
- iTween.Stop(base.gameObject);
- iTween[] componentsInChildren = base.GetComponentsInChildren<iTween>();
- for (int i = 0; i < componentsInChildren.Length; i++)
- {
- UnityEngine.Object.DestroyImmediate(componentsInChildren[i]);
- }
- this.UpdateAlpha(0f);
- }
- }
- }
- private void UpdateAlpha(float value)
- {
- this.sprite_.alpha = value;
- this.label_.alpha = value;
- float num = wf.Math.RoundMinMax(0.5f + value, 0f, 1f);
- this.sprite_.transform.localScale = new Vector2(num, num);
- }
- private static float kFadeTime = 0.3f;
- private Camera camera_;
- private UISprite sprite_;
- private UILabel label_;
- private bool visible_;
- private GameObject dummy_object_;
- }
|