新增物体高亮Action
This commit is contained in:
parent
8d6b8d51b6
commit
3fc72569c5
@ -156,6 +156,11 @@ public class ActionHelper
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return VideoAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3]);
|
||||
}
|
||||
case "HighLight":
|
||||
{
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return HighLightAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XMLTool.Condition condition:
|
||||
|
||||
102
Assets/Scripts/Actions/HighLightAction.cs
Normal file
102
Assets/Scripts/Actions/HighLightAction.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using HighlightPlus;
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFramework
|
||||
{
|
||||
internal class HighLightAction : IAction
|
||||
{
|
||||
|
||||
|
||||
public System.Action OnFinished { get; set; }
|
||||
|
||||
|
||||
private HighLightAction()
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly SimpleObjectPool<HighLightAction> mPool =
|
||||
new SimpleObjectPool<HighLightAction>(() => new HighLightAction(), null, 10);
|
||||
|
||||
string path;
|
||||
Color color = Color.green;
|
||||
bool isHigh = true;
|
||||
public static HighLightAction Allocate(string path, string isHigh, string color, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
retNode.Deinited = false;
|
||||
retNode.Reset();
|
||||
retNode.path = path;
|
||||
if (string.IsNullOrEmpty(color) == false)
|
||||
{
|
||||
retNode.color = Utility.ToColor(color);
|
||||
}
|
||||
bool.TryParse(isHigh, out retNode.isHigh);
|
||||
retNode.OnFinished = OnFinished;
|
||||
return retNode;
|
||||
}
|
||||
|
||||
|
||||
public ulong ActionID { get; set; }
|
||||
public ActionStatus Status { get; set; }
|
||||
|
||||
public void OnStart()
|
||||
{
|
||||
GameObject obj = Utility.FindObj(path);
|
||||
if (obj != null)
|
||||
{
|
||||
if (isHigh)
|
||||
{
|
||||
var effect = obj.GetOrAddComponent<HighlightEffect>();
|
||||
obj.GetOrAddComponent<HighlightTrigger>();
|
||||
effect.outlineColor = color;
|
||||
effect.highlighted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var effect = obj.GetComponent<HighlightEffect>();
|
||||
if (effect)
|
||||
{
|
||||
effect.highlighted = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void OnExecute(float dt)
|
||||
{
|
||||
this.Finish();
|
||||
OnFinished?.Invoke();
|
||||
}
|
||||
|
||||
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/HighLightAction.cs.meta
Normal file
11
Assets/Scripts/Actions/HighLightAction.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 491e5e519156b5e4f9591a0221d5b824
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -633,6 +633,30 @@ namespace XMLTool
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
case "HighLight":
|
||||
{
|
||||
var act = new StringListAction();
|
||||
XAttribute isHigh = action.Attribute("isHigh");
|
||||
if (isHigh != null)
|
||||
{
|
||||
act.args.Add(isHigh.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("true");
|
||||
}
|
||||
XAttribute color = action.Attribute("color");
|
||||
if (color != null)
|
||||
{
|
||||
act.args.Add(color.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("");
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
newAction = new Action();
|
||||
break;
|
||||
|
||||
@ -49,7 +49,10 @@
|
||||
|
||||
<!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow-->
|
||||
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false"></Action>
|
||||
|
||||
<!--设置物体高亮 value是物体路径 color是rgba isHigh设置是否显示高亮-->
|
||||
<Action type="HighLight" value="路径" isHigh="true" color="0,255,0,255"></Action>
|
||||
<!--延迟 value是秒-->
|
||||
<Action type="Delay" value="2"></Action>
|
||||
|
||||
|
||||
<!--判断UI点击-->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user