Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Inspectors in 1.0.0-pre.2 hide class members of derived classes

Discussion in 'XR Interaction Toolkit and Input' started by Alex-CG, Jan 28, 2021.

  1. Alex-CG

    Alex-CG

    Joined:
    May 10, 2015
    Posts:
    11
    While it's true the custom inspector is easier to work with, the new feature allowing custom Editors to be used in derived classes hides the new members of these derived classes, making the extension of the Toolkit cumbersome and actually harder than before, as it now requires a new custom Editor for each class derived from the base Interactors or Interactables.

    I think a simple solution for this would be to check if the serialized object is of the same class the editor is made for and then use "DrawPropertiesExcluding" to draw the new members. I don't know if this breaks any guideline for Unity Editors, but I've done this in my project and it works as intended.

    This is how the editors look using this approach, it visually separates the base class "fancy" editor and the members added from the derived class:

    upload_2021-1-28_11-57-48.png
     
    chris-massie likes this.
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    226
    This is amazing! I didn't know about that method. I'll look into seeing if we can make use of it so users won't have to make a custom Editor to show their added serialized fields. I knew that requiring users to go through that would be an unfortunate consequence of that change, but this may solve that problem.

    Thank you for the feedback!
     
    Alex-CG likes this.
  3. Alex-CG

    Alex-CG

    Joined:
    May 10, 2015
    Posts:
    11
    It's nice to see the feedback gets in. Since I needed to go on with the project I made a quick "fix" by creating extended classes and just changing all my behaviours extending the interactables to extend from these instead. I uploaded it here, but it's messy as it was, as I said, just a quick hack to keep working on other stuff:

    https://github.com/atcolombini/XRInteractableEditors