diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 8c6c6110..ebd121cd 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -209,6 +209,10 @@ public class ActionHelper var dictAction = (XMLTool.DictionaryAction)act; return TimeTipAction.Allocate(act.Value, dictAction.args); } + case "StrEvent": + { + return StrEventAction.Allocate(act.Name, act.Value); + } default: Debug.LogError($"没有找到此Action的类型{act.Type}"); break; diff --git a/Assets/Scripts/Actions/StrEventAction.cs b/Assets/Scripts/Actions/StrEventAction.cs new file mode 100644 index 00000000..89c7cea2 --- /dev/null +++ b/Assets/Scripts/Actions/StrEventAction.cs @@ -0,0 +1,77 @@ +using System; +using System.Runtime.CompilerServices; +using UnityEngine; + +namespace QFramework +{ + internal class StrEventAction : IAction + { + public string txt; + + + public System.Action OnFinished { get; set; } + + + private StrEventAction() + { + } + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new StrEventAction(), null, 10); + + string key = string.Empty; + string arg = string.Empty; + public static StrEventAction Allocate(string key, string arg, System.Action OnFinished = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.OnFinished = OnFinished; + retNode.key = key; + retNode.arg = arg; + return retNode; + } + + + public ulong ActionID { get; set; } + public ActionStatus Status { get; set; } + + public void OnStart() + { + StringEventSystem.Global.Send(key, arg.Split(",")); + this.Finish(); + } + + public void OnExecute(float dt) + { + + } + + public void OnFinish() + { + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } + + public bool Paused { get; set; } + + public void Deinit() + { + if (!Deinited) + { + OnFinished = null; + Deinited = true; + mPool.Recycle(this); + } + } + + public bool Deinited { get; set; } + } + + +} \ No newline at end of file diff --git a/Assets/Scripts/Actions/StrEventAction.cs.meta b/Assets/Scripts/Actions/StrEventAction.cs.meta new file mode 100644 index 00000000..d09f31f6 --- /dev/null +++ b/Assets/Scripts/Actions/StrEventAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7a45244e92d067b4495241480cdec7b7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Global/Global.cs b/Assets/Scripts/Global/Global.cs index 7c9cf1f6..339953fd 100644 --- a/Assets/Scripts/Global/Global.cs +++ b/Assets/Scripts/Global/Global.cs @@ -23,6 +23,8 @@ public class Global : Singleton public static string reportDemoPath = reportPath + "Demo.docx"; public static APPSetting appSetting { get; } = new APPSetting(); + public static string HighLightTrigger = "HighLightTrigger"; + public enum AppType { UnKnow = 1 << 0, @@ -33,4 +35,6 @@ public class Global : Singleton public static AppType appTpe = AppType.UnKnow; + + } diff --git a/Assets/Scripts/Item/DeviceItem.cs b/Assets/Scripts/Item/DeviceItem.cs index 0821ed95..2d9a2399 100644 --- a/Assets/Scripts/Item/DeviceItem.cs +++ b/Assets/Scripts/Item/DeviceItem.cs @@ -1,6 +1,7 @@ using HighlightPlus; using QFramework; using QFramework.Example; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -16,6 +17,7 @@ public class DeviceItem : MonoBehaviour var effect = gameObject.GetOrAddComponent(); gameObject.GetOrAddComponent(); effect.outlineColor = Color.green; + StringEventSystem.Global.Register(Global.HighLightTrigger, OnHighLightTriggerEvent).UnRegisterWhenGameObjectDestroyed(gameObject); } if (device.MeshCollider) { @@ -40,6 +42,16 @@ public class DeviceItem : MonoBehaviour } } + private void OnHighLightTriggerEvent(string[] obj) + { + if (obj.Length > 0) + { + bool isActive = true; + bool.TryParse(obj[0], out isActive); + gameObject.GetComponent().enabled = isActive; + } + } + private void OnMouseUpAsButton() { var effect = gameObject.GetComponent(); diff --git a/Doc/Xml閰嶇疆鏂囨。.xml b/Doc/Xml閰嶇疆鏂囨。.xml index 3e3e6975..080cfa82 100644 --- a/Doc/Xml閰嶇疆鏂囨。.xml +++ b/Doc/Xml閰嶇疆鏂囨。.xml @@ -121,6 +121,14 @@ + + + +