This repository has been archived on 2026-05-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
CompuLogic/Assets/Scripts/UI/UIGate.cs
T
2020-12-17 13:07:45 +01:00

64 lines
1.6 KiB
C#
Executable File

using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VectorGraphics;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UntitledLogicGame.Workspace;
namespace UntitledLogicGame.UI
{
public class UIGate : MonoBehaviour, IPointerDownHandler
{
#region Unity Properties
#endregion
#region Public Properties
public Gate GatePrefab
{
set
{
_gatePrefab = value;
var sprite = _gatePrefab.GetComponentInChildren<SpriteRenderer>().sprite;
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.Definition.Name;
GetComponentInChildren<TextMeshProUGUI>().text = _gatePrefab.Definition.Name;
}
}
#endregion
#region Private Properties
private Gate _gatePrefab;
#endregion
#region Unity Methods
private void Start()
{
}
public void OnPointerDown(PointerEventData eventData)
{
GameManager.Instance.CreateGate(_gatePrefab);
}
#endregion
#region Public Methods
#endregion
#region Private Methods
#endregion
}
}