//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI(){ if (!Application.isPlaying && GUILayout.Button("Select Property")){ System.Action<MethodInfo> MethodSelected = (method)=> { functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard); checkValue = BBParameter.CreateInstance( method.ReturnType, blackboard); comparison = CompareMethod.EqualTo; }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 0, true, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 0, true, true, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name); GUILayout.EndVertical(); GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; EditorUtils.BBParameterField("Value", checkValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI(){ if (!Application.isPlaying && GUILayout.Button("Select Property")){ System.Action<MethodInfo> MethodSelected = (method)=>{ functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard); }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 0, true, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 0, true, true, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Property Type", targetMethod.ReturnType.FriendlyName() ); GUILayout.EndVertical(); EditorUtils.BBParameterField("Save As", functionWrapper.GetVariables()[0], true); } }
public static ReflectedWrapper Create(MethodInfo method, IBlackboard bb) { if (method.ReturnType == typeof(void)) { return(ReflectedActionWrapper.Create(method, bb)); } return(ReflectedFunctionWrapper.Create(method, bb)); }
void SetMethod(MethodInfo method) { if (method != null){ functionWrapper = ReflectedFunctionWrapper.Create(method, blackboard); } }
public override void OnValidate(ITaskSystem ownerSystem) { if (functionWrapper != null && functionWrapper.HasChanged()){ functionWrapper = ReflectedFunctionWrapper.Create(functionWrapper.GetMethod(), blackboard); } }