using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static GameManager; using System.Reflection; using System; public class InitTapList : MonoBehaviour { public bool isPose=true; public GameObjectType type; public GameObject go; public List taplist; List golist=new List(); private void Awake() { StartCoroutine(Finder()); } IEnumerator Finder() { yield return null; go.SetActive(false); for (int i = 0;i().isOn=true; } fz.GetComponentInChildren().text=GetChineseDescription(taplist[i]); fz.GetComponent().init(type,taplist[i]); yield return FinderObj(taplist[i],fz); } yield return null; golist[0].GetComponent().isOn=true; } IEnumerator FinderObj(TapName tn,GameObject fz) { GameObject findgo=null; if(isPose) { while(!findgo) { findgo =GameObject.Find(GetChineseDescription(type)+"_"+GetChineseDescription(tn)); yield return null; } } fz.GetComponent().go =findgo; fz.name = GetChineseDescription(type)+"_"+GetChineseDescription(tn); golist.Add(fz) ; yield return null; } public static string GetChineseDescription(Enum value) { FieldInfo field = value.GetType().GetField(value.ToString()); ChineseDescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(ChineseDescriptionAttribute)) as ChineseDescriptionAttribute; return attribute == null ? value.ToString() : attribute.Description; } private void OnEnable() { } [AttributeUsage(AttributeTargets.Field)] public class ChineseDescriptionAttribute : Attribute { public string Description { get; private set; } public ChineseDescriptionAttribute(string description) { Description = description; } } }