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

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()
{

}

}

Why you want to hide transform?

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

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

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

This is what custom editors are for.

Perhaps you can do some magic with custom property drawers to inline it with attributes yourself, but editors are simple if verbose.

1 Like

Hi ThermalFusion. I need your help.

when character looking to the object for few second, text need to appera.
can you help me for this activity

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. !(http://[

](http://s595.photobucket.com/user/prince_charming1408/media/unity%20visual_zps65kyairg.jpg.html))

A custom inspector would be the way to go then. IIRC, it’s possible to do it with property drawers as well, but it’s a bit tricky and may require adding a method to the MonoBehaviour class itself.

Some references:

I also found the tutorials at Catlike Coding helpful:

1 Like

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.

1 Like

Alright got it figured out. Thanks for the help everyone. For anyone interested in scripting custom inspectors this post really helps Hiding or Disabling inspector properties using PropertyDrawers within Unity - Brecht Lecluyse They also show headers, spacing etc.