Пример #1
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren)
 {
     if (s_Style == null)
     {
         s_Style           = new GUIStyle("label");
         s_Style.padding   = new RectOffset();
         s_Style.alignment = TextAnchor.MiddleLeft;
         s_Style.clipping  = TextClipping.Clip;
     }
     m_Content.text = property.AsString();
     if (icon)
     {
         m_Content.image = label.image;
     }
     if (tooltip)
     {
         m_Content.tooltip = label.tooltip;
     }
     if (this.label)
     {
         EditorGUI.LabelField(position, label, m_Content, s_Style);
     }
     else
     {
         EditorGUI.LabelField(position, m_Content, s_Style);
     }
 }
Пример #2
0
        private T GetSerializedPropertyValue(SerializedProperty property)
        {
            SetupConvertor();
            var type = m_DynamicType;

            if (type == typeof(string))
            {
                return(StringConvertor(property.AsString()));
            }
            if (type == typeof(bool) && property.propertyType == SerializedPropertyType.Boolean)
            {
                return(BoolConvertor(property.boolValue));
            }
            if (type == typeof(int) && property.propertyType == SerializedPropertyType.Integer)
            {
                return(IntConvertor(property.intValue));
            }
            if (type == typeof(long) && property.propertyType == SerializedPropertyType.Integer)
            {
                return(LongConvertor(property.longValue));
            }
            if (type == typeof(float) && property.propertyType == SerializedPropertyType.Float)
            {
                return(FloatConvertor(property.floatValue));
            }
            if (type == typeof(double) && property.propertyType == SerializedPropertyType.Float)
            {
                return(DoubleConvertor(property.doubleValue));
            }
            if (type == typeof(string) && property.propertyType == SerializedPropertyType.String)
            {
                return(StringConvertor(property.stringValue));
            }
            if (type == typeof(char) && property.propertyType == SerializedPropertyType.Character)
            {
                return(CharConvertor(property.stringValue.Length == 0 ? ' ' : property.stringValue[0]));
            }
            if (type == typeof(UnityEngine.Object) && property.propertyType == SerializedPropertyType.ObjectReference)
            {
                return(ObjectConvertor(property.objectReferenceValue));
            }
            return(m_Default);
        }