新增高亮支持deviceName

This commit is contained in:
shenjianxing 2024-12-27 14:08:27 +08:00
parent d65de1e6c2
commit ed2f790dd3
4 changed files with 36 additions and 21 deletions

View File

@ -159,8 +159,8 @@ public class ActionHelper
} }
case "HighLight": case "HighLight":
{ {
var strAction = (XMLTool.StringListAction)act; var strAction = (XMLTool.DictionaryAction)act;
return HighLightAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); return HighLightAction.Allocate(act.Value, strAction.args);
} }
case "LoadRes": case "LoadRes":
{ {

View File

@ -1,5 +1,6 @@
using HighlightPlus; using HighlightPlus;
using System; using System;
using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -22,18 +23,26 @@ namespace QFramework
string path; string path;
Color color = Color.green; Color color = Color.green;
bool isHigh = true; bool isHigh = true;
public static HighLightAction Allocate(string path, string isHigh, string color, System.Action OnFinished = null) string deviceName = string.Empty;
public static HighLightAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false; retNode.Deinited = false;
retNode.Reset(); retNode.Reset();
retNode.path = path; retNode.path = path;
if (string.IsNullOrEmpty(color) == false)
if (datas.ContainsKey("color"))
{ {
retNode.color = Utility.ToColor(color);
retNode.color = Utility.ToColor(datas["color"]);
} }
bool.TryParse(isHigh, out retNode.isHigh); if (datas.ContainsKey("isHigh"))
{
bool.TryParse(datas["isHigh"], out retNode.isHigh);
}
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
retNode.OnFinished = OnFinished; retNode.OnFinished = OnFinished;
return retNode; return retNode;
} }
@ -44,7 +53,16 @@ namespace QFramework
public void OnStart() public void OnStart()
{ {
GameObject obj = Utility.FindObj(path); GameObject obj = null;
if (string.IsNullOrEmpty(deviceName) == false)
{
obj = DeviceController.Instance.GetDeviceObj(deviceName);
}
else
{
obj = Utility.FindObj(path);
}
if (obj != null) if (obj != null)
{ {
if (isHigh) if (isHigh)

View File

@ -763,24 +763,21 @@ namespace XMLTool
break; break;
case "HighLight": case "HighLight":
{ {
var act = new StringListAction(); var act = new DictionaryAction();
XAttribute isHigh = action.Attribute("isHigh"); XAttribute isHigh = action.Attribute("isHigh");
if (isHigh != null) if (isHigh != null)
{ {
act.args.Add(isHigh.Value); act.args.Add("isHigh", isHigh.Value);
}
else
{
act.args.Add("true");
} }
XAttribute color = action.Attribute("color"); XAttribute color = action.Attribute("color");
if (color != null) if (color != null)
{ {
act.args.Add(color.Value); act.args.Add("color", color.Value);
} }
else XAttribute deviceName = action.Attribute("deviceName");
if (deviceName != null)
{ {
act.args.Add(""); act.args.Add("deviceName", deviceName.Value);
} }
newAction = act; newAction = act;
} }

View File

@ -57,8 +57,8 @@
<!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow isDevice为true的话 value就要写device配置的Name--> <!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow isDevice为true的话 value就要写device配置的Name-->
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false" isDevice="false"></Action> <Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false" isDevice="false"></Action>
<!--设置物体高亮 value是物体路径 color是rgba isHigh设置是否显示高亮--> <!--设置物体高亮 deviceName可以用于设备名字 value是物体路径 color是rgba isHigh设置是否显示高亮-->
<Action type="HighLight" value="路径" isHigh="true" color="0,255,0,255"></Action> <Action type="HighLight" deviceName="设备名字" value="路径" isHigh="true" color="0,255,0,255"></Action>
<!--延迟 value是秒--> <!--延迟 value是秒-->
<Action type="Delay" value="2"></Action> <Action type="Delay" value="2"></Action>
<!-- <!--
@ -72,8 +72,8 @@
<!--判断UI点击--> <!--判断UI点击-->
<Condition type="UIClick" value="UI路径 可以使用快捷键Ctrl+Q获取"></Condition> <Condition type="UIClick" value="UI路径 可以使用快捷键Ctrl+Q获取"></Condition>
<!--判断物体点击 deviceName支持设备点击判断 有deviceName的情况下忽略value--> <!--判断物体点击-->
<Condition type="ObjClick" deviceName="" value="物体路径 可以使用快捷键Ctrl+Q获取" ></Condition> <Condition type="ObjClick" value="物体路径 可以使用快捷键Ctrl+Q获取"></Condition>
<!--判断键盘输入--> <!--判断键盘输入-->
<Condition type="Input" value="A"></Condition> <Condition type="Input" value="A"></Condition>
<!--判断变量名i是否等于1--> <!--判断变量名i是否等于1-->