//////////////////////////////////////// ///////////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///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")){ System.Action<FieldInfo> FieldSelected = (field)=>{ targetType = field.DeclaringType; fieldName = field.Name; setValue.SetType(field.FieldType); }; var menu = new UnityEditor.GenericMenu(); if (agent != null){ foreach(var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ){ menu = EditorUtils.GetFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)){ menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu); } menu.ShowAsContext(); Event.current.Use(); } if (agentType != null && !string.IsNullOrEmpty(fieldName)){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.Name); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); UnityEditor.EditorGUILayout.LabelField("Field Type", setValue.varType.FriendlyName() ); GUILayout.EndVertical(); EditorUtils.BBParameterField("Set Value", setValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI(){ if (!Application.isPlaying && GUILayout.Button("Select Field")){ System.Action<FieldInfo> FieldSelected = (field)=>{ targetType = field.DeclaringType; fieldName = field.Name; setValue = BBParameter.CreateInstance(field.FieldType, blackboard); }; if (agent != null){ EditorUtils.ShowGameObjectFieldSelectionMenu(agent.gameObject, typeof(object), FieldSelected); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu); menu.ShowAsContext(); Event.current.Use(); } } if (agentType != null && !string.IsNullOrEmpty(fieldName)){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.Name); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); UnityEditor.EditorGUILayout.LabelField("Field Type", setValue.varType.FriendlyName() ); GUILayout.EndVertical(); EditorUtils.BBParameterField("Set Value", setValue); } }
//////////////////////////////////////// ///////////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); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI(){ if (!Application.isPlaying && GUILayout.Button("Select Event")){ Action<EventInfo> Selected = (e)=> { targetType = e.DeclaringType; eventName = e.Name; }; if (agent != null){ EditorUtils.ShowGameObjectEventSelectionMenu(agent.gameObject, null, Selected); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetEventSelectionMenu(t, null, Selected, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetType != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Selected Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Event", eventName); GUILayout.EndVertical(); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI(){ if (!Application.isPlaying && GUILayout.Button("Select Property")){ System.Action<MethodInfo> MethodSelected = (method)=> { this.method = new SerializedMethodInfo(method); this.parameter.SetType(method.GetParameters()[0].ParameterType); }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(void), typeof(object), MethodSelected, 1, true, false); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(void), typeof(object), MethodSelected, 1, true, false, 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("Set Type", parameter.varType.FriendlyName() ); GUILayout.EndVertical(); EditorUtils.BBParameterField("Set Value", parameter); } }
///---------------------------------------------------------------------------------------------- ///Returns all nodes' menu public static UnityEditor.GenericMenu GetFullNodesMenu(this FlowGraph flowGraph, Vector2 mousePos, Port context, Object dropInstance) { var menu = new UnityEditor.GenericMenu(); if (context is ValueInput || context is ValueOutput) { menu = flowGraph.AppendTypeReflectionNodesMenu(menu, context.type, "", mousePos, context, dropInstance); } menu = flowGraph.AppendFlowNodesMenu(menu, "", mousePos, context, dropInstance); menu = flowGraph.AppendSimplexNodesMenu(menu, "Functions/Implemented", mousePos, context, dropInstance); menu = flowGraph.AppendAllReflectionNodesMenu(menu, "Functions/Reflected", mousePos, context, dropInstance); menu = flowGraph.AppendVariableNodesMenu(menu, "Variables", mousePos, context, dropInstance); menu = flowGraph.AppendMacroNodesMenu(menu, "MACROS", mousePos, context, dropInstance); menu = flowGraph.AppendMenuCallbackReceivers(menu, "", mousePos, context, dropInstance); return(menu); }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { base.OnTaskInspectorGUI(); if (!Application.isPlaying && GUILayout.Button("Select Property")) { var menu = new UnityEditor.GenericMenu(); menu = EditorUtils.GetInstanceMethodSelectionMenu(_agentType, typeof(object), typeof(object), SetMethod, 1, true, true, menu); menu.AddSeparator("/"); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(void), typeof(object), SetMethod, 1, true, false, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(void), typeof(object), SetMethod, 1, true, false, menu); menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(void), typeof(object), SetMethod, 1, true, false, menu); } if (NodeCanvas.Editor.NCPrefs.useBrowser) { menu.ShowAsBrowser("Select Property", this.GetType()); } else { menu.ShowAsContext(); } Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Set Type", functionWrapper.GetVariables()[0].varType.FriendlyName()); GUILayout.EndVertical(); NodeCanvas.Editor.BBParameterEditor.ParameterField("Set Value", functionWrapper.GetVariables()[0]); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Action Method")) { System.Action <MethodInfo> MethodSelected = (method) => { this.method = new SerializedMethodInfo(method); this.parameters.Clear(); foreach (var p in method.GetParameters()) { var newParam = new BBObjectParameter { bb = blackboard }; newParam.SetType(p.ParameterType); parameters.Add(newParam); } }; if (agent != null) { EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(Status), typeof(object), MethodSelected, 1, false, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) { menu = EditorUtils.GetMethodSelectionMenu(t, typeof(Status), typeof(object), MethodSelected, 1, false, true, menu); } menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name); GUILayout.EndVertical(); if (targetMethod.GetParameters().Length == 1) { var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase(); EditorUtils.BBParameterField(paramName, parameters[0]); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Static Method")) { UnityEditor.GenericMenu.MenuFunction2 MethodSelected = (m) => { SetMethod((MethodInfo)m); }; var menu = new UnityEditor.GenericMenu(); foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { foreach (var m in t.GetMethods(BindingFlags.Static | BindingFlags.Public).OrderBy(m => !m.IsSpecialName)) { if (m.IsGenericMethod) { continue; } menu.AddItem(new GUIContent(t.FriendlyName() + "/" + m.SignatureName()), false, MethodSelected, m); } } menu.ShowAsBrowser("Select Static Method", this.GetType()); Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.DeclaringType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName()); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray(); for (var i = 0; i < paramNames.Length; i++) { NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], parameters[i]); } if (targetMethod.ReturnType != typeof(void)) { NodeCanvas.Editor.BBParameterEditor.ParameterField("Save Return Value", returnValue, true); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")) { 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, 3, false, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component))) { menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 3, false, true, menu); } menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray(); var variables = functionWrapper.GetVariables(); for (var i = 0; i < paramNames.Length; i++) { EditorUtils.BBParameterField(paramNames[i], variables[i + 1]); } GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; EditorUtils.BBParameterField("Check Value", checkValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR //Override of right click node context menu for ability to change type protected override UnityEditor.GenericMenu OnContextMenu(UnityEditor.GenericMenu menu) { base.OnContextMenu(menu); if (simplexNode == null) { return(menu); } var type = simplexNode.GetType(); if (type.IsGenericType) { menu = EditorUtils.GetPreferedTypesSelectionMenu(type.GetGenericTypeDefinition(), (t) => { this.ReplaceWith(typeof(SimplexNodeWrapper <>).MakeGenericType(t)); }, menu, "Change Generic Type"); } return(menu); }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")) { var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 6, false, true, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, true, menu); if (typeof(UnityEngine.Component).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, true, menu); } } menu.ShowAsBrowser("Select Method", this.GetType()); Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray(); var variables = functionWrapper.GetVariables(); for (var i = 0; i < paramNames.Length; i++) { NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], variables[i + 1]); } GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; NodeCanvas.Editor.BBParameterEditor.ParameterField("Check Value", checkValue); } }
protected override UnityEditor.GenericMenu OnDragAndDropPortContextMenu(UnityEditor.GenericMenu menu, Port port) { if (macro == null) { return(menu); } if (port.IsOutputPort()) { menu.AddItem(new GUIContent(string.Format("Promote to new Output '{0}'", port.name)), false, () => { var def = new DynamicPortDefinition(port.name, port.type); var defPort = macro.AddOutputDefinition(def); BinderConnection.Create(port, defPort); }); } return(menu); }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")) { System.Action <FieldInfo> FieldSelected = (field) => { targetType = field.DeclaringType; fieldName = field.Name; saveAs.SetType(field.FieldType); }; var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector)) { menu = EditorUtils.GetFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component))) { menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu); } if (NodeCanvas.Editor.NCPrefs.useBrowser) { menu.ShowAsBrowser("Select Field", this.GetType()); } else { menu.ShowAsContext(); } Event.current.Use(); } if (agentType != null && !string.IsNullOrEmpty(fieldName)) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.Name); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); UnityEditor.EditorGUILayout.LabelField("Field Type", saveAs.varType.FriendlyName()); GUILayout.EndVertical(); EditorUtils.BBParameterField("Save As", saveAs, true); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { base.OnTaskInspectorGUI(); if (!Application.isPlaying && GUILayout.Button("Select Property")) { var menu = new UnityEditor.GenericMenu(); menu = EditorUtils.GetInstanceMethodSelectionMenu(_agentType, typeof(object), typeof(object), SetMethod, 0, true, true, menu); menu.AddSeparator("/"); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 0, true, true, menu); } } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu); menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu); } if (NodeCanvas.Editor.NCPrefs.useBrowser) { menu.ShowAsBrowser("Select Property", this.GetType()); } else { menu.ShowAsContext(); } Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedType().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; NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Event")) { Action <EventInfo> Selected = (e) => { targetType = e.DeclaringType; eventName = e.Name; }; var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0)) { menu = EditorUtils.GetEventSelectionMenu(comp.GetType(), typeof(T), Selected, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component))) { menu = EditorUtils.GetEventSelectionMenu(t, typeof(T), Selected, menu); } if (NodeCanvas.Editor.NCPrefs.useBrowser) { menu.ShowAsBrowser("Select Event", this.GetType()); } else { menu.ShowAsContext(); } Event.current.Use(); } if (targetType != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Selected Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Event", eventName); GUILayout.EndVertical(); EditorUtils.BBParameterField("Check Value", checkValue); } }
private void ShowAddPointerMenu <TItem>(string name, Action addItem, Action <TItem> addPointer) where TItem : IDiagramNodeItem { var ctxMenu = new UnityEditor.GenericMenu(); ctxMenu.AddItem(new GUIContent("New " + name), false, () => { InvertApplication.Execute(() => { addItem(); }); }); ctxMenu.AddSeparator(""); var nodeConfigSection = NodeViewModel.DiagramViewModel.CurrentRepository.AllOf <TItem>(); foreach (var item in nodeConfigSection) { var item1 = item; ctxMenu.AddItem(new GUIContent(item.Name), false, () => { InvertApplication.Execute(() => { addPointer(item1); }); }); } ctxMenu.ShowAsContext(); }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR void IEditorMenuCallbackReceiver.OnMenu(UnityEditor.GenericMenu menu, Vector2 pos, Port contextPort, object dropInstance) { if (contextPort != null) { if (contextPort is ValueInput && !contextPort.type.IsAssignableFrom(returnType)) { return; } if (contextPort is ValueOutput && !parameterTypes.Any(t => t.IsAssignableFrom(contextPort.type))) { return; } } menu.AddItem(new GUIContent(string.Format("Functions/Custom/Call '{0}()'", identifier)), false, () => { flowGraph.AddFlowNode <CustomFunctionCall>(pos, contextPort, dropInstance).SetFunction(this); }); }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")) { System.Action <FieldInfo> FieldSelected = (field) => { targetType = field.DeclaringType; fieldName = field.Name; checkValue = BBParameter.CreateInstance(field.FieldType, blackboard); comparison = CompareMethod.EqualTo; }; var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0)) { menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(Component))) { menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), FieldSelected, menu); } menu.ShowAsBrowser("Select Field", this.GetType()); Event.current.Use(); } if (agentType != null && !string.IsNullOrEmpty(fieldName)) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); GUILayout.EndVertical(); GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Action Method")) { var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector)) { menu = EditorUtils.GetMethodSelectionMenu(comp.GetType(), typeof(Status), typeof(object), SetMethod, 1, false, true, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) { menu = EditorUtils.GetMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu); } if (NodeCanvas.Editor.NCPrefs.useBrowser) { menu.ShowAsBrowser("Select Action Method", this.GetType()); } else { menu.ShowAsContext(); } Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name); GUILayout.EndVertical(); if (targetMethod.GetParameters().Length == 1) { var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase(); EditorUtils.BBParameterField(paramName, functionWrapper.GetVariables()[1]); } } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")) { System.Action <FieldInfo> FieldSelected = (field) => { targetType = field.DeclaringType; fieldName = field.Name; saveAs.SetType(field.FieldType); }; var menu = new UnityEditor.GenericMenu(); if (variable.value != null) { menu = EditorUtils.GetInstanceFieldSelectionMenu(variable.value.GetType(), typeof(object), FieldSelected, menu); menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), FieldSelected, menu); } menu.ShowAsBrowser("Select Field", GetType()); Event.current.Use(); } if (variable.value != null && !string.IsNullOrEmpty(fieldName)) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", variable.varType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); UnityEditor.EditorGUILayout.LabelField("Field Type", saveAs.varType.FriendlyName()); GUILayout.EndVertical(); Editor.BBParameterEditor.ParameterField("Variable", variable, true); NodeCanvas.Editor.BBParameterEditor.ParameterField("Save As", saveAs, true); } else { Editor.BBParameterEditor.ParameterField("Variable", variable, true); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Property")) { var menu = new UnityEditor.GenericMenu(); if (variable.value != null) { menu = EditorUtils.GetInstanceMethodSelectionMenu(variable.value.GetType(), typeof(void), typeof(object), SetMethod, 1, true, false, menu); menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(void), typeof(object), SetMethod, 1, true, false, menu); menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(void), typeof(object), SetMethod, 1, true, false, menu); } menu.ShowAsBrowser("Select Property", GetType()); Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Set Type", setValue.varType.FriendlyName()); GUILayout.EndVertical(); if (!targetMethod.IsStatic) { Editor.BBParameterEditor.ParameterField("Variable", variable, true); } Editor.BBParameterEditor.ParameterField("Set From", setValue, true); } else { Editor.BBParameterEditor.ParameterField("Variable", variable, true); } }
/************************************************************************************************************************/ /// <inheritdoc/> protected override void AddThresholdFunctionsToMenu(UnityEditor.GenericMenu menu) { const string EvenlySpaced = "Evenly Spaced"; var count = CurrentThresholds.arraySize; if (count <= 1) { menu.AddDisabledItem(new GUIContent(EvenlySpaced)); } else { var first = CurrentThresholds.GetArrayElementAtIndex(0).floatValue; var last = CurrentThresholds.GetArrayElementAtIndex(count - 1).floatValue; if (last == first) { last++; } AddPropertyModifierFunction(menu, $"{EvenlySpaced} ({first} to {last})", (_) => { for (int i = 0; i < count; i++) { CurrentThresholds.GetArrayElementAtIndex(i).floatValue = Mathf.Lerp(first, last, i / (float)(count - 1)); } }); } AddCalculateThresholdsFunction(menu, "From Speed", (state, threshold) => AnimancerUtilities.TryGetAverageVelocity(state, out var velocity) ? velocity.magnitude : float.NaN); AddCalculateThresholdsFunction(menu, "From Velocity X", (state, threshold) => AnimancerUtilities.TryGetAverageVelocity(state, out var velocity) ? velocity.x : float.NaN); AddCalculateThresholdsFunction(menu, "From Velocity Y", (state, threshold) => AnimancerUtilities.TryGetAverageVelocity(state, out var velocity) ? velocity.y : float.NaN); AddCalculateThresholdsFunction(menu, "From Velocity Z", (state, threshold) => AnimancerUtilities.TryGetAverageVelocity(state, out var velocity) ? velocity.z : float.NaN); AddCalculateThresholdsFunction(menu, "From Angular Speed (Rad)", (state, threshold) => AnimancerUtilities.TryGetAverageAngularSpeed(state, out var speed) ? speed : float.NaN); AddCalculateThresholdsFunction(menu, "From Angular Speed (Deg)", (state, threshold) => AnimancerUtilities.TryGetAverageAngularSpeed(state, out var speed) ? speed * Mathf.Rad2Deg : float.NaN); }
/************************************************************************************************************************/ private static void AddCalculateThresholdsFunction(UnityEditor.GenericMenu menu, string label, Func <AnimationClip, float, float> calculateThreshold) { AddPropertyModifierFunction(menu, label, (property) => { var count = CurrentClips.arraySize; for (int i = 0; i < count; i++) { var clip = CurrentClips.GetArrayElementAtIndex(i).objectReferenceValue as AnimationClip; if (clip == null) { continue; } var threshold = CurrentThresholds.GetArrayElementAtIndex(i); threshold.floatValue = calculateThreshold(clip, threshold.floatValue); } }); }
void HandNodeWindowContextMenu(Event e) { if (e.button == 1 && e.type == EventType.MouseDown) { UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu(); if (Tree.First != this && CanAsFirst) { menu.AddItem(new GUIContent("Make First"), false, ContextMakeFirst); } if (this.Parent != null) { menu.AddItem(new GUIContent("Make UnParent"), false, ContextMakeUnParent); } menu.AddItem(new GUIContent("Duplicate"), false, ContextDuplicate); menu.AddItem(new GUIContent("Delete"), false, ContextDelete); menu.ShowAsContext(); e.Use(); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR void IEditorMenuCallbackReceiver.OnMenu(UnityEditor.GenericMenu menu, Vector2 pos, Port sourcePort, object dropInstance) { if (sourcePort != null) { if (sourcePort is ValueInput && !sourcePort.type.IsAssignableFrom(returnType)) { return; } if (sourcePort is ValueOutput && !parameterTypes.Any(t => t.IsAssignableFrom(sourcePort.type))) { return; } } menu.AddItem(new GUIContent(string.Format("Functions/Custom/Call '{0}()'", identifier)), false, () => { var node = flowGraph.AddNode <CustomFunctionCall>(pos); node.SetFunction(this); FlowGraphExtensions.Finalize(node, sourcePort, null); }); }
protected override void OnVariableDropInGraph(Variable variable, Event e, Vector2 canvasMousePos) { if (variable != null) { var menu = new UnityEditor.GenericMenu(); menu.AddItem(new GUIContent(variable.name + "/" + "Get"), false, () => { var genericType = typeof(GetVariable <>).MakeGenericType(new System.Type[] { variable.varType }); var varNode = (VariableNode)AddNode(genericType, canvasMousePos); genericType.GetMethod("SetTargetVariableName").Invoke(varNode, new object[] { variable.name }); }); menu.AddItem(new GUIContent(variable.name + "/" + "Set"), false, () => { var genericType = typeof(SetVariable <>).MakeGenericType(new System.Type[] { variable.varType }); var varNode = (FlowNode)AddNode(genericType, canvasMousePos); genericType.GetMethod("SetTargetVariableName").Invoke(varNode, new object[] { variable.name }); }); menu.ShowAsContext(); e.Use(); } }
//Used above for convenience UnityEditor.GenericMenu AppendDragAndDropObjectMenu(UnityEditor.GenericMenu menu, UnityEngine.Object o, string category, Vector2 mousePos) { foreach (var _wrapperType in NodeCanvas.Editor.GraphEditorUtility.GetDropedReferenceNodeTypes <IDropedReferenceNode>(o)) { var wrapperType = _wrapperType; if (baseNodeType.IsAssignableFrom(wrapperType)) { menu.AddItem(new GUIContent(string.Format(category + "Add Node ({0})", wrapperType.FriendlyName())), false, (x) => { this.AddDropedReferenceNode(wrapperType, mousePos, null, (UnityEngine.Object)x); }, o); } } if (o is IExternalImplementedNode) { menu.AddItem(new GUIContent(category + "Add Implemented Node"), false, (x) => { this.AddExternalImplementedNodeWrapper(mousePos, null, (IExternalImplementedNode)x); }, o); } var targetType = o.GetType(); menu.AddItem(new GUIContent(string.Format(category + "Make Variable ({0})", targetType.FriendlyName())), false, (x) => { this.AddVariableGet(targetType, null, null, mousePos, null, x); }, o); return(menu); }
protected override void OnNodeInspectorGUI() { if (GUILayout.Button("Set GO TO Target")){ UnityEditor.GenericMenu.MenuFunction2 Selected = (object o)=> { _targetNode = (DTNode)o; }; var menu = new UnityEditor.GenericMenu(); foreach (DTNode node in graph.allNodes){ if (node != this) menu.AddItem( new GUIContent(node.name), false, Selected, node ); } menu.ShowAsContext(); Event.current.Use(); } if (_targetNode != null && GUILayout.Button("Select Target Node")){ Graph.currentSelection = _targetNode; } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")) { System.Action <FieldInfo> FieldSelected = (field) => { targetType = field.DeclaringType; fieldName = field.Name; checkValue = BBParameter.CreateInstance(field.FieldType, blackboard); comparison = CompareMethod.EqualTo; }; if (agent != null) { EditorUtils.ShowGameObjectFieldSelectionMenu(agent.gameObject, typeof(object), FieldSelected); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) { menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu); } menu.ShowAsContext(); Event.current.Use(); } } if (agentType != null && !string.IsNullOrEmpty(fieldName)) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); 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); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Action Method")) { var menu = new UnityEditor.GenericMenu(); foreach (var t in TypePrefs.GetPreferedTypesList(typeof(T))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu); if (typeof(T).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu); } } if (menu.GetItemCount() <= 0) { menu.AddItem(new GUIContent("No Action Methods"), false, null); } menu.ShowAsBrowser("Select Action Method", this.GetType()); Event.current.Use(); } if (targetMethod != null) { if (!targetMethod.IsStatic) { NodeCanvas.Editor.BBParameterEditor.ParameterField("Instance", target, true); } GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name); GUILayout.EndVertical(); if (targetMethod.GetParameters().Length == 1) { var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase(); NodeCanvas.Editor.BBParameterEditor.ParameterField(paramName, functionWrapper.GetVariables()[1]); } } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")) { var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector)) { menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(object), SetTargetField, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(object), SetTargetField, menu); if (typeof(Component).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), SetTargetField, menu); } } menu.ShowAsBrowser("Select Field", this.GetType()); Event.current.Use(); } if (targetField != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetField.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Field", targetField.Name); UnityEditor.EditorGUILayout.LabelField("Field Type", targetField.FieldType.FriendlyName()); UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetField), UnityEditor.MessageType.None); GUILayout.EndVertical(); GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Event")) { var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0)) { menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(UnityEvent <T>), SetTargetEvent, menu); menu = EditorUtils.GetInstancePropertySelectionMenu(comp.GetType(), typeof(UnityEvent <T>), SetTargetEvent, true, false, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(UnityEvent <T>), SetTargetEvent, menu); menu = EditorUtils.GetStaticPropertySelectionMenu(t, typeof(UnityEvent <T>), SetTargetEvent, true, false, menu); if (typeof(Component).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(UnityEvent <T>), SetTargetEvent, menu); menu = EditorUtils.GetInstancePropertySelectionMenu(t, typeof(UnityEvent <T>), SetTargetEvent, true, false, menu); } } menu.ShowAsBrowser("Select Event", this.GetType()); Event.current.Use(); } if (targetMember != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMember.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Event", targetMember.Name); UnityEditor.EditorGUILayout.LabelField("Event Type", eventType.FriendlyName()); GUILayout.EndVertical(); NodeCanvas.Editor.BBParameterEditor.ParameterField("Check Value", checkValue); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Action Method")) { var menu = new UnityEditor.GenericMenu(); if (agent != null) { foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(Status), typeof(object), SetMethod, 1, false, true, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu); if (typeof(UnityEngine.Component).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu); } } menu.ShowAsBrowser("Select Action Method", this.GetType()); Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name); GUILayout.EndVertical(); if (targetMethod.GetParameters().Length == 1) { var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase(); NodeCanvas.Editor.BBParameterEditor.ParameterField(paramName, parameters[0]); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Field")) { System.Action <FieldInfo> FieldSelected = (field) => { targetType = field.DeclaringType; fieldName = field.Name; setValue.SetType(field.FieldType); IsStatic = field.IsStatic; }; var menu = new UnityEditor.GenericMenu(); foreach (var t in TypePrefs.GetPreferedTypesList(typeof(T))) { menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), FieldSelected, menu); } if (menu.GetItemCount() <= 0) { menu.AddItem(new GUIContent("No Fields"), false, null); } menu.ShowAsBrowser("Select Field", this.GetType()); Event.current.Use(); } if (!string.IsNullOrEmpty(fieldName)) { if (!IsStatic) { NodeCanvas.Editor.BBParameterEditor.ParameterField("Instance", target, true); } GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", typeof(T).Name); UnityEditor.EditorGUILayout.LabelField("Field", fieldName); UnityEditor.EditorGUILayout.LabelField("Field Type", setValue.varType.FriendlyName()); GUILayout.EndVertical(); NodeCanvas.Editor.BBParameterEditor.ParameterField("Set Value", setValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Property")) { System.Action <MethodInfo> MethodSelected = (method) => { this.method = new SerializedMethodInfo(method); this.checkValue.SetType(method.ReturnType); 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///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")){ if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), SetMethod, 3, false, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 3, false, true, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], parameters[i]); } GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; EditorUtils.BBParameterField("Check Value", checkValue); } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Static Method")){ var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(object), true)){ foreach(var _m in t.GetMethods(BindingFlags.Static | BindingFlags.Public).OrderBy(m => !m.IsSpecialName) ){ var m = _m; if (m.IsGenericMethod) continue; var parameters = m.GetParameters(); if (parameters.Length > 3) continue; menu.AddItem(new GUIContent(t.FriendlyName() + "/" + m.SignatureName()), false, ()=>{SetMethod(m);}); } } menu.ShowAsContext(); Event.current.Use(); } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.DeclaringType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName()); if (targetMethod.ReturnType == typeof(IEnumerator)) GUILayout.Label("<b>This will execute as a Coroutine</b>"); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); var variables = functionWrapper.GetVariables(); if (targetMethod.ReturnType == typeof(void)){ for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], variables[i]); } } else { for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], variables[i+1]); } EditorUtils.BBParameterField("Save Return Value", variables[0], true); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")){ System.Action<MethodInfo> MethodSelected = (method) => { this.method = new SerializedMethodInfo(method); this.parameters.Clear(); foreach(var p in method.GetParameters()){ var newParam = new BBObjectParameter{bb = blackboard}; newParam.SetType(p.ParameterType); if (p.IsOptional){ newParam.value = p.DefaultValue; } parameters.Add(newParam); } if (method.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){ this.returnValue = new BBObjectParameter{bb = blackboard}; this.returnValue.SetType(method.ReturnType); } }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, false); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 3, false, false, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName()); if (targetMethod.ReturnType == typeof(IEnumerator)) GUILayout.Label("<b>This will execute as a Coroutine</b>"); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], parameters[i]); } if (targetMethod.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){ EditorUtils.BBParameterField("Save Return Value", returnValue, true); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")){ System.Action<MethodInfo> MethodSelected = (method) => { functionWrapper = ReflectedWrapper.Create(method, blackboard); }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, false); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 3, false, false, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName()); if (targetMethod.ReturnType == typeof(IEnumerator)) GUILayout.Label("<b>This will execute as a Coroutine</b>"); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); var variables = functionWrapper.GetVariables(); if (targetMethod.ReturnType == typeof(void)){ for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], variables[i]); } } else { for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], variables[i+1]); } if (targetMethod.ReturnType != typeof(IEnumerator)){ EditorUtils.BBParameterField("Save Return Value", variables[0], true); } } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")){ System.Action<MethodInfo> MethodSelected = (method)=> { this.method = new SerializedMethodInfo(method); this.parameters.Clear(); foreach(var p in method.GetParameters()){ var newParam = new BBObjectParameter{bb = blackboard}; newParam.SetType(p.ParameterType); if (p.IsOptional){ newParam.value = p.DefaultValue; } parameters.Add(newParam); } this.checkValue = new BBObjectParameter{bb = blackboard}; this.checkValue.SetType(method.ReturnType); comparison = CompareMethod.EqualTo; }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, 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, 3, false, true, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], parameters[i]); } GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int); comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison); GUI.enabled = true; EditorUtils.BBParameterField("Check Value", checkValue); } }
/// <summary> /// Processes input events /// </summary> public static void InputEvents(List<Rect> ignoreInput) { Event e = Event.current; mousePos = e.mousePosition; bool insideCanvas = curEditorState.canvasRect.Contains (e.mousePosition); for (int ignoreCnt = 0; ignoreCnt < ignoreInput.Count; ignoreCnt++) { if (ignoreInput [ignoreCnt].Contains (e.mousePosition)) { insideCanvas = false; break; } } curEditorState.focusedNode = null; if (insideCanvas && (e.type == EventType.MouseDown || e.type == EventType.MouseUp)) { curEditorState.focusedNode = NodeEditor.NodeAtPosition (e.mousePosition); if (e.button == 0) curEditorState.activeNode = curEditorState.focusedNode; } #if UNITY_EDITOR if (curEditorState.focusedNode != null) UnityEditor.Selection.activeObject = curEditorState.focusedNode; #endif switch (e.type) { case EventType.MouseDown: if (!insideCanvas) break; curEditorState.dragNode = false; curEditorState.panWindow = false; if (curEditorState.focusedNode != null) { // A click on a node if (e.button == 1) { // Right click -> Node Context Click // TODO: Node Editor: Editor-Independancy - GenericMenu conversion #if UNITY_EDITOR UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu (); menu.AddItem (new GUIContent ("Delete Node"), false, ContextCallback, new callbackObject ("deleteNode", curNodeCanvas, curEditorState)); menu.AddItem (new GUIContent ("Duplicate Node"), false, ContextCallback, new callbackObject ("duplicateNode", curNodeCanvas, curEditorState)); if (NodeTypes.getNodeData (curEditorState.focusedNode).transitions) menu.AddItem (new GUIContent ("Make Transition"), false, ContextCallback, new callbackObject ("startTransition", curNodeCanvas, curEditorState)); menu.ShowAsContext (); #endif e.Use (); } else if (e.button == 0) { if (!GUIToScreenRect (curEditorState.focusedNode.rect).Contains (e.mousePosition)) { // Left click at node edges -> Check for clicked connections to edit NodeOutput nodeOutput = curEditorState.focusedNode.GetOutputAtPos (e.mousePosition); if (nodeOutput != null) { // Output Node -> New Connection drawn from this curEditorState.connectOutput = nodeOutput; curEditorState.connectMousePos = mousePos; e.Use(); } else { // no output clicked, check input NodeInput nodeInput = curEditorState.focusedNode.GetInputAtPos (e.mousePosition); if (nodeInput != null && nodeInput.connection != null) { // Input node -> Loose and edit Connection curEditorState.connectOutput = nodeInput.connection; Node.RemoveConnection (nodeInput); e.Use(); } } } } } else { // A click on the empty canvas if (e.button == 2 || e.button == 0) { // Left/Middle Click -> Start scrolling curEditorState.panWindow = true; e.delta = Vector2.zero; } else if (e.button == 1) { // Right click -> Editor Context Click // TODO: Node Editor: Editor-Independancy - GenericMenu conversion if (curEditorState.connectOutput != null || curEditorState.makeTransition != null) { #if UNITY_EDITOR UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu (); // Iterate through all compatible nodes foreach (Node node in NodeTypes.nodes.Keys) { if (curEditorState.connectOutput != null) { foreach (var input in node.Inputs) { if (input.type == curEditorState.connectOutput.type) { menu.AddItem (new GUIContent ("Add " + NodeTypes.nodes[node].adress), false, ContextCallback, new callbackObject (node.GetID, curNodeCanvas, curEditorState)); break; } } } else if (curEditorState.makeTransition != null && NodeTypes.nodes [node].transitions) { menu.AddItem (new GUIContent ("Add " + NodeTypes.nodes[node].adress), false, ContextCallback, new callbackObject (node.GetID, curNodeCanvas, curEditorState)); } } menu.ShowAsContext (); #endif } else { #if UNITY_EDITOR UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu (); foreach (Node node in NodeTypes.nodes.Keys) { menu.AddItem (new GUIContent ("Add " + NodeTypes.nodes [node].adress), false, ContextCallback, new callbackObject (node.GetID, curNodeCanvas, curEditorState)); } menu.ShowAsContext (); #endif } e.Use(); } } break; case EventType.MouseUp: if (curEditorState.focusedNode != null) { if (curEditorState.makeTransition != null) { Node.CreateTransition (curEditorState.makeTransition, curEditorState.focusedNode); } else if (curEditorState.connectOutput != null) { // Apply a connection if theres a clicked input if (!curEditorState.focusedNode.Outputs.Contains (curEditorState.connectOutput)) { // If an input was clicked, it'll will now be connected NodeInput clickedInput = curEditorState.focusedNode.GetInputAtPos (e.mousePosition); if (Node.CanApplyConnection (curEditorState.connectOutput, clickedInput)) { // If it can connect (type is equals, it does not cause recursion, ...) Node.ApplyConnection (curEditorState.connectOutput, clickedInput); } } e.Use(); } } curEditorState.makeTransition = null; curEditorState.connectOutput = null; curEditorState.dragNode = false; curEditorState.panWindow = false; break; case EventType.ScrollWheel: if (insideCanvas) curEditorState.zoom = Mathf.Min (2.0f, Mathf.Max (0.6f, curEditorState.zoom + e.delta.y / 15)); if (Repaint != null) Repaint (); break; case EventType.KeyDown: if (!insideCanvas) break; // TODO: Node Editor: Shortcuts if (e.keyCode == KeyCode.N) // Start Navigating (curve to origin / active Node) curEditorState.navigate = true; if (e.keyCode == KeyCode.LeftControl && curEditorState.activeNode != null) // Snap curEditorState.activeNode.rect.position = new Vector2 (Mathf.RoundToInt ((curEditorState.activeNode.rect.position.x - curEditorState.panOffset.x) / 10) * 10 + curEditorState.panOffset.x, Mathf.RoundToInt ((curEditorState.activeNode.rect.position.y - curEditorState.panOffset.y) / 10) * 10 + curEditorState.panOffset.y); if (Repaint != null) Repaint (); break; case EventType.KeyUp: if (e.keyCode == KeyCode.N) // Stop Navigating curEditorState.navigate = false; if (Repaint != null) Repaint (); break; } // Some features that need constant updating if (curEditorState.panWindow) { // Scroll everything with the current mouse delta curEditorState.panOffset += e.delta / 2 * curEditorState.zoom; for (int nodeCnt = 0; nodeCnt < curNodeCanvas.nodes.Count; nodeCnt++) curNodeCanvas.nodes [nodeCnt].rect.position += e.delta / 2 * curEditorState.zoom; if (Repaint != null) Repaint (); } if (curEditorState.dragNode && curEditorState.activeNode != null && GUIUtility.hotControl == 0) { // Drag the active node with the current mouse delta curEditorState.activeNode.rect.position += e.delta / 2 * curEditorState.zoom; NodeEditorCallbacks.IssueOnMoveNode (curEditorState.activeNode); if (Repaint != null) Repaint (); } else curEditorState.dragNode = false; }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Action Method")){ if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(Status), typeof(object), SetMethod, 1, false, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(Status), typeof(object), SetMethod, 1, false, true, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name); GUILayout.EndVertical(); if (targetMethod.GetParameters().Length == 1){ var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase(); EditorUtils.BBParameterField(paramName, functionWrapper.GetVariables()[1]); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Action Method")){ System.Action<MethodInfo> MethodSelected = (method)=>{ this.method = new SerializedMethodInfo(method); this.parameters.Clear(); foreach(var p in method.GetParameters()){ var newParam = new BBObjectParameter{bb = blackboard}; newParam.SetType(p.ParameterType); parameters.Add(newParam); } }; if (agent != null){ EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(Status), typeof(object), MethodSelected, 1, false, true); } else { var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)) menu = EditorUtils.GetMethodSelectionMenu(t, typeof(Status), typeof(object), MethodSelected, 1, false, true, menu); menu.ShowAsContext(); Event.current.Use(); } } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name); GUILayout.EndVertical(); if (targetMethod.GetParameters().Length == 1){ var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase(); EditorUtils.BBParameterField(paramName, parameters[0]); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")){ var menu = new UnityEditor.GenericMenu(); if (agent != null){ foreach(var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ){ menu = EditorUtils.GetMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 3, false, false, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)){ menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 3, false, false, menu); } menu.ShowAsContext(); Event.current.Use(); } var m = targetMethod; if (m != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", m.Name); UnityEditor.EditorGUILayout.LabelField("Returns", m.ReturnType.FriendlyName()); if (m.ReturnType == typeof(IEnumerator)){ GUILayout.Label("<b>This will execute as a Coroutine!</b>"); } GUILayout.EndVertical(); var paramNames = m.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); var variables = functionWrapper.GetVariables(); if (m.ReturnType == typeof(void)){ for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], variables[i]); } } else { for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], variables[i+1]); } if (m.ReturnType != typeof(IEnumerator)){ EditorUtils.BBParameterField("Save Return Value", variables[0], true); } } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Static Method")){ UnityEditor.GenericMenu.MenuFunction2 MethodSelected = (m) => { var newMethod = (MethodInfo)m; this.method = new SerializedMethodInfo(newMethod); this.parameters.Clear(); foreach(var p in newMethod.GetParameters()){ var newParam = new BBObjectParameter{bb = blackboard}; newParam.SetType(p.ParameterType); if (p.IsOptional){ newParam.value = p.DefaultValue; } parameters.Add(newParam); } if (newMethod.ReturnType != typeof(void)){ this.returnValue = new BBObjectParameter{bb = blackboard}; this.returnValue.SetType(newMethod.ReturnType); } }; var menu = new UnityEditor.GenericMenu(); foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(object), true)){ foreach(var m in t.GetMethods(BindingFlags.Static | BindingFlags.Public).OrderBy(m => !m.IsSpecialName) ){ if (m.IsGenericMethod) continue; var parameters = m.GetParameters(); if (parameters.Length > 3) continue; menu.AddItem(new GUIContent(t.FriendlyName() + "/" + m.SignatureName()), false, MethodSelected, m); } } menu.ShowAsContext(); Event.current.Use(); } if (targetMethod != null){ GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.DeclaringType.FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName()); GUILayout.EndVertical(); var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray(); for (var i = 0; i < paramNames.Length; i++){ EditorUtils.BBParameterField(paramNames[i], parameters[i]); } if (targetMethod.ReturnType != typeof(void)){ EditorUtils.BBParameterField("Save Return Value", returnValue, true); } } }
//////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Property")){ var menu = new UnityEditor.GenericMenu(); if (agent != null){ foreach(var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ){ menu = EditorUtils.GetMethodSelectionMenu(comp.GetType(), typeof(void), typeof(object), SetMethod, 1, true, false, menu); } menu.AddSeparator("/"); } foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)){ menu = EditorUtils.GetMethodSelectionMenu(t, typeof(void), typeof(object), SetMethod, 1, true, false, 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("Set Type", functionWrapper.GetVariables()[0].varType.FriendlyName() ); GUILayout.EndVertical(); EditorUtils.BBParameterField("Set Value", functionWrapper.GetVariables()[0]); } }