67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
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
|
|
{
|
|
public string sceneName;
|
|
void Awake()
|
|
{
|
|
// 初始化框架
|
|
MotionEngine.Initialize(this, HandleMotionFrameworkLog);
|
|
}
|
|
void Start()
|
|
{
|
|
// 创建游戏模块
|
|
CreateGameModules();
|
|
|
|
SceneManager.LoadScene(sceneName);
|
|
}
|
|
void Update()
|
|
{
|
|
// 更新框架
|
|
MotionEngine.Update();
|
|
}
|
|
|
|
private async void CreateGameModules()
|
|
{
|
|
//webrequest管理器
|
|
MotionEngine.CreateModule<WebRequestManager>();
|
|
|
|
|
|
}
|
|
|
|
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}");
|
|
}
|
|
}
|
|
} |