public static void Rebuild() { PropertyDrawers.drawers = new Dictionary <Type, PropertyDrawer>(); Assembly[] assemblies = AppDomain.get_CurrentDomain().GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Assembly assembly = assemblies[i]; try { Type[] exportedTypes = assembly.GetExportedTypes(); Type[] array = exportedTypes; for (int j = 0; j < array.Length; j++) { Type type = array[j]; if (typeof(PropertyDrawer).IsAssignableFrom(type) && type.get_IsClass() && !type.get_IsAbstract()) { PropertyDrawerAttribute attribute = CustomAttributeHelpers.GetAttribute <PropertyDrawerAttribute>(type); Type type2 = (attribute != null) ? attribute.InspectedType : null; if (type2 != null && !PropertyDrawers.drawers.ContainsKey(type2)) { PropertyDrawers.drawers.Add(type2, (PropertyDrawer)Activator.CreateInstance(type)); } } } } catch (Exception ex) { NotSupportedException arg_B2_0 = ex as NotSupportedException; } } }
public static void Init() { ActionTargets.lookup.Clear(); using (List <Type> .Enumerator enumerator = Actions.List.GetEnumerator()) { while (enumerator.MoveNext()) { Type current = enumerator.get_Current(); IEnumerable <Attribute> attributes = CustomAttributeHelpers.GetAttributes(current, typeof(ActionTarget)); using (IEnumerator <Attribute> enumerator2 = attributes.GetEnumerator()) { while (enumerator2.MoveNext()) { Attribute current2 = enumerator2.get_Current(); ActionTargets.AddActionTarget(current, (ActionTarget)current2); } } } } using (List <Type> .Enumerator enumerator3 = Actions.List.GetEnumerator()) { while (enumerator3.MoveNext()) { Type current3 = enumerator3.get_Current(); if (!ActionTargets.HasNoActionTargetsAttribute(current3) && !ActionTargets.HasActionTargets(current3)) { ActionTargets.GenerateActionTargets(current3); } } } }
public static void Rebuild() { CustomActionEditors.Clear(); Assembly[] assemblies = AppDomain.get_CurrentDomain().GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Assembly assembly = assemblies[i]; try { Type[] exportedTypes = assembly.GetExportedTypes(); Type[] array = exportedTypes; for (int j = 0; j < array.Length; j++) { Type type = array[j]; if (typeof(CustomActionEditor).IsAssignableFrom(type) && type.get_IsClass() && !type.get_IsAbstract()) { CustomActionEditorAttribute attribute = CustomAttributeHelpers.GetAttribute <CustomActionEditorAttribute>(type); if (attribute != null) { CustomActionEditors.editorsLookup.Add(attribute.InspectedType, type); } } } } catch (Exception ex) { NotSupportedException arg_87_0 = ex as NotSupportedException; } } }
public static string GetTooltip(FieldInfo field) { if (field == null) { return(null); } return(Actions.GetTooltip(CustomAttributeHelpers.GetCustomAttributes(field))); }
public static string GetActionCategory(Type objType) { if (objType == null) { return(null); } return(Actions.GetActionCategory(CustomAttributeHelpers.GetCustomAttributes(objType))); }
public static bool IsObsolete(Type type) { if (type == null) { return(true); } object[] customAttributes = CustomAttributeHelpers.GetCustomAttributes(type); return(Enumerable.Any <ObsoleteAttribute>(Enumerable.OfType <ObsoleteAttribute>(customAttributes))); }
private static void FindObjectTypeAttribute(Type actionType, FieldInfo field) { ObjectTypeAttribute attribute = CustomAttributeHelpers.GetAttribute <ObjectTypeAttribute>(field); if (attribute == null || attribute.get_ObjectType() == null) { return; } ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_ObjectType(), field.get_Name(), false)); }
public static UIHint GetUIHint(object[] attributes) { UIHintAttribute attribute = CustomAttributeHelpers.GetAttribute <UIHintAttribute>(attributes); if (attribute == null) { return(0); } return(attribute.get_Hint()); }
public static Type GetObjectType(object[] attributes, Type defaultType = null) { ObjectTypeAttribute attribute = CustomAttributeHelpers.GetAttribute <ObjectTypeAttribute>(attributes); if (attribute != null) { return(attribute.get_ObjectType()); } return(defaultType ?? typeof(Object)); }
public static string GetActionSection(IEnumerable <object> attributes) { ActionSection attribute = CustomAttributeHelpers.GetAttribute <ActionSection>(attributes); if (attribute == null) { return(null); } return(attribute.get_Section()); }
public static string GetNote(IEnumerable <object> attributes) { NoteAttribute attribute = CustomAttributeHelpers.GetAttribute <NoteAttribute>(attributes); if (attribute == null) { return(null); } return(attribute.get_Text()); }
public static string GetTooltip(Type type, IEnumerable <object> attributes) { string text = Labels.GetTypeTooltip(type); TooltipAttribute attribute = CustomAttributeHelpers.GetAttribute <TooltipAttribute>(attributes); if (attribute != null) { text = text + Environment.get_NewLine() + attribute.get_Text(); } return(text); }
public static IEnumerable <Attribute> GetAttributes(Type type, Type attributeType) { object[] customAttributes = CustomAttributeHelpers.GetCustomAttributes(type); List <Attribute> list = new List <Attribute>(); object[] array = customAttributes; for (int i = 0; i < array.Length; i++) { object obj = array[i]; if (obj.GetType() == attributeType) { list.Add(obj as Attribute); } } return(list); }
public static void OpenWikiPage(SkillStateAction action) { HelpUrlAttribute attribute = CustomAttributeHelpers.GetAttribute <HelpUrlAttribute>(action.GetType()); if (attribute != null) { Application.OpenURL(attribute.get_Url()); return; } string topic = Labels.StripNamespace(action.ToString()); if (!EditorCommands.OpenWikiPage(topic)) { EditorCommands.SearchWikiHelp(action); } }
private static void GenerateActionTargets(Type actionType) { FieldInfo[] fields = actionType.GetFields(20); FieldInfo[] array = fields; for (int i = 0; i < array.Length; i++) { FieldInfo field = array[i]; if (!CustomAttributeHelpers.HasUIHint(field, 10)) { ActionTargets.FindCheckForComponentAttribute(actionType, field); ActionTargets.FindObjectTypeAttribute(actionType, field); ActionTargets.FindMaterialParameters(actionType, field); ActionTargets.FindGameObjectParameters(actionType, field); ActionTargets.FindColliderParameters(actionType, field); ActionTargets.FindUIHintParameters(actionType, field); } } }
private static void FindUIHintParameters(Type actionType, FieldInfo field) { IEnumerable <UIHintAttribute> attributes = CustomAttributeHelpers.GetAttributes <UIHintAttribute>(field); using (IEnumerator <UIHintAttribute> enumerator = attributes.GetEnumerator()) { while (enumerator.MoveNext()) { UIHintAttribute current = enumerator.get_Current(); UIHint hint = current.get_Hint(); UIHint uIHint = hint; if (uIHint == 6) { ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(AnimationClip), field.get_Name(), false)); } } } }
public static string GetObsoleteMessage(Type type) { if (type == null) { return(""); } object[] customAttributes = CustomAttributeHelpers.GetCustomAttributes(type); object[] array = customAttributes; for (int i = 0; i < array.Length; i++) { object obj = array[i]; ObsoleteAttribute obsoleteAttribute = obj as ObsoleteAttribute; if (obsoleteAttribute != null) { return(obsoleteAttribute.get_Message()); } } return(""); }
private static void FindCheckForComponentAttribute(Type actionType, FieldInfo field) { CheckForComponentAttribute attribute = CustomAttributeHelpers.GetAttribute <CheckForComponentAttribute>(field); if (attribute != null) { if (attribute.get_Type0() != null) { ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_Type0(), field.get_Name(), false)); } if (attribute.get_Type1() != null) { ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_Type1(), field.get_Name(), false)); } if (attribute.get_Type2() != null) { ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_Type2(), field.get_Name(), false)); } } }
private static void CheckActionParameter(SkillState state, SkillStateAction action, FieldInfo field) { if (state == null || action == null || field == null || state.get_Fsm() == null) { return; } Object ownerObject = state.get_Fsm().get_OwnerObject(); FsmErrorChecker.ownerIsAsset = SkillPrefabs.IsPersistent(ownerObject); FsmErrorChecker.gameObject = state.get_Fsm().get_GameObject(); FsmErrorChecker.checkingFsm = state.get_Fsm(); FsmErrorChecker.checkingState = state; FsmErrorChecker.checkingAction = action; FsmErrorChecker.checkingParameter = field.get_Name(); Type fieldType = field.get_FieldType(); object value = field.GetValue(action); FsmErrorChecker.attributes = CustomAttributeHelpers.GetCustomAttributes(field); FsmErrorChecker.CheckParameterType(fieldType, value); }
public static SkillInt FsmIntField(GUIContent label, Skill fsm, SkillInt fsmInt, object[] attributes) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); if (fsmInt.get_UseVariable()) { fsmInt = VariableEditor.DoFsmIntPopup(label, fsm, fsmInt); } else { UIHint uIHint = CustomAttributeHelpers.GetUIHint(attributes); UIHint uIHint2 = uIHint; if (uIHint2 == 8) { fsmInt.set_Value(EditorGUILayout.LayerField(label, Convert.ToInt32(fsmInt.get_Value(), CultureInfo.get_CurrentCulture()), new GUILayoutOption[0])); } else { fsmInt.set_Value(EditorGUILayout.IntField(label, fsmInt.get_Value(), new GUILayoutOption[0])); } } fsmInt = (SkillInt)VariableEditor.VariableToggle(fsmInt, label.get_text()); VariableEditor.EndVariableEditor(fsmInt); return(fsmInt); }
public static bool HasNoActionTargetsAttribute(Type actionType) { return(CustomAttributeHelpers.HasAttribute <NoActionTargetsAttribute>(actionType)); }
private static void FindGameObjectParameters(Type actionType, FieldInfo field) { if ((field.get_FieldType() == typeof(SkillOwnerDefault) || field.get_FieldType() == typeof(SkillGameObject) || field.get_FieldType() == typeof(GameObject)) && !CustomAttributeHelpers.HasAttribute <CheckForComponentAttribute>(field)) { ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(GameObject), field.get_Name(), false)); } }
public static bool HasUIHint(FieldInfo field, UIHint uiHintValue) { return(CustomAttributeHelpers.HasUIHint(field.GetCustomAttributes(true), uiHintValue)); }
public static bool HasUIHint(object[] attributes, UIHint uiHintValue) { IEnumerable <UIHintAttribute> attributes2 = CustomAttributeHelpers.GetAttributes <UIHintAttribute>(attributes); return(Enumerable.Any <UIHintAttribute>(attributes2, (UIHintAttribute uiHint) => uiHint.get_Hint() == uiHintValue)); }
public static void BuildList() { Actions.actionsList.Clear(); Assembly[] assemblies = AppDomain.get_CurrentDomain().GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Assembly assembly = assemblies[i]; try { Type[] exportedTypes = assembly.GetExportedTypes(); Type[] array = exportedTypes; for (int j = 0; j < array.Length; j++) { Type type = array[j]; if (typeof(ISkillStateAction).IsAssignableFrom(type) && type.get_IsClass() && !type.get_IsAbstract() && (!FsmEditorSettings.HideObsoleteActions || (FsmEditorSettings.HideObsoleteActions && !CustomAttributeHelpers.IsObsolete(type)))) { Actions.actionsList.Add(type); } } } catch (Exception ex) { NotSupportedException arg_90_0 = ex as NotSupportedException; } } Actions.BuildCategoryList(); Actions.InitCategories(); Actions.UpdateUsage(); ActionScripts.Init(); ActionTargets.Init(); }
public static IEnumerable <T> GetAttributes <T>(Type type) where T : Attribute { return(CustomAttributeHelpers.GetAttributes <T>(type.GetCustomAttributes(true))); }
public static SkillString FsmStringField(GUIContent label, Skill fsm, SkillString fsmString, object[] attributes) { if (fsmString.get_UseVariable()) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); fsmString = VariableEditor.DoFsmStringPopup(label, fsm, fsmString); } else { if (fsmString.get_Value() == null) { fsmString.set_Value(string.Empty); } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); UIHint uIHint = CustomAttributeHelpers.GetUIHint(attributes); switch (uIHint) { case 1: { GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Label(label, new GUILayoutOption[0]); Rect rect = GUILayoutUtility.GetRect(SkillEditorContent.TempContent(fsmString.get_Value(), ""), SkillEditorStyles.TextArea, new GUILayoutOption[] { GUILayout.MinHeight(44f) }); rect.set_width(340f); fsmString.set_Value(EditorGUI.TextArea(rect, fsmString.get_Value())); GUILayout.EndVertical(); goto IL_363; } case 2: fsmString.set_Value(ActionEditor.EditComponentName(label, fsmString.get_Value(), typeof(Behaviour))); goto IL_363; case 3: fsmString.set_Value(ActionEditor.EditComponentName(label, fsmString.get_Value(), typeof(MonoBehaviour))); ActionEditor.TrySetBehaviourContext(fsmString.get_Value()); goto IL_363; case 4: fsmString.set_Value(ActionEditor.EditMethodName(label, fsmString.get_Value(), false)); goto IL_363; case 6: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimationNamePopup(fsmString); goto IL_363; case 7: fsmString.set_Value(EditorGUILayout.TagField(label, fsmString.get_Value(), new GUILayoutOption[0])); goto IL_363; case 8: StringEditor.LayerNamePopup(label, fsmString, null, null); goto IL_363; case 11: { fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); EditorGUI.BeginChangeCheck(); string text = SkillEditorGUILayout.ScriptListPopup(); if (EditorGUI.EndChangeCheck() && text != "") { fsmString.set_Value(text); goto IL_363; } goto IL_363; } case 15: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.FsmNamePopup(fsmString); goto IL_363; case 16: fsmString.set_Value(ActionEditor.EditFsmEvent(label, fsmString.get_Value())); goto IL_363; case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.VariablePopup(fsmString, uIHint); goto IL_363; case 32: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorFloatPopup(fsmString); goto IL_363; case 33: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorBoolPopup(fsmString); goto IL_363; case 34: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorIntPopup(fsmString); goto IL_363; case 35: fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); ActionEditor.AnimatorTriggerPopup(fsmString); goto IL_363; case 36: StringEditor.SortingLayerNamePopup(label, fsmString, null, null); goto IL_363; } fsmString.set_Value(EditorGUILayout.TextField(label, fsmString.get_Value(), new GUILayoutOption[0])); } IL_363: fsmString = (SkillString)VariableEditor.VariableToggle(fsmString, label.get_text()); VariableEditor.EndVariableEditor(fsmString); return(fsmString); }
private static void CheckActionForErrors(SkillState state, SkillStateAction action) { if (action == null) { FsmErrorChecker.AddError(new FsmError(state, null, Strings.get_FsmErrorChecker_MissingActionError())); return; } action.Init(state); FsmErrorChecker.fsmEventTargetContext = null; string actionLabel = Labels.GetActionLabel(action); if (FsmEditorSettings.CheckForMissingActions && action is MissingAction) { FsmErrorChecker.AddError(new FsmError(state, action, Strings.get_FsmErrorChecker_StateHasMissingActionError())); return; } if (FsmEditorSettings.CheckForObsoleteActions) { string obsoleteMessage = CustomAttributeHelpers.GetObsoleteMessage(action.GetType()); if (!string.IsNullOrEmpty(obsoleteMessage)) { FsmErrorChecker.AddError(new FsmError(state, action, obsoleteMessage)); } } Type type = action.GetType(); FieldInfo[] fields = ActionData.GetFields(type); FieldInfo[] array = fields; for (int i = 0; i < array.Length; i++) { FieldInfo fieldInfo = array[i]; Type fieldType = fieldInfo.get_FieldType(); object value = fieldInfo.GetValue(action); if (fieldType == typeof(SkillEventTarget)) { SkillEventTarget fsmEventTarget = (SkillEventTarget)value; if (actionLabel == "Set Event Target") { FsmErrorChecker.fsmEventTargetContextGlobal = fsmEventTarget; } else { FsmErrorChecker.fsmEventTargetContext = fsmEventTarget; } } FsmErrorChecker.CheckActionParameter(state, action, fieldInfo); } string text = ""; try { text = action.ErrorCheck(); } catch (Exception ex) { Debug.Log(string.Concat(new object[] { "Bad ErrorCheck: ", type, "\n", ex })); } if (!string.IsNullOrEmpty(text)) { FsmErrorChecker.AddError(new FsmError(state, action, text)); } }
public static IEnumerable <T> GetAttributes <T>(FieldInfo field) where T : Attribute { return(CustomAttributeHelpers.GetAttributes <T>(field.GetCustomAttributes(true))); }
public static bool HasAttribute <T>(FieldInfo field) where T : Attribute { return(CustomAttributeHelpers.HasAttribute <T>(field.GetCustomAttributes(true))); }