新增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":
|
case "UIClick":
|
||||||
return UIClickCondition.Allocate(condition.Value);
|
return UIClickCondition.Allocate(condition.Value);
|
||||||
case "ObjClick":
|
case "ObjClick":
|
||||||
return ObjClickCondition.Allocate(condition.Value);
|
var dict = (XMLTool.DictionaryCondition)condition;
|
||||||
|
return ObjClickCondition.Allocate(dict.Value, dict.args);
|
||||||
case "Input":
|
case "Input":
|
||||||
return InputCondition.Allocate(condition.Value);
|
return InputCondition.Allocate(condition.Value);
|
||||||
case "Var":
|
case "Var":
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
@ -14,21 +15,30 @@ namespace QFramework
|
|||||||
private ObjClickCondition() { }
|
private ObjClickCondition() { }
|
||||||
public GameObject obj = null;
|
public GameObject obj = null;
|
||||||
string path;
|
string path;
|
||||||
public static ObjClickCondition Allocate(string path)
|
string deviceName;
|
||||||
|
public static ObjClickCondition Allocate(string path, Dictionary<string, string> datas)
|
||||||
{
|
{
|
||||||
var conditionAction = mSimpleObjectPool.Allocate();
|
var conditionAction = mSimpleObjectPool.Allocate();
|
||||||
conditionAction.ActionID = ActionKit.ID_GENERATOR++;
|
conditionAction.ActionID = ActionKit.ID_GENERATOR++;
|
||||||
conditionAction.Deinited = false;
|
conditionAction.Deinited = false;
|
||||||
conditionAction.Reset();
|
conditionAction.Reset();
|
||||||
conditionAction.path = path;
|
conditionAction.path = path;
|
||||||
|
conditionAction.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : null;
|
||||||
return conditionAction;
|
return conditionAction;
|
||||||
}
|
}
|
||||||
public bool Check()
|
public bool Check()
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(deviceName))
|
||||||
{
|
{
|
||||||
obj = Utility.FindObj(path);
|
obj = Utility.FindObj(path);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obj = DeviceController.Instance.GetDeviceObj(deviceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (obj != null && Input.GetMouseButtonUp(0))
|
if (obj != null && Input.GetMouseButtonUp(0))
|
||||||
{
|
{
|
||||||
Vector3 mousePos = Input.mousePosition;
|
Vector3 mousePos = Input.mousePosition;
|
||||||
@ -79,11 +89,11 @@ namespace QFramework
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ObjClickConditionExtension
|
//public static class ObjClickConditionExtension
|
||||||
{
|
//{
|
||||||
public static ISequence ObjClickCondition(this ISequence self, string uipath)
|
// public static ISequence ObjClickCondition(this ISequence self, string uipath)
|
||||||
{
|
// {
|
||||||
return self.Append(QFramework.ObjClickCondition.Allocate(uipath));
|
// return self.Append(QFramework.ObjClickCondition.Allocate(uipath));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
@ -1040,13 +1040,29 @@ namespace XMLTool
|
|||||||
|
|
||||||
public static Condition ParseCondition(XElement action)
|
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,
|
case "ObjClick":
|
||||||
Name = action.Attribute("name")?.Value,
|
var act = new DictionaryCondition();
|
||||||
Value = action.Attribute("value")?.Value,
|
|
||||||
SubActions = ParseActions(action)
|
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;
|
return newAction;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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" value="物体路径 可以使用快捷键Ctrl+Q获取"></Condition>
|
<Condition type="ObjClick" deviceName="" value="物体路径 可以使用快捷键Ctrl+Q获取" ></Condition>
|
||||||
<!--判断键盘输入-->
|
<!--判断键盘输入-->
|
||||||
<Condition type="Input" value="A"></Condition>
|
<Condition type="Input" value="A"></Condition>
|
||||||
<!--判断变量名i是否等于1-->
|
<!--判断变量名i是否等于1-->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user