using ObjectScripts; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; public class Tester : MonoBehaviour { List gameObjects; double updateRate; double counterRate; [SerializeField] GameObject prefab; // Start is called before the first frame update void Start() { gameObjects = new List(); for (int i = 0; i < 10; i++) gameObjects.Add(Instantiate(prefab)); updateRate = counterRate = 5; } // Update is called once per frame void Update() { if(counterRate > updateRate) { Parallel.ForEach(gameObjects, x => { DataObject data = x.GetComponent(); data.Handler.UpdateRate = (float)updateRate; data.SetNewTargetPos(new Vector3(Random.Range(-500, 500), 0, Random.Range(-500, 500))); }); counterRate = 0; } counterRate += Time.deltaTime; } }