Exemplo n.º 1
0
 private static void SaveSharedVariable(SharedVariable sharedVariable, string namePrefix)
 {
     if (sharedVariable == null)
     {
         return;
     }
     BinarySerialization.SaveField(typeof(string), namePrefix + "Type", sharedVariable.GetType().ToString(), null);
     BinarySerialization.SaveField(typeof(string), namePrefix + "Name", sharedVariable.Name, null);
     if (sharedVariable.IsShared)
     {
         BinarySerialization.SaveField(typeof(bool), namePrefix + "IsShared", sharedVariable.IsShared, null);
     }
     if (sharedVariable.IsGlobal)
     {
         BinarySerialization.SaveField(typeof(bool), namePrefix + "IsGlobal", sharedVariable.IsGlobal, null);
     }
     if (sharedVariable.NetworkSync)
     {
         BinarySerialization.SaveField(typeof(bool), namePrefix + "NetworkSync", sharedVariable.NetworkSync, null);
     }
     if (!string.IsNullOrEmpty(sharedVariable.PropertyMapping))
     {
         BinarySerialization.SaveField(typeof(string), namePrefix + "PropertyMapping", sharedVariable.PropertyMapping, null);
         if (!object.Equals(sharedVariable.PropertyMappingOwner, null))
         {
             BinarySerialization.SaveField(typeof(GameObject), namePrefix + "PropertyMappingOwner", sharedVariable.PropertyMappingOwner, null);
         }
     }
     BinarySerialization.SaveFields(sharedVariable, namePrefix);
 }
Exemplo n.º 2
0
 public static void Save(BehaviorSource behaviorSource)
 {
     BinarySerialization.fieldIndex             = 0;
     BinarySerialization.taskSerializationData  = new TaskSerializationData();
     BinarySerialization.fieldSerializationData = BinarySerialization.taskSerializationData.fieldSerializationData;
     if (behaviorSource.Variables != null)
     {
         for (int i = 0; i < behaviorSource.Variables.Count; i++)
         {
             BinarySerialization.taskSerializationData.variableStartIndex.Add(BinarySerialization.fieldSerializationData.startIndex.Count);
             BinarySerialization.SaveSharedVariable(behaviorSource.Variables[i], string.Empty);
         }
     }
     if (!object.ReferenceEquals(behaviorSource.EntryTask, null))
     {
         BinarySerialization.SaveTask(behaviorSource.EntryTask, -1);
     }
     if (!object.ReferenceEquals(behaviorSource.RootTask, null))
     {
         BinarySerialization.SaveTask(behaviorSource.RootTask, 0);
     }
     if (behaviorSource.DetachedTasks != null)
     {
         for (int j = 0; j < behaviorSource.DetachedTasks.Count; j++)
         {
             BinarySerialization.SaveTask(behaviorSource.DetachedTasks[j], -1);
         }
     }
     behaviorSource.TaskData = BinarySerialization.taskSerializationData;
     if (behaviorSource.Owner != null)
     {
         EditorUtility.SetDirty(behaviorSource.Owner.GetObject());
     }
 }
Exemplo n.º 3
0
 // Token: 0x06000153 RID: 339 RVA: 0x0000BE20 File Offset: 0x0000A020
 private static void SaveNodeData(NodeData nodeData)
 {
     BinarySerialization.SaveField(typeof(Vector2), "NodeDataOffset", 0, nodeData.Offset, null);
     BinarySerialization.SaveField(typeof(string), "NodeDataComment", 0, nodeData.Comment, null);
     BinarySerialization.SaveField(typeof(bool), "NodeDataIsBreakpoint", 0, nodeData.IsBreakpoint, null);
     BinarySerialization.SaveField(typeof(bool), "NodeDataCollapsed", 0, nodeData.Collapsed, null);
     BinarySerialization.SaveField(typeof(int), "NodeDataColorIndex", 0, nodeData.ColorIndex, null);
     BinarySerialization.SaveField(typeof(List <string>), "NodeDataWatchedFields", 0, nodeData.WatchedFieldNames, null);
 }
Exemplo n.º 4
0
 private static void SaveFields(object obj, string namePrefix)
 {
     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")))
         {
             object value = allFields[i].GetValue(obj);
             if (!object.ReferenceEquals(value, null))
             {
                 BinarySerialization.SaveField(allFields[i].FieldType, namePrefix + allFields[i].Name, value, allFields[i]);
             }
         }
     }
 }
 // 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: 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());
 }
Exemplo n.º 8
0
 public static void Save(GlobalVariables globalVariables)
 {
     if (globalVariables == null)
     {
         return;
     }
     BinarySerialization.fieldIndex = 0;
     globalVariables.VariableData   = new VariableSerializationData();
     if (globalVariables.Variables == null || globalVariables.Variables.Count == 0)
     {
         return;
     }
     BinarySerialization.fieldSerializationData = globalVariables.VariableData.fieldSerializationData;
     for (int i = 0; i < globalVariables.Variables.Count; i++)
     {
         globalVariables.VariableData.variableStartIndex.Add(BinarySerialization.fieldSerializationData.startIndex.Count);
         BinarySerialization.SaveSharedVariable(globalVariables.Variables[i], string.Empty);
     }
     EditorUtility.SetDirty(globalVariables);
 }
Exemplo n.º 9
0
 // Token: 0x06000151 RID: 337 RVA: 0x0000BC20 File Offset: 0x00009E20
 public static void Save(GlobalVariables globalVariables)
 {
     if (globalVariables == null)
     {
         return;
     }
     BinarySerialization.fieldIndex = 0;
     globalVariables.VariableData   = new VariableSerializationData();
     if (globalVariables.Variables == null || globalVariables.Variables.Count == 0)
     {
         return;
     }
     BinarySerialization.fieldSerializationData = globalVariables.VariableData.fieldSerializationData;
     for (int i = 0; i < globalVariables.Variables.Count; i++)
     {
         globalVariables.VariableData.variableStartIndex.Add(BinarySerialization.fieldSerializationData.startIndex.Count);
         BinarySerialization.SaveSharedVariable(globalVariables.Variables[i], 0);
     }
     globalVariables.Version = "1.5.7";
     BehaviorDesignerUtility.SetObjectDirty(globalVariables);
 }
Exemplo n.º 10
0
 private static void SaveTask(Task task, int parentTaskIndex)
 {
     BinarySerialization.taskSerializationData.types.Add(task.GetType().ToString());
     BinarySerialization.taskSerializationData.parentIndex.Add(parentTaskIndex);
     BinarySerialization.taskSerializationData.startIndex.Add(BinarySerialization.fieldSerializationData.startIndex.Count);
     BinarySerialization.SaveField(typeof(int), "ID", task.ID, null);
     BinarySerialization.SaveField(typeof(string), "FriendlyName", task.FriendlyName, null);
     BinarySerialization.SaveField(typeof(bool), "IsInstant", task.IsInstant, null);
     BinarySerialization.SaveNodeData(task.NodeData);
     BinarySerialization.SaveFields(task, string.Empty);
     if (task is ParentTask)
     {
         ParentTask parentTask = task as ParentTask;
         if (parentTask.Children != null && parentTask.Children.Count > 0)
         {
             for (int i = 0; i < parentTask.Children.Count; i++)
             {
                 BinarySerialization.SaveTask(parentTask.Children[i], parentTask.ID);
             }
         }
     }
 }
 // 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);
     }
 }
Exemplo n.º 12
0
        private static void PropertySelected(object selected)
        {
            bool flag = false;

            if (!Application.isPlaying && VariableInspector.mPropertyMappingBehaviorSource.Owner.GetObject() is Behavior && (VariableInspector.mPropertyMappingBehaviorSource.Owner.GetObject() as Behavior).ExternalBehavior != null)
            {
                VariableInspector.mPropertyMappingBehaviorSource.CheckForSerialization(true, null);
                VariableInspector.mPropertyMappingVariable = VariableInspector.mPropertyMappingBehaviorSource.GetVariable(VariableInspector.mPropertyMappingVariable.Name);
                flag = true;
            }
            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
            {
                SerializeJSON.Save(VariableInspector.mPropertyMappingBehaviorSource);
            }
            if (flag)
            {
                ExternalBehavior externalBehavior = (VariableInspector.mPropertyMappingBehaviorSource.Owner as Behavior).ExternalBehavior;
                externalBehavior.BehaviorSource.Owner = externalBehavior;
                externalBehavior.BehaviorSource.CheckForSerialization(true, VariableInspector.mPropertyMappingBehaviorSource);
            }
        }
Exemplo n.º 13
0
        private static void SaveField(Type fieldType, string fieldName, object value, FieldInfo fieldInfo = null)
        {
            string text = fieldType.Name + fieldName;

            BinarySerialization.fieldSerializationData.typeName.Add(text);
            BinarySerialization.fieldSerializationData.startIndex.Add(BinarySerialization.fieldIndex);
            if (typeof(IList).IsAssignableFrom(fieldType))
            {
                Type fieldType2;
                if (fieldType.IsArray)
                {
                    fieldType2 = fieldType.GetElementType();
                }
                else
                {
                    Type type = fieldType;
                    while (!type.IsGenericType)
                    {
                        type = type.BaseType;
                    }
                    fieldType2 = type.GetGenericArguments()[0];
                }
                IList list = value as IList;
                if (list == null)
                {
                    BinarySerialization.AddByteData(typeof(int), BinarySerialization.IntToBytes(0));
                }
                else
                {
                    BinarySerialization.AddByteData(typeof(int), BinarySerialization.IntToBytes(list.Count));
                    if (list.Count > 0)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (object.ReferenceEquals(list[i], null))
                            {
                                BinarySerialization.AddByteData(fieldType2, BinarySerialization.IntToBytes(-1));
                            }
                            else
                            {
                                BinarySerialization.SaveField(fieldType2, text + i, list[i], fieldInfo);
                            }
                        }
                    }
                }
            }
            else if (typeof(Task).IsAssignableFrom(fieldType))
            {
                if (fieldInfo != null && BehaviorDesignerUtility.HasAttribute(fieldInfo, typeof(InspectTaskAttribute)))
                {
                    BinarySerialization.AddByteData(fieldType, BinarySerialization.StringToBytes(value.GetType().ToString()));
                    BinarySerialization.SaveFields(value, text);
                }
                else
                {
                    BinarySerialization.AddByteData(fieldType, BinarySerialization.IntToBytes((value as Task).ID));
                }
            }
            else if (typeof(SharedVariable).IsAssignableFrom(fieldType))
            {
                BinarySerialization.SaveSharedVariable(value as SharedVariable, text);
            }
            else if (typeof(UnityEngine.Object).IsAssignableFrom(fieldType))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.IntToBytes(BinarySerialization.fieldSerializationData.unityObjects.Count));
                BinarySerialization.fieldSerializationData.unityObjects.Add(value as UnityEngine.Object);
            }
            else if (fieldType.Equals(typeof(int)) || fieldType.IsEnum)
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.IntToBytes((int)value));
            }
            else if (fieldType.Equals(typeof(short)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.Int16ToBytes((short)value));
            }
            else if (fieldType.Equals(typeof(uint)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.UIntToBytes((uint)value));
            }
            else if (fieldType.Equals(typeof(float)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.FloatToBytes((float)value));
            }
            else if (fieldType.Equals(typeof(double)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.DoubleToBytes((double)value));
            }
            else if (fieldType.Equals(typeof(long)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.LongToBytes((long)value));
            }
            else if (fieldType.Equals(typeof(bool)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.BoolToBytes((bool)value));
            }
            else if (fieldType.Equals(typeof(string)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.StringToBytes((string)value));
            }
            else if (fieldType.Equals(typeof(byte)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.ByteToBytes((byte)value));
            }
            else if (fieldType.Equals(typeof(Vector2)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.Vector2ToBytes((Vector2)value));
            }
            else if (fieldType.Equals(typeof(Vector3)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.Vector3ToBytes((Vector3)value));
            }
            else if (fieldType.Equals(typeof(Vector4)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.Vector4ToBytes((Vector4)value));
            }
            else if (fieldType.Equals(typeof(Quaternion)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.QuaternionToBytes((Quaternion)value));
            }
            else if (fieldType.Equals(typeof(Color)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.ColorToBytes((Color)value));
            }
            else if (fieldType.Equals(typeof(Rect)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.RectToBytes((Rect)value));
            }
            else if (fieldType.Equals(typeof(Matrix4x4)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.Matrix4x4ToBytes((Matrix4x4)value));
            }
            else if (fieldType.Equals(typeof(LayerMask)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.IntToBytes(((LayerMask)value).value));
            }
            else if (fieldType.Equals(typeof(AnimationCurve)))
            {
                BinarySerialization.AddByteData(fieldType, BinarySerialization.AnimationCurveToBytes((AnimationCurve)value));
            }
            else if (fieldType.IsClass || (fieldType.IsValueType && !fieldType.IsPrimitive))
            {
                if (object.ReferenceEquals(value, null))
                {
                    value = Activator.CreateInstance(fieldType, true);
                }
                BinarySerialization.SaveFields(value, text);
            }
            else
            {
                UnityEngine.Debug.LogError("Missing Serialization for " + fieldType);
            }
        }
Exemplo n.º 14
0
        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 = (PrefabUtility.GetPrefabType(behavior) != PrefabType.PrefabInstance || 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
                    {
                        SerializeJSON.Save(behavior.GetBehaviorSource());
                    }
                }
                externalModification = true;
            }
            GUI.enabled        = true;
            serializedProperty = serializedObject.FindProperty("group");
            EditorGUILayout.PropertyField(serializedProperty, true, new GUILayoutOption[0]);
            if (fromInspector && (showVariables = EditorGUILayout.Foldout(showVariables, "Variables")))
            {
                EditorGUI.indentLevel++;
                List <SharedVariable> allVariables   = behavior.GetAllVariables();
                BehaviorSource        behaviorSource = behavior.GetBehaviorSource();
                bool flag = false;
                if (!Application.isPlaying && behavior.ExternalBehavior != null)
                {
                    behaviorSource.CheckForSerialization(true, null);
                    flag = true;
                }
                bool flag2 = false;
                if (VariableInspector.SyncVariables(behaviorSource, allVariables))
                {
                    flag2 = true;
                }
                if (allVariables != null && allVariables.Count > 0)
                {
                    List <SharedVariable> allVariables2 = behaviorSource.GetAllVariables();
                    if (VariableInspector.DrawAllVariables(false, behaviorSource, ref allVariables2, false, ref BehaviorInspector.variablePosition, ref BehaviorInspector.selectedVariableIndex, ref BehaviorInspector.selectedVariableName, ref BehaviorInspector.selectedVariableTypeIndex, false, true))
                    {
                        flag2 = true;
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("There are no variables to display", new GUILayoutOption[0]);
                }
                if (flag)
                {
                    ExternalBehavior externalBehavior2 = (behaviorSource.Owner as Behavior).ExternalBehavior;
                    externalBehavior2.BehaviorSource.Owner = externalBehavior2;
                    externalBehavior2.BehaviorSource.CheckForSerialization(true, behaviorSource);
                }
                if (flag2)
                {
                    if (BehaviorDesignerPreferences.GetBool(BDPreferences.BinarySerialization))
                    {
                        BinarySerialization.Save(behaviorSource);
                    }
                    else
                    {
                        SerializeJSON.Save(behaviorSource);
                    }
                }
                EditorGUI.indentLevel--;
            }
            if (!fromInspector || (showOptions = EditorGUILayout.Foldout(showOptions, "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 (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                return(true);
            }
            return(false);
        }