/// <summary> /// Create the specified ID. /// </summary> /// <param name="id">I.</param> /// <param name="transitionAssetPath"></param> public static CocoSceneSwitchControl Create(CocoSceneID id, string transitionAssetPath = null) { if (string.IsNullOrEmpty(transitionAssetPath)) { transitionAssetPath = DEFAULT_TRANSITION_ASSET_PATH; } CocoSceneSwitchControl control = CocoLoad.InstantiateOrCreate <CocoSceneSwitchControl> (transitionAssetPath); m_EnterSceneID = id; return(control); }
public TModuleEntity AddModule <TModule, TModuleEntity> (string assetPath = null, object moduleId = null) where TModule : CocoModuleBase where TModuleEntity : CocoModuleBase { TModuleEntity module = CocoLoad.InstantiateOrCreate <TModuleEntity> (assetPath, transform); if (!AddModule <TModule> (module, moduleId)) { Destroy(module.gameObject); return(null); } return(module); }
/// <summary> /// Creates the temp role. /// 创建一个临时的角色,不放在Control下,你需要自己删除 /// </summary> /// <returns>The temp role.</returns> /// <param name="roleId">Role identifier.</param> /// <param name="roleName">Role name.</param> /// <param name="parent">parent transform</param> /// <param name="recordDress">record dress</param> public CocoRoleEntity CreateTempRole(string roleId, string roleName, Transform parent = null, bool recordDress = false) { CocoRoleHolder roleHolder = assetControl.ConfigHolder.GetRoleHolder(roleId); if (roleHolder == null) { Debug.LogErrorFormat("{0}->CreateTempRole: can NOT found role holder for role id {1}", GetType().Name, roleId); return(null); } CocoRoleEntity role = CocoLoad.InstantiateOrCreate <CocoRoleEntity> (string.Empty, parent); role.name = roleName; role.DressRecordKey = GetRoleKey(roleId, roleName); role.IsDressRecordActive = recordDress; role.Init(roleHolder); return(role); }
public TModule AddModule <TModule> (Type moduleType, string assetPath = null, object moduleId = null) where TModule : CocoModuleBase { if (moduleType == null) { return(AddModule <TModule> (assetPath, moduleId)); } if (!moduleType.IsSubclassOf(typeof(CocoModuleBase))) { Debug.LogErrorFormat("{0}->AddModule: can NOT add module [{1}<{2}>], because the type is NOT module!", GetType(), moduleId, moduleType.Name); return(null); } TModule module = (TModule)CocoLoad.InstantiateOrCreate(moduleType, assetPath, transform); if (!AddModule <TModule> (module, moduleId)) { Destroy(module.gameObject); return(null); } return(module); }