///---------------------------------------------------------------------------------------------- ///---------------------------------------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 != HideFlags.HideInInspector)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 10, false, false, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, false, menu); if (typeof(UnityEngine.Component).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, false, menu); } } menu.ShowAsBrowser("Select Method", this.GetType()); Event.current.Use(); } if (targetMethod != null) { GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name); UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName()); UnityEditor.EditorGUILayout.HelpBox(DocsByReflection.GetMemberSummary(targetMethod), UnityEditor.MessageType.None); 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++) { NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], parameters[i]); } if (targetMethod.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)) { 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 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(DocsByReflection.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); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR 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 != HideFlags.HideInInspector)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 0, true, true, menu); } menu.AddSeparator("/"); } foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu); if (typeof(UnityEngine.Component).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu); } } menu.ShowAsBrowser("Select Property", this.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("Property Type", targetMethod.ReturnType.FriendlyName()); UnityEditor.EditorGUILayout.HelpBox(DocsByReflection.GetMemberSummary(targetMethod), UnityEditor.MessageType.None); GUILayout.EndVertical(); NodeCanvas.Editor.BBParameterEditor.ParameterField("Save As", returnValue, true); } }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR protected override void OnTaskInspectorGUI() { if (!Application.isPlaying && GUILayout.Button("Select Method")) { var menu = new UnityEditor.GenericMenu(); foreach (var t in TypePrefs.GetPreferedTypesList(typeof(T))) { menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, false, menu); if (typeof(T).IsAssignableFrom(t)) { menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 6, false, false, menu); } } if (menu.GetItemCount() <= 0) { menu.AddItem(new GUIContent("No Functions"), false, null); } menu.ShowAsBrowser("Select Method", this.GetType()); Event.current.Use(); } var m = targetMethod; if (m != null) { if (!targetMethod.IsStatic) { NodeCanvas.Editor.BBParameterEditor.ParameterField("Instance", target, true); } GUILayout.BeginVertical("box"); UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName()); UnityEditor.EditorGUILayout.LabelField("Method", m.Name); UnityEditor.EditorGUILayout.LabelField("Returns", m.ReturnType.FriendlyName()); UnityEditor.EditorGUILayout.HelpBox(DocsByReflection.GetMemberSummary(targetMethod), UnityEditor.MessageType.None); 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++) { NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], variables[i]); } } else { for (var i = 0; i < paramNames.Length; i++) { NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], variables[i + 1]); } if (m.ReturnType != typeof(IEnumerator)) { NodeCanvas.Editor.BBParameterEditor.ParameterField("Save Return Value", variables[0], true); } } } }