94 lines
2.3 KiB
C#
94 lines
2.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DefaultNamespace;
|
|
using DefaultNamespace.ProcessMode;
|
|
using Framework.Scripts.Runtime.Engine.Engine.Camera;
|
|
using UnityEngine;
|
|
|
|
// 添加游戏开发中常用的游戏模块的命名空间
|
|
using MotionFramework;
|
|
using MotionFramework.Console;
|
|
using MotionFramework.Event;
|
|
using MotionFramework.Scripts.Runtime.Engine.Engine.Network.WebRequest;
|
|
using MotionFramework.Utility;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class GameLauncher : MonoBehaviour
|
|
{
|
|
[Tooltip("在编辑器下模拟运行")]
|
|
public bool SimulationOnEditor = true;
|
|
|
|
void Awake()
|
|
{
|
|
#if !UNITY_EDITOR
|
|
SimulationOnEditor = false;
|
|
#endif
|
|
// 初始化控制台
|
|
if (Application.isEditor || Debug.isDebugBuild)
|
|
DeveloperConsole.Initialize();
|
|
|
|
// 初始化框架
|
|
MotionEngine.Initialize(this, HandleMotionFrameworkLog);
|
|
}
|
|
void Start()
|
|
{
|
|
// 创建游戏模块
|
|
CreateGameModules();
|
|
|
|
//SceneManager.LoadScene("工具间");
|
|
}
|
|
void Update()
|
|
{
|
|
// 更新框架
|
|
MotionEngine.Update();
|
|
}
|
|
void OnGUI()
|
|
{
|
|
// 绘制控制台
|
|
if (Application.isEditor || Debug.isDebugBuild)
|
|
DeveloperConsole.Draw();
|
|
}
|
|
|
|
private void CreateGameModules()
|
|
{
|
|
// 创建事件管理器
|
|
MotionEngine.CreateModule<EventManager>();
|
|
|
|
//webrequest管理器
|
|
MotionEngine.CreateModule<WebRequestManager>();
|
|
|
|
//工具包
|
|
MotionEngine.CreateModule<ToolsPackManager>();
|
|
//数据配置文件
|
|
MotionEngine.CreateModule<DataConfigManager>();
|
|
|
|
//流程管理器
|
|
MotionEngine.CreateModule<AnimationProcessManager>();
|
|
|
|
}
|
|
|
|
private void HandleMotionFrameworkLog(ELogLevel logLevel, string log)
|
|
{
|
|
if (logLevel == ELogLevel.Log)
|
|
{
|
|
UnityEngine.Debug.Log(log);
|
|
}
|
|
else if (logLevel == ELogLevel.Error)
|
|
{
|
|
UnityEngine.Debug.LogError(log);
|
|
}
|
|
else if (logLevel == ELogLevel.Warning)
|
|
{
|
|
UnityEngine.Debug.LogWarning(log);
|
|
}
|
|
else if (logLevel == ELogLevel.Exception)
|
|
{
|
|
UnityEngine.Debug.LogError(log);
|
|
}
|
|
else
|
|
{
|
|
throw new NotImplementedException($"{logLevel}");
|
|
}
|
|
}
|
|
} |