public static bool IsSupportedParameterType(Type parameterType) { return(TypeHelpers.IsSupportedParameterType(parameterType)); }
public static GenericMenu GenerateEnumTypesMenu(SkillVariable fsmVariable) { return(TypeHelpers.GenerateEnumTypesMenu(fsmVariable)); }
public static GenericMenu GeneratePropertyMenu(SkillProperty fsmProperty) { return(TypeHelpers.GeneratePropertyMenu(fsmProperty)); }
public static List <Type> GetDerivedTypeList(Type ofType, bool includeBaseType = true) { return(TypeHelpers.GetDerivedTypeList(ofType, includeBaseType)); }
public static IEnumerable <FieldInfo> GetSerializedFields(Type type) { return(TypeHelpers.GetSerializedFields(type)); }
public override bool OnGUI() { if (callMethod.manualUI) { return(DrawDefaultInspector()); } EditField("behaviour"); FsmEditorGUILayout.ReadonlyTextField(cachedTypeName); CheckCache(); EditorGUILayout.BeginHorizontal(); FsmEditorGUILayout.PrefixLabel("Method"); var buttonRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.popup); var methodName = callMethod.methodName != null ? callMethod.methodName.Value : ""; if (GUI.Button(buttonRect, methodName, EditorStyles.popup)) { TypeHelpers.GenerateMethodMenu(cachedType, SelectMethod).DropDown(buttonRect); } EditorGUILayout.EndHorizontal(); FsmEditorGUILayout.ReadonlyTextField(cachedMethodSignature); //EditorGUI.indentLevel++; if (cachedParameters != null && cachedParameters.Length > 0) { GUILayout.Label("Parameters", EditorStyles.boldLabel); for (int i = 0; i < cachedParameters.Length; i++) { //GUILayout.Label(callMethod.parameters[i].RealType.ToString()); callMethod.parameters[i] = FsmEditor.ActionEditor.EditFsmVar(cachedParameterLabels[i], callMethod.parameters[i], parameterAttributes); } } if (cachedMethod != null && cachedMethod.ReturnType != typeof(void)) { GUILayout.Label("Return", EditorStyles.boldLabel); callMethod.storeResult = FsmEditor.ActionEditor.EditFsmVar(cachedReturnLabel, callMethod.storeResult, returnAttributes); } //EditorGUI.indentLevel--; FsmEditorGUILayout.LightDivider(); EditField("everyFrame"); EditField("updateType"); FsmEditorGUILayout.LightDivider(); EditField("manualUI"); if (GUI.changed) { UpdateCache(); } return(GUI.changed); }
private static void AddPropertyMenuItems(ref GenericMenu menu, Type type, string path, int depth, bool setProperty) { if (type != null && !type.get_IsEnum() && depth < 3) { List <MemberInfo> fieldsAndProperties = ReflectionUtils.GetFieldsAndProperties(type, 20); fieldsAndProperties.Sort((MemberInfo x, MemberInfo y) => string.CompareOrdinal(x.get_Name(), y.get_Name())); using (List <MemberInfo> .Enumerator enumerator = fieldsAndProperties.GetEnumerator()) { while (enumerator.MoveNext()) { MemberInfo current = enumerator.get_Current(); if (!TypeHelpers.FilterMember(current)) { Type memberUnderlyingType = ReflectionUtils.GetMemberUnderlyingType(current); string name = current.get_Name(); bool flag = memberUnderlyingType.get_IsClass() || (setProperty ? TypeHelpers.CanSetProperty(current) : TypeHelpers.CanGetProperty(current)); if (flag) { string text = (path != "") ? (path + '/' + name) : name; if (TypeHelpers.HasProperties(memberUnderlyingType)) { if (TypeHelpers.CanSetProperty(current)) { menu.AddItem(new GUIContent(text + '/' + Labels.StripNamespace(memberUnderlyingType.ToString())), false, new GenericMenu.MenuFunction2(TypeHelpers.SetFsmPropertyName), text); } } else { menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(TypeHelpers.SetFsmPropertyName), text); } } if (string.IsNullOrEmpty(TypeHelpers.subPropertyPath) && depth > 0 && memberUnderlyingType.IsSubclassOf(typeof(Component))) { menu.AddItem(new GUIContent(path + Strings.get_SubMenu_More_()), false, new GenericMenu.MenuFunction2(TypeHelpers.GenerateSubPropertyMenu), path); break; } if (flag || memberUnderlyingType.IsSubclassOf(typeof(Component))) { TypeHelpers.AddPropertyMenuItems(ref menu, memberUnderlyingType, (path != "") ? (path + '/' + name) : name, depth + 1, setProperty); } } } } } }
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); }
public static GenericMenu GenerateStaticMethodMenu(Type type, GenericMenu.MenuFunction2 selectionFunction) { return(TypeHelpers.GenerateMethodMenu(type, selectionFunction, 24)); }
public static string GetTypeTooltip(Type type) { if (type == null) { return(""); } string text; if (Labels.typeTooltips.TryGetValue(type, ref text)) { return(text); } text = "Type: "; if (type == typeof(SkillOwnerDefault)) { text += "GameObject"; } else { if (type == typeof(SkillEvent)) { text += "FsmEvent"; } else { if (type == typeof(SkillVar)) { text += "FsmVar"; } else { if (type == typeof(SkillArray)) { text += "Array"; } else { if (type.IsSubclassOf(typeof(NamedVariable))) { PropertyInfo property = type.GetProperty("Value"); if (property != null) { text += Labels.StripUnityEngineNamespace(TypeHelpers.GetFriendlyName(property.get_PropertyType())); } else { text += "Unknown"; } } else { if (type.get_IsArray()) { text = Labels.GetTypeTooltip(type.GetElementType()) + " Array"; } else { text += TypeHelpers.GetFriendlyName(type); } } } } } } Labels.typeTooltips.Add(type, Labels.NicifyTypeTooltip(text)); return(text); }