Search Unity

Is there a way to disable items in the script to hide in inspector

Discussion in 'Scripting' started by TheSenpaiCode, Nov 17, 2018.

  1. TheSenpaiCode

    TheSenpaiCode

    Joined:
    Jan 21, 2016
    Posts:
    50
    I'm curious if there is a way to have a bool or a check box that once checked to hide a public transform. For example

    public class NPC : MonoBehaviour {


    public Transform FaceImage;

    public bool DisableFace = false; <--------- if this is checked I want to disable the public Transform "FaceImage" in the inspector. so it doesn't show up. how would one go about doing this?

    void Start()
    {

    }

    }
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    Why you want to hide transform?

    upload_2018-11-18_0-8-31.png

    You can collapse
    upload_2018-11-18_0-8-59.png

    And other component you can move up / down (not Transform)
     
  3. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    Kiwasi likes this.
  4. Ratheeshr

    Ratheeshr

    Joined:
    May 10, 2018
    Posts:
    3
  5. Ratheeshr

    Ratheeshr

    Joined:
    May 10, 2018
    Posts:
    3
    when character looking to the object for few second, text need to appera.
    can you help me for this activity
     
  6. TheSenpaiCode

    TheSenpaiCode

    Joined:
    Jan 21, 2016
    Posts:
    50
    I think I explained it wrong. I'm not trying to hide or collapse that transform Here is a Image of what I'm trying to do.


     
  7. Errorsatz

    Errorsatz

    Joined:
    Aug 8, 2012
    Posts:
    555
    Last edited: Nov 19, 2018
    Antypodish likes this.
  8. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Yup as said, custom inspectors are the way to go here.

    From an UX point of view, I'd encourage you to group together the Face properties, and maybe just disable (grey out) the Face Image property instead of hiding it. That makes the connection between the checkbox and the property more obvious, and it also won't cause a reformat of the other properties where they can jump around and throw the user off a little bit when they're trying to find a property in a specific location.
     
    Kiwasi likes this.
  9. TheSenpaiCode

    TheSenpaiCode

    Joined:
    Jan 21, 2016
    Posts:
    50