From f47ddf5c86a8824703b6026b823650d88ffe727a Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Tue, 7 Jan 2025 17:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=E8=B7=B3=E6=AD=A5=20=E4=B8=8D?= =?UTF-8?q?=E6=89=A7=E8=A1=8Cfinished?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/NextOperationAction.cs | 7 +++-- Assets/Scripts/Controller/DeviceController.cs | 26 +++++++++++++++++++ .../Scripts/Controller/OperationController.cs | 12 ++++++++- Assets/Scripts/Item/DeviceItem.cs | 8 +++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Actions/NextOperationAction.cs b/Assets/Scripts/Actions/NextOperationAction.cs index 403c2032..697707ee 100644 --- a/Assets/Scripts/Actions/NextOperationAction.cs +++ b/Assets/Scripts/Actions/NextOperationAction.cs @@ -15,7 +15,7 @@ namespace QFramework private static readonly SimpleObjectPool mPool = new SimpleObjectPool(() => new NextOperationAction(), null, 10); - public static NextOperationAction Allocate( System.Action OnFinished = null) + public static NextOperationAction Allocate(System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; @@ -31,7 +31,6 @@ namespace QFramework public void OnStart() { - TypeEventSystem.Global.Send(); } public void OnExecute(float dt) @@ -56,6 +55,10 @@ namespace QFramework { if (!Deinited) { + if (Status != ActionStatus.NotStart) + { + TypeEventSystem.Global.Send(); + } OnFinished = null; Deinited = true; mPool.Recycle(this); diff --git a/Assets/Scripts/Controller/DeviceController.cs b/Assets/Scripts/Controller/DeviceController.cs index 097e73bd..09a22be4 100644 --- a/Assets/Scripts/Controller/DeviceController.cs +++ b/Assets/Scripts/Controller/DeviceController.cs @@ -1,9 +1,11 @@ using HighlightPlus; using QFramework; +using QFramework.Example; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.EventSystems; using XMLTool; public class DeviceController : MonoSingleton @@ -61,7 +63,31 @@ public class DeviceController : MonoSingleton return GetDeviceItem(name)?.gameObject; } + private void Update() + { + var uitip = UIKit.GetPanel(); + if (uitip != null) + { + UIKit.OpenPanelAsync(UILevel.PopUI).ToAction().Start(this, () => + { + }); + } + Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); + RaycastHit hit; + if (Physics.Raycast(ray, out hit)) + { + var deviceItem = hit.transform.GetComponent(); + if (uitip != null && deviceItem != null && deviceItem.tipItem != null && EventSystem.current.IsPointerOverGameObject() == false) + { + uitip.Set(deviceItem.tipItem.label); + uitip.Active(true); + return; + } + } + uitip?.Active(false); + + } public DeviceItem GetDeviceItem(string name) { if (deviceDict.ContainsKey(name)) diff --git a/Assets/Scripts/Controller/OperationController.cs b/Assets/Scripts/Controller/OperationController.cs index 07853dce..cbeb9eab 100644 --- a/Assets/Scripts/Controller/OperationController.cs +++ b/Assets/Scripts/Controller/OperationController.cs @@ -116,6 +116,10 @@ public class OperationController : MonoSingleton public void Execute(int targetIndex) { + if (this.index == targetIndex) + { + return; + } if (isStepRun) { curAction?.Deinit(); @@ -127,7 +131,13 @@ public class OperationController : MonoSingleton var seq = ActionKit.Sequence(); if (this.index >= 0) { - for (int i = this.index; i < targetIndex; i++) + int startIndex = this.index; + // ǰⲽ Ѿ Ҫfinished + if (curAction != null && curAction.Status == ActionStatus.Finished) + { + startIndex += 1; + } + for (int i = startIndex; i < targetIndex; i++) { // ɶ ֱִ IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished); diff --git a/Assets/Scripts/Item/DeviceItem.cs b/Assets/Scripts/Item/DeviceItem.cs index 2d9a2399..03612200 100644 --- a/Assets/Scripts/Item/DeviceItem.cs +++ b/Assets/Scripts/Item/DeviceItem.cs @@ -9,6 +9,7 @@ using UnityEngine; public class DeviceItem : MonoBehaviour { public XMLTool.Device device; + public TipItem tipItem; public void Init(XMLTool.Device device) { this.device = device; @@ -34,11 +35,8 @@ public class DeviceItem : MonoBehaviour } if (string.IsNullOrEmpty(device.Tip) == false) { - gameObject.AddComponent().Set(device.Tip); - } - else - { - gameObject.AddComponent().Set(device.Name); + tipItem = gameObject.GetOrAddComponent(); + tipItem.Set(device.Tip); } }