/// <summary> /// Open a new UI window /// </summary> /// <param name="name"> The name of the UI window to be opened </param> /// <param name="mode"> The mode to be used to open the UI window </param> /// <param name="args"> Extra arguments passed to UIWindow.OnOpen() </param> /// <returns></returns> public GUIWindow Open(string name, UIMode mode = UIMode.DEFAULT, params object[] args) { #if UNITY_EDITOR Debug.Log(LogUtility.MakeLogStringFormat("UI", IsInViewport(name) ? name + " is already in viewport" : "Open " + name)); #endif if (IsInViewport(name)) { return(uiWindowsOpened[name]); } GUIWindow uiWindow = Instantiate(ResourceUtility.GetGUIPrefab <GUIWindow>(name), transform, false); uiWindow.transform.SetAsFirstSibling(); uiWindowsOpened.Add(name, uiWindow); uiWindow.OnOpen(args); if (mode != UIMode.PERMANENT) { uiWindowStack.Push(name); } return(uiWindow); }
public void CreateFloatingTextForDamage(float damage, Vector3 worldPosition) { FloatingText floatingText = reusableFloatingTexts.Count > 0 ? reusableFloatingTexts.Pop() : Instantiate(ResourceUtility.GetGUIPrefab <FloatingText>("FloatingText"), transform); floatingText.Text = Mathf.FloorToInt(damage).ToString(); floatingText.transform.position = Camera.main.WorldToScreenPoint(worldPosition); floatingText.gameObject.SetActive(true); }
public FloatingText CreateFloatingTextForDamage(float damage, Vector3 worldPosition, bool isCritical = false) { Vector3 position = Camera.main.WorldToScreenPoint(worldPosition); FloatingText floatingText = reusableFloatingTexts.Count > 0 ? reusableFloatingTexts.Pop() : Instantiate(ResourceUtility.GetGUIPrefab <FloatingText>("FloatingText"), position, Quaternion.identity, transform); floatingText.Text = Mathf.FloorToInt(damage).ToString(); floatingText.TextColor = isCritical ? Color.red : Color.yellow; floatingText.transform.position = position; floatingText.gameObject.SetActive(true); return(floatingText); }
public FloatingText CreateFloatingText(string message, Vector3 worldPosition) { Vector3 position = Camera.main.WorldToScreenPoint(worldPosition); FloatingText floatingText = reusableFloatingTexts.Count > 0 ? reusableFloatingTexts.Pop() : Instantiate(ResourceUtility.GetGUIPrefab <FloatingText>("FloatingText"), position, Quaternion.identity, transform); floatingText.Text = message; floatingText.transform.position = position; floatingText.gameObject.SetActive(true); return(floatingText); }