Beispiel #1
0
 // Token: 0x0600055A RID: 1370 RVA: 0x00017AD8 File Offset: 0x00015CD8
 private void Awake()
 {
     if (PrefabControllerBase.m_onAwake != null)
     {
         PrefabControllerBase.m_onAwake(base.gameObject);
     }
 }
        // Token: 0x0600056E RID: 1390 RVA: 0x00018144 File Offset: 0x00016344
        public bool CreateAllControllers(bool autoBind = true)
        {
            bool result = true;

            this.CtrlList.Clear();
            foreach (ControllerDesc controllerDesc in this.CtrlDescList)
            {
                PrefabControllerBase prefabControllerBase = PrefabControllerBase.AddControllerToGameObject(base.gameObject, controllerDesc.m_attachPath, controllerDesc.m_ctrlTypeDNName, controllerDesc.m_ctrlName, controllerDesc.m_luaModuleName, false);
                if (prefabControllerBase == null)
                {
                    global::Debug.LogError(string.Format("PrefabControllerCreater.CreateAllControllers AddControllerToGameObject fail {0} {1} {2}", controllerDesc.m_ctrlName, controllerDesc.m_attachPath, controllerDesc.m_ctrlTypeDNName));
                }
                this.CtrlList.Add(prefabControllerBase);
            }
            if (autoBind)
            {
                foreach (PrefabControllerBase prefabControllerBase2 in this.CtrlList)
                {
                    if (prefabControllerBase2 != null)
                    {
                        prefabControllerBase2.BindFields();
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        // Token: 0x06000564 RID: 1380 RVA: 0x00017DE0 File Offset: 0x00015FE0
        public static PrefabControllerBase AddControllerToGameObject(GameObject root, string path, TypeDNName ctrlTypeDNName, string ctrlName, string luaModuleName = null, bool autoBind = false)
        {
            Type type = ClassLoader.Instance.LoadType(ctrlTypeDNName);

            if (type == null)
            {
                global::Debug.LogError(string.Format("AddControllerToGameObject fail for {0}", ctrlTypeDNName.m_typeFullName));
                return(null);
            }
            int num = path.IndexOf('/');

            if (num == -1)
            {
                if (!root.name.Contains(path))
                {
                    global::Debug.LogError(string.Format("AddControllerToGameObject fail path error {0}", path));
                    return(null);
                }
                PrefabControllerBase prefabControllerBase = root.GetComponent(type) as PrefabControllerBase;
                if (prefabControllerBase != null)
                {
                    return(prefabControllerBase);
                }
                root.GetComponent(type);
                prefabControllerBase = (root.AddComponent(type) as PrefabControllerBase);
                if (prefabControllerBase != null)
                {
                    if (type.IsDefined(typeof(HotFixManuallyAttribute), false) && !string.IsNullOrEmpty(luaModuleName))
                    {
                        LuaManager.TryInitHotfixForObj(prefabControllerBase, luaModuleName, null);
                    }
                    prefabControllerBase.Initlize(ctrlName, autoBind);
                }
                return(prefabControllerBase);
            }
            else
            {
                string    name      = path.Substring(num + 1);
                Transform transform = root.transform.Find(name);
                if (transform == null)
                {
                    global::Debug.LogError(string.Format("AddControllerToGameObject fail path error {0}", path));
                    return(null);
                }
                GameObject           gameObject           = transform.gameObject;
                PrefabControllerBase prefabControllerBase = gameObject.GetComponent(type) as PrefabControllerBase;
                if (prefabControllerBase != null)
                {
                    return(prefabControllerBase);
                }
                prefabControllerBase = (gameObject.AddComponent(type) as PrefabControllerBase);
                if (prefabControllerBase != null)
                {
                    prefabControllerBase.Initlize(ctrlName, autoBind);
                }
                return(prefabControllerBase);
            }
        }
Beispiel #4
0
        // Token: 0x06000562 RID: 1378 RVA: 0x00017C94 File Offset: 0x00015E94
        protected virtual UnityEngine.Object BindFieldImpl(Type fieldType, string path, AutoBindAttribute.InitState initState, string fieldName, string ctrlName = null, bool optional = false)
        {
            UnityEngine.Object result      = null;
            GameObject         childByPath = this.GetChildByPath(path);

            if (childByPath == null)
            {
                global::Debug.LogError(string.Format("BindFields fail can not found child {0} in {1} {2}", path, base.gameObject, base.GetType().Name));
                return(null);
            }
            if (fieldType == typeof(GameObject))
            {
                result = childByPath;
            }
            else if (fieldType.IsSubclassOf(typeof(PrefabControllerBase)))
            {
                PrefabControllerBase prefabControllerBase = childByPath.GetComponent(fieldType) as PrefabControllerBase;
                if (prefabControllerBase == null)
                {
                    if (!optional)
                    {
                        global::Debug.LogError(string.Format("BindFields fail can not found comp in child {0} {1}", path, fieldType.Name));
                    }
                    return(null);
                }
                result = prefabControllerBase;
            }
            else if (fieldType.IsSubclassOf(typeof(Component)))
            {
                Component component = childByPath.GetComponent(fieldType);
                if (component == null)
                {
                    if (!optional)
                    {
                        global::Debug.LogError(string.Format("BindFields fail can not found comp in child {0} {1}", path, fieldType.Name));
                    }
                    return(null);
                }
                result = component;
            }
            return(result);
        }