public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { position.height = EditorGUIUtility.singleLineHeight; SerializedProperty argumentType = property.FindPropertyRelative("m_ArgumentType"); EditorGUI.PropertyField(position, argumentType, new GUIContent("Type")); if (argumentType.enumValueIndex > 0) { position.y += position.height; SerializedProperty valueProperty = property.FindPropertyRelative(ArgumentVariable.GetPropertyValuePath((ArgumentType)argumentType.enumValueIndex)); EditorGUI.PropertyField(position, valueProperty, new GUIContent("Value")); } }
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) { return(ActionStatus.Failure); } return(ActionStatus.Success); }