// 组件添加到对象时, 自动决定类型 void OnEnable( ) { // 启动探测类型 Type = DetectType(gameObject); if (!CheckName(gameObject.name)) { Type = CodeGenObjectType.Unknown; Debug.LogError(string.Format("UIBinder: Invalid object name to generated code, {0} ", gameObject.name)); } }
static UIBinder FindGameObjectByType(GameObject[] objlist, CodeGenObjectType type) { foreach (GameObject go in objlist) { var binder = go.GetComponent <UIBinder>(); if (binder == null) { continue; } if (binder.Type == type) { return(binder); } } return(null); }