public static SkillVar FsmVarPopup(GUIContent label, Skill fsm, SkillVar fsmVar, VariableType variableType = -1, Type objectConstraint = null) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); fsmVar = VariableEditor.DoFsmVarPopup(label, fsm, fsmVar, variableType, objectConstraint); VariableEditor.EndVariableEditor(fsmVar.get_NamedVar()); return(fsmVar); }
private void FindVariableUsage(object obj, int currentDepth = 0) { if (obj != null && currentDepth < 7) { NamedVariable namedVariable = obj as NamedVariable; if (namedVariable != null && namedVariable.get_UsesVariable()) { this.AddVariableUsage(namedVariable); return; } SkillVar fsmVar = obj as SkillVar; if (fsmVar != null && !string.IsNullOrEmpty(fsmVar.variableName)) { this.AddVariableUsage(fsmVar.get_NamedVar()); return; } if (obj.GetType().get_IsArray()) { Array array = (Array)obj; for (int i = 0; i < array.get_Length(); i++) { this.FindVariableUsage(array.GetValue(i), currentDepth); } return; } IEnumerable <FieldInfo> serializedFields = TypeHelpers.GetSerializedFields(obj.GetType()); using (IEnumerator <FieldInfo> enumerator = serializedFields.GetEnumerator()) { while (enumerator.MoveNext()) { FieldInfo current = enumerator.get_Current(); SkillSearch.currentInfo.fieldInObject = obj; SkillSearch.currentInfo.field = current; object value = current.GetValue(obj); this.FindVariableUsage(value, currentDepth + 1); } } } }
private static SkillVar DoFsmVarPopup(GUIContent label, Skill fsm, SkillVar fsmVar, VariableType typeConstraint, Type objectConstraint) { ActionEditor.DoVariableSelector(label, fsm, fsmVar.get_Type(), fsmVar.get_NamedVar(), typeConstraint, objectConstraint); fsmVar.useVariable = true; return(fsmVar); }
private static void CheckParameterType(Type type, object fieldValue) { if (type == null) { return; } if (type == typeof(SkillGameObject)) { FsmErrorChecker.CheckFsmGameObjectParameter((SkillGameObject)fieldValue); } else { if (type == typeof(SkillOwnerDefault)) { FsmErrorChecker.CheckOwnerDefaultParameter((SkillOwnerDefault)fieldValue); } else { if (type == typeof(GameObject)) { FsmErrorChecker.CheckGameObjectParameter((GameObject)fieldValue); } else { if (type == typeof(SkillEvent)) { FsmErrorChecker.CheckFsmEventParameter((SkillEvent)fieldValue); } else { if (type == typeof(SkillString)) { FsmErrorChecker.CheckFsmStringParameter((SkillString)fieldValue); } else { if (type == typeof(string)) { FsmErrorChecker.CheckStringParameter((string)fieldValue); } else { if (type.get_IsArray()) { Array array = (Array)fieldValue; if (array != null) { Type elementType = type.GetElementType(); for (int i = 0; i < array.get_Length(); i++) { FsmErrorChecker.CheckParameterType(elementType, array.GetValue(i)); } } } else { Object @object = fieldValue as Object; if (@object != null) { FsmErrorChecker.CheckObjectParameter(@object); } } } } } } } } if (type.IsSubclassOf(typeof(NamedVariable))) { if (FsmEditorSettings.CheckForRequiredField && FsmErrorChecker.IsRequiredField()) { if (fieldValue == null) { FsmErrorChecker.AddRequiredFieldError(); return; } NamedVariable namedVariable = (NamedVariable)fieldValue; if ((namedVariable.get_UseVariable() || FsmErrorChecker.IsVariableField()) && string.IsNullOrEmpty(namedVariable.get_Name())) { FsmErrorChecker.AddRequiredFieldError(); return; } } } else { if (type == typeof(SkillVar) && FsmEditorSettings.CheckForRequiredField && FsmErrorChecker.IsRequiredField()) { SkillVar fsmVar = (SkillVar)fieldValue; if (fsmVar.useVariable && (fsmVar.get_NamedVar() == null || fsmVar.get_NamedVar().get_IsNone())) { FsmErrorChecker.AddRequiredFieldError(); } } } }