// Token: 0x060001F7 RID: 503 RVA: 0x00012608 File Offset: 0x00010808 public static Dictionary <string, object> SerializeTask(Task task, bool serializeChildren, ref List <Object> unityObjects) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Type", task.GetType()); dictionary.Add("NodeData", JSONSerialization.SerializeNodeData(task.NodeData)); dictionary.Add("ID", task.ID); dictionary.Add("Name", task.FriendlyName); dictionary.Add("Instant", task.IsInstant); if (task.Disabled) { dictionary.Add("Disabled", task.Disabled); } JSONSerialization.SerializeFields(task, ref dictionary, ref unityObjects); if (serializeChildren && task is ParentTask) { ParentTask parentTask = task as ParentTask; if (parentTask.Children != null && parentTask.Children.Count > 0) { Dictionary <string, object>[] array = new Dictionary <string, object> [parentTask.Children.Count]; for (int i = 0; i < parentTask.Children.Count; i++) { array[i] = JSONSerialization.SerializeTask(parentTask.Children[i], serializeChildren, ref unityObjects); } dictionary.Add("Children", array); } } return(dictionary); }
// Token: 0x060001F9 RID: 505 RVA: 0x0001280C File Offset: 0x00010A0C private static Dictionary <string, object> SerializeVariable(SharedVariable sharedVariable, ref List <Object> unityObjects) { if (sharedVariable == null) { return(null); } Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Type", sharedVariable.GetType()); dictionary.Add("Name", sharedVariable.Name); if (sharedVariable.IsShared) { dictionary.Add("IsShared", sharedVariable.IsShared); } if (sharedVariable.IsGlobal) { dictionary.Add("IsGlobal", sharedVariable.IsGlobal); } if (sharedVariable.NetworkSync) { dictionary.Add("NetworkSync", sharedVariable.NetworkSync); } if (!string.IsNullOrEmpty(sharedVariable.PropertyMapping)) { dictionary.Add("PropertyMapping", sharedVariable.PropertyMapping); if (!object.Equals(sharedVariable.PropertyMappingOwner, null)) { dictionary.Add("PropertyMappingOwner", unityObjects.Count); unityObjects.Add(sharedVariable.PropertyMappingOwner); } } JSONSerialization.SerializeFields(sharedVariable, ref dictionary, ref unityObjects); return(dictionary); }
// Token: 0x060001F6 RID: 502 RVA: 0x000125C4 File Offset: 0x000107C4 private static Dictionary <string, object>[] SerializeVariables(List <SharedVariable> variables, ref List <Object> unityObjects) { Dictionary <string, object>[] array = new Dictionary <string, object> [variables.Count]; for (int i = 0; i < variables.Count; i++) { array[i] = JSONSerialization.SerializeVariable(variables[i], ref unityObjects); } return(array); }
// Token: 0x06000259 RID: 601 RVA: 0x000164C4 File Offset: 0x000146C4 public static TaskSerializer CopySerialized(Task task) { TaskSerializer taskSerializer = new TaskSerializer(); taskSerializer.offset = (task.NodeData.NodeDesigner as NodeDesigner).GetAbsolutePosition() + new Vector2(10f, 10f); taskSerializer.unityObjects = new List <Object>(); taskSerializer.serialization = MiniJSON.Serialize(JSONSerialization.SerializeTask(task, false, ref taskSerializer.unityObjects)); return(taskSerializer); }
// Token: 0x060001A6 RID: 422 RVA: 0x0000F010 File Offset: 0x0000D210 private void SerializeVariables() { if (this.mVariableSource == null) { this.mVariableSource = GlobalVariables.Instance; } if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(this.mVariableSource); } else { JSONSerialization.Save(this.mVariableSource); } }
// Token: 0x060001F5 RID: 501 RVA: 0x0001253C File Offset: 0x0001073C public static void Save(GlobalVariables variables) { if (variables == null) { return; } JSONSerialization.variableSerializationData = new VariableSerializationData(); JSONSerialization.fieldSerializationData = JSONSerialization.variableSerializationData.fieldSerializationData; Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Variables", JSONSerialization.SerializeVariables(variables.Variables, ref JSONSerialization.fieldSerializationData.unityObjects)); JSONSerialization.variableSerializationData.JSONSerialization = MiniJSON.Serialize(dictionary); variables.VariableData = JSONSerialization.variableSerializationData; variables.Version = "1.5.7"; BehaviorDesignerUtility.SetObjectDirty(variables); }
// Token: 0x060002B9 RID: 697 RVA: 0x0001AB2C File Offset: 0x00018D2C public static bool DrawVariables(IVariableSource variableSource, BehaviorSource behaviorSource, ref string variableName, ref bool focusNameField, ref int variableTypeIndex, ref Vector2 scrollPosition, ref List <float> variablePosition, ref float variableStartPosition, ref int selectedVariableIndex, ref string selectedVariableName, ref int selectedVariableTypeIndex) { scrollPosition = GUILayout.BeginScrollView(scrollPosition, new GUILayoutOption[0]); bool flag = false; bool flag2 = false; List <SharedVariable> list = (variableSource == null) ? null : variableSource.GetAllVariables(); if (VariableInspector.DrawHeader(variableSource, behaviorSource == null, ref variableStartPosition, ref variableName, ref focusNameField, ref variableTypeIndex, ref selectedVariableIndex, ref selectedVariableName, ref selectedVariableTypeIndex)) { flag = true; } list = ((variableSource == null) ? null : variableSource.GetAllVariables()); if (list != null && list.Count > 0) { GUI.enabled = !flag2; if (VariableInspector.DrawAllVariables(true, variableSource, ref list, true, ref variablePosition, ref selectedVariableIndex, ref selectedVariableName, ref selectedVariableTypeIndex, true, true)) { flag = true; } } if (flag && variableSource != null) { variableSource.SetAllVariables(list); } GUI.enabled = true; GUILayout.EndScrollView(); if (flag && !EditorApplication.isPlayingOrWillChangePlaymode && behaviorSource != null && behaviorSource.Owner is Behavior) { Behavior behavior = behaviorSource.Owner as Behavior; if (behavior.ExternalBehavior != null) { if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(behaviorSource); } else { JSONSerialization.Save(behaviorSource); } BehaviorSource behaviorSource2 = behavior.ExternalBehavior.GetBehaviorSource(); behaviorSource2.CheckForSerialization(true, null); VariableInspector.SyncVariables(behaviorSource2, list); } } return(flag); }
// Token: 0x06000187 RID: 391 RVA: 0x0000D71C File Offset: 0x0000B91C public static bool DrawInspectorGUI(BehaviorSource behaviorSource, bool fromInspector, ref bool showVariables) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.LabelField("Behavior Name", new GUILayoutOption[] { GUILayout.Width(120f) }); behaviorSource.behaviorName = EditorGUILayout.TextField(behaviorSource.behaviorName, new GUILayoutOption[0]); if (fromInspector && GUILayout.Button("Open", new GUILayoutOption[0])) { BehaviorDesignerWindow.ShowWindow(); BehaviorDesignerWindow.instance.LoadBehavior(behaviorSource, false, true); } GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Behavior Description", new GUILayoutOption[0]); behaviorSource.behaviorDescription = EditorGUILayout.TextArea(behaviorSource.behaviorDescription, new GUILayoutOption[] { GUILayout.Height(48f) }); if (fromInspector) { string text = "BehaviorDesigner.VariablesFoldout." + behaviorSource.GetHashCode(); if (showVariables = EditorGUILayout.Foldout(EditorPrefs.GetBool(text, true), "Variables")) { EditorGUI.indentLevel++; List <SharedVariable> allVariables = behaviorSource.GetAllVariables(); if (allVariables != null && VariableInspector.DrawAllVariables(false, behaviorSource, ref allVariables, false, ref ExternalBehaviorInspector.variablePosition, ref ExternalBehaviorInspector.selectedVariableIndex, ref ExternalBehaviorInspector.selectedVariableName, ref ExternalBehaviorInspector.selectedVariableTypeIndex, true, false)) { if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(behaviorSource); } else { JSONSerialization.Save(behaviorSource); } } EditorGUI.indentLevel--; } EditorPrefs.SetBool(text, showVariables); } return(EditorGUI.EndChangeCheck()); }
// Token: 0x060002C6 RID: 710 RVA: 0x0001BDC4 File Offset: 0x00019FC4 private static void PropertySelected(object selected) { VariableInspector.SelectedPropertyMapping selectedPropertyMapping = selected as VariableInspector.SelectedPropertyMapping; if (selectedPropertyMapping.Property.Equals("None")) { VariableInspector.mPropertyMappingVariable.PropertyMapping = string.Empty; VariableInspector.mPropertyMappingVariable.PropertyMappingOwner = null; } else { VariableInspector.mPropertyMappingVariable.PropertyMapping = selectedPropertyMapping.Property; VariableInspector.mPropertyMappingVariable.PropertyMappingOwner = selectedPropertyMapping.GameObject; } if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(VariableInspector.mPropertyMappingBehaviorSource); } else { JSONSerialization.Save(VariableInspector.mPropertyMappingBehaviorSource); } }
// Token: 0x060001F4 RID: 500 RVA: 0x000123A8 File Offset: 0x000105A8 public static void Save(BehaviorSource behaviorSource) { behaviorSource.CheckForSerialization(false, null); JSONSerialization.taskSerializationData = new TaskSerializationData(); JSONSerialization.fieldSerializationData = JSONSerialization.taskSerializationData.fieldSerializationData; Dictionary <string, object> dictionary = new Dictionary <string, object>(); if (behaviorSource.EntryTask != null) { dictionary.Add("EntryTask", JSONSerialization.SerializeTask(behaviorSource.EntryTask, true, ref JSONSerialization.fieldSerializationData.unityObjects)); } if (behaviorSource.RootTask != null) { dictionary.Add("RootTask", JSONSerialization.SerializeTask(behaviorSource.RootTask, true, ref JSONSerialization.fieldSerializationData.unityObjects)); } if (behaviorSource.DetachedTasks != null && behaviorSource.DetachedTasks.Count > 0) { Dictionary <string, object>[] array = new Dictionary <string, object> [behaviorSource.DetachedTasks.Count]; for (int i = 0; i < behaviorSource.DetachedTasks.Count; i++) { array[i] = JSONSerialization.SerializeTask(behaviorSource.DetachedTasks[i], true, ref JSONSerialization.fieldSerializationData.unityObjects); } dictionary.Add("DetachedTasks", array); } if (behaviorSource.Variables != null && behaviorSource.Variables.Count > 0) { dictionary.Add("Variables", JSONSerialization.SerializeVariables(behaviorSource.Variables, ref JSONSerialization.fieldSerializationData.unityObjects)); } JSONSerialization.taskSerializationData.Version = "1.5.7"; JSONSerialization.taskSerializationData.JSONSerialization = MiniJSON.Serialize(dictionary); behaviorSource.TaskData = JSONSerialization.taskSerializationData; if (behaviorSource.Owner != null && !behaviorSource.Owner.Equals(null)) { BehaviorDesignerUtility.SetObjectDirty(behaviorSource.Owner.GetObject()); } }
// Token: 0x060001FA RID: 506 RVA: 0x0001290C File Offset: 0x00010B0C private static void SerializeFields(object obj, ref Dictionary <string, object> dict, ref List <Object> unityObjects) { FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType()); for (int i = 0; i < allFields.Length; i++) { if (!BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(NonSerializedAttribute)) && ((!allFields[i].IsPrivate && !allFields[i].IsFamily) || BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(SerializeField))) && (!(obj is ParentTask) || !allFields[i].Name.Equals("children"))) { if (allFields[i].GetValue(obj) != null) { string key = (allFields[i].FieldType.Name + allFields[i].Name).ToString(); if (typeof(IList).IsAssignableFrom(allFields[i].FieldType)) { IList list = allFields[i].GetValue(obj) as IList; if (list != null) { List <object> list2 = new List <object>(); for (int j = 0; j < list.Count; j++) { if (list[j] == null) { list2.Add(null); } else { Type type = list[j].GetType(); if (list[j] is Task) { Task task = list[j] as Task; list2.Add(task.ID); } else if (list[j] is SharedVariable) { list2.Add(JSONSerialization.SerializeVariable(list[j] as SharedVariable, ref unityObjects)); } else if (list[j] is Object) { Object @object = list[j] as Object; if (!object.ReferenceEquals(@object, null) && @object != null) { list2.Add(unityObjects.Count); unityObjects.Add(@object); } } else if (type.Equals(typeof(LayerMask))) { list2.Add(((LayerMask)list[j]).value); } else if (type.IsPrimitive || type.IsEnum || type.Equals(typeof(string)) || type.Equals(typeof(Vector2)) || type.Equals(typeof(Vector3)) || type.Equals(typeof(Vector4)) || type.Equals(typeof(Quaternion)) || type.Equals(typeof(Matrix4x4)) || type.Equals(typeof(Color)) || type.Equals(typeof(Rect))) { list2.Add(list[j]); } else { Dictionary <string, object> item = new Dictionary <string, object>(); JSONSerialization.SerializeFields(list[j], ref item, ref unityObjects); list2.Add(item); } } } if (list2 != null) { dict.Add(key, list2); } } } else if (typeof(Task).IsAssignableFrom(allFields[i].FieldType)) { Task task2 = allFields[i].GetValue(obj) as Task; if (task2 != null) { if (BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(InspectTaskAttribute))) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Type", task2.GetType()); JSONSerialization.SerializeFields(task2, ref dictionary, ref unityObjects); dict.Add(key, dictionary); } else { dict.Add(key, task2.ID); } } } else if (typeof(SharedVariable).IsAssignableFrom(allFields[i].FieldType)) { if (!dict.ContainsKey(key)) { dict.Add(key, JSONSerialization.SerializeVariable(allFields[i].GetValue(obj) as SharedVariable, ref unityObjects)); } } else if (typeof(Object).IsAssignableFrom(allFields[i].FieldType)) { Object object2 = allFields[i].GetValue(obj) as Object; if (!object.ReferenceEquals(object2, null) && object2 != null) { dict.Add(key, unityObjects.Count); unityObjects.Add(object2); } } else if (allFields[i].FieldType.Equals(typeof(LayerMask))) { dict.Add(key, ((LayerMask)allFields[i].GetValue(obj)).value); } else if (allFields[i].FieldType.IsPrimitive || allFields[i].FieldType.IsEnum || allFields[i].FieldType.Equals(typeof(string)) || allFields[i].FieldType.Equals(typeof(Vector2)) || allFields[i].FieldType.Equals(typeof(Vector3)) || allFields[i].FieldType.Equals(typeof(Vector4)) || allFields[i].FieldType.Equals(typeof(Quaternion)) || allFields[i].FieldType.Equals(typeof(Matrix4x4)) || allFields[i].FieldType.Equals(typeof(Color)) || allFields[i].FieldType.Equals(typeof(Rect))) { dict.Add(key, allFields[i].GetValue(obj)); } else if (allFields[i].FieldType.Equals(typeof(AnimationCurve))) { AnimationCurve animationCurve = allFields[i].GetValue(obj) as AnimationCurve; Dictionary <string, object> dictionary2 = new Dictionary <string, object>(); if (animationCurve.keys != null) { Keyframe[] keys = animationCurve.keys; List <List <object> > list3 = new List <List <object> >(); for (int k = 0; k < keys.Length; k++) { list3.Add(new List <object> { keys[k].time, keys[k].value, keys[k].inTangent, keys[k].outTangent, keys[k].tangentMode }); } dictionary2.Add("Keys", list3); } dictionary2.Add("PreWrapMode", animationCurve.preWrapMode); dictionary2.Add("PostWrapMode", animationCurve.postWrapMode); dict.Add(key, dictionary2); } else { Dictionary <string, object> value = new Dictionary <string, object>(); JSONSerialization.SerializeFields(allFields[i].GetValue(obj), ref value, ref unityObjects); dict.Add(key, value); } } } } }
// Token: 0x06000148 RID: 328 RVA: 0x0000B544 File Offset: 0x00009744 public static bool DrawInspectorGUI(Behavior behavior, SerializedObject serializedObject, bool fromInspector, ref bool externalModification, ref bool showOptions, ref bool showVariables) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.LabelField("Behavior Name", new GUILayoutOption[] { GUILayout.Width(120f) }); behavior.GetBehaviorSource().behaviorName = EditorGUILayout.TextField(behavior.GetBehaviorSource().behaviorName, new GUILayoutOption[0]); if (fromInspector && GUILayout.Button("Open", new GUILayoutOption[0])) { BehaviorDesignerWindow.ShowWindow(); BehaviorDesignerWindow.instance.LoadBehavior(behavior.GetBehaviorSource(), false, true); } GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Behavior Description", new GUILayoutOption[0]); behavior.GetBehaviorSource().behaviorDescription = EditorGUILayout.TextArea(behavior.GetBehaviorSource().behaviorDescription, BehaviorDesignerUtility.TaskInspectorCommentGUIStyle, new GUILayoutOption[] { GUILayout.Height(48f) }); serializedObject.Update(); GUI.enabled = ((int)PrefabUtility.GetPrefabType(behavior) != 3 || BehaviorDesignerPreferences.GetBool(BDPreferences.EditablePrefabInstances)); SerializedProperty serializedProperty = serializedObject.FindProperty("externalBehavior"); ExternalBehavior externalBehavior = serializedProperty.objectReferenceValue as ExternalBehavior; EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); serializedObject.ApplyModifiedProperties(); if ((!object.ReferenceEquals(behavior.ExternalBehavior, null) && !behavior.ExternalBehavior.Equals(externalBehavior)) || (!object.ReferenceEquals(externalBehavior, null) && !externalBehavior.Equals(behavior.ExternalBehavior))) { if (!object.ReferenceEquals(behavior.ExternalBehavior, null)) { behavior.ExternalBehavior.BehaviorSource.Owner = behavior.ExternalBehavior; behavior.ExternalBehavior.BehaviorSource.CheckForSerialization(true, behavior.GetBehaviorSource()); } else { behavior.GetBehaviorSource().EntryTask = null; behavior.GetBehaviorSource().RootTask = null; behavior.GetBehaviorSource().DetachedTasks = null; behavior.GetBehaviorSource().Variables = null; behavior.GetBehaviorSource().CheckForSerialization(true, null); behavior.GetBehaviorSource().Variables = null; if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(behavior.GetBehaviorSource()); } else { JSONSerialization.Save(behavior.GetBehaviorSource()); } } externalModification = true; } GUI.enabled = true; serializedProperty = serializedObject.FindProperty("group"); EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); string text; if (fromInspector) { text = "BehaviorDesigner.VariablesFoldout." + behavior.GetHashCode(); if (showVariables = EditorGUILayout.Foldout(EditorPrefs.GetBool(text, true), "Variables")) { EditorGUI.indentLevel++; bool flag = false; BehaviorSource behaviorSource = behavior.GetBehaviorSource(); List <SharedVariable> allVariables = behaviorSource.GetAllVariables(); if (allVariables != null && allVariables.Count > 0) { if (VariableInspector.DrawAllVariables(false, behaviorSource, ref allVariables, false, ref BehaviorInspector.variablePosition, ref BehaviorInspector.selectedVariableIndex, ref BehaviorInspector.selectedVariableName, ref BehaviorInspector.selectedVariableTypeIndex, false, true)) { if (!EditorApplication.isPlayingOrWillChangePlaymode && behavior.ExternalBehavior != null) { BehaviorSource behaviorSource2 = behavior.ExternalBehavior.GetBehaviorSource(); behaviorSource2.CheckForSerialization(true, null); if (VariableInspector.SyncVariables(behaviorSource2, allVariables)) { if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(behaviorSource2); } else { JSONSerialization.Save(behaviorSource2); } } } flag = true; } } else { EditorGUILayout.LabelField("There are no variables to display", new GUILayoutOption[0]); } if (flag) { if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization)) { BinarySerialization.Save(behaviorSource); } else { JSONSerialization.Save(behaviorSource); } } EditorGUI.indentLevel--; } EditorPrefs.SetBool(text, showVariables); } text = "BehaviorDesigner.OptionsFoldout." + behavior.GetHashCode(); if (!fromInspector || (showOptions = EditorGUILayout.Foldout(EditorPrefs.GetBool(text, true), "Options"))) { if (fromInspector) { EditorGUI.indentLevel++; } serializedProperty = serializedObject.FindProperty("startWhenEnabled"); EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); serializedProperty = serializedObject.FindProperty("pauseWhenDisabled"); EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); serializedProperty = serializedObject.FindProperty("restartWhenComplete"); EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); serializedProperty = serializedObject.FindProperty("resetValuesOnRestart"); EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); serializedProperty = serializedObject.FindProperty("logTaskChanges"); EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]); if (fromInspector) { EditorGUI.indentLevel--; } } if (fromInspector) { EditorPrefs.SetBool(text, showOptions); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); return(true); } return(false); }