public void Start() { UnityUtility.setMainThreadID(Thread.CurrentThread.ManagedThreadId); Application.targetFrameRate = 60; AppDomain app = AppDomain.CurrentDomain; app.UnhandledException += UnhandledException; mFrameComponentMap = new Dictionary<string, FrameSystem>(); mFrameComponentInit = new List<FrameSystem>(); mFrameComponentUpdate = new List<FrameSystem>(); mFrameComponentDestroy = new List<FrameSystem>(); mTimeLock = new ThreadTimeLock(15); // 本地日志的初始化在移动平台上依赖于插件,所以在本地日志系统之前注册插件 registeFrameSystem(UnityUtility.Typeof<AndroidPluginManager>()); registeFrameSystem(UnityUtility.Typeof<AndroidAssetLoader>()); #if !UNITY_EDITOR // 由于本地日志系统的特殊性,必须在最开始就初始化 FrameBase.mLocalLog = new LocalLog(); FrameBase.mLocalLog.init(); #endif UnityUtility.setLogCallback(getLogCallback()); UnityUtility.log("start game!", LOG_LEVEL.FORCE); UnityUtility.log("QualitySettings.currentLevel:" + QualitySettings.GetQualityLevel(), LOG_LEVEL.FORCE); UnityUtility.log("QualitySettings.activeColorSpace:" + QualitySettings.activeColorSpace, LOG_LEVEL.FORCE); UnityUtility.log("Graphics.activeTier:" + Graphics.activeTier, LOG_LEVEL.FORCE); UnityUtility.log("SystemInfo.graphicsDeviceType:" + SystemInfo.graphicsDeviceType, LOG_LEVEL.FORCE); UnityUtility.log("SystemInfo.maxTextureSize:" + SystemInfo.maxTextureSize, LOG_LEVEL.FORCE); UnityUtility.log("SystemInfo.supportsInstancing:" + SystemInfo.supportsInstancing, LOG_LEVEL.FORCE); UnityUtility.log("SystemInfo.graphicsShaderLevel:" + SystemInfo.graphicsShaderLevel, LOG_LEVEL.FORCE); try { DateTime startTime = DateTime.Now; start(); UnityUtility.log("start消耗时间:" + (DateTime.Now - startTime).TotalMilliseconds); // 根据设置的顺序对列表进行排序 mFrameComponentInit.Sort(FrameSystem.compareInit); mFrameComponentUpdate.Sort(FrameSystem.compareUpdate); mFrameComponentDestroy.Sort(FrameSystem.compareDestroy); notifyBase(); registe(); init(); } catch (Exception e) { string innerMessage = e.InnerException != null ? e.InnerException.Message : "empty"; UnityUtility.logError("init failed! " + e.Message + ", inner exception:" + innerMessage + "\nstack:" + e.StackTrace); } // 初始化完毕后启动游戏 launch(); mCurTime = DateTime.Now; }
protected virtual void initFrameSystem() { registeFrameSystem(UnityUtility.Typeof<TimeManager>()); registeFrameSystem(UnityUtility.Typeof<ApplicationConfig>()); registeFrameSystem(UnityUtility.Typeof<FrameConfig>()); registeFrameSystem(UnityUtility.Typeof<HttpUtility>()); #if !UNITY_IOS && !NO_SQLITE registeFrameSystem(UnityUtility.Typeof<SQLite>()); #endif registeFrameSystem(UnityUtility.Typeof<DataBase>()); registeFrameSystem(UnityUtility.Typeof<CommandSystem>(), -1, -1, 2001); // 命令系统在大部分管理器都销毁完毕后再销毁 registeFrameSystem(UnityUtility.Typeof<GlobalTouchSystem>()); registeFrameSystem(UnityUtility.Typeof<CharacterManager>()); registeFrameSystem(UnityUtility.Typeof<AudioManager>()); registeFrameSystem(UnityUtility.Typeof<GameSceneManager>()); registeFrameSystem(UnityUtility.Typeof<KeyFrameManager>()); registeFrameSystem(UnityUtility.Typeof<DllImportExtern>()); registeFrameSystem(UnityUtility.Typeof<ShaderManager>()); registeFrameSystem(UnityUtility.Typeof<CameraManager>()); registeFrameSystem(UnityUtility.Typeof<InputManager>()); registeFrameSystem(UnityUtility.Typeof<SceneSystem>()); registeFrameSystem(UnityUtility.Typeof<GamePluginManager>()); registeFrameSystem(UnityUtility.Typeof<ClassPool>(), -1, -1, 3101); registeFrameSystem(UnityUtility.Typeof<ClassPoolThread>(), -1, -1, 3102); registeFrameSystem(UnityUtility.Typeof<ListPool>(), -1, -1, 3103); registeFrameSystem(UnityUtility.Typeof<ListPoolThread>(), -1, -1, 3104); registeFrameSystem(UnityUtility.Typeof<DictionaryPool>(), -1, -1, 3105); registeFrameSystem(UnityUtility.Typeof<DictionaryPoolThread>(), -1, -1, 3106); registeFrameSystem(UnityUtility.Typeof<BytesPool>(), -1, -1, 3107); registeFrameSystem(UnityUtility.Typeof<BytesPoolThread>(), -1, -1, 3108); registeFrameSystem(UnityUtility.Typeof<HeadTextureManager>()); registeFrameSystem(UnityUtility.Typeof<MovableObjectManager>()); registeFrameSystem(UnityUtility.Typeof<EffectManager>()); registeFrameSystem(UnityUtility.Typeof<TPSpriteManager>()); registeFrameSystem(UnityUtility.Typeof<SocketFactory>()); registeFrameSystem(UnityUtility.Typeof<SocketFactoryThread>()); registeFrameSystem(UnityUtility.Typeof<PathKeyframeManager>()); registeFrameSystem(UnityUtility.Typeof<EventSystem>()); registeFrameSystem(UnityUtility.Typeof<StringBuilderPool>()); registeFrameSystem(UnityUtility.Typeof<StringBuilderPoolThread>()); #if USE_ILRUNTIME registeFrameSystem(UnityUtility.Typeof<ILRSystem>()); #endif // 布局管理器也需要在最后更新,确保所有游戏逻辑都更新完毕后,再更新界面 registeFrameSystem(UnityUtility.Typeof<LayoutManager>(), 1000, 1000, 1000); // 物体管理器和资源管理器必须最后注册,以便最后销毁,作为最后的资源清理 registeFrameSystem(UnityUtility.Typeof<ObjectPool>(), 2000, 2000, 2000); registeFrameSystem(UnityUtility.Typeof<ResourceManager>(), 3000, 3000, 3000); }
public void Update() { if (!FrameBase.mGameFramework.isEnableScriptDebug()) { return; } if (mGameCamera == null) { return; } CameraLinker linker = mGameCamera.getCurLinker(); if (linker != null) { CurLinkerName = UnityUtility.Typeof(linker).ToString(); LinkedObject = linker.getLinkObject().getObject(); LinkedObjectName = linker.getLinkObject().getName(); Relative = linker.getRelativePosition(); if (LinkedObject != null) { CurRelative = mGameCamera.getWorldPosition() - LinkedObject.transform.position; } else { CurRelative = Vector3.zero; } } else { CurLinkerName = StringUtility.EMPTY; LinkedObjectName = StringUtility.EMPTY; LinkedObject = null; Relative = Vector3.zero; CurRelative = Vector3.zero; } ActiveComponent.Clear(); var allComponents = mGameCamera.getAllComponent().getUpdateList(); foreach (var item in allComponents) { if (item.Value.isActive()) { ActiveComponent.Add(item.Key.ToString()); } } }
//------------------------------------------------------------------------------------------------------------- protected override void initFrameSystem() { base.initFrameSystem(); registeFrameSystem(UnityUtility.Typeof <GameConfig>()); }