Add UI over plate to down plated ingreedients
This commit is contained in:
parent
16b86e4ec4
commit
ef24f6f0e8
11 changed files with 650 additions and 1983 deletions
16
Assets/Scripts/PlateIconSingleUI.cs
Normal file
16
Assets/Scripts/PlateIconSingleUI.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlateIconSingleUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private Image image;
|
||||
|
||||
public void SetKitchenObjectSO(KitchenObjectSO kitchenObjectSO)
|
||||
{
|
||||
image.sprite = kitchenObjectSO.sprite;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/PlateIconSingleUI.cs.meta
Normal file
11
Assets/Scripts/PlateIconSingleUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bb1226f765ef3974789570cd9ab1d05d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Assets/Scripts/PlateIconsUI.cs
Normal file
41
Assets/Scripts/PlateIconsUI.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlateIconsUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private PlateKitchenObject plateKitchenObject;
|
||||
[SerializeField] private Transform iconTemplate;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
iconTemplate.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
plateKitchenObject.OnIngreedientAdded += PlateKitchenObject_OnIngreedientAdded;
|
||||
}
|
||||
|
||||
private void PlateKitchenObject_OnIngreedientAdded(object sender, PlateKitchenObject.OnIngreedientAddedEventArgs e)
|
||||
{
|
||||
UpdateVisual();
|
||||
}
|
||||
|
||||
private void UpdateVisual()
|
||||
{
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
if (child == iconTemplate) continue;
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
foreach (KitchenObjectSO kitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList())
|
||||
{
|
||||
Transform iconTransform = Instantiate(iconTemplate, transform);
|
||||
iconTransform.gameObject.SetActive(true);
|
||||
iconTransform.GetComponent<PlateIconSingleUI>().SetKitchenObjectSO(kitchenObjectSO);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlateIconsUI.cs.meta
Normal file
11
Assets/Scripts/PlateIconsUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f1353c3b53a138c4ab06cfb45514baf6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -43,4 +43,9 @@ public class PlateKitchenObject : KitchenObject
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<KitchenObjectSO> GetKitchenObjectSOList()
|
||||
{
|
||||
return kitchenObjectSOList;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue