names in toolbar
This commit is contained in:
+12
-12
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using Unity.VectorGraphics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -16,23 +17,17 @@ namespace UntitledLogicGame.UI
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public Gate GatePrefab {
|
||||
public Gate GatePrefab
|
||||
{
|
||||
set
|
||||
{
|
||||
_gatePrefab = value;
|
||||
var sprite = _gatePrefab.GetComponentInChildren<SpriteRenderer>().sprite;
|
||||
GetComponent<SVGImage>().sprite = sprite;
|
||||
RectTransform.sizeDelta = new Vector2(100 * sprite.rect.width / 700f, 100); // TODO get max width from UIManager
|
||||
var subimage = GetComponentInChildren<SVGImage>();
|
||||
subimage.sprite = sprite;
|
||||
subimage.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 100 * sprite.rect.width / 700f); // TODO get max width from UIManager
|
||||
gameObject.name = "UI_" + _gatePrefab.GateType.ToString();
|
||||
}
|
||||
}
|
||||
public RectTransform RectTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rectTransform == null)
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
return _rectTransform;
|
||||
GetComponentInChildren<TextMeshProUGUI>().text = _gatePrefab.GateType.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +42,11 @@ namespace UntitledLogicGame.UI
|
||||
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
GameManager.Instance.CreateGate(_gatePrefab);
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace UntitledLogicGame.UI
|
||||
{
|
||||
var uiGate = Instantiate(UIGatePrefab, GateBar.transform);
|
||||
uiGate.GatePrefab = gatePrefab;
|
||||
uiGate.RectTransform.anchoredPosition = new Vector2(currentPos, 0);
|
||||
currentPos += uiGate.RectTransform.sizeDelta.x;
|
||||
uiGate.GetComponent<RectTransform>().anchoredPosition = new Vector2(currentPos, 0);
|
||||
currentPos += 100f;
|
||||
}
|
||||
|
||||
MovingBar.SetActive(false);
|
||||
|
||||
Reference in New Issue
Block a user