/// <summary> /// 运行lua的脚本 /// </summary> public void Run() { _hotfix = GameFrameworkMode.GetModule <HotFixLuaManager>(); #if HOTFIX_XLUA if (string.IsNullOrEmpty(_luaScript)) { scriptEnv = luaEnv.NewTable(); // 为每个脚本设置一个独立的环境,可一定程度上防止脚本间全局变量、函数冲突 LuaTable meta = luaEnv.NewTable(); meta.Set("__index", luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); scriptEnv.Set("self", this); foreach (var injection in injections) { scriptEnv.Set(injection.name, injection.value); } string luaScript = _hotfix.LuaScriptLoader(luaScriptName); luaEnv.DoString(luaScript, luaScriptName, scriptEnv); Action luaAwake = scriptEnv.Get <Action>("Awake"); scriptEnv.Get("Start", out _luaStart); scriptEnv.Get("Update", out _luaUpdate); scriptEnv.Get("Close", out _luaClose); scriptEnv.Get("Enable", out _luaEnable); scriptEnv.Get("Disable", out _luaDisable); _luaScript = luaScriptName; luaAwake?.Invoke(); } #endif }
public async void AddPrefab(string assetBundleName, string assetName, PoolPrefabInfo prefabInfo) { if (_prefabs.ContainsKey(assetName)) { Debug.Log("已经存在资源:" + assetName); return; } if (prefabInfo.Prefab == null) { //根据assetName,直接从ResourceManager里面加载 prefabInfo.Prefab = await GameFrameworkMode.GetModule <ResourceManager>().LoadAsset <GameObject>(assetBundleName, assetName); if (prefabInfo.Prefab == null) { Debug.Log("预设资源为null:" + assetName); return; } } _prefabs[assetName] = prefabInfo; _spawneds[assetName] = new List <GameObject>(); Initialization(assetName, prefabInfo); }
public DataTableManager() { _allDataTables = new Dictionary <int, DataTableBase>(); _resource = GameFrameworkMode.GetModule <ResourceManager>(); }
public LocalizationManager() { _resource = GameFrameworkMode.GetModule <ResourceManager>(); stringsDict = new Dictionary <string, string>(); isInit = false; }
public HotFixLuaManager() { _resource = GameFrameworkMode.GetModule <ResourceManager>(); }
private void OnDestroy() { GameFrameworkMode.ShutDown(); }
private void FixedUpdate() { GameFrameworkMode.FixedUpdate(); }
private void Update() { GameFrameworkMode.Update(); }
IEnumerator Start() { //默认不销毁 DontDestroyOnLoad(gameObject); #region Module Event = GameFrameworkMode.GetModule <EventManager>(); State = GameFrameworkMode.GetModule <GameStateManager>(); Node = GameFrameworkMode.GetModule <NodeManager>(); DataTable = GameFrameworkMode.GetModule <DataTableManager>(); Resource = GameFrameworkMode.GetModule <ResourceManager>(); Scene = GameFrameworkMode.GetModule <ScenarioManager>(); UI = GameFrameworkMode.GetModule <UIManager>(); WebRequest = GameFrameworkMode.GetModule <WebRequestManager>(); Audio = GameFrameworkMode.GetModule <AudioManager>(); Localization = GameFrameworkMode.GetModule <LocalizationManager>(); Setting = GameFrameworkMode.GetModule <SettingManager>(); System = GameFrameworkMode.GetModule <SystemManager>(); Network = GameFrameworkMode.GetModule <NetworkManager>(); Pool = GameFrameworkMode.GetModule <PoolManager>(); Coroutines = GameFrameworkMode.GetModule <CoroutineManager>(); HotFixLua = GameFrameworkMode.GetModule <HotFixLuaManager>(); HotFixILRuntime = GameFrameworkMode.GetModule <HotFixILRuntimeManager>(); #endregion #region Resource Resource.ResUpdateType = ResUpdateType; Resource.ResUpdatePath = ResUpdatePath; Resource.LocalPathType = LocalPathType; //添加对象池管理器 GameObject gameObjectPoolHelper = new GameObject("IGameObjectPoolHelper"); gameObjectPoolHelper.transform.SetParent(transform); Resource.SetGameObjectPoolHelper(gameObjectPoolHelper.AddComponent <GameObjectPoolHelper>()); #endregion #region UI // 如果没有主动绑定UI节点,那么就自动寻找当前场景Canvas组件 if (UIRoot == null) { UIRoot = FindObjectOfType <Canvas>().gameObject; } if (UIRoot != null) { UI.InitUIRoot(UIRoot); } #endregion #region Auido //设置音频播放 GameObject audioPlayer = new GameObject("AudioSourcePlayer"); audioPlayer.transform.SetParent(transform); //添加AduioSource Audio.SetDefaultAudioSource(audioPlayer.AddComponent <AudioSource>(), audioPlayer.AddComponent <AudioSource>(), audioPlayer.AddComponent <AudioSource>()); #endregion #region WebRequest //设置帮助类 GameObject webRequestHelper = new GameObject("IWebRequestHelper"); webRequestHelper.transform.SetParent(transform); GameObject webDownloadHelper = new GameObject("IWebDownloadMonoHelper"); webDownloadHelper.transform.SetParent(transform); WebRequest.SetWebRequestHelper(webRequestHelper.AddComponent <WebRquestMonoHelper>()); WebRequest.SetWebDownloadHelper(webDownloadHelper.AddComponent <WebDownloadMonoHelper>()); #endregion #region Coroutine GameObject coroutineRoot = new GameObject("CoroutineRoot"); coroutineRoot.transform.SetParent(transform); Coroutines.Initialize(coroutineRoot); #endregion #region Setting /*Transform debugT = transform.Find("[Graphy]"); * if (debugT != null) * { * GameObject debugHelper = debugT.gameObject; * Setting.SetDebuger(debugHelper); * Setting.DebugEnable = DebugEnable; * }*/ GameObject debugHelper = new GameObject("DebugHelper"); debugHelper.transform.SetParent(transform); Setting.SetDebuger(debugHelper.AddComponent <DebugHelper>().gameObject); Setting.DebugEnable = DebugEnable; // 帧率 FrameRate = m_FrameRate; #endregion #region State //开启整个项目的流程 Assembly = typeof(GameMode).Assembly; State.CreateContext(Assembly); yield return(new WaitForEndOfFrame()); State.SetStateStart(); #endregion }
public AudioManager() { _resourceManager = GameFrameworkMode.GetModule <ResourceManager>(); }