Hello, i always get an error when i come to line 7 in the scond block:
public float[] positionGameobject1;
public string[] gameObjectName;
private int gameObjectNameNumber;
private int positionGameObject1Number;
public void PlaceSchmiede()
{
Debug.Log("Button pressed");
placeableObjectPrefab = Resources.Load("Prefabs/Schmiede") as GameObject;
Debug.Log("Button pressed1");
Debug.Log(gameObjectNameNumber);
gameObjectName[gameObjectNameNumber] = "Schmiede";
Debug.Log("Button pressed2");
gameObjectNameNumber++;
Debug.Log("Button pressed3");
benutzernameSpeichern.SaveBuildingsName();
Debug.Log("Button pressed4");
buttonSchmiedeClicked = true;
Debug.Log("Button pressed5");
}

I think i am doing wrong with this string array “gameObjectName” but i dont know what is wrong.
It should check for the first entry in the array so 0 and put there the string “Schmiede” but instead i get an errormessage.
Here are some notes on IndexOutOfRangeException and ArgumentOutOfRangeException:
http://plbm.com/?p=236
Hey thank you for your help.
When write this line:
public string[] gameObjectName = new string[10];
I will get a string array with 10 emptys to fill.
They go from 0 to 9 when i want to go direktly to the slots.
(hope this is correct)
So when the value “gameObjectNameNumber” is 0 the string “Schmiede” has to be written in the array “gameObjectName” to position 0.
Am i thinking the right way here?
public void PlaceSchmiede()
{
Debug.Log("Button pressed");
placeableObjectPrefab = Resources.Load("Prefabs/Schmiede") as GameObject;
Debug.Log("Button pressed1");
Debug.Log(gameObjectNameNumber);
gameObjectName[gameObjectNameNumber] = "Schmiede";
Debug.Log("Button pressed2");
gameObjectNameNumber++;
Debug.Log("Button pressed3");
benutzernameSpeichern.SaveBuildingsName();
Debug.Log("Button pressed4");
buttonSchmiedeClicked = true;
Debug.Log("Button pressed5");
}
That is correct. Arrays and Lists are zero-based, so 10 entries is from 0 to 9.
Hmm but i am getting the same error from this.
Creating an array like this:
public string[] gameObjectName = new string[10];
Then put some Data in:
gameObjectName[0] = "Schmiede";
Same error as bevor:
It’s a public string array. Therefore it will be serialized in the inspector. So it doesn’t matter what you define in the field initializer. So if you don’t want this variable to be serialized in the inspector, either make it private or mark it with the NonSerialized attribute. If you want the array to be serialized and you also want to “recreate” the array in code, move the creation of the array to Awake or inside your method where you want to set the string(s).
Good catch @Bunny83 , that’s probably what is wrong.
@Kernkraft here is another way to go for initializing arrays:
List<string>TempList = new List<string>(); // empty
TempList.Add( "Hello!");
TempList.Add( "Goodbye!");
// and now we can make the array
gameObjectName = TempList.ToArray();
and now gameObjectName has “Hello!” and “Goodbye!” and is size 2.
In this case it would make more sense to just do
gameObjectName = new string[] {
"Hello!",
"Goodbye!"
};
Though using a List may be useful when you “outsource” the filling of the array / list to other methods so you can simply pass the list along and have them fill in the content.
I like that … “outsourcing.” Fitting.
And I think that’s kinda what OP is doing… he seems to be filling it in some kind of button responder function.
Many thanks to both of you your info helped me a lot 
I did the List thing get rid of the error and then transform it back to an array and safe it to a file.
But also i have another question about the list.
Is it possible to write in a specific position?
Like this:
public List<string> gameObjectName = new List<string>();
gameObjectName[1].Add("Hello")
gameObjectName[3].Add("Goodbye")
Of course, as long as it is within the bounds of the array (0 or greater and less than .Length)
Finally got my object saving working.
Thanks a lot again.