public void ShowNumFavorability(int num = -1) { Debug.Log("GameConfigKey.ShowNumFavorability " + num); Transform tf = transform.Find("FlyText/Num"); int childCount = tf.childCount; int curIndex = 0; for (int i = curIndex; i < childCount; i++) { tf.GetChild(i).gameObject.Show(); } if (num == 0) { tf.GetChild(curIndex).GetComponent <Image>().sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Common_NumFavorability"); tf.GetChild(curIndex).GetComponent <Image>().SetNativeSize(); curIndex++; tf.GetChild(curIndex).GetComponent <Image>().sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Common_Num0"); tf.GetChild(curIndex).GetComponent <Image>().SetNativeSize(); curIndex++; } else if (num > 0) { tf.GetChild(curIndex).GetComponent <Image>().sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Common_NumFavorability"); tf.GetChild(curIndex).GetComponent <Image>().SetNativeSize(); curIndex++; List <int> numlist = new List <int>(); int curNum = num; while (curNum > 0) { numlist.Add(curNum % 10); curNum = curNum / 10; } for (int i = numlist.Count - 1; i >= 0; i--) { tf.GetChild(curIndex).GetComponent <Image>().sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Common_Num" + numlist[i].ToString()); tf.GetChild(curIndex).GetComponent <Image>().SetNativeSize(); curIndex++; } } else { tf.GetChild(curIndex).GetComponent <Image>().sprite = AssetManager.Instance.GetSpriteAtlas("UIAtlas_Common_NumMax"); tf.GetChild(curIndex).GetComponent <Image>().SetNativeSize(); curIndex++; } for (int i = curIndex; i < childCount; i++) { tf.GetChild(i).gameObject.Hide(); } FlyText.ShowFlyText(tf); }
void flyText(Vector3 pos, Color color, string content) { GameObject go = Instantiate(Resources.Load <GameObject>("Prefabs/Text_FlyText"), pos, Quaternion.identity) as GameObject; go.transform.SetParent(GameObject.Find("Canvas").transform); FlyText ft = go.GetComponent <FlyText>(); ft.color = color; ft.content = content; }