using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Experimental.VFX; using UnityEngine.UI; using UltraCombos.Configuration; public class DebugUI : MonoBehaviour { public bool debugMode = true; public GameObject debugUI; public VisualEffect vfx; public GameObject baseEmitter; public GameObject target; public GameObject emitter; public GameObject button; public string stat = "wait"; [Config] [Range(0f, 0.02f)] public float growingSpeed; [Config] [Range(10, 30)] public float fadeSpeed; [Config] [Range(0f, 0.5f)] public float smooth; float spawn_t; float total_t; float lerp_val; Vector3 final_pos; bool showObject; void Start() { stat = "wait"; debugUI.SetActive(debugMode); button.GetComponent().text = stat; spawn_t = 0; total_t = 0; lerp_val = 0; } // Update is called once per frame void Update() { updateVFX(); if (Input.GetKeyDown(KeyCode.A)) { debugMode = !debugMode; debugUI.SetActive(debugMode); if (debugMode) { showObject = true; setObjectVisible(showObject); } else { showObject = false; setObjectVisible(showObject); } } else if (debugMode && Input.GetKeyDown(KeyCode.D)){ showObject = !showObject; setObjectVisible(showObject); } if(stat == "growing") { total_t += Time.deltaTime; lerp_val += growingSpeed; if(lerp_val >= 1) { lerp_val = 1; stat = "completed"; StartCoroutine("sendCompleted"); setButtonInteractable(true); button.GetComponent().text = stat; Debug.Log(stat); } } else if(stat == "vanishing") { vfx.SetBool("isEnteringVanish", false); lerp_val -= growingSpeed; if(lerp_val <= 0) { lerp_val = 0; stat = "wait"; setButtonInteractable(true); button.GetComponent().text = stat; Debug.Log(stat); } } lerp_val = Mathf.Clamp(lerp_val, 0, 1); vfx.SetFloat("_LerpVal", lerp_val); Vector3 base_pos = baseEmitter.GetComponent().position; Vector3 target_pos = target.GetComponent().position; emitter.GetComponent().position = Vector3.Lerp(base_pos, target_pos, lerp_val); } IEnumerator sendCompleted() { yield return new WaitForSeconds(0.5f); vfx.SendEvent("Completed"); } public void switchStat() { if(stat == "wait") { enterGrow(); } else if(stat == "completed") { enterVanish(); } button.GetComponent().text = stat; } public void enterGrow() { setButtonInteractable(false); spawn_t = total_t; stat = "growing"; vfx.SendEvent("MouseDown"); vfx.SetBool("isGrowing", true); Debug.Log(stat); } public void enterVanish() { setButtonInteractable(false); vfx.SetBool("isEnteringVanish", true); stat = "vanishing"; vfx.SendEvent("MouseUp"); vfx.SetBool("isGrowing", false); Debug.Log(stat); } private void setObjectVisible(bool isShowed) { baseEmitter.GetComponent().enabled = isShowed; target.GetComponent().enabled = isShowed; emitter.GetComponent().enabled = isShowed; } private void setButtonInteractable(bool _stat) { button.GetComponentInParent