Ejemplo n.º 1
0
        public void DrawField(string fieldName, Object context, object target)
        {
            var field     = target.GetField(fieldName);
            var attribute = field.GetCustomAttribute <EditorSerializeAttribute>();

            if (attribute.PreviousName != null)
            {
                EditorFieldsDatabase.RenameField(context, attribute.PreviousName, field.Name);
            }

            var editorField = EditorFieldsDatabase.GetEditorField(context, field.Name);

            if (editorField == null)
            {
                return;
            }

            var value = field.GetValue(target);

            Deserialize(editorField, target, field, ref value);

            EditorGUI.BeginChangeCheck();

            value = MightyGUIUtilities.DrawLayoutField(field, context, target, value,
                                                       !attribute.Options.Contains(EditorFieldOption.DontFold), attribute.Options.Contains(EditorFieldOption.Asset));

            if (EditorGUI.EndChangeCheck())
            {
                Serialize(attribute, editorField, value, field.FieldType);
            }
        }
Ejemplo n.º 2
0
        protected override void DrawNativeProperty(MightyNativeProperty nativeProperty, ShowPropertyAttribute attribute)
        {
            var property = nativeProperty.MemberInfo;

            if (!m_showPropertyCache.Contains(nativeProperty))
            {
                EnableDrawer(nativeProperty, attribute);
            }
            var value = m_showPropertyCache[nativeProperty].Value;

            if (MightyGUIUtilities.DrawLayoutField(attribute.DrawPrettyName ? property.Name.GetPrettyName() : property.Name, value,
                                                   nativeProperty.MemberInfo.PropertyType, attribute.Enabled))
            {
                return;
            }

            MightyGUIUtilities.DrawHelpBox($"{nameof(ShowPropertyDrawer)} doesn't support the type {property.PropertyType.Name}");
        }
Ejemplo n.º 3
0
        protected override void DrawField(MightyNonSerializedField nonSerializedField, ShowNonSerializedAttribute attribute)
        {
            var field = nonSerializedField.MemberInfo;

            if (!m_showNonSerializedCache.Contains(nonSerializedField))
            {
                EnableDrawer(nonSerializedField, attribute);
            }
            var value = m_showNonSerializedCache[nonSerializedField].Value;

            if (MightyGUIUtilities.DrawLayoutField(attribute.DrawPrettyName ? field.Name.GetPrettyName() : field.Name, value,
                                                   nonSerializedField.MemberInfo.FieldType, attribute.Enabled))
            {
                return;
            }

            MightyGUIUtilities.DrawHelpBox($"{nameof(ShowNonSerializedAttribute)} doesn't support the type {field.FieldType.Name}");
        }