扩展功能 show 支持root

This commit is contained in:
shenjianxing 2025-01-04 15:20:16 +08:00
parent 4e33c3b66f
commit cc1f9e7498
2 changed files with 18 additions and 1 deletions

View File

@ -20,6 +20,7 @@ public class ShowAction : IAction
string isShow = string.Empty;
string deviceName = string.Empty;
string isDevice = string.Empty;
string isRoot = string.Empty;
public static ShowAction Allocate(string path, Dictionary<string, string> datas, System.Action onDelayFinish = null)
{
var retNode = mPool.Allocate();
@ -30,6 +31,7 @@ public class ShowAction : IAction
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;
retNode.isRoot = datas.ContainsKey("isRoot") ? datas["isRoot"] : null;
return retNode;
}
@ -79,8 +81,18 @@ public class ShowAction : IAction
{
bool isActive = true;
bool.TryParse(isShow, out isActive);
if (string.IsNullOrEmpty(isRoot))
{
obj.SetActive(isActive);
}
else if (isRoot == "true")
{
for (int i = 0; i < obj.transform.childCount; i++)
{
obj.transform.GetChild(i).gameObject.SetActive(isActive);
}
}
}
this.Finish();
}

View File

@ -593,6 +593,11 @@ namespace XMLTool
{
act.args.Add("deviceName", deviceName.Value);
}
XAttribute isRoot = action.Attribute("isRoot");
if (isRoot != null)
{
act.args.Add("isRoot", isRoot.Value);
}
newAction = act;
}
break;