扩展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);
case "Show":
{
var strAction = (XMLTool.StringListAction)act;
return ShowAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
var strAction = (XMLTool.DictionaryAction)act;
return ShowAction.Allocate(act.Value, strAction.args);
}
case "TextTip":
{

View File

@ -25,6 +25,7 @@ namespace QFramework
Animation anim;
string frame;
string speed;
string deviceName;
public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
@ -35,6 +36,7 @@ namespace QFramework
retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : "";
retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : "";
retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : "";
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : "";
retNode.OnFinished = OnFinished;
return retNode;
}
@ -43,7 +45,15 @@ namespace QFramework
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)
{
try

View File

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

View File

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

View File

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