using System; using System.Collections; using System.Collections.Generic; using DefaultNamespace.Dto; using DG.Tweening; using MotionFramework; using Newtonsoft.Json; using UnityEngine; namespace DefaultNamespace.ProcessMode { public class test : MonoBehaviour { private AnimationProcessManager processManager; private IEnumerator Start() { processManager = MotionEngine.GetModule(); yield return new WaitForSeconds(1); processManager.AddProcess("Teaching"); string json = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/DataConfig/StepData.json"); StepsContainer stepsContainer = JsonConvert.DeserializeObject(json); foreach (var stepData in stepsContainer.Steps) { List actions = new List(); foreach (var actionData in stepData.Actions) { List targetObjects = new List(); foreach (var objectName in actionData.TargetObjects) { GameObject obj = GameObject.Find(objectName); if (obj != null) { targetObjects.Add(obj); } else { Debug.LogError($"Object not found: {objectName}"); } } Action action = () => { Debug.Log(actionData.Description); }; actions.Add(new ActionWithDescription(targetObjects, action, actionData.Description, actionData.IsSequential)); } AnimationStep step = new AnimationStep(stepData.StepDescription, stepData.Score, actions); processManager.AddStepToProcess("Teaching", step); } } // private List CreateStepActions() // { // List actions = new List(); // // GameObject obj1 = GameObject.Find("变电箱_门"); // GameObject 插座 = GameObject.Find("插座"); // Action action1 = () => { }; // Action action2 = () => { }; // // actions.Add(new ActionWithDescription(new List() { obj1,插座 }, action1, $"步骤 {1} 的动作描述")); // actions.Add(new ActionWithDescription(new List() { 插座,obj1}, action1, $"步骤 {2} 的动作描述")); // // return actions; // } // // private List CreateStepActions1() // { // List actions = new List(); // // GameObject obj1 = GameObject.Find("变电箱_门"); // GameObject 插座 = GameObject.Find("插座"); // Action action1 = () => { }; // // actions.Add(new ActionWithDescription(new List() { obj1 }, action1, $"步骤 {1} 的动作描述")); // actions.Add(new ActionWithDescription(new List() { 插座 }, action1, $"步骤 {2} 的动作描述")); // // return actions; // } // private void Update() // { // if (Input.GetMouseButtonDown(0)) // { // // 假设您有方法来检测点击对象 // GameObject clickedObject = DetectClickedObject(); // if (clickedObject != null) // { // processManager.HandleClick(clickedObject); // } // } // } // // private GameObject DetectClickedObject() // { // Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // RaycastHit hit; // if (Physics.Raycast(ray, out hit)) // { // return hit.collider.gameObject; // } // // return null; // } } }