public static void SetTypeIndex(InstructionVariable variable, int index)
        {
            var wasReference = variable.IsReference;
            var isReference  = index >= _locationOffset;

            variable.IsReference = isReference;

            if (wasReference && !isReference)
            {
                VariableReferenceDrawer.ResetLocation(variable.Reference);
            }
            else if (!wasReference && isReference)
            {
                VariableValueDrawer.SetTypeIndex(variable.Value, 0);
            }

            if (isReference)
            {
                VariableReferenceDrawer.SetLocationIndex(variable.Reference, index - _locationOffset);
            }
            else
            {
                VariableValueDrawer.SetTypeIndex(variable.Value, index);
            }
        }
        public static void Draw(Rect position, InstructionVariable variable, GUIContent label)
        {
            var typeNames = GetTypeNames();

            var typeWidth = position.width * 0.5f;
            var typeRect  = new Rect(position.x, position.y, typeWidth, position.height);
            var valueRect = new Rect(typeRect.xMax + 5, position.y, position.width - typeWidth - 5, position.height);

            var index = GetTypeIndex(variable);

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                index = EditorGUI.Popup(typeRect, index, typeNames);

                if (changes.changed)
                {
                    SetTypeIndex(variable, index);
                }
            }

            if (variable.IsReference)
            {
                VariableReferenceDrawer.DrawName(valueRect, variable.Reference);
            }
            else
            {
                VariableValueDrawer.DrawValue(valueRect, variable.Value, null, null);
            }
        }
 public static int GetTypeIndex(InstructionVariable variable)
 {
     if (variable.IsReference)
     {
         var index = VariableReferenceDrawer.GetLocationIndex(variable.Reference);
         return(index + _locationOffset);
     }
     else
     {
         return(VariableValueDrawer.GetTypeIndex(variable.Value));
     }
 }