1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using ObjectScripts;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using UnityEngine;
- public class Tester : MonoBehaviour
- {
- List<GameObject> gameObjects;
- double updateRate;
- double counterRate;
- [SerializeField] GameObject prefab;
- // Start is called before the first frame update
- void Start()
- {
- gameObjects = new List<GameObject>();
- 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<DataObject>();
- data.Handler.UpdateRate = (float)updateRate;
- data.SetNewTargetPos(new Vector3(Random.Range(-500, 500), 0, Random.Range(-500, 500)));
- });
- counterRate = 0;
- }
- counterRate += Time.deltaTime;
- }
- }
|