1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Unity.Mathematics;
- using UnityEngine;
- using UnityEngine.UI;
- public class PathSign : MonoBehaviour
- {
- public GameObject bindObj;
- public Vector3 bindPos;
- public void SetIndex(int index) {
- this.GetComponentInChildren<Text>().text = index.ToString();
- }
- // Update is called once per frame
- void LateUpdate()
- {
- if (bindObj != null)
- {
- this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bindPos) / Screen.width * 1920.0f;
- float alpha = this.GetComponent<RectTransform>().anchoredPosition.y < 1000 ? 1 : (1 - (this.GetComponent<RectTransform>().anchoredPosition.y - 1000) / 16);
- this.GetComponent<Image>().color = new Color(1, 1, 1, alpha);
- float dyScale = 72 / CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance;
- dyScale = math.clamp(dyScale, 1, 4);
- this.transform.localScale = new Vector3(dyScale, dyScale, dyScale);
- if (!bindObj.activeSelf || !bindObj.transform.parent.gameObject.activeSelf || !bindObj.transform.parent.parent.gameObject.activeSelf)
- {
- this.GetComponent<Image>().enabled = false;
- this.GetComponentInChildren<Text>().enabled = false;
- if(this.GetComponentInChildren<Button>() != null)
- this.GetComponentInChildren<Button>().interactable = false;
- }
- else {
- this.GetComponent<Image>().enabled = true;
- this.GetComponentInChildren<Text>().enabled = true;
- if (this.GetComponentInChildren<Button>() != null)
- this.GetComponentInChildren<Button>().interactable = true;
- }
- }
- }
- }
|