123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TransportButton : MonoBehaviour
- {
- [SerializeField]
- private Image imageButton;
- [SerializeField]
- private Button transportButton;
-
- Transform location;
-
- void LateUpdate ()
- {
- if (location != null)
- {
- if (imageButton!=null)
- {
- imageButton.enabled = true;
- transportButton.enabled = true;
- }
- if (Camera.main != null)
- {
- transform.position = Camera.main.WorldToScreenPoint(location.position);
- }
- }
- else
- {
- if (imageButton != null)
- {
- imageButton.enabled = false;
- transportButton.enabled = false;
- }
- }
- }
- public void Activate(Transform location)
- {
- gameObject.SetActive(true);
- this.location = location;
- }
- public void Deactivate()
- {
- gameObject.SetActive(false);
- }
- }
|