using System; using System.IO; using System.Linq; using UnityEngine; using System.Collections; using System.Collections.Generic; public class ruutudeloomine2 : MonoBehaviour { List ruudud=new List(); void Start () { //Lugege uute ruutude koordinaadid sisse failist GameObject ruut=(GameObject)GameObject.Find ("Ruut"); for (int x=-5; x<5; x=x+2) { GameObject uusRuut=(GameObject)Instantiate (ruut); uusRuut.transform.position=new Vector3(x, 0, 0); uusRuut.renderer.material.color=Color.black; ruudud.Add(uusRuut); } } void OnGUI(){ if (GUI.Button (new Rect (310, 10, 80, 20), "Vajuta")) { foreach (GameObject ruut in ruudud.Where( r => r.transform.position.x>0)) { ruut.transform.position += Vector3.right; } // File.WriteAllLines("D:\\dotnet\\unity\\ruudukohad.txt", // ruudud.Select (r => r.transform.position.x.ToString()).ToArray()); } //Salvestage ruutude uued koordinaadid faili } }