//是否存在界面 public static bool HasUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null) { //获取界面配置表数据 IDataTable <DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable <DRUIForm>(); DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId); if (drUIForm == null) { return(false); } //获取界面资源路径 string assetName = RuntimeAssetUtility.GetUIFormAsset(drUIForm.AssetName); //界面组名为空则直接检查当前是否存在界面 if (string.IsNullOrEmpty(uiGroupName)) { return(uiComponent.HasUIForm(assetName)); } //获取界面组 IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName); if (uiGroup == null) { return(false); } //界面组中检查 return(uiGroup.HasUIForm(assetName)); }
//获取界面 public static UGUIForm GetUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null) { //获取界面配置表数据 IDataTable <DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable <DRUIForm>(); DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId); if (drUIForm == null) { return(null); } //获取界面资源路径 string assetName = RuntimeAssetUtility.GetUIFormAsset(drUIForm.AssetName); UIForm uiform = null; //界面组名为空则直接获取界面 if (string.IsNullOrEmpty(uiGroupName)) { uiform = uiComponent.GetUIForm(assetName); if (uiform == null) { return(null); } } else { IUIGroup group = uiComponent.GetUIGroup(uiGroupName); if (group == null) { return(null); } uiform = group.GetUIForm(assetName) as UIForm; } if (uiform == null) { return(null); } return(uiform.Logic as UGUIForm); }
private int m_BackgroundMusicId = 0; //切换场景时的背景音乐 //流程进入回调 public override void OnEnter(IFsm <IProcedureManager> procedureOwner) { m_IsChangeSceneComplete = false; //订阅事件 GameEntry.Event.Subscribe(LoadSceneSuccessEventArgs.EventId, OnLoadSceneSuccess); GameEntry.Event.Subscribe(LoadSceneFailureEventArgs.EventId, OnLoadSceneFailure); GameEntry.Event.Subscribe(LoadSceneUpdateEventArgs.EventId, OnLoadSceneUpdate); GameEntry.Event.Subscribe(LoadSceneDependencyAssetEventArgs.EventId, OnLoadSceneDependencyAsset); //停止所有声音 GameEntry.Sound.StopAllLoadingSounds(); //停止正在加载所有声音 GameEntry.Sound.StopAllLoadedSounds(); //停止加载完成的声音 //隐藏所有实体 GameEntry.Entity.HideAllLoadingEntities(); //加载中的实体 GameEntry.Entity.HideAllLoadedEntities(); //加载完成的实体 //卸载所有场景 string[] loadedSceneAssetNames = GameEntry.Scene.GetLoadedSceneAssetNames(); for (int i = 0; i < loadedSceneAssetNames.Length; i++) { GameEntry.Scene.UnloadScene(loadedSceneAssetNames[i]); } //还原游戏进度 GameEntry.Base.ResetNormalGameSpeed(); //获取场景数据 int sceneId = procedureOwner.GetData <VarInt>(Constant.ProcedureData.NextSceneId).Value; m_ChangeToMenu = sceneId == MenuSceneId; //是否切换到菜单场景 IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>(); DRScene drScene = dtScene.GetDataRow(sceneId); if (drScene == null) { HotLog.Warning("Can not load scene '{0}' from data table.", sceneId.ToString()); return; } //加载场景 GameEntry.Scene.LoadScene(RuntimeAssetUtility.GetSceneAsset(drScene.AssetName), RuntimeConstant.AssetPriority.SceneAsset, this); m_BackgroundMusicId = drScene.BackgroundMusicId; }