Posts

Showing posts with the label inspector

SerializeField and HideInInspector in unity in C# script

You can declare a variable as private or public according to you if you don't want to access variable outside of class then declare as private and want to access in other classes then declare public. Unity have two attribute for these variables lets take a look  [SerializeField]  Whenever you declare a private variable it is only accessible inside its class and variable can not be shown in inspector window in editor. So if you want to change value of this private variable you have to change inside script.      private   int  num =  5 ; this variable "num" will not show in inspector window.  If we want to show private variable in inspector window then we can use SerializeField attribute for example      [ SerializeField ]    private   int  num =  5 ; next declared variable after SerializeField attribute will be visible in inspector and we can change its value just by changing in inspector inst...