Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Bad coding practices.

Discussion in 'Scripting' started by tranos, Jan 10, 2020.

  1. tranos

    tranos

    Joined:
    Feb 19, 2014
    Posts:
    143
    Hello. I use a lot, public fields (instead of properties because of invisibility in the inspector ) that are in singleton and are accessible from other scripts. What are good practices and characteristics of c# that I can use in unity to do the above?
     
  2. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    551
    Hello ! That's easy, let it be private or protected and use the [SerializedField] attribute on each field you want accessible in the inspector !
     
  3. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,448
unityunity