private GameObject LoadModel(CocoAssetModelHolder modelHolder) { var go = CocoLoad.Instantiate(modelHolder.AssetEntity, transform); LoadModelMaterials(go, modelHolder); return(go); }
public void Init(CocoRoleHolder roleHolder) { RoleHolder = roleHolder; // dress Dress = AddUnit <CocoRoleDress> (); StartCoroutine(CocoWait.WaitForFunc(() => { return(!Dress.IsReady); }, () => { // body Body = AddUnit <CocoRoleBody> (); // shadow if (RoleHolder.enableShadow) { Shadow = CocoLoad.Instantiate <CocoRoleShadow> ("role/role_shadow", transform, CocoLoad.TransStayOption.Local); Shadow.FollowTarget = Body.GetBone(CocoRoleBoneID.Root); } // layer if (transform.parent != null) { transform.SetSelfAndChildLayer(transform.parent.gameObject.layer); } IsReady = true; })); }
static public CocoSkinnedMeshEffect Create(SkinnedMeshRenderer _SkinnedRenderer) { CocoSkinnedMeshEffect effect = CocoLoad.Instantiate <CocoSkinnedMeshEffect> ("Coco_SkinnedMesh_Effect", _SkinnedRenderer.transform); effect.SetSkinnedMeshRenderer(_SkinnedRenderer); return(effect); }
protected override void InitObjects() { base.InitObjects(); m_StoreControl = CocoLoad.GetOrAddComponent <CocoStoreControl> (gameObject); BindValue(m_StoreControl); }
public static void PlayOnTarget(GameObject targetGo, AudioClip clip, bool loop = false) { if (Instance.Manager.IsLayerMuted(SoundLayer.Main)) { return; } if (targetGo == null || clip == null) { return; } AudioSource audio = CocoLoad.GetOrAddComponent <AudioSource> (targetGo); audio.playOnAwake = false; AudioClip oldClip = audio.clip; if (oldClip != clip) { if (oldClip != null) { audio.clip = null; Resources.UnloadAsset(oldClip); } audio.clip = clip; } audio.loop = loop; audio.Play(); if (!Instance.m_TargetSet.Contains(targetGo)) { Instance.m_TargetSet.Add(targetGo); } }
/// <summary> /// Init this instance. /// </summary> private void init() { InitGlobalModules(); if (CocoDebugSettingsData.Instance.IsFPSHudEnabled) { CocoHudFPS hudFPS = CocoLoad.GetOrAddComponent <CocoHudFPS> (gameObject); hudFPS.startPos = CocoDebugSettingsData.Instance.FPSHudStartPos; } }
/// <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); }
public bool AddDressObject(string id, GameObject go) { if (m_DressObjectDic.ContainsKey(id)) { return(false); } CocoLoad.SetParent(go, transform); RebindModelBone(go); m_DressObjectDic.Add(id, go); return(true); }
public bool AddDressObject(string id, string assetPath) { if (m_DressObjectDic.ContainsKey(id)) { return(false); } GameObject go = CocoLoad.Instantiate(assetPath, transform); RebindModelBone(go); m_DressObjectDic.Add(id, go); return(true); }
public T AddUnit <T> () where T : CocoRoleUnitBase { string unitId = typeof(T).Name; if (m_UnitDic.ContainsKey(unitId)) { return(m_UnitDic [unitId] as T); } T unit = CocoLoad.GetOrAddComponent <T> (gameObject); unit.Init(this); m_UnitDic.Add(unitId, unit); return(unit); }
public override void Init(CocoRoleEntity owner) { base.Init(owner); DressHolder = Owner.RoleHolder.DressHolder; if (DressHolder == null) { Debug.LogErrorFormat("[{0}<{1}>]->Init: dress holder NOT exists!", name, GetType().Name); } m_DressData = new CocoRoleDressData(((CocoAssetConfigHolder)DressHolder.ParentHolder).ItemHolderDic); m_DressData.InitBasicCoverItemDic(Owner.RoleHolder.boneItemId, Owner.RoleHolder.basicItemIds); m_ItemLoader = CocoLoad.GetOrAddComponent <CocoDressItemLoader> (gameObject); LoadBone(); }
/// <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> (CocoModuleBase module, object moduleId = null) where TModule : CocoModuleBase { Dictionary <object, CocoModuleBase> moduleDic = GetModuleDic <TModule> (); string moduleKey = GetModuleKeyById(ref moduleId); if (moduleDic.ContainsKey(moduleKey)) { Debug.LogErrorFormat("{0}->AddModule: can NOT add module [{1}<{2}>], because the one with same id already exists!", GetType(), moduleId, module.GetType().Name); return(null); } if (module.transform.parent != transform) { CocoLoad.SetParent(module, transform); } // init module CocoRoot.BindValue <TModule> ((TModule)module, moduleId); module.Init(moduleId); moduleDic.Add(moduleKey, module); return((TModule)module); }
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); }