Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    8,222
    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!