This commit is contained in:
MuHua-123
2025-08-27 17:14:02 +08:00
parent 38f522bb92
commit 47c27ec82f
79 changed files with 2080 additions and 4808 deletions
@@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using MuHua;
/// <summary>
/// 场景 - 管理器
/// </summary>
public class ManagerScene : ModuleSingle<ManagerScene> {
/// <summary> 场景加载完成 </summary>
public static event Action OnCompleteLoad;
/// <summary> 平滑进度 </summary>
public float smoothedProgress;
protected override void Awake() => NoReplace(false);
#region
/// <summary> 协程加载内置场景 </summary>
public void Load(string sceneName, Action complete = null, LoadSceneMode mode = LoadSceneMode.Single) {
StartCoroutine(ILoad(sceneName, complete, mode));
}
/// <summary> 协程加载内置场景 </summary>
public IEnumerator ILoad(string sceneName, Action complete, LoadSceneMode mode) {
smoothedProgress = 0f;
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName, mode);
operation.allowSceneActivation = false;
while (!operation.isDone) { yield return ILoad(operation); }
SettingsProgress(false, smoothedProgress);
complete?.Invoke();
OnCompleteLoad?.Invoke();
}
/// <summary> 协程处理进度 </summary>
public IEnumerator ILoad(AsyncOperation operation) {
// 输出加载进度
float progress = Mathf.Clamp01(operation.progress / 0.9f);
smoothedProgress = Mathf.MoveTowards(smoothedProgress, progress, Time.deltaTime);
SettingsProgress(true, smoothedProgress);
// 当加载进度达到90%且平滑变量和实际进度一致时,激活场景
if (operation.progress < 0.9f || smoothedProgress < 1f) { yield break; }
operation.allowSceneActivation = true;
}
#endregion
/// <summary> 设置进度 </summary>
private void SettingsProgress(bool active, float progress) {
// ModuleUI.LoadingSettings(active, progress);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dc0f04b4d1e94e3469c593bff5d56655
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -4,46 +4,10 @@ using UnityEngine;
using MuHua;
/// <summary>
/// 游戏管理
/// 全局管理
/// </summary>
public class SingleManager : ModuleSingle<SingleManager> {
/// <summary> 运行模式 </summary>
public static EnumRunningMode runningMode;
protected override void Awake() => NoReplace();
/// <summary> 设置运行模式 </summary>
public static void SetRunningMode(EnumRunningMode runningMode) {
SingleManager.runningMode = runningMode;
}
protected override void Awake() {
NoReplace();
// ManagerScene.OnComplete += ManagerScene_OnComplete;
}
private void Start() {
// ModuleUI.Jump(EnumPage.Menu);
// ModuleInput.Mode(EnumInputMode.None);
// ModuleCamera.Mode(EnumCameraMode.None);
// SceneManager.LoadScene("MenuScene");
}
private void ManagerScene_OnComplete() {
// if (runningMode == EnumRunningMode.None) {
// ModuleUI.Jump(EnumPage.Menu);
// ModuleInput.Mode(EnumInputMode.None);
// ModuleCamera.Mode(EnumCameraMode.None);
// }
// if (runningMode == EnumRunningMode.Standard) {
// ModuleUI.Jump(EnumPage.Battle);
// // ModuleInput.Mode(EnumInputMode.ThirdPerson);
// // ModuleCamera.Mode(EnumCameraMode.ThirdPerson);
// }
}
public void StartGame() {
// ManagerScene.LoadScene(null);
// ModuleUI.Jump(EnumPage.Battle);
// ModuleInput.Mode(EnumInputMode.Standard);
// ModuleCamera.Mode(EnumCameraMode.MoveAxis);
}
}