扩展show的参数 支持deviceName

animAction 支持deviceName
This commit is contained in:
shenjianxing 2025-01-02 14:19:47 +08:00
parent 7e1a45c50c
commit ed940235af
5 changed files with 51 additions and 27 deletions

View File

@ -130,8 +130,8 @@ public class ActionHelper
return SetVarAction.Allocate(act.Name, act.Value); return SetVarAction.Allocate(act.Name, act.Value);
case "Show": case "Show":
{ {
var strAction = (XMLTool.StringListAction)act; var strAction = (XMLTool.DictionaryAction)act;
return ShowAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); return ShowAction.Allocate(act.Value, strAction.args);
} }
case "TextTip": case "TextTip":
{ {

View File

@ -25,6 +25,7 @@ namespace QFramework
Animation anim; Animation anim;
string frame; string frame;
string speed; string speed;
string deviceName;
public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null) public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
@ -35,6 +36,7 @@ namespace QFramework
retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : ""; retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : "";
retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : ""; retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : "";
retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : ""; retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : "";
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : "";
retNode.OnFinished = OnFinished; retNode.OnFinished = OnFinished;
return retNode; return retNode;
} }
@ -43,7 +45,15 @@ namespace QFramework
public void OnStart() public void OnStart()
{ {
GameObject obj = Utility.FindObj(path); GameObject obj = null;
if (string.IsNullOrEmpty(deviceName))
{
obj = Utility.FindObj(path);
}
else
{
obj = DeviceController.Instance.GetDeviceObj(deviceName);
}
if (obj != null) if (obj != null)
{ {
try try

View File

@ -17,17 +17,19 @@ public class ShowAction : IAction
private static readonly SimpleObjectPool<ShowAction> mPool = private static readonly SimpleObjectPool<ShowAction> mPool =
new SimpleObjectPool<ShowAction>(() => new ShowAction(), null, 10); new SimpleObjectPool<ShowAction>(() => new ShowAction(), null, 10);
string path; string path;
bool isShow = true; string isShow = string.Empty;
bool isDevice = false; string deviceName = string.Empty;
public static ShowAction Allocate(string path, string isShow, string isDevice, System.Action onDelayFinish = null) string isDevice = string.Empty;
public static ShowAction Allocate(string path, Dictionary<string, string> datas, System.Action onDelayFinish = 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;
bool.TryParse(isShow, out retNode.isShow); retNode.isShow = datas.ContainsKey("isShow") ? datas["isShow"] : string.Empty;
bool.TryParse(isDevice, out retNode.isDevice); retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
retNode.isDevice = datas.ContainsKey("isDevice") ? datas["isDevice"] : string.Empty;
return retNode; return retNode;
} }
@ -53,22 +55,31 @@ public class ShowAction : IAction
public void OnStart() public void OnStart()
{ {
GameObject obj = null; GameObject obj = null;
if (isDevice) if (string.IsNullOrEmpty(deviceName) == false)
{
obj = DeviceController.Instance.GetDeviceObj(deviceName);
}
else
{
if (string.IsNullOrEmpty(isDevice) == false && isDevice == "true")
{ {
obj = DeviceController.Instance.GetDeviceObj(path); obj = DeviceController.Instance.GetDeviceObj(path);
} }
else else
{ {
obj = Utility.FindObj(path); obj = Utility.FindObj(path);
} }
}
if (obj == null) if (obj == null)
{ {
Debug.LogError("ûÓÐÕÒµ½ÎïÌå :" + path); Debug.LogError("ûÓÐÕÒµ½ÎïÌå :" + path);
} }
else else
{ {
obj.SetActive(isShow); bool isActive = true;
bool.TryParse(isShow, out isActive);
obj.SetActive(isActive);
} }
this.Finish(); this.Finish();

View File

@ -374,7 +374,11 @@ namespace XMLTool
{ {
act.args.Add("speed", speed.Value); act.args.Add("speed", speed.Value);
} }
var deviceName = action.Attribute("deviceName");
if (deviceName != null)
{
act.args.Add("deviceName", deviceName.Value);
}
newAction = act; newAction = act;
} }
break; break;
@ -572,25 +576,22 @@ namespace XMLTool
break; break;
case "Show": case "Show":
{ {
var act = new StringListAction(); var act = new DictionaryAction();
XAttribute isShow = action.Attribute("isShow"); XAttribute isShow = action.Attribute("isShow");
if (isShow != null) if (isShow != null)
{ {
act.args.Add(isShow.Value); act.args.Add("isShow",isShow.Value);
}
else
{
act.args.Add("true");
} }
XAttribute isDevice = action.Attribute("isDevice"); XAttribute isDevice = action.Attribute("isDevice");
if (isDevice != null) if (isDevice != null)
{ {
act.args.Add(isDevice.Value); act.args.Add("isDevice", isDevice.Value);
} }
else XAttribute deviceName = action.Attribute("deviceName");
if (deviceName != null)
{ {
act.args.Add("false"); act.args.Add("deviceName", deviceName.Value);
} }
newAction = act; newAction = act;
} }

View File

@ -17,8 +17,8 @@
<Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action> <Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action>
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步--> <!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
<Action type="NextOperation"></Action> <Action type="NextOperation"></Action>
<!--播放动画 reset=true则动画停在第一帧 frame是指定格在动画的某一帧 如果为-1 正常播放动画 speed 动画播放速度 默认为1 --> <!--播放动画 reset=true则动画停在第一帧 frame是指定格在动画的某一帧 如果为-1 正常播放动画 speed 动画播放速度 默认为1 deviceName与物体路径二选一 -->
<Action type="Anim" value="物体路径" animName="动画名字" frame="-1" speed="1"></Action> <Action type="Anim" value="物体路径" deviceName="" animName="动画名字" frame="-1" speed="1"></Action>
<!--右下角生成按钮 可生成多个 用逗号分开--> <!--右下角生成按钮 可生成多个 用逗号分开-->
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action> <Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key --> <!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key -->
@ -60,8 +60,10 @@
宽度不要小于500 否则进度条看不太清楚--> 宽度不要小于500 否则进度条看不太清楚-->
<Action type="Video" value="test.mp4" size="500,500" offset="10,10" finishedEvent="finished" closeEvent="close"></Action> <Action type="Video" value="test.mp4" size="500,500" offset="10,10" finishedEvent="finished" closeEvent="close"></Action>
<!--物体显隐 用于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> 如果deviceName存在 则不用isDevice
-->
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" deviceName="设备名字" isShow="false" isDevice="false"></Action>
<!--设置物体高亮 deviceName可以用于设备名字 value是物体路径 color是rgba isHigh设置是否显示高亮--> <!--设置物体高亮 deviceName可以用于设备名字 value是物体路径 color是rgba isHigh设置是否显示高亮-->
<Action type="HighLight" deviceName="设备名字" value="路径" isHigh="true" color="0,255,0,255"></Action> <Action type="HighLight" deviceName="设备名字" value="路径" isHigh="true" color="0,255,0,255"></Action>
<!--延迟 value是秒--> <!--延迟 value是秒-->