private bool ShowChangeText(ParameterCategory category, float val) { if (parameters.ContainsKey(category)) { GameObject obj; parameters.TryGetValue(category, out obj); GameObject text = Instantiate(preChangeNum); text.transform.SetParent(UIManager.Instance.Canvas.transform); text.transform.localScale = Vector3.one; string numText = (val >= 0) ? "+" + val.ToString() : val.ToString(); CustomNumberText cusText = text.GetComponent <CustomNumberText>(); cusText.Text = numText; cusText.Alignment = TextAlignment.Center; text.transform.position = obj.transform.position; text.transform.localPosition = new Vector2(text.transform.localPosition.x, text.transform.localPosition.y + 60); StartCoroutine(CorChangeVal(text, category)); return(true); } else { Debug.LogWarning(category + " parameter DOESN'T EXIST"); return(false); } }
// Use this for initialization void Start() { text = GetComponent <Text>(); cusText = GetComponent <CustomNumberText>(); if (text == null && cusText == null) { Debug.LogError("This Object DOESN'T HAVE Textable Component"); enabled = false; return; } }