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.

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:
    7,020
    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!