15 const float SmoothProgressSpeed = 10f;
24 return Instance.gameObject.activeSelf;
37 private GameObject defaultPrefab = null;
41 private GameObject defaultIconPrefab = null;
44 private GameObject defaultOrbsPrefab = null;
48 private GameObject progressBarContainer = null;
52 private Transform progressBar = null;
56 private TextMesh messageText = null;
60 private TextMesh progressText = null;
63 private Animator animator = null;
69 return smoothProgress;
73 private float smoothProgress = 0f;
74 private float targetProgress = 0f;
75 private bool closing =
false;
76 private GameObject instantiatedCustomObject;
81 public string ProgressFormat =
"0.0";
93 if (gameObject.activeSelf)
99 transform.parent = null;
103 gameObject.SetActive(
true);
104 progressText.gameObject.SetActive(progressStyle ==
ProgressStyleEnum.Percentage);
105 progressBarContainer.gameObject.SetActive(progressStyle ==
ProgressStyleEnum.ProgressBar);
107 messageText.text = message;
114 switch (indicatorStyle)
121 if (defaultIconPrefab == null)
123 UnityEngine.Debug.LogError(
"No Icon prefab available in loading dialog, spawning without one");
127 instantiatedCustomObject = GameObject.Instantiate(defaultIconPrefab) as GameObject;
128 instantiatedCustomObject.transform.localPosition =
new Vector3(0.0f, 13.0f, 0.0f);
129 instantiatedCustomObject.transform.localRotation = Quaternion.identity;
130 instantiatedCustomObject.transform.localScale =
new Vector3(10.0f, 10.0f, 10.0f);
132 instantiatedCustomObject.transform.Translate(messageText.transform.position);
133 instantiatedCustomObject.transform.SetParent(messageText.transform,
false);
138 if (defaultOrbsPrefab != null)
140 instantiatedCustomObject = GameObject.Instantiate(defaultOrbsPrefab) as GameObject;
141 instantiatedCustomObject.transform.localPosition =
new Vector3(0.0f, 25.0f, 0.0f);
143 instantiatedCustomObject.transform.localScale =
new Vector3(3.0f, 3.0f, 3.0f);
145 instantiatedCustomObject.transform.Translate(messageText.transform.position);
146 instantiatedCustomObject.transform.SetParent(messageText.transform,
false);
152 if (defaultPrefab == null && prefab == null)
154 UnityEngine.Debug.LogError(
"No prefab available in loading dialog, spawning without one");
158 instantiatedCustomObject = GameObject.Instantiate(defaultPrefab) as GameObject;
159 instantiatedCustomObject.transform.localPosition =
new Vector3(0.0f, 20.0f, 0.0f);
160 instantiatedCustomObject.transform.localRotation = Quaternion.identity;
161 instantiatedCustomObject.transform.localScale =
new Vector3(10.0f, 10.0f, 10.0f);
163 instantiatedCustomObject.transform.Translate(messageText.transform.position);
164 instantiatedCustomObject.transform.SetParent(messageText.transform,
false);
168 animator.SetTrigger(
"Open");
175 public void Open(
string message)
187 if (!gameObject.activeSelf) {
return; }
189 messageText.text = message;
199 targetProgress = Mathf.Clamp01(progress) * 100;
201 if (targetProgress == 100)
203 smoothProgress = targetProgress;
204 if (instantiatedCustomObject != null && instantiatedCustomObject.name.Contains(
"Orbs"))
216 if (!gameObject.activeSelf) {
return; }
219 progressText.gameObject.SetActive(
false);
220 messageText.gameObject.SetActive(
false);
221 animator.SetTrigger(
"Close");
226 gameObject.SetActive(
false);
227 progressText.gameObject.SetActive(
false);
228 messageText.gameObject.SetActive(
false);
231 private void Update()
233 smoothProgress = Mathf.Lerp(smoothProgress, targetProgress, Time.deltaTime * SmoothProgressSpeed);
234 progressBar.localScale =
new Vector3(smoothProgress / 100, 1f, 1f);
235 progressText.text = smoothProgress.ToString(ProgressFormat) +
"%";
240 if (animator.GetCurrentAnimatorStateInfo(0).IsName(
"Closed"))
244 transform.parent = null;
245 gameObject.SetActive(
false);
248 if (instantiatedCustomObject != null)
250 GameObject.Destroy(instantiatedCustomObject);