扩展objclick 支持反向判断

This commit is contained in:
shenjianxing 2025-01-02 14:45:55 +08:00
parent ed940235af
commit f5846b0919
3 changed files with 21 additions and 3 deletions

View File

@ -16,6 +16,7 @@ namespace QFramework
public GameObject obj = null;
string path;
string deviceName;
bool isRight;
public static ObjClickCondition Allocate(string path, Dictionary<string, string> datas)
{
var conditionAction = mSimpleObjectPool.Allocate();
@ -24,6 +25,11 @@ namespace QFramework
conditionAction.Reset();
conditionAction.path = path;
conditionAction.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : null;
conditionAction.isRight = true;
if (datas.ContainsKey("isRight"))
{
bool.TryParse(datas["isRight"], out conditionAction.isRight);
}
return conditionAction;
}
public bool Check()
@ -46,7 +52,14 @@ namespace QFramework
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
return obj == hit.collider.gameObject;
if (isRight)
{
return obj == hit.collider.gameObject;
}
else
{
return obj != hit.collider.gameObject;
}
}
}
return false;

View File

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

View File

@ -79,8 +79,8 @@
<!--判断UI点击-->
<Condition type="UIClick" value="UI路径 可以使用快捷键Ctrl+Q获取"></Condition>
<!--判断物体点击-->
<Condition type="ObjClick" value="物体路径 可以使用快捷键Ctrl+Q获取"></Condition>
<!--判断物体点击 isRight = true 则点击到目标物体 才算满足 false 则点击了其他物体就满足 常用于错误的点击-->
<Condition type="ObjClick" value="物体路径 可以使用快捷键Ctrl+Q获取" isRight="true"></Condition>
<!--判断键盘输入-->
<Condition type="Input" value="A"></Condition>
<!--判断变量名i是否等于1-->