private void InitMethod(MethodInfo method) { if (method == null) { //Debug.Log("InitMethod: None"); // TODO: select none ClearCache(); } else { //Debug.Log("InitMethod: " + method.Name); cachedMethod = method; cachedMethodSignature = TypeHelpers.GetMethodSignature(method); cachedParameters = method.GetParameters(); cachedParameterLabels = new GUIContent[cachedParameters.Length]; callMethod.methodName.Value = method.Name; for (int i = 0; i < cachedParameters.Length; i++) { var parameter = cachedParameters[i]; cachedParameterLabels[i] = new GUIContent(Labels.NicifyVariableName(parameter.Name)); } cachedReturnLabel = new GUIContent("Store Result", Labels.GetTypeTooltip(method.ReturnType)); } }
public static GenericMenu GenerateMethodMenu(Type type, GenericMenu.MenuFunction2 selectionFunction, BindingFlags bindingFlags) { GenericMenu genericMenu = new GenericMenu(); if (type == null) { return(genericMenu); } MethodInfo[] methods = type.GetMethods(bindingFlags); MethodInfo[] array = methods; for (int i = 0; i < array.Length; i++) { MethodInfo methodInfo = array[i]; if (TypeHelpers.IsValidMethod(methodInfo)) { string text = TypeHelpers.GetMethodSignature(methodInfo); if (methodInfo.get_DeclaringType() == typeof(MonoBehaviour) || methodInfo.get_DeclaringType() == typeof(Component) || methodInfo.get_DeclaringType() == typeof(Behaviour) || methodInfo.get_DeclaringType() == typeof(Object)) { text = "Inherited/" + text; } genericMenu.AddItem(new GUIContent(text), false, selectionFunction, methodInfo); } } return(genericMenu); }
// NOTE: This should match format generated by TypeHelpers. private string GetMethodSignatureFromSettings() { if (callMethod.methodName == null || callMethod.parameters == null || callMethod.storeResult == null) { return(""); } return(TypeHelpers.GetMethodSignature(callMethod.methodName.Value, callMethod.parameters, callMethod.storeResult)); }
public static MethodInfo FindMethod(Type type, string methodSignature) { if (type == null) { return(null); } MethodInfo[] methods = type.GetMethods(20); MethodInfo[] array = methods; for (int i = 0; i < array.Length; i++) { MethodInfo methodInfo = array[i]; if (!methodInfo.get_IsSpecialName() && string.Equals(methodSignature, TypeHelpers.GetMethodSignature(methodInfo), 5)) { return(methodInfo); } } return(null); }