protected override float GetControlHeight(float width)
        {
            var height = EditorGUIUtility.singleLineHeight;

            if (!Filter(value))
            {
                height += EditorGUIUtility.standardVerticalSpacing;
                height += LudiqGUIUtility.GetHelpBoxHeight(InvalidValueMessage(value), MessageType.Error, width);
            }

            return(height);
        }
        protected override void OnControlGUI(Rect position)
        {
            EditorGUI.BeginChangeCheck();

            var oldValue = (UnityObject)accessor.value;

            var fieldPosition = new Rect
                                (
                position.x,
                position.y,
                position.width,
                GetObjectFieldHeight(position.width)
                                );

            UnityObject newValue;

            if (fuzzy)
            {
                newValue = LudiqGUI.ObjectField
                           (
                    fieldPosition,
                    oldValue,
                    accessor.definedType,
                    scene,
                    allowAssetObjects,
                    typeLabel,
                    typeIcon,
                    Filter,
                    GetOptions,
                    visualType,
                    hidableFrame
                           );
            }
            else
            {
                newValue = EditorGUI.ObjectField
                           (
                    fieldPosition,
                    oldValue,
                    accessor.definedType,
                    scene != null
                           );
            }

            y += EditorGUIUtility.singleLineHeight;

            var isValid = Filter(newValue);

            if (!isValid)
            {
                y += EditorGUIUtility.standardVerticalSpacing;

                var message = InvalidValueMessage(newValue);

                var invalidValueMessagePosition = position.VerticalSection(ref y, LudiqGUIUtility.GetHelpBoxHeight(message, MessageType.Error, position.width));

                EditorGUI.HelpBox(invalidValueMessagePosition, message, MessageType.Error);

                if (newValue != null && GUI.Button(invalidValueMessagePosition, GUIContent.none, GUIStyle.none))
                {
                    EditorGUIUtility.PingObject(newValue);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (isValid)
                {
                    accessor.RecordUndo();
                    accessor.value = newValue;
                }
                else
                {
                    Debug.LogWarning(InvalidValueMessage(newValue));
                }
            }
        }
 protected override float GetInnerHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(message, MessageType.Warning, width));
 }
Beispiel #4
0
 public float GetHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(message, messageType, width));
 }
 protected override float GetControlHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(GetMessage(label), MessageType.Warning, width));
 }