Applying the AssetList and SceneObjectsOnly attributes don't work as expected

Issue #16 closed
Deniz Ozkaynak
created an issue

Sample code:

[Title("Player Objects")]
    [Indent]
    [SceneObjectsOnly]
    [AssetList(Tag = "Player")]
    public GameObject[] DebuggableObjects;

Produces a list populated only with Project assets, no Scene assets whatsoever (as if the SceneObjectsOnly was overridden). Tried swapping order of the attributes, no change.

Comments (6)

  1. Bjarke Elias Clauson-Kaas Ørrild

    AssetLists only works with objects from the asset database and adding [SceneObjectsOnly] unfortunately don't change that fact.

    Also, the AssetList right now, does not transfer other attributes (such as your [SceneObjectsOnly]) down to its elements, unlike lists does. So that is why you are not seeing the error from SceneObjectsOnly as otherwise would be shown.

    I've thought a bit about adding a more generic version of AssetLists, where you provide the elements that should be selectable. It could look something like this:

    [ToggleList(Source="GetSelectableSceneObjects")]
    public GameObject[] SceneObjects;
    
    private GameObject[] GetSelectableSceneObjects()
    {
         return ...
    }
    
  2. Deniz Ozkaynak reporter

    Ahhh I see, although this is implied by the name AssetList, it would be good to explicitly say in the docs that the attribute only pulls from the asset database. That went completely over my head =)

    A more generic version would be stellar! My specific use-case for this attribute was to collect a list of all objects in the "Debug" layer inside the Scene, for our devs to quickly access all debugging functionality from one place. Not important, just a nice to have.

  3. Bjarke Elias Clauson-Kaas Ørrild

    Absolutely! It should definitely be added to the documentation, I bet you are not the only one who will try that 😄

    I'll add it as a note.

    Btw, if you simply want to display a list of gamobjects, you could simply create a read-only property and put the ShowInInspector attribute on it.

    [ShowInInspector]
    public GameObject[] DebuggableObjects
    {
        get { return GameObject.FindGameObjectsWithTag("Debug"); }
    }
    

    The GUI list will become read-only and the GUI will be disabled. But paging still works, and you can still ping objects by clicking on the object field, and the "inspect object in a new inspector window" button that we've added to the object field drawer, works as well. 😋

    O1CdWP0Xdp9kFzOyYnz2rZa-CgRVfYhBm_IorPxDdTmKyRAmB7Ojtcczm-rpED-weFhLnKLq-YyzjHUoHPibe1NlSmh0egFbdyHzE6LvoMAI4av1wcwKsmUDuTGzHRrg.png

  4. Log in to comment