From 3edd6355830ab0b983cf40eb87c598652a942c86 Mon Sep 17 00:00:00 2001 From: lujiajian <204551278@qq.com> Date: Wed, 5 Nov 2025 09:17:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Framework/Manager/TutorialGuideManager.cs | 333 ++++++++----- .../Runtime/Engine/Core/MotionEngine.cs | 459 +++++++++--------- .../Scripts/Document/DocumentManagement.cs | 42 +- 3 files changed, 462 insertions(+), 372 deletions(-) diff --git a/3d/Assets/Framework/Manager/TutorialGuideManager.cs b/3d/Assets/Framework/Manager/TutorialGuideManager.cs index 371b47f..fe7f40f 100644 --- a/3d/Assets/Framework/Manager/TutorialGuideManager.cs +++ b/3d/Assets/Framework/Manager/TutorialGuideManager.cs @@ -24,11 +24,6 @@ namespace Framework.Manager [SerializeField] private TutorialGuideConfig guideConfig; - [Space(5)] - [Tooltip("是否启用引导跳转功能")] - [SerializeField] - private bool enableSmartGuideJump = true; - [Space(10)] [Header("状态信息")] [SerializeField, ReadOnly] @@ -38,11 +33,6 @@ namespace Framework.Manager // [SerializeField, ReadOnly] private bool isGuideDisabled = false; - [Space(5)] - [Tooltip("是否启用UI显示状态检测")] - [SerializeField] - private bool enableUIStateCheck = true; - // 运行时存储UI对象的字典 private Dictionary uiObjects = new Dictionary(); @@ -52,15 +42,9 @@ namespace Framework.Manager // ProcessManager引用,用于获取当前流程步骤信息 // private ProcessManager processManager; - // 记录已匹配引导的步骤名称,避免同一步骤内重复匹配 - private string lastMatchedStepName = string.Empty; - // 记录被隐藏但需要重新显示的步骤名称 private HashSet hiddenStepsToRedisplay = new HashSet(); - // 记录当前步骤名称下已执行的引导数量,用于支持同一步骤下的多个引导按顺序执行 - private Dictionary stepExecutionCount = new Dictionary(); - // 安全帽点击特殊处理状态 private bool hasHelmetClicked = false; // 是否已点击安全帽 private string helmetClickedObjectName = string.Empty; // 点击的安全帽对象名称 @@ -474,6 +458,107 @@ namespace Framework.Manager } } + /// + /// 验证UI名称匹配 + /// + /// 如果应该继续引导返回true,如果应该停止返回false,如果不需要验证返回null + private bool? ValidateUINameMatch(string uiName) + { + if (string.IsNullOrEmpty(uiName)) + { + if (uiName == "") + { + Debug.Log("TutorialGuideManager: 传入空字符串,自动跳到下一步引导"); + } + else + { + Debug.Log("TutorialGuideManager: 未传入uiName参数,使用原有引导逻辑"); + } + return null; + } + + var currentStep = GetCurrentStep(); + if (currentStep == null) + { + Debug.LogWarning("TutorialGuideManager: 无法获取当前引导步骤,跳过参数匹配检查"); + return false; + } + + // 处理特殊UI名称 + if (uiName == "下一步") + { + return null; // 继续执行 + } + + if (IsSpecialUIName(uiName)) + { + return HandleSpecialUIName(uiName, currentStep); + } + + // 普通UI名称匹配 + if (uiName != currentStep.uiObjectName) + { + Debug.Log($"TutorialGuideManager: 参数匹配失败 - 传入的uiName: '{uiName}' 与当前步骤的uiObjectName: '{currentStep.uiObjectName}' 不匹配,停止引导"); + return false; + } + + Debug.Log($"TutorialGuideManager: 参数匹配成功 - 传入的uiName: '{uiName}' 与当前步骤的uiObjectName: '{currentStep.uiObjectName}' 匹配,继续引导"); + return null; // 继续执行 + } + + /// + /// 检查是否为特殊UI名称 + /// + private bool IsSpecialUIName(string uiName) + { + return uiName == "大厅位置" || uiName == "地磅位置" || uiName == "电脑房" || uiName == "关闭" || uiName == "对话"; + } + + /// + /// 处理特殊UI名称 + /// + private bool HandleSpecialUIName(string uiName, GuideStepConfig currentStep) + { + if (uiName != currentStep.uiObjectName) + { + return false; + } + + if (uiName != "对话") + { + currentIndex++; + } + + HideGuide(); + return true; + } + + /// + /// 执行引导步骤 + /// + private async UniTask ExecuteGuideStep(GuideStepConfig currentStep) + { + if (uiObjects.TryGetValue(currentStep.uiObjectName, out GameObject uiObject)) + { + if (IsUIObjectFullyDisplayed(uiObject)) + { + Debug.Log($"执行引导步骤: {currentStep.stepName} 查询的对象:{uiObject.name}"); + GuideMask.Instance.CreateRectangleMask(uiObject); + FocusInputFieldIfApplicable(uiObject); + return true; + } + else + { + Debug.Log($"UI对象 {uiObject.name} 存在但未完全显示,使用延迟查找"); + return await DelayedFindUIObjectAsync(currentStep); + } + } + else + { + return await DelayedFindUIObjectAsync(currentStep); + } + } + //触发上一个引导步骤 public async UniTask TriggerPrevGuide() { @@ -722,9 +807,7 @@ namespace Framework.Manager { isGuiding = false; currentIndex = -1; - lastMatchedStepName = string.Empty; // 清除已匹配步骤记录 hiddenStepsToRedisplay.Clear(); // 清除待重新显示步骤记录 - stepExecutionCount.Clear(); // 清除步骤执行计数记录 // 重置安全帽点击状态 hasHelmetClicked = false; @@ -882,18 +965,19 @@ namespace Framework.Manager /// 触发当前UI对象的事件 /// 自动检测UI组件类型并触发相应的事件 /// - /// 是否成功触发了事件 public void TriggerCurrentUIEvent() { var currentStep = GetCurrentStep(); if (currentStep == null) { Debug.LogWarning("TutorialGuideManager: 无法获取当前引导步骤,无法触发UI事件"); + return; } if (!uiObjects.TryGetValue(currentStep.uiObjectName, out GameObject uiObject)) { Debug.LogWarning($"TutorialGuideManager: 当前UI对象 {currentStep.uiObjectName} 未注册,无法触发事件"); + return; } Debug.Log($"TutorialGuideManager: 开始触发UI对象 {currentStep.uiObjectName} 的事件"); @@ -1453,7 +1537,6 @@ namespace Framework.Manager var orderedSteps = guideConfig.GetOrderedSteps(); int count = 0; - string lastNonEmptyStepName = string.Empty; bool foundTargetStep = false; // 遍历所有步骤,计算指定步骤名称下的引导数量 @@ -1469,18 +1552,12 @@ namespace Framework.Manager { foundTargetStep = true; count++; - lastNonEmptyStepName = step.stepName; } // 如果已经找到目标步骤,但遇到了新的步骤名称,停止计数 else if (foundTargetStep) { break; } - // 更新lastNonEmptyStepName - else - { - lastNonEmptyStepName = step.stepName; - } } // 如果当前步骤的stepName为空 else @@ -1497,7 +1574,6 @@ namespace Framework.Manager if (count == 0) { foundTargetStep = false; - lastNonEmptyStepName = string.Empty; for (int i = 0; i < orderedSteps.Count; i++) { @@ -1509,16 +1585,11 @@ namespace Framework.Manager { foundTargetStep = true; count++; - lastNonEmptyStepName = step.stepName; } else if (foundTargetStep) { break; } - else - { - lastNonEmptyStepName = step.stepName; - } } else if (foundTargetStep) { @@ -1553,106 +1624,17 @@ namespace Framework.Manager } var orderedSteps = guideConfig.GetOrderedSteps(); - - // 收集所有匹配的引导步骤索引 - List matchedIndices = new List(); - string lastNonEmptyStepName = string.Empty; - bool foundTargetStep = false; - - // 精确匹配(包括顺序延续逻辑) - for (int i = 0; i < orderedSteps.Count; i++) - { - var step = orderedSteps[i]; - - // 如果当前步骤的stepName不为空 - if (!string.IsNullOrEmpty(step.stepName)) - { - // 如果找到了目标步骤,开始收集 - if (step.stepName == stepName) - { - foundTargetStep = true; - matchedIndices.Add(i); - lastNonEmptyStepName = step.stepName; - Debug.Log($"TutorialGuideManager: 精确匹配找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}'"); - } - // 如果已经找到目标步骤,但遇到了新的步骤名称,停止收集 - else if (foundTargetStep) - { - break; - } - // 更新lastNonEmptyStepName - else - { - lastNonEmptyStepName = step.stepName; - } - } - // 如果当前步骤的stepName为空 - else - { - // 如果已经找到目标步骤,继续收集(顺序延续) - if (foundTargetStep) - { - matchedIndices.Add(i); - Debug.Log($"TutorialGuideManager: 顺序延续找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}', lastNonEmptyStepName='{lastNonEmptyStepName}'"); - } - } - } + List matchedIndices = FindExactMatchIndices(orderedSteps, stepName); // 如果精确匹配没有结果,尝试包含匹配 if (matchedIndices.Count == 0) { - foundTargetStep = false; - lastNonEmptyStepName = string.Empty; - - for (int i = 0; i < orderedSteps.Count; i++) - { - var step = orderedSteps[i]; - - if (!string.IsNullOrEmpty(step.stepName)) - { - if (step.stepName.Contains(stepName)) - { - foundTargetStep = true; - matchedIndices.Add(i); - lastNonEmptyStepName = step.stepName; - Debug.Log($"TutorialGuideManager: 包含匹配找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}'"); - } - else if (foundTargetStep) - { - break; - } - else - { - lastNonEmptyStepName = step.stepName; - } - } - else if (foundTargetStep) - { - matchedIndices.Add(i); - Debug.Log($"TutorialGuideManager: 包含匹配顺序延续找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}', lastNonEmptyStepName='{lastNonEmptyStepName}'"); - } - } + matchedIndices = FindContainsMatchIndices(orderedSteps, stepName); } Debug.Log($"TutorialGuideManager: 步骤名称 '{stepName}' 总共找到 {matchedIndices.Count} 个匹配的引导步骤"); - // 根据执行索引返回对应的引导步骤 - if (executionIndex >= 0 && executionIndex < matchedIndices.Count) - { - int guideIndex = matchedIndices[executionIndex]; - Debug.Log($"TutorialGuideManager: 找到匹配的引导步骤: {stepName} -> 执行索引: {executionIndex}, 引导索引: {guideIndex}, UI对象: {orderedSteps[guideIndex].uiObjectName}"); - return guideIndex; - } - else if (matchedIndices.Count > 0) - { - // 如果执行索引超出范围,说明该步骤的所有引导都已执行完毕 - // 返回-1让系统按顺序继续执行下一个引导,而不是返回第一个匹配的 - Debug.Log($"TutorialGuideManager: 执行索引超出范围,步骤 '{stepName}' 的所有引导步骤已执行完毕,将按顺序继续"); - return -1; - } - - Debug.Log($"TutorialGuideManager: 未找到匹配的引导步骤: {stepName}"); - return -1; + return SelectGuideIndexByExecutionIndex(matchedIndices, orderedSteps, stepName, executionIndex); } catch (System.Exception ex) { @@ -1661,6 +1643,109 @@ namespace Framework.Manager } } + /// + /// 查找精确匹配的引导步骤索引(包括顺序延续逻辑) + /// + private List FindExactMatchIndices(List orderedSteps, string stepName) + { + List matchedIndices = new List(); + bool foundTargetStep = false; + string lastNonEmptyStepName = string.Empty; + + for (int i = 0; i < orderedSteps.Count; i++) + { + var step = orderedSteps[i]; + + if (!string.IsNullOrEmpty(step.stepName)) + { + if (step.stepName == stepName) + { + foundTargetStep = true; + matchedIndices.Add(i); + lastNonEmptyStepName = step.stepName; + Debug.Log($"TutorialGuideManager: 精确匹配找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}'"); + } + else if (foundTargetStep) + { + break; + } + else + { + lastNonEmptyStepName = step.stepName; + } + } + else if (foundTargetStep) + { + matchedIndices.Add(i); + Debug.Log($"TutorialGuideManager: 顺序延续找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}', lastNonEmptyStepName='{lastNonEmptyStepName}'"); + } + } + + return matchedIndices; + } + + /// + /// 查找包含匹配的引导步骤索引(包括顺序延续逻辑) + /// + private List FindContainsMatchIndices(List orderedSteps, string stepName) + { + List matchedIndices = new List(); + bool foundTargetStep = false; + string lastNonEmptyStepName = string.Empty; + + for (int i = 0; i < orderedSteps.Count; i++) + { + var step = orderedSteps[i]; + + if (!string.IsNullOrEmpty(step.stepName)) + { + if (step.stepName.Contains(stepName)) + { + foundTargetStep = true; + matchedIndices.Add(i); + lastNonEmptyStepName = step.stepName; + Debug.Log($"TutorialGuideManager: 包含匹配找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}'"); + } + else if (foundTargetStep) + { + break; + } + else + { + lastNonEmptyStepName = step.stepName; + } + } + else if (foundTargetStep) + { + matchedIndices.Add(i); + Debug.Log($"TutorialGuideManager: 包含匹配顺序延续找到引导步骤: 索引={i}, stepName='{step.stepName}', uiObjectName='{step.uiObjectName}', lastNonEmptyStepName='{lastNonEmptyStepName}'"); + } + } + + return matchedIndices; + } + + /// + /// 根据执行索引选择引导步骤索引 + /// + private int SelectGuideIndexByExecutionIndex(List matchedIndices, List orderedSteps, string stepName, int executionIndex) + { + if (executionIndex >= 0 && executionIndex < matchedIndices.Count) + { + int guideIndex = matchedIndices[executionIndex]; + Debug.Log($"TutorialGuideManager: 找到匹配的引导步骤: {stepName} -> 执行索引: {executionIndex}, 引导索引: {guideIndex}, UI对象: {orderedSteps[guideIndex].uiObjectName}"); + return guideIndex; + } + else if (matchedIndices.Count > 0) + { + Debug.Log($"TutorialGuideManager: 执行索引超出范围,步骤 '{stepName}' 的所有引导步骤已执行完毕,将按顺序继续"); + return -1; + } + + Debug.Log($"TutorialGuideManager: 未找到匹配的引导步骤: {stepName}"); + return -1; + } + #endregion } } \ No newline at end of file diff --git a/3d/Assets/Framework/Scripts/Runtime/Engine/Core/MotionEngine.cs b/3d/Assets/Framework/Scripts/Runtime/Engine/Core/MotionEngine.cs index a9a339b..e5ba4d7 100644 --- a/3d/Assets/Framework/Scripts/Runtime/Engine/Core/MotionEngine.cs +++ b/3d/Assets/Framework/Scripts/Runtime/Engine/Core/MotionEngine.cs @@ -6,262 +6,265 @@ using UnityEngine; namespace MotionFramework { - public static class MotionEngine - { - private class ModuleWrapper - { - public int Priority { private set; get; } - public IModule Module { private set; get; } + public static class MotionEngine + { + private class ModuleWrapper + { + public int Priority { private set; get; } + public IModule Module { private set; get; } - public ModuleWrapper(IModule module, int priority) - { - Module = module; - Priority = priority; - } - } + public ModuleWrapper(IModule module, int priority) + { + Module = module; + Priority = priority; + } + } - private static readonly List _coms = new List(100); - private static MonoBehaviour _behaviour; - private static bool _isDirty = false; - private static long _frame = 0; + private static readonly List _coms = new List(100); + private static MonoBehaviour _behaviour; + private static bool _isDirty = false; + private static long _frame = 0; - /// - /// 初始化框架 - /// - public static void Initialize(MonoBehaviour behaviour, Action logCallback) - { - if (behaviour == null) - throw new Exception("MotionFramework behaviour is null."); - if (_behaviour != null) - throw new Exception($"{nameof(MotionEngine)} is already initialized."); + /// + /// 初始化框架 + /// + public static void Initialize(MonoBehaviour behaviour, Action logCallback) + { + if (behaviour == null) + throw new ArgumentNullException(nameof(behaviour), "MotionFramework behaviour cannot be null"); + if (_behaviour != null) + throw new InvalidOperationException($"{nameof(MotionEngine)} is already initialized"); - UnityEngine.Object.DontDestroyOnLoad(behaviour.gameObject); - _behaviour = behaviour; + UnityEngine.Object.DontDestroyOnLoad(behaviour.gameObject); + _behaviour = behaviour; - // 注册日志回调 - if (logCallback != null) - MotionLog.RegisterCallback(logCallback); + // 注册日志回调 + if (logCallback != null) + MotionLog.RegisterCallback(logCallback); - behaviour.StartCoroutine(CheckFrame()); - } + behaviour.StartCoroutine(CheckFrame()); + } - /// - /// 检测MotionEngine更新方法 - /// - private static IEnumerator CheckFrame() - { - var wait = new WaitForSeconds(1f); - yield return wait; + /// + /// 检测MotionEngine更新方法 + /// + private static IEnumerator CheckFrame() + { + var wait = new WaitForSeconds(1f); + yield return wait; - // 说明:初始化之后,如果忘记更新MotionEngine,这里会抛出异常 - if (_frame == 0) - throw new Exception($"Please call update method : MotionEngine.Update"); - } + // 说明:初始化之后,如果忘记更新MotionEngine,这里会记录警告而不是抛出异常 + // 避免在协程中抛出未处理的异常导致程序崩溃 + if (_frame == 0) + { + MotionLog.Warning("MotionEngine.Update() has not been called. Please ensure Update() is called every frame."); + } + } - /// - /// 更新框架 - /// - public static void Update() - { - _frame++; + /// + /// 更新框架 + /// + public static void Update() + { + _frame++; - // 如果有新模块需要重新排序 - if (_isDirty) - { - _isDirty = false; - _coms.Sort((left, right) => - { - if (left.Priority > right.Priority) - return -1; - else if (left.Priority == right.Priority) - return 0; - else - return 1; - }); - } + // 如果有新模块需要重新排序 + if (_isDirty) + { + _isDirty = false; + _coms.Sort((left, right) => + { + if (left.Priority > right.Priority) + return -1; + else if (left.Priority == right.Priority) + return 0; + else + return 1; + }); + } - // 轮询所有模块 - for (int i = 0; i < _coms.Count; i++) - { - _coms[i].Module.OnUpdate(); - } - } + // 轮询所有模块 + for (int i = 0; i < _coms.Count; i++) + { + _coms[i].Module.OnUpdate(); + } + } - /// - /// 绘制所有模块的GUI内容 - /// - internal static void DrawModulesGUIContent() - { - for (int i = 0; i < _coms.Count; i++) - { - _coms[i].Module.OnGUI(); - } - } + /// + /// 绘制所有模块的GUI内容 + /// + internal static void DrawModulesGUIContent() + { + for (int i = 0; i < _coms.Count; i++) + { + _coms[i].Module.OnGUI(); + } + } - /// - /// 查询游戏模块是否存在 - /// - public static bool Contains() where T : class, IModule - { - System.Type type = typeof(T); - return Contains(type); - } + /// + /// 查询游戏模块是否存在 + /// + public static bool Contains() where T : class, IModule + { + System.Type type = typeof(T); + return Contains(type); + } - /// - /// 查询游戏模块是否存在 - /// - public static bool Contains(System.Type moduleType) - { - for (int i = 0; i < _coms.Count; i++) - { - if (_coms[i].Module.GetType() == moduleType) - return true; - } - return false; - } + /// + /// 查询游戏模块是否存在 + /// + public static bool Contains(System.Type moduleType) + { + for (int i = 0; i < _coms.Count; i++) + { + if (_coms[i].Module.GetType() == moduleType) + return true; + } + return false; + } - /// - /// 创建游戏模块 - /// - /// 模块类 - /// 运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行 - public static T CreateModule(int priority = 0) where T : class, IModule - { - return CreateModule(null, priority); - } + /// + /// 创建游戏模块 + /// + /// 模块类 + /// 运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行 + public static T CreateModule(int priority = 0) where T : class, IModule + { + return CreateModule(null, priority); + } - /// - /// 创建游戏模块 - /// - /// 模块类 - /// 创建参数 - /// 运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行 - public static T CreateModule(System.Object createParam, int priority = 0) where T : class, IModule - { - if (priority < 0) - throw new Exception("The priority can not be negative"); + /// + /// 创建游戏模块 + /// + /// 模块类 + /// 创建参数 + /// 运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行 + public static T CreateModule(System.Object createParam, int priority = 0) where T : class, IModule + { + if (priority < 0) + throw new ArgumentOutOfRangeException(nameof(priority), priority, "Priority cannot be negative"); - if (Contains(typeof(T))) - throw new Exception($"Game module {typeof(T)} is already existed"); + if (Contains(typeof(T))) + throw new InvalidOperationException($"Game module {typeof(T)} already exists"); - - - - int minPriority = GetMinPriority(); - priority = --minPriority; - + // 如果没有设置优先级 + if (priority == 0) + { + int minPriority = GetMinPriority(); + priority = --minPriority; + } - MotionLog.Log($"Create game module : {typeof(T)}"); - T module = Activator.CreateInstance(); - ModuleWrapper wrapper = new ModuleWrapper(module, priority); - wrapper.Module.OnCreate(createParam); - _coms.Add(wrapper); - _isDirty = true; - return module; - } + MotionLog.Log($"Create game module : {typeof(T)}"); + T module = Activator.CreateInstance(); + ModuleWrapper wrapper = new ModuleWrapper(module, priority); + wrapper.Module.OnCreate(createParam); + _coms.Add(wrapper); + _isDirty = true; + return module; + } - /// - /// 销毁模块 - /// - /// 模块类 - public static bool DestroyModule() - { - var moduleType = typeof(T); - for (int i = 0; i < _coms.Count; i++) - { - if (_coms[i].Module.GetType() == moduleType) - { - _coms[i].Module.OnDestroy(); - _coms.RemoveAt(i); - return true; - } - } - return false; - } + /// + /// 销毁模块 + /// + /// 模块类 + public static bool DestroyModule() + { + var moduleType = typeof(T); + for (int i = 0; i < _coms.Count; i++) + { + if (_coms[i].Module.GetType() == moduleType) + { + _coms[i].Module.OnDestroy(); + _coms.RemoveAt(i); + return true; + } + } + return false; + } - /// - /// 获取游戏模块 - /// - /// 模块类 - public static T GetModule() where T : class, IModule - { - System.Type type = typeof(T); - for (int i = 0; i < _coms.Count; i++) - { - if (_coms[i].Module.GetType() == type) - return _coms[i].Module as T; - } + /// + /// 获取游戏模块 + /// + /// 模块类 + public static T GetModule() where T : class, IModule + { + System.Type type = typeof(T); + for (int i = 0; i < _coms.Count; i++) + { + if (_coms[i].Module.GetType() == type) + return _coms[i].Module as T; + } - MotionLog.Warning($"Not found game module {type}"); - return null; - } + MotionLog.Warning($"Not found game module {type}"); + return null; + } - /// - /// 获取当前模块里最小的优先级 - /// - private static int GetMinPriority() - { - int minPriority = 0; - for (int i = 0; i < _coms.Count; i++) - { - if (_coms[i].Priority < minPriority) - minPriority = _coms[i].Priority; - } - return minPriority; //小于等于零 - } + /// + /// 获取当前模块里最小的优先级 + /// + private static int GetMinPriority() + { + int minPriority = 0; + for (int i = 0; i < _coms.Count; i++) + { + if (_coms[i].Priority < minPriority) + minPriority = _coms[i].Priority; + } + return minPriority; //小于等于零 + } - #region 协程相关 - /// - /// 开启一个协程 - /// - public static Coroutine StartCoroutine(IEnumerator coroutine) - { - if (_behaviour == null) - throw new Exception($"{nameof(MotionEngine)} is not initialize. Use MotionEngine.Initialize"); - return _behaviour.StartCoroutine(coroutine); - } + #region 协程相关 + /// + /// 开启一个协程 + /// + public static Coroutine StartCoroutine(IEnumerator coroutine) + { + if (_behaviour == null) + throw new InvalidOperationException($"{nameof(MotionEngine)} is not initialized. Use MotionEngine.Initialize"); + return _behaviour.StartCoroutine(coroutine); + } - /// - /// 停止一个协程 - /// - public static void StopCoroutine(Coroutine coroutine) - { - if (_behaviour == null) - throw new Exception($"{nameof(MotionEngine)} is not initialize. Use MotionEngine.Initialize"); - _behaviour.StopCoroutine(coroutine); - } + /// + /// 停止一个协程 + /// + public static void StopCoroutine(Coroutine coroutine) + { + if (_behaviour == null) + throw new InvalidOperationException($"{nameof(MotionEngine)} is not initialized. Use MotionEngine.Initialize"); + _behaviour.StopCoroutine(coroutine); + } - /// - /// 开启一个协程 - /// - public static void StartCoroutine(string methodName) - { - if (_behaviour == null) - throw new Exception($"{nameof(MotionEngine)} is not initialize. Use MotionEngine.Initialize"); - _behaviour.StartCoroutine(methodName); - } + /// + /// 开启一个协程 + /// + public static void StartCoroutine(string methodName) + { + if (_behaviour == null) + throw new InvalidOperationException($"{nameof(MotionEngine)} is not initialized. Use MotionEngine.Initialize"); + _behaviour.StartCoroutine(methodName); + } - /// - /// 停止一个协程 - /// - public static void StopCoroutine(string methodName) - { - if (_behaviour == null) - throw new Exception($"{nameof(MotionEngine)} is not initialize. Use MotionEngine.Initialize"); - _behaviour.StopCoroutine(methodName); - } + /// + /// 停止一个协程 + /// + public static void StopCoroutine(string methodName) + { + if (_behaviour == null) + throw new InvalidOperationException($"{nameof(MotionEngine)} is not initialized. Use MotionEngine.Initialize"); + _behaviour.StopCoroutine(methodName); + } - /// - /// 停止所有协程 - /// - public static void StopAllCoroutines() - { - if (_behaviour == null) - throw new Exception($"{nameof(MotionEngine)} is not initialize. Use MotionEngine.Initialize"); - _behaviour.StopAllCoroutines(); - } - #endregion - } + /// + /// 停止所有协程 + /// + public static void StopAllCoroutines() + { + if (_behaviour == null) + throw new InvalidOperationException($"{nameof(MotionEngine)} is not initialized. Use MotionEngine.Initialize"); + _behaviour.StopAllCoroutines(); + } + #endregion + } } \ No newline at end of file diff --git a/3d/Assets/Zion/Scripts/Document/DocumentManagement.cs b/3d/Assets/Zion/Scripts/Document/DocumentManagement.cs index 01b0e95..1d1680b 100644 --- a/3d/Assets/Zion/Scripts/Document/DocumentManagement.cs +++ b/3d/Assets/Zion/Scripts/Document/DocumentManagement.cs @@ -244,73 +244,73 @@ public class DocumentManagement : MonoBehaviour Debug.Log($"题目包含调拨入库,显示调拨入库相关单据"); return documentGoListDBRK; } - + if (examName.Contains("到货验收")) { Debug.Log($"题目包含到货验收,显示采购物资入库单据"); return purchaseDocumentCollections; } - + if (examName.Contains("代保管物资出库")) { Debug.Log($"题目包含代保管出库,显示代保管出库"); return documentGoListTC; } - - if (examName.Contains("退出退役资产代保管入库作业") || - examName.Contains("代保管物资入库") || + + if (examName.Contains("退出退役资产代保管入库作业") || + examName.Contains("代保管物资入库") || examName.Contains("退出退役代保管入库")) { Debug.Log($"题目包含代保管入库,显示退出退役资产代保管入库作业"); return documentGoListTCYUDBGRK; } - + if (examName.Contains("跨省调拨物资")) { Debug.Log($"题目包含跨省调拨物资,显示退出退役资产物资代保管出库作业"); return documentGoListKSDBWZ; } - + if (examName.Contains("借用物资出库")) { return documentGoListXSKBSJYWZ; } - + if (examName.Contains("库存物资报废")) { return documentGoListKCWZBF; } - + if (examName.Contains("领用出库")) { return documentGoListWZLYCK; } - + if (examName.Contains("退料物资入库")) { return documentGoListTLWZRK; } - + if (examName.Contains("电缆分支箱跨地市物资调配")) { return GetDocumentCollectionForCableBranchBox(examName); } - + if (examName.Contains("重点物资排产计划制定")) { return documentGoListDLZDWZPCJH; } - + if (examName.Contains("废旧物资入库") || examName.Contains("不可用办理实物退库")) { return documentGoListDLFJWZRK; } - + if (examName.Contains("借用物资系统归还系统操作") || examName.Contains("借用物资入库")) { return documentGoListJYWZRK; } - + return null; } @@ -321,7 +321,7 @@ public class DocumentManagement : MonoBehaviour { inventoryReversalVoucherAnalyzer = (Framework.Dto.InventoryReversalVoucherAnalyzer)MotionEngine.GetModule().materialTaskObj; var doc = documentGoListDLFZXKSWZDP.ToList(); - + if (inventoryReversalVoucherAnalyzer.formselection == "需求数量缺失") { doc.RemoveAt(1); @@ -330,7 +330,7 @@ public class DocumentManagement : MonoBehaviour { doc.RemoveAt(0); } - + return doc.ToArray(); } @@ -370,10 +370,12 @@ public class DocumentManagement : MonoBehaviour { return; } - - for (int i = 0; i < documentCollections.Length; i++) + if (documentCollections != null) { - GenerateDocument(documentCollections[i].name); + for (int i = 0; i < documentCollections.Length; i++) + { + GenerateDocument(documentCollections[i].name); + } } ////保存按钮