This commit is contained in:
yzx 2024-06-12 10:34:39 +08:00
parent b2c7b7badb
commit 5ad1d14b3d
16 changed files with 434 additions and 277 deletions

View File

@ -45,12 +45,14 @@
<Analyzer Include="E:\Program Files\Unity 2022.3.22f1\Editor\Data\Tools\Unity.SourceGenerators\Unity.Properties.SourceGenerator.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\taoruiqi\Script\ElectricCheckPen.cs" />
<Compile Include="Assets\Scripts\ProcessMode\ProcessMode.cs" />
<Compile Include="Assets\Scripts\ToolsPack\ToolsPackWindowManager.cs" />
<Compile Include="Assets\Standard Assets 1\Utility\FOVKick.cs" />
<Compile Include="Assets\HighlightPlus\Scripts\HighlightEffectOccluderManager.cs" />
<Compile Include="Assets\Standard Assets 1\Vehicles\Aircraft\Scripts\AeroplaneControlSurfaceAnimator.cs" />
<Compile Include="Assets\Standard Assets 1\Vehicles\Aircraft\Scripts\LandingGear.cs" />
<Compile Include="Assets\Scripts\ProcessMode\ActionWithDescription.cs" />
<Compile Include="Assets\Standard Assets 1\Utility\DragRigidbody.cs" />
<Compile Include="Assets\HighlightPlus\Scripts\HighlightProfile.cs" />
<Compile Include="Assets\StandaloneFileBrowser\Sample\CanvasSampleOpenFileTextMultiple.cs" />
@ -65,6 +67,7 @@
<Compile Include="Assets\Standard Assets 1\Utility\WaypointCircuit.cs" />
<Compile Include="Assets\Standard Assets 1\Characters\ThirdPersonCharacter\Scripts\ThirdPersonUserControl.cs" />
<Compile Include="Assets\taoruiqi\Pliers.cs" />
<Compile Include="Assets\taoruiqi\AdhesiveTape.cs" />
<Compile Include="Assets\taoruiqi\WorkPermit.cs" />
<Compile Include="Assets\Standard Assets 1\CrossPlatformInput\Scripts\PlatformSpecific\MobileInput.cs" />
<Compile Include="Assets\StandaloneFileBrowser\StandaloneFileBrowserWindows.cs" />
@ -109,6 +112,7 @@
<Compile Include="Assets\Standard Assets 1\CrossPlatformInput\Scripts\VirtualInput.cs" />
<Compile Include="Assets\StandaloneFileBrowser\Sample\CanvasSampleSaveFileImage.cs" />
<Compile Include="Assets\Ladder.cs" />
<Compile Include="Assets\Scripts\ProcessMode\IncorrectClick.cs" />
<Compile Include="Assets\Standard Assets 1\Utility\ForcedReset.cs" />
<Compile Include="Assets\Standard Assets 1\Utility\DynamicShadowSettings.cs" />
<Compile Include="Assets\Standard Assets 1\Vehicles\Aircraft\Scripts\JetParticleEffect.cs" />
@ -162,8 +166,10 @@
<Compile Include="Assets\HighlightPlus\Scripts\HighlightSeeThroughOccluder.cs" />
<Compile Include="Assets\Scripts\ProcessMode\ProcessUIManager.cs" />
<Compile Include="Assets\Standard Assets 1\Vehicles\Aircraft\Scripts\AeroplaneAiControl.cs" />
<Compile Include="Assets\JunctionBox.cs" />
<Compile Include="Assets\Scripts\FaultRecords\FaultRecord.cs" />
<Compile Include="Assets\Scripts\ProcessMode\AnimationProcessManager.cs" />
<Compile Include="Assets\Screwdriver.cs" />
<Compile Include="Assets\Standard Assets 1\Characters\FirstPersonCharacter\Scripts\HeadBob.cs" />
<Compile Include="Assets\Standard Assets 1\Characters\RollerBall\Scripts\BallUserControl.cs" />
<Compile Include="Assets\StandaloneFileBrowser\StandaloneFileBrowserEditor.cs" />
@ -174,6 +180,7 @@
<Compile Include="Assets\Standard Assets 1\Vehicles\Car\Scripts\Mudguard.cs" />
<Compile Include="Assets\Scripts\DataConfigManager.cs" />
<Compile Include="Assets\taoruiqi\Script\ThreeTransformerPhotovoltaicView.cs" />
<Compile Include="Assets\taoruiqi\Script\InteractiveObjects.cs" />
<None Include="Assets\TextMesh Pro\Shaders\TMPro.cginc" />
<None Include="Assets\TextMesh Pro\Shaders\TMP_SDF-Mobile Overlay.shader" />
<None Include="Assets\StreamingAssets\FaultRecords\FaultRecords.json" />

View File

@ -6,6 +6,9 @@ public class ScriptDescriptionEditor : Editor
{
private GUIStyle descriptionStyle;
private void OnEnable()
{
descriptionStyle = new GUIStyle(EditorStyles.label)

View File

@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using DefaultNamespace.ProcessMode;
using Framework.Scripts.Runtime.Engine.Engine.Camera;
using UnityEngine;
@ -64,6 +65,10 @@ public class GameLauncher : MonoBehaviour
MotionEngine.CreateModule<ToolsPackManager>();
//数据配置文件
MotionEngine.CreateModule<DataConfigManager>();
//流程管理器
MotionEngine.CreateModule<AnimationProcessManager>();
}
private void HandleMotionFrameworkLog(ELogLevel logLevel, string log)

View File

@ -114,12 +114,12 @@ Material:
- _UVSec: 0
- _ZWrite: 1
- __dirty: 0
- _step_p1: 1
- _step_p2: 1
- _step_p3: 1
- _step_p4: 1
- _step_p5: 1
- _step_p6: 1
- _step_p1: 0
- _step_p2: 0
- _step_p3: 0
- _step_p4: 0
- _step_p5: 0
- _step_p6: 0
m_Colors:
- _BaseCol: {r: 0.23429155, g: 0.28497556, b: 0.3679245, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}

View File

@ -20720,6 +20720,63 @@ Transform:
m_Children: []
m_Father: {fileID: 1886732940}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1199227227
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1091812145067508994, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6026879024415736155, guid: fa12b84946083d14cb4447029910be28, type: 3}
propertyPath: m_Name
value: APP
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fa12b84946083d14cb4447029910be28, type: 3}
--- !u!1 &1203342266
GameObject:
m_ObjectHideFlags: 0
@ -26534,6 +26591,64 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1513575210}
m_CullTransparentMesh: 1
--- !u!1 &1516723166
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1516723168}
- component: {fileID: 1516723167}
- component: {fileID: 1516723169}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1516723167
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1516723166}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51f73ee94f284a86b677a6bc74544094, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1516723168
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1516723166}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 303.8186, y: 1.9446667, z: 164.25206}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1516723169
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1516723166}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 63b7e72fa2d34c0ca56c938039f733e2, type: 3}
m_Name:
m_EditorClassIdentifier:
toolsPackScene: 1
--- !u!1 &1521115505
GameObject:
m_ObjectHideFlags: 0
@ -28056,74 +28171,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1588077158}
m_CullTransparentMesh: 1
--- !u!1 &1610656807
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1610656810}
- component: {fileID: 1610656809}
- component: {fileID: 1610656808}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1610656808
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1610656807}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1610656809
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1610656807}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1610656810
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1610656807}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1614669908
GameObject:
m_ObjectHideFlags: 0
@ -230358,9 +230405,10 @@ SceneRoots:
- {fileID: 1886732940}
- {fileID: 1467737217}
- {fileID: 826737787}
- {fileID: 1610656810}
- {fileID: 1805985062}
- {fileID: 1204801357}
- {fileID: 1987581050}
- {fileID: 1505150131}
- {fileID: 1986025700}
- {fileID: 1516723168}
- {fileID: 1199227227}

View File

@ -40,7 +40,7 @@ public class Screwdriver : MonoBehaviour
/// <summary>
/// 螺丝
/// </summary>
/// </summary>a
public GameObject[] ScrewObj;
/// <summary>
@ -202,6 +202,7 @@ public class Screwdriver : MonoBehaviour
ScrewL.gameObject.SetActive(false);
}
/// <summary>
/// 集中器右侧螺丝
/// </summary>

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace.ProcessMode
{
public class ActionWithDescription
{
public List<GameObject> TargetObjects { get; set; } // 需要点击的目标物体列表
public Action Action { get; set; } // 与点击关联的动画或反应
public string Description { get; set; } // 动作描述
public int CurrentObjectIndex { get; set; } // 当前对象的点击索引
public ActionWithDescription(List<GameObject> targetObjects, Action action, string description)
{
TargetObjects = targetObjects ?? new List<GameObject>();
Action = action;
Description = description;
CurrentObjectIndex = 0; // 初始化为第一个对象
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f69314a2c8ae4f2f9463f3d3a29d7a30
timeCreated: 1718109086

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using MotionFramework;
using UnityEngine;
@ -6,40 +7,16 @@ using UnityEngine.UI;
namespace DefaultNamespace.ProcessMode
{
[ScriptDescription("流程模式管理器")]
public class AnimationProcessManager : MonoBehaviour
public class AnimationProcessManager : ModuleSingleton<AnimationProcessManager>, IModule
{
private Dictionary<string, AnimationProcess> processes; // 存储不同类型流程的字典
private Dictionary<string, AnimationProcess> processes = new Dictionary<string, AnimationProcess>();
public ProcessMode currentMode; // 当前模式
private int currentStepIndex; // 当前步骤索引
private ProcessUIManager uiManager; // 引用UIManager实例
private int currentActionIndex; // 当前动作索引,确保动作顺序
private int currentActionGameIndex; // 当前动作索引,确保动作顺序
private List<IncorrectClick> incorrectClicks; // 错误点击的记录列表
/// <summary>
/// 构造函数
/// </summary>
/// <param name="uiManager">UIManager实例</param>
public AnimationProcessManager(ProcessUIManager uiManager)
{
this.uiManager = uiManager;
processes = new Dictionary<string, AnimationProcess>();
InitializeProcesses(); // 初始化流程
currentStepIndex = 0;
}
/// <summary>
/// 初始化所有流程
/// </summary>
private void InitializeProcesses()
{
AddProcess("Teaching"); // 添加教学流程
AddProcess("Training"); // 添加培训流程
AddProcess("Practice"); // 添加练习流程
AddProcess("Assessment"); // 添加考核流程
}
/// <summary>
/// 添加一个新的流程
/// </summary>
/// <param name="type">流程类型</param>
public void AddProcess(string type)
{
if (!processes.ContainsKey(type))
@ -48,11 +25,6 @@ namespace DefaultNamespace.ProcessMode
}
}
/// <summary>
/// 向指定类型的流程中添加步骤
/// </summary>
/// <param name="type">流程类型</param>
/// <param name="step">要添加的步骤</param>
public void AddStepToProcess(string type, AnimationStep step)
{
if (processes.ContainsKey(type))
@ -61,24 +33,6 @@ namespace DefaultNamespace.ProcessMode
}
}
/// <summary>
/// 获取指定类型流程的总评分
/// </summary>
/// <param name="type">流程类型</param>
/// <returns>总评分</returns>
public float GetTotalScoreForProcess(string type)
{
if (processes.ContainsKey(type))
{
return processes[type].CalculateTotalScore();
}
return 0;
}
/// <summary>
/// 处理用户点击事件
/// </summary>
/// <param name="clickedObject">被点击的对象</param>
public void HandleClick(GameObject clickedObject)
{
string type = currentMode.ToString();
@ -90,35 +44,113 @@ namespace DefaultNamespace.ProcessMode
if (currentStepIndex < process.Steps.Count)
{
AnimationStep step = process.Steps[currentStepIndex];
ActionWithDescription currentAction = step.Actions[currentActionIndex];
if (step.CorrectObject == clickedObject)
// 检查当前点击是否为当前动作预期的对象
if (currentAction.CurrentObjectIndex < currentAction.TargetObjects.Count &&
currentAction.TargetObjects[currentAction.CurrentObjectIndex] == clickedObject)
{
step.PlayAnimation();
Debug.Log($"正确点击了:{clickedObject.name}");
currentAction.CurrentObjectIndex++; // 正确点击,递增对象索引
switch (currentMode)
// 检查是否完成了当前动作中的所有对象点击
if (currentAction.CurrentObjectIndex >= currentAction.TargetObjects.Count)
{
case ProcessMode.Teaching:
uiManager.HighlightNextStep(step); // 高亮下一个步骤
break;
case ProcessMode.Training:
uiManager.ShowTrainingStep(step); // 显示培训步骤
break;
case ProcessMode.Practice:
uiManager.ShowPracticeStep(step); // 显示练习步骤
break;
case ProcessMode.Assessment:
// 无提示
break;
}
Debug.Log($"完成了动作 {currentActionIndex + 1}");
step.PlayAnimation(currentActionIndex); // 播放当前动作的动画
DisplayActionFeedback(currentMode, currentAction); // 显示反馈
currentStepIndex++;
// 重置当前动作对象索引,并准备下一个动作
currentActionIndex++;
currentAction.CurrentObjectIndex = 0;
if (currentActionIndex >= step.Actions.Count)
{
Debug.Log("所有动作完成!");
currentActionIndex = 0; // 重置动作索引或进入下一个大步骤
currentStepIndex++;
}
else
{
Debug.Log("开始下一个动作!");
PrepareNextStep(currentMode, process, currentStepIndex);
}
}
}
else
{
Debug.Log("Incorrect object clicked.");
Debug.Log($"错误点击或顺序错误:{clickedObject.name}");
// 错误点击处理,可以选择重置当前动作的索引或其他处理逻辑
}
}
}
}
private void DisplayActionFeedback(ProcessMode mode, ActionWithDescription action)
{
switch (mode)
{
case ProcessMode.Teaching:
// 高亮显示下一个需要点击的地方
// HighlightNextStep(action.);
break;
case ProcessMode.Training:
// 在画面右上角显示流程步骤
// uiManager.ShowTrainingStep(action.Description);
break;
case ProcessMode.Practice:
// 只显示当前步骤
// uiManager.ShowPracticeStep(action.Description);
break;
case ProcessMode.Assessment:
// 无任何提示
break;
}
}
private void PrepareNextStep(ProcessMode mode, AnimationProcess process, int nextStepIndex)
{
if (nextStepIndex < process.Steps.Count)
{
ActionWithDescription nextAction = process.Steps[nextStepIndex].Actions[0];
if (mode == ProcessMode.Teaching)
{
// HighlightNextStep(nextAction.TargetObject);
}
else if (mode == ProcessMode.Training)
{
// uiManager.ShowTrainingStep("开始下一个步骤...");
}
}
else
{
// uiManager.DisplayMessage("所有步骤完成!");
}
}
private void HighlightNextStep(GameObject target)
{
// 实现高亮逻辑,比如改变对象颜色或添加光环效果
}
public void OnCreate(object createParam)
{
processes = new Dictionary<string, AnimationProcess>();
incorrectClicks = new List<IncorrectClick>();
}
public void OnUpdate()
{
}
public void OnDestroy()
{
}
public void OnGUI()
{
}
}
}

View File

@ -9,32 +9,24 @@ namespace DefaultNamespace.ProcessMode
/// </summary>
public class AnimationStep
{
public string Description { get; set; } // 步骤描述
public string StepDescription { get; set; } // 步骤描述
public float Score { get; set; } // 步骤评分
public Action Animation { get; private set; } // DOTween动画
public GameObject CorrectObject { get; set; } // 正确的点击对象
public List<ActionWithDescription> Actions { get; private set; } // 动作列表
/// <summary>
/// 构造函数
/// </summary>
/// <param name="description">步骤描述</param>
/// <param name="score">步骤评分</param>
/// <param name="animation">要播放的动画</param>
/// <param name="correctObject">正确的点击对象</param>
public AnimationStep(string description, float score, Action animation, GameObject correctObject)
public AnimationStep(string stepDescription, float score, List<ActionWithDescription> actions)
{
Description = description;
StepDescription = stepDescription;
Score = score;
Animation = animation;
CorrectObject = correctObject;
Actions = actions;
}
/// <summary>
/// 播放动画
/// </summary>
public void PlayAnimation()
public void PlayAnimation(int index)
{
Animation?.Invoke();
if (index >= 0 && index < Actions.Count)
{
Actions[index].Action?.Invoke(); // 执行动画
Debug.Log(Actions[index].Description); // 输出动作描述
}
}
}
}

View File

@ -0,0 +1,19 @@
using UnityEngine;
namespace DefaultNamespace.ProcessMode
{
public class IncorrectClick
{
public GameObject ClickedObject { get; set; }
public int StepIndex { get; set; }
public int ActionIndex { get; set; } // 新增:动作索引
public IncorrectClick(GameObject clickedObject, int stepIndex, int actionIndex)
{
ClickedObject = clickedObject;
StepIndex = stepIndex;
ActionIndex = actionIndex;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e49a83ec6ff240d38d3b702d006793b2
timeCreated: 1718155453

View File

@ -1,84 +1,85 @@
using UnityEngine;
using UnityEngine.UI;
namespace DefaultNamespace.ProcessMode
{
public class ProcessUIManager
{
public Text trainingTextBox; // 培训模式的文本框
public Text practiceTextBox; // 练习模式的文本框
public GameObject highlightObject; // 高亮对象,用于教学模式
public AnimationProcessManager processManager; // 流程管理器实例
private void Start()
{
processManager = new AnimationProcessManager(this); // 传递UIManager实例
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
GameObject clickedObject = DetectClickedObject();
if (clickedObject != null)
{
processManager.HandleClick(clickedObject);
}
}
}
/// <summary>
/// 检测点击的对象
/// </summary>
/// <returns>点击的对象</returns>
private GameObject DetectClickedObject()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
return hit.collider.gameObject;
}
return null;
}
/// <summary>
/// 显示培训步骤信息
/// </summary>
/// <param name="step">当前步骤</param>
public void ShowTrainingStep(AnimationStep step)
{
if (trainingTextBox != null)
{
trainingTextBox.text = step.Description;
}
}
/// <summary>
/// 显示练习步骤信息
/// </summary>
/// <param name="step">当前步骤</param>
public void ShowPracticeStep(AnimationStep step)
{
if (practiceTextBox != null)
{
practiceTextBox.text = step.Description;
}
}
/// <summary>
/// 高亮显示下一个需要点击的地方(教学模式)
/// </summary>
/// <param name="step">当前步骤</param>
public void HighlightNextStep(AnimationStep step)
{
if (highlightObject != null)
{
highlightObject.SetActive(true);
// 假设你有一个方法来定位高亮对象
// highlightObject.transform.position = ...;
}
}
}
}
// using UnityEngine;
// using UnityEngine.UI;
//
// namespace DefaultNamespace.ProcessMode
// {
// public class ProcessUIManager : MonoBehaviour
// {
// public Text trainingTextBox; // 培训模式的文本框
// public Text practiceTextBox; // 练习模式的文本框
// public GameObject highlightObject; // 高亮对象,用于教学模式
//
// public AnimationProcessManager processManager; // 流程管理器实例
//
// private void Start()
// {
// processManager = new AnimationProcessManager(); // 传递UIManager实例
// }
//
// private void Update()
// {
// if (Input.GetMouseButtonDown(0))
// {
// GameObject clickedObject = DetectClickedObject();
// if (clickedObject != null)
// {
// processManager.HandleClick(clickedObject);
// }
// }
// }
//
// /// <summary>
// /// 检测点击的对象
// /// </summary>
// /// <returns>点击的对象</returns>
// private GameObject DetectClickedObject()
// {
// Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// RaycastHit hit;
// if (Physics.Raycast(ray, out hit))
// {
// return hit.collider.gameObject;
// }
//
// return null;
// }
//
// /// <summary>
// /// 显示培训步骤信息
// /// </summary>
// /// <param name="step">当前步骤</param>
// public void ShowTrainingStep(AnimationStep step)
// {
// if (trainingTextBox != null)
// {
// trainingTextBox.text = step.Description;
// }
// }
//
// /// <summary>
// /// 显示练习步骤信息
// /// </summary>
// /// <param name="step">当前步骤</param>
// public void ShowPracticeStep(AnimationStep step)
// {
// if (practiceTextBox != null)
// {
// practiceTextBox.text = step.Description;
// }
// }
//
// /// <summary>
// /// 高亮显示下一个需要点击的地方(教学模式)
// /// </summary>
// /// <param name="step">当前步骤</param>
// public void HighlightNextStep(AnimationStep step)
// {
// if (highlightObject != null)
// {
// highlightObject.SetActive(true);
// // 假设你有一个方法来定位高亮对象
// // highlightObject.transform.position = ...;
// }
// }
// }
// }

View File

@ -1,4 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using MotionFramework;
using UnityEngine;
namespace DefaultNamespace.ProcessMode
@ -7,40 +11,54 @@ namespace DefaultNamespace.ProcessMode
{
private AnimationProcessManager processManager;
public GameObject device1; // 假设这是场景中的一个设备
public GameObject device2; // 假设这是场景中的另一个设备
private void Start()
private IEnumerator Start()
{
processManager = GetComponent<AnimationProcessManager>();
processManager = MotionEngine.GetModule<AnimationProcessManager>();
// 设置模式
processManager.currentMode = ProcessMode.Teaching;
// 创建步骤并避免未初始化的错误
AnimationStep step1 = null;
AnimationStep step2 = null;
yield return new WaitForSeconds(1);
processManager.AddProcess("Teaching");
List<ActionWithDescription> actions = CreateStepActions();
AnimationStep step = new AnimationStep($"描述步骤", 100, actions);
processManager.AddStepToProcess("Teaching", step);
step1 = new AnimationStep("Step 1: Click device1", 10, () =>
{
device1.transform.DOMove(new Vector3(0, 1, 0), 1).OnComplete(() =>
{
processManager.AddStepToProcess("Teaching", step1);
});
}, device1);
// List<ActionWithDescription> actions1 = CreateStepActions1();
// AnimationStep step1 = new AnimationStep($"描述步骤", 100, actions1);
// processManager.AddStepToProcess("Teaching", step1);
}
step2 = new AnimationStep("Step 2: Click device2", 20, () =>
{
device2.transform.DOScale(new Vector3(2, 2, 2), 1).OnComplete(() =>
{
processManager.AddStepToProcess("Teaching", step2);
});
}, device2);
private List<ActionWithDescription> CreateStepActions()
{
List<ActionWithDescription> actions = new List<ActionWithDescription>();
// 向流程中添加步骤
processManager.AddStepToProcess("Teaching", step1);
processManager.AddStepToProcess("Teaching", step2);
GameObject obj1 = GameObject.Find("变电箱_门");
GameObject = GameObject.Find("插座");
Action action1 = () => { };
Action action2 = () => { };
actions.Add(new ActionWithDescription(new List<GameObject>() { obj1, }, action1, $"步骤 {1} 的动作描述"));
actions.Add(new ActionWithDescription(new List<GameObject>() { ,obj1}, action1, $"步骤 {2} 的动作描述"));
return actions;
}
private List<ActionWithDescription> CreateStepActions1()
{
List<ActionWithDescription> actions = new List<ActionWithDescription>();
GameObject obj1 = GameObject.Find("变电箱_门");
GameObject = GameObject.Find("插座");
Action action1 = () => { };
actions.Add(new ActionWithDescription(new List<GameObject>() { obj1 }, action1, $"步骤 {1} 的动作描述"));
actions.Add(new ActionWithDescription(new List<GameObject>() { }, action1, $"步骤 {2} 的动作描述"));
return actions;
}
private void Update()
@ -64,6 +82,7 @@ namespace DefaultNamespace.ProcessMode
{
return hit.collider.gameObject;
}
return null;
}
}

View File

@ -15,7 +15,7 @@ namespace ToolsPack
{
private HighlightEffect _highlight;
private int index;
[SerializeField] private ModelTypeEnum _modelTypeEnum;
[SerializeField] private ModelTypeEnum _modelTypeEnum;
private void Awake()
{

View File

@ -69,7 +69,7 @@ public class ElectricCheckPen : MonoBehaviour
{
ElectricCheckPenOBJ.gameObject.transform.DOLocalMove(new Vector3(3.334f, 0.489f, 0.107f), 1f).OnComplete(() =>
{
ElectricCheckPenOBJ.gameObject.transform.DOLocalRotate(new Vector3(20.78f, 72.47f, 171.503f), 1.5f).OnComplete(() =>
{
Debug.Log("123");