新增objclick适配deviceName
This commit is contained in:
parent
6bceb42936
commit
d65de1e6c2
@ -24,6 +24,9 @@ namespace XMLTool
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class DictionaryCondition : Condition
|
||||
{
|
||||
public Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -237,7 +237,8 @@ public class ActionHelper
|
||||
case "UIClick":
|
||||
return UIClickCondition.Allocate(condition.Value);
|
||||
case "ObjClick":
|
||||
return ObjClickCondition.Allocate(condition.Value);
|
||||
var dict = (XMLTool.DictionaryCondition)condition;
|
||||
return ObjClickCondition.Allocate(dict.Value, dict.args);
|
||||
case "Input":
|
||||
return InputCondition.Allocate(condition.Value);
|
||||
case "Var":
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@ -14,20 +15,29 @@ namespace QFramework
|
||||
private ObjClickCondition() { }
|
||||
public GameObject obj = null;
|
||||
string path;
|
||||
public static ObjClickCondition Allocate(string path)
|
||||
string deviceName;
|
||||
public static ObjClickCondition Allocate(string path, Dictionary<string, string> datas)
|
||||
{
|
||||
var conditionAction = mSimpleObjectPool.Allocate();
|
||||
conditionAction.ActionID = ActionKit.ID_GENERATOR++;
|
||||
conditionAction.Deinited = false;
|
||||
conditionAction.Reset();
|
||||
conditionAction.path = path;
|
||||
conditionAction.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : null;
|
||||
return conditionAction;
|
||||
}
|
||||
public bool Check()
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
obj = Utility.FindObj(path);
|
||||
if (string.IsNullOrEmpty(deviceName))
|
||||
{
|
||||
obj = Utility.FindObj(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = DeviceController.Instance.GetDeviceObj(deviceName);
|
||||
}
|
||||
}
|
||||
if (obj != null && Input.GetMouseButtonUp(0))
|
||||
{
|
||||
@ -79,11 +89,11 @@ namespace QFramework
|
||||
}
|
||||
}
|
||||
|
||||
public static class ObjClickConditionExtension
|
||||
{
|
||||
public static ISequence ObjClickCondition(this ISequence self, string uipath)
|
||||
{
|
||||
return self.Append(QFramework.ObjClickCondition.Allocate(uipath));
|
||||
}
|
||||
}
|
||||
//public static class ObjClickConditionExtension
|
||||
//{
|
||||
// public static ISequence ObjClickCondition(this ISequence self, string uipath)
|
||||
// {
|
||||
// return self.Append(QFramework.ObjClickCondition.Allocate(uipath));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@ -1040,13 +1040,29 @@ namespace XMLTool
|
||||
|
||||
public static Condition ParseCondition(XElement action)
|
||||
{
|
||||
Condition newAction = new Condition
|
||||
Condition newAction = null;
|
||||
string type = action.Attribute("type")?.Value;
|
||||
switch (type)
|
||||
{
|
||||
Type = action.Attribute("type")?.Value,
|
||||
Name = action.Attribute("name")?.Value,
|
||||
Value = action.Attribute("value")?.Value,
|
||||
SubActions = ParseActions(action)
|
||||
};
|
||||
case "ObjClick":
|
||||
var act = new DictionaryCondition();
|
||||
|
||||
XAttribute deviceName = action.Attribute("deviceName");
|
||||
if (deviceName != null)
|
||||
{
|
||||
act.args.Add("deviceName", deviceName.Value);
|
||||
}
|
||||
newAction = act;
|
||||
break;
|
||||
default:
|
||||
newAction = new Condition();
|
||||
break;
|
||||
}
|
||||
newAction.Type = type;
|
||||
newAction.Name = action.Attribute("name")?.Value;
|
||||
newAction.Value = action.Attribute("value")?.Value;
|
||||
newAction.SubActions = ParseActions(action);
|
||||
|
||||
return newAction;
|
||||
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@
|
||||
|
||||
<!--判断UI点击-->
|
||||
<Condition type="UIClick" value="UI路径 可以使用快捷键Ctrl+Q获取"></Condition>
|
||||
<!--判断物体点击-->
|
||||
<Condition type="ObjClick" value="物体路径 可以使用快捷键Ctrl+Q获取"></Condition>
|
||||
<!--判断物体点击 deviceName支持设备点击判断 有deviceName的情况下忽略value-->
|
||||
<Condition type="ObjClick" deviceName="" value="物体路径 可以使用快捷键Ctrl+Q获取" ></Condition>
|
||||
<!--判断键盘输入-->
|
||||
<Condition type="Input" value="A"></Condition>
|
||||
<!--判断变量名i是否等于1-->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user