public override void OnGUI(Rect position)
 {
     if (myattribute == null)
     {
         myattribute = attribute as LabelFieldAttribute;
     }
     EditorGUI.LabelField(position, myattribute.str);
 }
Ejemplo n.º 2
0
        public void ConstructorTest()
        {
            // Arrange
            const bool IsHeaderHidden = true;

            // Act
            var attr = new LabelFieldAttribute(IsHeaderHidden);

            // Assert
            Assert.AreEqual(IsHeaderHidden, attr.IsHeaderHidden);
        }
Ejemplo n.º 3
0
        public void DrawBefore(CyberAttribute cyberAttribute)
        {
            LabelFieldAttribute attribute = cyberAttribute as LabelFieldAttribute;

            TheEditor.PrepareToRefuseGui(this.GetType());



            var rect = EditorGUILayout.GetControlRect();

            if (attribute.IgnoreIndentLv == false)
            {
                rect = EditorGUI.IndentedRect(rect);
            }



            GUI.Label(rect, attribute.Label, attribute.ApplyStyle(new GUIStyle(EditorStyles.label)));
            TheEditor.RefuseGui(this.GetType());
        }
        //-------------------------------------------------------------------------------------
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            LabelFieldAttribute name_field_attribute = (LabelFieldAttribute)attribute;
            SerializedProperty  name_property        = property.FindPropertyRelative(name_field_attribute.LabelField);

            if (name_property != null)
            {
                string name = label.text;

                switch (name_property.propertyType)
                {
                case SerializedPropertyType.Generic:
                    break;

                case SerializedPropertyType.Integer:
                    name = name_property.intValue.ToString();
                    break;

                case SerializedPropertyType.Boolean:
                    name = name_property.boolValue.ToString();
                    break;

                case SerializedPropertyType.Float:
                    name = name_property.floatValue.ToString();
                    break;

                case SerializedPropertyType.String:
                    name = name_property.stringValue;
                    break;

                case SerializedPropertyType.Color:
                    name = property.colorValue.ToString();
                    break;

                case SerializedPropertyType.ObjectReference:
                    name = name_property.objectReferenceValue.name;
                    break;

                case SerializedPropertyType.LayerMask:
                    break;

                case SerializedPropertyType.Enum:
                    name = name_property.enumDisplayNames[name_property.enumValueIndex];
                    break;

                case SerializedPropertyType.Vector2:
                    name = name_property.vector2Value.ToString();
                    break;

                case SerializedPropertyType.Vector3:
                    name = name_property.vector3Value.ToString();
                    break;

                case SerializedPropertyType.Vector4:
                    name = name_property.vector4Value.ToString();
                    break;

                case SerializedPropertyType.Rect:
                    name = name_property.rectValue.ToString();
                    break;

                case SerializedPropertyType.ArraySize:
                    break;

                case SerializedPropertyType.Character:
                    break;

                case SerializedPropertyType.AnimationCurve:
                    break;

                case SerializedPropertyType.Bounds:
                    name = name_property.boundsValue.ToString();
                    break;

                case SerializedPropertyType.Gradient:
                    break;

                case SerializedPropertyType.Quaternion:
                    name = name_property.quaternionValue.ToString();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                label.text = name;
            }

            EditorGUI.PropertyField(position, property, label, true);
        }