Пример #1
0
        public void SetTypeIndex(SerializedProperty property, int index)
        {
            var isReferenceProperty = property.FindPropertyRelative("IsReference");
            var referenceProperty   = property.FindPropertyRelative("Reference");
            var valueProperty       = property.FindPropertyRelative("Value");

            var wasReference = isReferenceProperty.boolValue;
            var isReference  = index >= _locationOffset;

            isReferenceProperty.boolValue = isReference;

            if (wasReference && !isReference)
            {
                VariableReferenceDrawer.ResetLocation(referenceProperty);
            }
            else if (!wasReference && isReference)
            {
                VariableValueDrawer.SetTypeIndex(valueProperty, 0);
            }

            if (isReference)
            {
                VariableReferenceDrawer.SetLocationIndex(referenceProperty, index - _locationOffset);
            }
            else
            {
                VariableValueDrawer.SetTypeIndex(valueProperty, index);
            }
        }
Пример #2
0
        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);
            }
        }