新增通用字符串通知
This commit is contained in:
parent
448bab5f03
commit
1de8149678
@ -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;
|
||||
|
||||
77
Assets/Scripts/Actions/StrEventAction.cs
Normal file
77
Assets/Scripts/Actions/StrEventAction.cs
Normal file
@ -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<StrEventAction> mPool =
|
||||
new SimpleObjectPool<StrEventAction>(() => 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; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Actions/StrEventAction.cs.meta
Normal file
11
Assets/Scripts/Actions/StrEventAction.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a45244e92d067b4495241480cdec7b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -23,6 +23,8 @@ public class Global : Singleton<Global>
|
||||
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<Global>
|
||||
|
||||
public static AppType appTpe = AppType.UnKnow;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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<HighlightEffect>();
|
||||
gameObject.GetOrAddComponent<HighlightTrigger>();
|
||||
effect.outlineColor = Color.green;
|
||||
StringEventSystem.Global.Register<string[]>(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<HighlightTrigger>().enabled = isActive;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseUpAsButton()
|
||||
{
|
||||
var effect = gameObject.GetComponent<HighlightEffect>();
|
||||
|
||||
@ -121,6 +121,14 @@
|
||||
<Action type="TimeTip" value="这里是文字描述<color=#FF00FF>{0}</color>-{1}" time="5" values="5,10|50,100" format="{0:F1}" finishedEvent="close" needClick="false" reverse="false" ></Action>
|
||||
|
||||
|
||||
|
||||
<!--通用事件通知
|
||||
|
||||
HighLightTrigger:value=false 关闭device悬浮高亮 value=true 开启
|
||||
|
||||
-->
|
||||
<Action type="StrEvent" name="HighLightTrigger" value="false"></Action>
|
||||
|
||||
<!--预加载模块 要在app.xml的Data标签内-->
|
||||
<PreLoad>
|
||||
<Action type="Parallel">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user