Weird issue with List and for loop.

I have a list which contains Vector3 values of some GameObjects saved in a database in the form of string.
I am trying to assign these values to an array of GameObjects. I am able to retrieve the values correctly which is confirmed by the Debug.Log in the console, however, a weird thing is happening. When I check in the Inspector, all of the gameObjects have the last value from the loop assigned to them. I am posting screenshots and code to explain the issue.


DataService ds;
public GameObject Points;

void Start () {

ds = new DataService (Constants.DB_NAME);
List<SceneMain> sceneMains = ds.GetAllSavedScene ();
	//Debug.Log (sceneMains.Count + "--------------");

	foreach (SceneMain sceneMain in sceneMains) {
		//Debug.Log (sceneMain.scene.ToString ());
		foreach (ScenePoint point in sceneMain.points) {
			Debug.Log ("Saved Points : "+ point.ToString ());
			for (int i = 0; i <sceneMain.points.Count; i++) {
				string[] temp = point.point_position.Substring(1,point.point_position.Length-2).Split(',');
				float x = float.Parse(temp[0]);
				float y = float.Parse(temp[1]);
				float z = float.Parse(temp[2]);
				Vector3 rValue = new Vector3(x,y,z);
				Points *.transform.position = new Vector3 (rValue .x,rValue .y,rValue .z);*

_ Debug.Log ("Restored Points ; " + Points .transform.position);_
* }*
* }*
Please help.

I think the trouble comes from the fact that you have in indexed loop

for (int i = 0; i <sceneMain.points.Count; i++)

inside a foreach loop

foreach (ScenePoint point in sceneMain.points)

Your indexed loop keeps counting up but is reusing the same point from the foreach loop (which is independent from your index).
I suggest removing the foreach loop and set

point = sceneMain.points 

at the beginning of the indexed loop.