powerfun-unity/Assets/Scenes/Ride/Scripts/PlayerItemFactory.cs
2021-04-12 17:35:56 +08:00

43 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Assertions;
namespace Assets.Scenes.Ride.Scripts
{
public class NearByItemFactory : MonoBehaviour
{
private GameObject nearByItem;
// Start is called before the first frame update
void Start()
{
nearByItem = Resources.Load<GameObject>("UI/Prefab/Ride/NearbyItem");
Assert.IsNotNull(nearByItem);
}
float t = 1;
// Update is called once per frame
void Update()
{
t -= Time.deltaTime;
while (t < 0)
{
//var nearList = MapUDPService.GetNearRiderData(1, 20, new double[] { playerController.Nextlatlong.x, playerController.Nextlatlong.y });
//Debug.Log(nearList.Count());
GameObject newObj; // Create GameObject instance
for (int i = 0; i < 5; i++)
{
// Create new instances of our prefab until we've created as many as we specified
newObj = (GameObject)Instantiate(nearByItem, transform);
var nearByItemscript = newObj.GetComponent<NearByItemScript>();
nearByItemscript.setName("");
nearByItemscript.setRatio("");
nearByItemscript.setSpeed("");
nearByItemscript.setHead("");
t = 1;
}
}
}
}
}