1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using DG.Tweening;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ThreeDNav : MonoBehaviour
- {
- public Vector2[] targetPos;
- public Image s_image;
- public List<Button> btns;
- public List<RectTransform> layers;
- public GameObject content;
- public RectTransform znz;
- private void Start()
- {
- CameraManager.SwitchCamera(0);
- InitButton();
- StaticLod.instance.OnFoucusStatic("Bird0");
- }
- void InitButton()
- {
- 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>());
- }
- for (int i = 0; i < btns.Count; i++)
- {
- int index = i;
- btns[index].onClick.AddListener(() =>
- {
- 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;
- Tweener tw = s_image.GetComponent<RectTransform>().DOLocalMoveX(targetPos[index].x, 0.3f);
- tw.SetEase(Ease.OutBack);
- if (index < layers.Count)
- {
- layers[index].gameObject.SetActive(true);
- }
- if (index == 1)
- {
- StaticLod.instance.OnFoucusStatic("Bird0");
- }
- else {
- StaticLod.instance.OnFoucusStatic("TaoKou");
- }
- });
- }
- }
- private void Update()
- {
- znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
- }
- }
|