mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交帧同步案例
This commit is contained in:
7
JNFrame/Assets/Script/battle/GBaseMode.cs
Normal file
7
JNFrame/Assets/Script/battle/GBaseMode.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Script.battle
|
||||
{
|
||||
public class GBaseMode
|
||||
{
|
||||
|
||||
}
|
||||
}
|
3
JNFrame/Assets/Script/battle/GBaseMode.cs.meta
Normal file
3
JNFrame/Assets/Script/battle/GBaseMode.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66eaac44e0ad4bf3b54c2806f86280c7
|
||||
timeCreated: 1706252585
|
83
JNFrame/Assets/Script/battle/GBattleModeManager.cs
Normal file
83
JNFrame/Assets/Script/battle/GBattleModeManager.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Script.battle
|
||||
{
|
||||
//各种模式场景
|
||||
public enum GBattleMode
|
||||
{
|
||||
Not = -1,
|
||||
Default = 0
|
||||
}
|
||||
|
||||
//初始化参数类
|
||||
public class GBattleModeInfo
|
||||
{
|
||||
public List<GameObject> modes;
|
||||
public GameObject root;
|
||||
}
|
||||
|
||||
//全局战斗模式管理器
|
||||
public class GBattleModeManager : SingletonScene<GBattleModeManager>
|
||||
{
|
||||
|
||||
public static string[] Worlds = { "WorldScene" };
|
||||
|
||||
//当前模式
|
||||
private GBattleMode _current = GBattleMode.Not;
|
||||
|
||||
//初始化管理器
|
||||
public void Init(GBattleModeInfo info)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//打开指定模式
|
||||
public async UniTask Open(GBattleMode mode)
|
||||
{
|
||||
|
||||
//销毁之前模式
|
||||
await Close();
|
||||
_current = mode;
|
||||
await LoadScene(mode);
|
||||
|
||||
}
|
||||
|
||||
//关闭当前模式
|
||||
public async UniTask Close()
|
||||
{
|
||||
|
||||
await UnloadScene(_current);
|
||||
_current = GBattleMode.Not;
|
||||
|
||||
}
|
||||
|
||||
//获取场景名称
|
||||
public string GetWorldName(GBattleMode mode)
|
||||
{
|
||||
return Worlds[(int)mode];
|
||||
}
|
||||
|
||||
//加载场景
|
||||
private async UniTask LoadScene(GBattleMode mode)
|
||||
{
|
||||
if (mode == GBattleMode.Not) return;
|
||||
Debug.Log($"[GBattleModeManager] 打开场景{GetWorldName(mode)}");
|
||||
await SceneManager.LoadSceneAsync(GetWorldName(mode), LoadSceneMode.Additive);
|
||||
}
|
||||
|
||||
//销毁场景
|
||||
private async UniTask UnloadScene(GBattleMode mode)
|
||||
{
|
||||
|
||||
if (mode == GBattleMode.Not) return;
|
||||
Debug.Log($"[GBattleModeManager] 关闭场景{GetWorldName(mode)}");
|
||||
await SceneManager.UnloadSceneAsync(GetWorldName(mode));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
3
JNFrame/Assets/Script/battle/GBattleModeManager.cs.meta
Normal file
3
JNFrame/Assets/Script/battle/GBattleModeManager.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36bc28f3467d4641abb08e83398a8a30
|
||||
timeCreated: 1706167381
|
Reference in New Issue
Block a user