I can’t add const to an array and readonly is not preventing the array from being edited.
public const string OceanMenu = "OceanMenu";
public const string IslandMenu = "IslandMenu";
public static readonly string[] MenuScenes = new string[] {OceanMenu, IslandMenu,};
DefaultSceneNames.MenuScenes[1] = "override";
for (int i = 0; i < 20; i++)
{
int randomIndex = Random.Range(0, DefaultSceneNames.MenuScenes.Length);
Debug.Log(DefaultSceneNames.MenuScenes[randomIndex]);
}
The readonly modifier obviously only affects the variable, not the array object behind the variable. I personally don’t bother when coding games cos of the general tongue-in-the-cheekness, but you can use ReadOnlyCollection<T> class if you need this.