mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2026-07-31 16:19:03 +02:00
a
This commit is contained in:
21
Assets/Scripts/UI/BuildingMenu.cs
Normal file
21
Assets/Scripts/UI/BuildingMenu.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildingMenu : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] GameObject slotPrefab;
|
||||
[SerializeField] List<PlacedObjectTypeSO> placedObjectTypeSOList;
|
||||
|
||||
void Start()
|
||||
{
|
||||
foreach(PlacedObjectTypeSO p in placedObjectTypeSOList)
|
||||
{
|
||||
GameObject slot = Instantiate(slotPrefab, gameObject.transform);
|
||||
slot.GetComponent<BuildingMenuSlot>().placedObjectTypeSO = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/BuildingMenu.cs.meta
Normal file
11
Assets/Scripts/UI/BuildingMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcce99e456cd44549aa61d6dd97c9846
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Scripts/UI/BuildingMenuSlot.cs
Normal file
31
Assets/Scripts/UI/BuildingMenuSlot.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class BuildingMenuSlot : MonoBehaviour
|
||||
{
|
||||
public PlacedObjectTypeSO placedObjectTypeSO;
|
||||
|
||||
Image img;
|
||||
Button btn;
|
||||
TextMeshProUGUI textObj;
|
||||
|
||||
void Start()
|
||||
{
|
||||
img = transform.Find("Image").gameObject.GetComponent<Image>();
|
||||
btn = GetComponent<Button>();
|
||||
textObj = transform.Find("Text").gameObject.GetComponent<TextMeshProUGUI>();
|
||||
|
||||
|
||||
img.sprite = placedObjectTypeSO.iconSprite;
|
||||
textObj.text = placedObjectTypeSO.nameString;
|
||||
btn.onClick.AddListener(OnClick);
|
||||
}
|
||||
|
||||
void OnClick()
|
||||
{
|
||||
GridBuildingSystem.instance.SelectBuilding(placedObjectTypeSO);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/BuildingMenuSlot.cs.meta
Normal file
11
Assets/Scripts/UI/BuildingMenuSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49a86965eb0eda744b944b1e786c49ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user