-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoodPref2Script.cs
More file actions
38 lines (33 loc) · 955 Bytes
/
Copy pathFoodPref2Script.cs
File metadata and controls
38 lines (33 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class FoodPref2Script : MonoBehaviour
{
public RawImage img;
public TMP_Text name;
public int index;
public Dish dish;
public void OpenReceipt()
{
Debug.Log("open");
AppManager.Instance.currentDish = dish;
AppManager.Instance.SwitchScreen(4);
}
private async void ScrollCellContent(object _dish)
{
dish = (Dish)_dish;
name.text = dish.name;
img.texture = await LoadImg(dish.img[0].url);
}
async Task<Texture> LoadImg(string endpoint)
{
using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(endpoint))
{
await request.SendWebRequest();
var texture = DownloadHandlerTexture.GetContent(request);
return texture;
}
}
}