3DTD/Assets/Scripts/UI/UIManager.cs

54 lines
1.1 KiB
C#

using UnityEngine;
public class UIManager : MonoBehaviour
{
public Animator anim;
public string animationCall;
public GameObject activateGo;
public bool deactivateSelf;
public UIManager affectedObj;
public bool count;
public int maxCount = 2;
public int currentCount = 0;
private void Awake()
{
if(count)
currentCount = 0;
}
public void OnMouseEnter()
{
anim.SetTrigger(animationCall);
if (activateGo != null)
activateGo.SetActive(true);
if (deactivateSelf)
{
gameObject.SetActive(false);
if (count)
ResetCount();
}
//gameObject.SetActive(false);
if (count)
currentCount++;
if (currentCount >= maxCount && count)
gameObject.SetActive(false);
if (affectedObj != null && affectedObj.currentCount >= affectedObj.maxCount && affectedObj.count)
ResetCount();
}
public void ResetCount()
{
affectedObj.gameObject.SetActive(true);
affectedObj.currentCount = 0;
}
}