Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

Does Unity Allocate Memory When Setting Public Array Size in Inspector?

Discussion in 'Editor & General Support' started by joe_04_04, Nov 9, 2017.

  1. joe_04_04

    joe_04_04

    Joined:
    Sep 15, 2017
    Posts:
    14
    If I declare a public GameObject array in my script, compile it, then set the size field that appears in the inspector, does Unity allocate the memory for this? or do I still need to specify it in the script?

    public GameObject objectArray[] = new GameObject[10];
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,363
    Yes Unity will resize the array if you change it in the inspector.
     
  3. joe_04_04

    joe_04_04

    Joined:
    Sep 15, 2017
    Posts:
    14
    Thank you very much!