This commit is contained in:
2026-09-29 18:09:08 +08:00
parent c91eaef60b
commit f4b5347fde
14 changed files with 866 additions and 762 deletions
@@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: a263e71fce79f2f4cb5b5f1fa6b7291a
m_currentHash:
serializedVersion: 2
Hash: e88239bd385df7eeb8432db63ac72d7d
Hash: 00000000000000000000000000000000
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0
m_BundleLocalCatalog: 0
@@ -48,8 +48,10 @@ MonoBehaviour:
- {fileID: 11400000, guid: c0b3b611be2f4f24f9d72d2676e58d51, type: 2}
- {fileID: 11400000, guid: b4f01f1670cc33f4587db7361d183233, type: 2}
- {fileID: 11400000, guid: 427f94f67624e374895487c87f881a7f, type: 2}
- {fileID: 11400000, guid: 67fa7860cdcff1c4a9f5c95454c4aacb, type: 2}
- {fileID: 11400000, guid: ca4eb1ed7a9a8bc4bbcc5d865fd723a4, type: 2}
- {fileID: 11400000, guid: 59a1dc2550990aa4091c8db201571a43, type: 2}
- {fileID: 11400000, guid: 423112d828faf6d4db0c2f290f5ec330, type: 2}
- {fileID: 11400000, guid: 9971f2f92adebd44faa29cc332720d65, type: 2}
- {fileID: 11400000, guid: ec57fb26f5bb61544b2831e9485b32fe, type: 2}
- {fileID: 11400000, guid: 39ca999e15083df459f52c7743a44f50, type: 2}
@@ -169,7 +171,7 @@ MonoBehaviour:
m_Key: HostingServiceUploadSpeed
- m_AssemblyName: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
m_ClassName: System.String
m_Data: Library/com.unity.addressables/aa/Android/Android
m_Data: Library/com.unity.addressables/aa/Windows/StandaloneWindows64
m_Key: ContentRoot
- m_AssemblyName: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
m_ClassName: System.Boolean
@@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: b4f01f1670cc33f4587db7361d183233, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_Compression: 2
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
@@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: 39ca999e15083df459f52c7743a44f50, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_Compression: 2
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
@@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: 427f94f67624e374895487c87f881a7f, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_Compression: 2
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
@@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: ca4eb1ed7a9a8bc4bbcc5d865fd723a4, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_Compression: 2
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
@@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: fcc697a6587205543acfb2a32347c100, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_Compression: 2
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
@@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: c0b3b611be2f4f24f9d72d2676e58d51, type: 2}
m_InternalBundleIdMode: 1
m_Compression: 1
m_Compression: 2
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
@@ -82,6 +82,31 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-4809546455936809197
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: swim2
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1853114097551451906}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-2643829409718807925
AnimatorState:
serializedVersion: 6
@@ -253,7 +278,7 @@ AnimatorStateMachine:
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: 1771328740008945305}
- {fileID: 3899798646363139309}
- {fileID: -4809546455936809197}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
@@ -327,31 +352,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6badf29928730704f891ff4e7b659d0b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1101 &3899798646363139309
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: swim2
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102526986454134208}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.9979864
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &7229380922095566941
AnimatorState:
serializedVersion: 6
+2 -2
View File
@@ -234792,7 +234792,7 @@ AnimationClip:
m_Curve:
- serializedVersion: 3
time: 0
value: {x: -1.6, y: -1.6, z: -1.6}
value: {x: 1.6, y: -1.6, z: -1.6}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
@@ -1174524,7 +1174524,7 @@ AnimationClip:
m_Curve:
- serializedVersion: 3
time: 0
value: -1.6
value: 1.6
inSlope: 0
outSlope: 0
tangentMode: 136
@@ -179,9 +179,57 @@ public class MonsterMoveLine
return;
}
foreach (var text in handles.Result)
// ⭐ 主线程只做 Unity API 访问:把每个 TextAsset 的 name/text 读成纯托管字符串后立即释放句柄。
// .text 返回托管 string 拷贝,释放句柄后仍可安全在后台线程使用。
int fileCount = handles.Result.Count;
string[] fileNames = new string[fileCount];
string[] fileTexts = new string[fileCount];
for (int i = 0; i < fileCount; i++)
{
var lines = text.text.Split('\n');
fileNames[i] = handles.Result[i].name;
fileTexts[i] = handles.Result[i].text;
}
Addressables.Release(handles);
// ⭐ 座位镜像状态主线程读一次传入后台(后台线程不访问任何 Unity/游戏静态状态)
bool mirrored = SeatMirror.IsMirrored;
var warnings = new List<string>();
// ⭐ 重活挪到后台线程:全部路线文件的 Split + 逐坐标点 float 解析是纯托管计算,
// 文件大时主线程同步解析会卡死数秒(进度条停在20%冻结的根源)。
// await 完成后自动切回 Unity 主线程再写共享缓存。
var parsedCurves = await Task.Run(() => ParseBezierFiles(fileNames, fileTexts, mirrored, warnings));
// 后台收集的告警回主线程输出(Debug API 只能在主线程调用),只打前 20 条防刷屏
for (int i = 0; i < warnings.Count && i < 20; i++)
Debug.LogWarning(warnings[i]);
// ⭐ 回到主线程写共享缓存 + 构建点数组/节点向量缓存
// (同名直接覆盖,清场后理论上无重复,防御性覆盖确保永远用当前玩法数据)
foreach (var curve in parsedCurves)
{
curves.Add(curve);
dic_BezierCurveDatas[curve.name] = curve;
BuildCurvePointsArray(curve);
}
// ⭐ 座位镜像状态提示:镜像未初始化(-1)时按不镜像处理,排查进房时序问题用
if (SeatMirror.LocalServerPos < 0)
Debug.LogWarning("[MonsterMoveLine] 加载路线时 SeatMirror 未初始化(未收到 RoomJoinNotice),本次按不镜像处理");
Debug.Log($"曲线读取完成共{dic_BezierCurveDatas.Count}条 镜像={SeatMirror.IsMirrored}(本地服务端座位={SeatMirror.LocalServerPos})");
}
/// <summary>
/// ⭐ 后台线程解析全部路线文本(纯托管计算,禁止访问任何 Unity API):
/// 逐行 Split + InvariantCulture float 解析 + 曲线组装 + 镜像翻转(镜像标志由主线程传入)。
/// 解析告警收集到 warnings 列表,由调用方回主线程统一输出。
/// </summary>
private static List<BezierCurveData> ParseBezierFiles(string[] fileNames, string[] fileTexts, bool mirrored, List<string> warnings)
{
var result = new List<BezierCurveData>();
for (int f = 0; f < fileTexts.Length; f++)
{
var lines = fileTexts[f].Split('\n');
foreach (var line in lines)
{
if (string.IsNullOrWhiteSpace(line))
@@ -206,7 +254,7 @@ public class MonsterMoveLine
}
else
{
Debug.LogWarning($"[MonsterMoveLine] 坐标格式非法已跳过: '{parts[i]}'({text.name} 曲线 {curve.name})");
warnings.Add($"[MonsterMoveLine] 坐标格式非法已跳过: '{parts[i]}'({fileNames[f]} 曲线 {curve.name})");
}
}
}
@@ -221,23 +269,25 @@ public class MonsterMoveLine
for (int i = 1; i < points.Count - 1; i++)
curve.controlPoints.Add(points[i]);
// ⭐ 座位镜像:本端在上方座位时路线整条上下翻转(写入字典/建缓存前,只翻一次)
FlipCurveYForMirror(curve);
curves.Add(curve);
// ⭐ 同名直接覆盖(清场后理论上无重复,防御性覆盖确保永远用当前玩法数据)
dic_BezierCurveDatas[curve.name] = curve;
// ⭐ 同步构建点数组缓存(批量加载路径)
BuildCurvePointsArray(curve);
// ⭐ 座位镜像:本端在上方座位时路线整条上下翻转(与 FlipCurveYForMirror 同逻辑)。
// B样条求值(de Boor)是逐点线性插值,对控制点 y 取反后求样条 ≡ 原样条求值后 y 取反,
// 曲线形状严格镜像不形变。
if (mirrored)
{
curve.start.y = -curve.start.y;
curve.end.y = -curve.end.y;
for (int i = 0; i < curve.controlPoints.Count; i++)
{
Vector2 p = curve.controlPoints[i];
p.y = -p.y;
curve.controlPoints[i] = p;
}
}
Addressables.Release(handles);
// ⭐ 座位镜像状态提示:镜像未初始化(-1)时按不镜像处理,排查进房时序问题用
if (SeatMirror.LocalServerPos < 0)
Debug.LogWarning("[MonsterMoveLine] 加载路线时 SeatMirror 未初始化(未收到 RoomJoinNotice),本次按不镜像处理");
Debug.Log($"曲线读取完成共{dic_BezierCurveDatas.Count}条 镜像={SeatMirror.IsMirrored}(本地服务端座位={SeatMirror.LocalServerPos})");
result.Add(curve);
}
}
return result;
}
public static async Task UnLoadBezierTxtAsync(string path)
@@ -2,6 +2,7 @@ using Assets.MyGame.Scripts.Net.API;
using Assets.MyGame.Scripts.Net.WebResponses;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -116,12 +117,10 @@ namespace Assets.MyGame.Scripts.Net
}
if (UIManager.Instance.Get<GameMainPanel_Base>(uIPanel)==null)
{
UIManager.Instance.ShowAsync(uIPanel, UIPanel.HomeMainPanel, msg);
// 卸载所有已加载的游戏地图场景(保证场景唯一性)
// ① 先卸载其他已加载的游戏地图场景(保证场景唯一性),不卸载即将加载的目标场景
string[] gameScenes = { "FLZY", "YYSC", "XJMH", "HHWK" };
foreach (var sn in gameScenes)
{
// 不卸载即将加载的目标场景
if (sn == sceneName) continue;
var s = SceneManager.GetSceneByName(sn);
if (s.IsValid() && s.isLoaded)
@@ -130,16 +129,15 @@ namespace Assets.MyGame.Scripts.Net
_loadedGameScenes.Remove(sn);
}
}
// 目标场景仅加载一次:标记已加载后不再重复 LoadSceneAsync(防止人机通知触发重复加载)
if (!string.IsNullOrEmpty(sceneName) && !_loadedGameScenes.Contains(sceneName))
{
_loadedGameScenes.Add(sceneName);
var targetScene = SceneManager.GetSceneByName(sceneName);
if (!targetScene.IsValid() || !targetScene.isLoaded)
SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
}
UIManager.Instance.Close(UIPanel.HomeMainPanel);
// ② 先显示游戏面板(加载页面,含进度条):ShowAsync 的 onShown 回调在面板实例化并显示后触发,
// 用它保证"面板先显示 → 再加载场景 → 再加载资源"的严格先后顺序。
// 全程为协程异步,不做 WaitForCompletion 之类的同步等待,不阻塞主线程。
UIManager.Instance.ShowAsync(uIPanel, UIPanel.HomeMainPanel, msg, (panel) =>
{
UIManager.Instance.StartCoroutine(LoadSceneThenResources(panel, sceneName));
});
WebSocketManager.Instance.isGame = true;
}
else
@@ -165,6 +163,30 @@ namespace Assets.MyGame.Scripts.Net
}
/// <summary>
/// ③ 加载游戏场景(异步等待完成)→ ④ 场景就绪后再让面板加载资源(鱼/音频/路线等)。
/// 全程逐帧 yield 等待,不做同步等待,不阻塞主线程。
/// </summary>
private static IEnumerator LoadSceneThenResources(UIBase panel, string sceneName)
{
// ③ 目标场景仅加载一次:标记已加载后不再重复 LoadSceneAsync(防止人机通知触发重复加载)
if (!string.IsNullOrEmpty(sceneName) && !_loadedGameScenes.Contains(sceneName))
{
_loadedGameScenes.Add(sceneName);
var targetScene = SceneManager.GetSceneByName(sceneName);
if (!targetScene.IsValid() || !targetScene.isLoaded)
{
var op = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
while (op != null && !op.isDone) yield return null;
}
}
// ④ 场景就绪后再加载面板资源
if (panel is GameMainPanel_FishBase fishPanel)
fishPanel.BeginLoadResources();
}
/// <summary>
/// 把 RoomJoinNotice 玩家数据写入 currRoomData.players(存在则更新,不存在则添加)。
/// JoinGame 里 SetUserInfo 按 userId 从 currRoomData.players 查显示信息
@@ -49,7 +49,12 @@ public class FLZY_JL_Boss : MonsterControl_BossBase
AudioManager.Instance.PlayerFX(62006);
}
animator.SetTrigger(Random.Range(0, 2) == 0 ? "swim1" : "swim2");
// ⭐ 座位镜像:swim1=正常姿态 / swim2=镜像姿态(翻转动画)。
// 本端在上方座位(SeatMirror.IsMirrored=镜像视角)时交换选择,
// 保证金龙/雷龙在镜像世界里保持与正常视角相同的朝向观感;
// 随机性不变(仍是各50%),只是镜像时 swim1/swim2 对调
bool useSwim1 = (Random.Range(0, 2) == 0) ^ SeatMirror.IsMirrored;
animator.SetTrigger(useSwim1 ? "swim1" : "swim2");
isMove = false;
animator.speed = 1;
File diff suppressed because it is too large Load Diff
@@ -320,7 +320,11 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
// ⭐ 无操作自动退出:加载期间不计时,LoadResources 完成后重新开始计;确保倒计时面板初始隐藏
_idleExitArmed = false;
HideIdleExitWarning();
LoadResources();
// ⭐ 资源加载不再在这里启动:由 WebSocketReponseList 在"面板已显示 → 游戏场景加载完成"后
// 调用 BeginLoadResources() 触发,保证加载顺序为 面板 → 场景 → 资源。
// ⭐ 切换房间:继续用离房时留下的合并进度条,先把新面板自带的进度条藏掉,避免出现两条进度条
if (_changeRoomBar != null && JinDuTiao != null)
JinDuTiao.Hide();
RefreshGGKCount();
//UIManager.Instance.ShowBoard("太好看了");
var v = JsonConvert.DeserializeObject<WebSocketResponseBase<RoomJoinNotice>>(args.ToString());
@@ -1155,6 +1159,15 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
/// </summary>
private static int _resourceFlowToken = 0;
/// <summary>
/// 外部触发资源加载:由 WebSocketReponseList 在"游戏面板已显示 → 游戏场景加载完成"后调用,
/// 保证加载顺序为 面板(加载页面)→ 场景 → 资源。
/// </summary>
public void BeginLoadResources()
{
LoadResources();
}
public async void LoadResources()
{
// ⭐ 捕获本轮令牌:同时使之前所有在途的加载/卸载残留流程作废
@@ -1170,18 +1183,22 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
CreateFishManager.Instance.isResources = false;
// ⭐ 重置卸载标记,下次进入可重新加载
_resourcesUnloaded = false;
await AudioResourcesData.LoadAudioGame();
// ⭐ 加载顺序(配套 AA 分包规划:路线最轻先进 → 鱼 → 音频最重殿后):
// ① 路线(几十KB,进房首屏关键,进度条 0→30%)
// ② 鱼预制体(30→70%)
// ③ 音频(70→80%,Union 全库音频是最重的一步,放最后不再拖住前段进度)
// EnterRoom 位置不动(出鱼系统就绪时序与原逻辑一致,仅资源加载顺序调整)
await MonsterMoveLine.LoadBezier();
if (flow != _resourceFlowToken) return; // ⭐ 期间已退出/切换,本轮作废
SetLoadProgress(0.2f);
await MonsterMoveLine.LoadBezier();
if (flow != _resourceFlowToken) return;
SetLoadProgress(0.4f);
SetLoadProgress(0.3f);
await FishResourcesData.LoadFishAssetsData();
if (flow != _resourceFlowToken) return;
SetLoadProgress(0.6f);
SetLoadProgress(0.7f);
await AudioResourcesData.LoadAudioGame();
if (flow != _resourceFlowToken) return;
await Addressables.LoadAssetsAsync<AudioClip>("Audio", clip =>
{