Search Unity

Unity UI Inheriting from Toggle does not show custom fields in inspector

Discussion in 'UGUI & TextMesh Pro' started by MaskedMouse, Nov 30, 2021.

  1. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    When inheriting from toggle and creating your own public fields, they do not show up in the inspector.
    Usually how to bypass this, is to create an own custom inspector and call
    base.OnInspectorGUI()


    But while I was looking at what the
    base.OnInspectorGUI
    does, it has a method call
    Code (CSharp):
    1. // We do this here to avoid requiring the user to also write a Editor for their Selectable-derived classes.
    2. // This way if we are on a derived class we dont draw anything else, otherwise draw the remaining properties.
    3. ChildClassPropertiesGUI();
    So in theory, this should draw the properties of the inherited class right?
    It doesn't though.

    The current workaround is switching the inspector to Debug mode, then it does show the fields. So in a way I can edit the fields I added. Though it is far from ideal.

    tldr;
    All I am wondering is
    ChildClassPropertiesGUI()
    supposed to draw the inherited class' fields?
    If so, it is not working for
    Toggle
    at least.
     
  2. Telestrator

    Telestrator

    Joined:
    Aug 21, 2018
    Posts:
    10
    same issue here