89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using MotionFramework;
|
|
using UnityEngine;
|
|
|
|
namespace DefaultNamespace.ProcessMode
|
|
{
|
|
public class test : MonoBehaviour
|
|
{
|
|
private AnimationProcessManager processManager;
|
|
|
|
|
|
private IEnumerator Start()
|
|
{
|
|
processManager = MotionEngine.GetModule<AnimationProcessManager>();
|
|
|
|
|
|
yield return new WaitForSeconds(1);
|
|
|
|
|
|
processManager.AddProcess("Teaching");
|
|
|
|
List<ActionWithDescription> actions = CreateStepActions();
|
|
AnimationStep step = new AnimationStep($"描述步骤", 100, actions);
|
|
processManager.AddStepToProcess("Teaching", step);
|
|
|
|
|
|
// List<ActionWithDescription> actions1 = CreateStepActions1();
|
|
// AnimationStep step1 = new AnimationStep($"描述步骤", 100, actions1);
|
|
// processManager.AddStepToProcess("Teaching", step1);
|
|
}
|
|
|
|
private List<ActionWithDescription> CreateStepActions()
|
|
{
|
|
List<ActionWithDescription> actions = new List<ActionWithDescription>();
|
|
|
|
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()
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
} |