summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-03-10 14:07:40 +0800
committerchai <chaifix@163.com>2022-03-10 14:07:40 +0800
commit22891bf59032ba88262824255a706d652031384b (patch)
tree7595439ba9966c9402d37e37cee5e8cf098757d5 /Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs
parent8b04ea73e540067f83870b61d89db4868fea5e8a (diff)
* move folder
Diffstat (limited to 'Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs')
-rw-r--r--Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs61
1 files changed, 0 insertions, 61 deletions
diff --git a/Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs
deleted file mode 100644
index d66bf706..00000000
--- a/Assets/ThirdParty/Behavior Designer/Runtime/Conditionals/Reflection/CompareFieldValue.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using UnityEngine;
-using System;
-using System.Reflection;
-
-namespace BehaviorDesigner.Runtime.Tasks
-{
- [TaskDescription("Compares the field value to the value specified. Returns success if the values are the same.")]
- [HelpURL("http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=151")]
- [TaskCategory("Reflection")]
- [TaskIcon("{SkinColor}ReflectionIcon.png")]
- public class CompareFieldValue : Conditional
- {
- [Tooltip("The GameObject to compare the field on")]
- public SharedGameObject targetGameObject;
- [Tooltip("The component to compare the field on")]
- public SharedString componentName;
- [Tooltip("The name of the field")]
- public SharedString fieldName;
- [Tooltip("The value to compare to")]
- public SharedVariable compareValue;
-
- public override TaskStatus OnUpdate()
- {
- if (compareValue == null) {
- Debug.LogWarning("Unable to compare field - compare value is null");
- return TaskStatus.Failure;
- }
-
- var type = TaskUtility.GetTypeWithinAssembly(componentName.Value);
- if (type == null) {
- Debug.LogWarning("Unable to compare field - type is null");
- return TaskStatus.Failure;
- }
-
- var component = GetDefaultGameObject(targetGameObject.Value).GetComponent(type);
- if (component == null) {
- Debug.LogWarning("Unable to compare the field with component " + componentName.Value);
- return TaskStatus.Failure;
- }
-
- // If you are receiving a compiler error on the Windows Store platform see this topic:
- // http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=46
- var field = component.GetType().GetField(fieldName.Value);
- var fieldValue = field.GetValue(component);
-
- if (fieldValue == null && compareValue.GetValue() == null) {
- return TaskStatus.Success;
- }
-
- return fieldValue.Equals(compareValue.GetValue()) ? TaskStatus.Success : TaskStatus.Failure;
- }
-
- public override void OnReset()
- {
- targetGameObject = null;
- componentName = null;
- fieldName = null;
- compareValue = null;
- }
- }
-} \ No newline at end of file