Giter Site home page Giter Site logo

Comments (8)

karmacod3r avatar karmacod3r commented on August 15, 2024 4

Hope this is not off topic:
Only an incomplete solution, but I managed to get Attributes working in my custom editor by using NaughtyAttributes.InspectorEditor as base class. Only thing is that I needed to make InspectorEditor.OnEnable "protected virtual" so I could override.
In my custom editor I override OnInspectorGUI and do what I need after base.OnInspectorGUI().

from naughtyattributes.

dbrizov avatar dbrizov commented on August 15, 2024 3

Fixed in version 2.0.0.
The attributes are now reimplemented with Unity's CustomPropertyDrawer so they work in custom inspectors. There are some exceptions, however (like ReorderableList, EnableIf...). For these to work you need to call NaughtyEditorGUI.PropertyField_Layout instead of EditorGUILayout.PropertyField when you are creating your custom editors

from naughtyattributes.

dbrizov avatar dbrizov commented on August 15, 2024

I have to check that out mate, but I don't think it's possible at the moment. The problem is that I am not using the Unity's API to create custom attributes (if I was this issue wouldn't have happened). There were some limitations, and I decided to create my own API for creating attributes. I need to think of a fix, because your case is a very common thing.

from naughtyattributes.

mattnewport avatar mattnewport commented on August 15, 2024

The way I usually use this in a Custom Inspector is something like this:

void OnEnable()
{
    ...
    prop = serializedObject.FindProperty("prop");
    ...
}

public override void OnInspectorGUI()
{
    ...
    EditorGUILayout.PropertyField(prop);
    ...
}

So I'd be fine with doing something like:

public override void OnInspectorGUI()
{
   ...
   NaughtyAttributes.GUILayout.PropertyField(prop);
   ...
}

If that's easier to get working. Just as long as there's some way to get the custom drawing from a Custom Inspector, it doesn't have to be via EditorGUILayout.PropertyField().

from naughtyattributes.

dbrizov avatar dbrizov commented on August 15, 2024

Well, I am using EditorGUILayout.PropertyField(property, includeChildren) for drawing the properties, but not for all attributes. The ReorderableList for example uses some stuff from the UnityEditorInternal namespace. I need to see what exactly is the problem here, but I like your advice with the NaughtyAttributes.GUILayout.PropertyField(prop).

from naughtyattributes.

mattnewport avatar mattnewport commented on August 15, 2024

The first Attribute I used and the one I had problems with was ShowIf - it could be that some of the others work fine and that just happens to be one of the ones that doesn't.

from naughtyattributes.

themorfeus avatar themorfeus commented on August 15, 2024

Hope this is not off topic:
Only an incomplete solution, but I managed to get Attributes working in my custom editor by using NaughtyAttributes.InspectorEditor as base class. Only thing is that I needed to make InspectorEditor.OnEnable "protected virtual" so I could override.
In my custom editor I override OnInspectorGUI and do what I need after base.OnInspectorGUI().

This works, although it would be helpful to mark OnEnable and OnDisable as protected virtual, so that they can be overriden in inheriting inspectors.

from naughtyattributes.

celojevic avatar celojevic commented on August 15, 2024

This problem still exists when making a custom editor like the latest answer by BgBg in this link: http://answers.unity.com/answers/1904868/view.html

[ReadOnly] and [ShowIf] attributes dont draw as expected. And the editor doesnt contain any of the property field stuff as in the last comment above ^

from naughtyattributes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.