Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How do I declare a public member that doesn't show up in the inspector?

Discussion in 'Scripting' started by darkhog, Jan 1, 2016.

  1. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    I need to declare few public members of MonoBehaviour I'm making, however since those are meant to be changed by other scripts only, I don't want them to be shown in the Inspector. How do I do it?
     
  2. kietus

    kietus

    Joined:
    Jun 4, 2013
    Posts:
    54
    Hello,

    You can use HideInInspector .
    Or, If you declare your member as property it should not be shown in inspector.
    Code (csharp):
    1.  
    2. public int MyProperty {get;set;}
    3.  
     
  3. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
    Use a property or the HideInInspector attribute.
    If you want a private field in the inspector you can use the SerializeField attribute on it.
     
  4. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    property will have one more advantage. It will be show up in debug mode with a weird name.