Interface d'amélioration s'affiche onClick pour FarmersAssociation Interface n'est présentement pas rétroactive des infos de l'unité
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class AllyUpgrade : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
[SerializeField]
|
|
private GameObject upgradeUI;
|
|
[SerializeField]
|
|
private List<UnitCard> upgradeUnitCardList = new List<UnitCard>();
|
|
[SerializeField]
|
|
private List<GameObject> upgradePrefabList = new List<GameObject>();
|
|
private GameObject _instance = null;
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (eventData.button == 0) //Left click
|
|
{
|
|
Debug.Log("Event clicked...");
|
|
if (!_instance)
|
|
{
|
|
GameObject sceneCanvas = GameObject.Find("Canvas");
|
|
if (sceneCanvas != null)
|
|
{
|
|
Canvas canvas = sceneCanvas.GetComponent<Canvas>();
|
|
if (canvas == null)
|
|
{
|
|
Debug.Log("Canvas introuvable...");
|
|
}
|
|
else
|
|
{
|
|
_instance = Instantiate(upgradeUI, Camera.main.WorldToScreenPoint(transform.position), Quaternion.identity, canvas.transform);
|
|
}
|
|
}
|
|
Debug.Log(_instance.transform.position);
|
|
Debug.Log(Camera.main.WorldToScreenPoint(transform.position));
|
|
|
|
GameObject upgradeParent = _instance.transform.GetChild(0).gameObject;
|
|
for (int i = 0; i < upgradeParent.transform.childCount; i++)
|
|
{
|
|
GameObject upgradeEnfant = upgradeParent.transform.GetChild(i).gameObject;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Destroy(_instance);
|
|
Debug.Log("Destroyed....");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|