Пример #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty sourceProperty = property.FindPropertyRelative("SourceNode");

            if (sourceProperty.objectReferenceValue != null)
            {
                Rect inputNoteRect = EditorGUI.PrefixLabel(position, label);
                if (label != GUIContent.none)
                {
                    EditorGUI.LabelField(inputNoteRect, "Input", EditorStyles.centeredGreyMiniLabel);
                }
            }
            else
            {
                SerializedProperty valueProperty = property.FindPropertyRelative("defaultValue");

                if (valueProperty != null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.PropertyField(position, valueProperty, label);
                    if (EditorGUI.EndChangeCheck())
                    {
                        InputSocket inputSocket = (InputSocket)PropertyUtility.GetTargetObjectOfProperty(property);
                        property.serializedObject.ApplyModifiedProperties();
                        inputSocket.AfterContentChanged();
                    }
                }
            }

            property.FindPropertyRelative("drawRect").rectValue = position;
        }
Пример #2
0
        protected override float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
        {
            Enum targetEnum = PropertyUtility.GetTargetObjectOfProperty(property) as Enum;

            return((targetEnum != null)
                                ? GetPropertyHeight(property)
                                : GetPropertyHeight(property) + GetHelpBoxHeight());
        }
Пример #3
0
        protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);

            Enum targetEnum = PropertyUtility.GetTargetObjectOfProperty(property) as Enum;

            if (targetEnum != null)
            {
                Enum enumNew = EditorGUI.EnumFlagsField(rect, label.text, targetEnum);
                property.intValue = (int)Convert.ChangeType(enumNew, targetEnum.GetType());
            }
            else
            {
                string message = attribute.GetType().Name + " can be used only on enums";
                DrawDefaultPropertyAndHelpBox(rect, property, message, MessageType.Warning);
            }

            EditorGUI.EndProperty();
        }