private bool DrawSharedVariableSynchronizer(VariableSynchronizerInspector.Synchronizer synchronizer, Type valueType)
        {
            VariableSynchronizerInspector.DrawComponentSelector(synchronizer, typeof(Behavior), VariableSynchronizerInspector.ComponentListType.BehaviorDesignerGroup);
            int num  = 0;
            int num2 = -1;

            string[] array = null;
            if (synchronizer.component != null)
            {
                Behavior behavior = synchronizer.component as Behavior;
                num = FieldInspector.GetVariablesOfType(valueType, synchronizer.global, synchronizer.targetName, behavior.GetBehaviorSource(), out array, ref num2, valueType == null);
            }
            else
            {
                array = new string[]
                {
                    "None"
                };
            }
            EditorGUI.BeginChangeCheck();
            num = EditorGUILayout.Popup("Shared Variable", num, array, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                if (num != 0)
                {
                    if (num2 != -1 && num >= num2)
                    {
                        synchronizer.targetName = array[num].Substring(8, array[num].Length - 8);
                        synchronizer.global     = true;
                    }
                    else
                    {
                        synchronizer.targetName = array[num];
                        synchronizer.global     = false;
                    }
                    if (valueType == null)
                    {
                        SharedVariable variable;
                        if (synchronizer.global)
                        {
                            variable = GlobalVariables.Instance.GetVariable(synchronizer.targetName);
                        }
                        else
                        {
                            Behavior behavior2 = synchronizer.component as Behavior;
                            variable = behavior2.GetVariable(array[num]);
                        }
                        this.sharedVariableValueTypeName = variable.GetType().GetProperty("Value").PropertyType.FullName;
                        this.sharedVariableValueType     = null;
                    }
                }
                else
                {
                    synchronizer.targetName = null;
                }
            }
            if (string.IsNullOrEmpty(synchronizer.targetName))
            {
                GUI.enabled = (false);
            }
            return(GUI.enabled);
        }
 public static SharedVariable DrawSharedVariable(Task task, GUIContent guiContent, FieldInfo fieldInfo, Type fieldType, SharedVariable sharedVariable)
 {
     if (!fieldType.Equals(typeof(SharedVariable)) && sharedVariable == null)
     {
         sharedVariable = (Activator.CreateInstance(fieldType, true) as SharedVariable);
         if (TaskUtility.HasAttribute(fieldInfo, typeof(RequiredFieldAttribute)) || TaskUtility.HasAttribute(fieldInfo, typeof(SharedRequiredAttribute)))
         {
             sharedVariable.IsShared = true;
         }
         GUI.changed = true;
     }
     if (sharedVariable == null || sharedVariable.IsShared)
     {
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         string[] array           = null;
         int      num             = -1;
         int      num2            = FieldInspector.GetVariablesOfType((sharedVariable == null) ? null : sharedVariable.GetType().GetProperty("Value").PropertyType, sharedVariable != null && sharedVariable.IsGlobal, (sharedVariable == null) ? string.Empty : sharedVariable.Name, FieldInspector.behaviorSource, out array, ref num, fieldType.Equals(typeof(SharedVariable)));
         Color    backgroundColor = GUI.backgroundColor;
         if (num2 == 0 && !TaskUtility.HasAttribute(fieldInfo, typeof(SharedRequiredAttribute)))
         {
             GUI.backgroundColor = Color.red;
         }
         int num3 = num2;
         num2 = EditorGUILayout.Popup(guiContent.text, num2, array, BehaviorDesignerUtility.SharedVariableToolbarPopup, new GUILayoutOption[0]);
         GUI.backgroundColor = backgroundColor;
         if (num2 != num3)
         {
             if (num2 == 0)
             {
                 if (fieldType.Equals(typeof(SharedVariable)))
                 {
                     sharedVariable = null;
                 }
                 else
                 {
                     sharedVariable          = (Activator.CreateInstance(fieldType, true) as SharedVariable);
                     sharedVariable.IsShared = true;
                 }
             }
             else if (num != -1 && num2 >= num)
             {
                 sharedVariable = GlobalVariables.Instance.GetVariable(array[num2].Substring(8, array[num2].Length - 8));
             }
             else
             {
                 sharedVariable = FieldInspector.behaviorSource.GetVariable(array[num2]);
             }
             GUI.changed = true;
         }
         if (!fieldType.Equals(typeof(SharedVariable)) && !TaskUtility.HasAttribute(fieldInfo, typeof(RequiredFieldAttribute)) && !TaskUtility.HasAttribute(fieldInfo, typeof(SharedRequiredAttribute)))
         {
             sharedVariable = FieldInspector.DrawSharedVariableToggleSharedButton(sharedVariable);
             GUILayout.Space(-3f);
         }
         GUILayout.EndHorizontal();
         GUILayout.Space(3f);
     }
     else
     {
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         ObjectDrawerAttribute[] array2;
         ObjectDrawer            objectDrawer;
         if (fieldInfo != null && (array2 = (fieldInfo.GetCustomAttributes(typeof(ObjectDrawerAttribute), true) as ObjectDrawerAttribute[])).Length > 0 && (objectDrawer = ObjectDrawerUtility.GetObjectDrawer(task, array2[0])) != null)
         {
             objectDrawer.Value = sharedVariable;
             objectDrawer.OnGUI(guiContent);
         }
         else
         {
             FieldInspector.DrawFields(task, sharedVariable, guiContent);
         }
         if (!TaskUtility.HasAttribute(fieldInfo, typeof(RequiredFieldAttribute)) && !TaskUtility.HasAttribute(fieldInfo, typeof(SharedRequiredAttribute)))
         {
             sharedVariable = FieldInspector.DrawSharedVariableToggleSharedButton(sharedVariable);
         }
         GUILayout.EndHorizontal();
     }
     return(sharedVariable);
 }