| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 | using DG.Tweening;using System;using System.Collections;using System.Collections.Generic;using System.Xml;using Unity.VisualScripting;using UnityEngine;using UnityEngine.UI;public class OnePicNav : MonoBehaviour{    public static OnePicNav instance;    public Vector2[] targetPos;    public List<Button> btns;    public Image s_image;    public List<RectTransform> layers;    public GameObject content;    public RectTransform znz;    public RectTransform[] runtimePointStatic;    public List<Transform> runtimePointStaticBind;    public GameObject shaPan;    public int lastIndex = -99;    // Start is called before the first frame update    void Start()    {        instance = this;        InitButton();    }    void InitButton() {        shaPan = GameObject.FindGameObjectWithTag("ShaPan");        Debug.Log(shaPan);        runtimePointStaticBind.Add(shaPan.transform.GetChild(6).GetChild(0));        runtimePointStaticBind.Add(shaPan.transform.GetChild(6).GetChild(1));        runtimePointStaticBind.Add(shaPan.transform.GetChild(6).GetChild(2));        CameraManager.SwitchCamera(1);        btns = new List<Button>();        Button[] bts = this.GetComponentsInChildren<Button>();        for (int i = 0; i < bts.Length; i++) {            btns.Add(bts[i]);        }        layers = new List<RectTransform>();        for (int i = 0; i < content.transform.childCount; i++) {            layers.Add(content.transform.GetChild(i).GetComponent<RectTransform>());        }        layers[0].gameObject.SetActive(true);        for (int i = 0; i < btns.Count; i++)        {            int index = i;            btns[index].onClick.AddListener(() =>            {                OnButtnClick(index);            });        }    }    public void OnButtnClick(int index) {        if (lastIndex == index)            return;        if (lastIndex > -1) {            layers[lastIndex].GetComponent<YZTRootLayer>().OnUILeave();        }        for (int j = 0; j < layers.Count; j++)        {            layers[j].gameObject.SetActive(false);        }        for (int j = 0; j < btns.Count; j++)        {            btns[j].GetComponentInChildren<Text>().color = new Color32(137, 147, 173, 255);        }        btns[index].GetComponentInChildren<Text>().color = Color.white;        lastIndex = index;        Tweener tw = s_image.GetComponent<RectTransform>().DOLocalMoveX(targetPos[index].x, 0.3f);        tw.SetEase(Ease.OutBack);        if (index < layers.Count)            if (index == 0 || index == 2 || index == 5)            {                if (layers[index].GetComponent<YZTRootLayer>().viewMode == ViewMode.miniMap)                {                    CameraManager.SwitchCamera(1);                }                else                {                    CameraManager.SwitchCamera(0);                }            }            else            {                CameraManager.SwitchCamera(0);            }        layers[index].gameObject.SetActive(true);    }    public void SwitchToGlobalWeather()    {        OnButtnClick(2);        layers[2].GetComponent<GCJKLayer>().OnGlobalWeatherClick();    }    public void SwitchToGlobalWaterHeight()    {        OnButtnClick(5);        layers[5].GetComponent<SWYJLayer>().OnGlobalSWBtnClick();    }    // Update is called once per frame    void LateUpdate()    {        if (CameraManager.instance.mainCamera.enabled)            znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);        else            znz.transform.rotation = Quaternion.identity;        for (int i = 0; i < runtimePointStatic.Length; i++)        {            bool cameraEnable = CameraManager.instance.secondCamera.enabled;            runtimePointStatic[i].gameObject.SetActive(cameraEnable);            if (cameraEnable)                runtimePointStatic[i].anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(runtimePointStaticBind[i].transform.position) * 1920.0f / Screen.width;        }    }}
 |