public override ActionStatus OnUpdate() { var type = Utility.GetType(m_ComponentName); if (type == null) { Debug.LogWarning("Unable to invoke - type is null"); return(ActionStatus.Failure); } var component = this.m_TargetObject.GetComponent(type); if (component == null) { Debug.LogWarning("Unable to invoke with component " + m_ComponentName); return(ActionStatus.Failure); } List <object> parameterList = new List <object>(); List <Type> typeList = new List <Type>(); for (int i = 0; i < m_Arguments.Count; i++) { ArgumentVariable argument = m_Arguments[i]; if (!argument.IsNone) { object value = argument.GetValue(); parameterList.Add(value); typeList.Add(value.GetType()); } } var methodInfo = component.GetType().GetMethod(this.m_MethodName, typeList.ToArray()); if (methodInfo == null) { Debug.LogWarning("Unable to invoke method " + this.m_MethodName + " on component " + this.m_ComponentName); return(ActionStatus.Failure); } bool?result = methodInfo.Invoke(component, parameterList.ToArray()) as bool?; if (result != null && !(bool)result) { if (!string.IsNullOrEmpty(this.m_FailureNotification.text)) { this.m_FailureNotification.Show(); } return(ActionStatus.Failure); } return(ActionStatus.Success); }
public override ActionStatus OnUpdate() { var type = Utility.GetType(m_ComponentName); if (type == null) { Debug.LogWarning("Unable to invoke - type is null"); return(ActionStatus.Failure); } var component = this.m_TargetObject.GetComponent(type); if (component == null) { Debug.LogWarning("Unable to invoke with component " + m_ComponentName); return(ActionStatus.Failure); } List <object> parameterList = new List <object>(); List <Type> typeList = new List <Type>(); for (int i = 0; i < m_Arguments.Count; i++) { ArgumentVariable argument = m_Arguments[i]; if (!argument.IsNone) { object value = argument.GetValue(); parameterList.Add(value); typeList.Add(value.GetType()); } } var methodInfo = component.GetType().GetMethod(this.m_MethodName, typeList.ToArray()); if (methodInfo == null) { Debug.LogWarning("Unable to invoke method " + this.m_MethodName + " on component " + this.m_ComponentName); return(ActionStatus.Failure); } float result = System.Convert.ToSingle(methodInfo.Invoke(component, parameterList.ToArray())); if (this.m_Condition == Condition.Greater && result < this.m_Number || this.m_Condition == Condition.Less && result > this.m_Number) { this.m_FailureNotification.Show(); return(ActionStatus.Failure); } return(ActionStatus.Success); }