-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoodPrefScript.cs
More file actions
54 lines (49 loc) · 1.35 KB
/
Copy pathFoodPrefScript.cs
File metadata and controls
54 lines (49 loc) · 1.35 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class FoodPrefScript : MonoBehaviour
{
public RawImage img;
public TMP_Text name;
public GameObject close;
public int index;
public Dish dish;
public void OpenReceipt()
{
var DPP = AppManager.Instance.dishesPlayerPrefs;
var AM = AppManager.Instance;
//Debug.Log("open");
AM.currentDish = dish;
DPP.viewedDishes.Add(dish);
if (DPP.viewedDishes.Count>6)
{
DPP.viewedDishes.Remove(DPP.viewedDishes[0]);
}
AM.SwitchScreen(4);
string s = JsonUtility.ToJson(DPP);
PlayerPrefs.SetString("dish", s);
}
public async void ScrollCellContent(Dish _dish)
{
dish = _dish;
name.text = _dish.name;
_dish.showed = true;
try
{
img.texture = await LoadImg(_dish.img[0].url);
}
catch
{ }
}
async Task<Texture> LoadImg(string endpoint)
{
using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(endpoint))
{
await request.SendWebRequest();
var texture = DownloadHandlerTexture.GetContent(request);
return texture;
}
}
}