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-16 19:00:40 +01:00

65 lines
1.6 KiB
C#
Executable File

using System.Collections;
using System.Collections.Generic;
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;
GetComponent<SVGImage>().sprite = sprite;
RectTransform.sizeDelta = new Vector2(100 * sprite.rect.width / 700f, 100); // TODO get max width from UIManager
gameObject.name = "UI_" + _gatePrefab.GateType.ToString();
}
}
public RectTransform RectTransform
{
get
{
if (_rectTransform == null)
_rectTransform = GetComponent<RectTransform>();
return _rectTransform;
}
}
#endregion
#region Private Properties
private Gate _gatePrefab;
private RectTransform _rectTransform;
#endregion
#region Unity Methods
public void OnPointerDown(PointerEventData eventData)
{
GameManager.Instance.CreateGate(_gatePrefab);
}
#endregion
#region Public Methods
#endregion
#region Private Methods
#endregion
}
}