界面
结构
代码
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using UnityEngine.UI; 5 using DG.Tweening; 6 7 public class HomePage : MonoBehaviour 8 { 9 public Button btn1; 10 public Button btn2; 11 //public Button btn3; 12 13 public Button b1; 14 public Button b2; 15 public Button b3; 16 public Button b4; 17 public Button b5; 18 19 20 public GameObject big1; 21 public GameObject big2; 22 //public GameObject big3; 23 public CanvasGroup bigAlpha1; 24 public CanvasGroup bigAlpha3; 25 26 public GameObject obj1; 27 public GameObject obj2; 28 public GameObject obj3; 29 public GameObject obj4; 30 public GameObject obj5; 31 32 33 public ZuZhiPage zuZhi; 34 public Page1 faLv; 35 public Page1 guiZhang; 36 public Page1 tiXi; 37 public Page1 qiTa; 38 public Page1 wenJian; 39 public Page1 guiDing; 40 [SerializeField] 41 private HomeJianTou jianTou; 42 // Use this for initialization 43 void Start () 44 { 45 Screen.SetResolution(1920,1080,true); 46 Cursor.visible = false; 47 48 obj1.transform.position = new Vector3(962, 543, 0); 49 obj2.transform.position = new Vector3(962, 543, 0); 50 obj3.transform.position = new Vector3(962, 543, 0); 51 obj4.transform.position = new Vector3(962, 543, 0); 52 obj5.transform.position = new Vector3(962, 543, 0); 53 54 obj1.SetActive(false); 55 obj2.SetActive(false); 56 obj3.SetActive(false); 57 obj4.SetActive(false); 58 obj5.SetActive(false); 59 60 jianTou.hideFunc(); 61 62 //960 63 //540 64 btn1.onClick.AddListener(()=> { 65 Debug.Log("1"); 66 67 //hideBtn(); 68 69 zuZhi.showFunc(); 70 }); 71 btn2.onClick.AddListener(() => { 72 Debug.Log("2"); 73 74 if (bigAlpha1.alpha == 0) 75 { 76 hideBtn(); 77 } 78 else 79 { 80 showBtn(); 81 } 82 83 }); 84 /*btn3.onClick.AddListener(() => { 85 Debug.Log("3"); 86 hideBtn(); 87 tiXi.showFunc(); 88 });*/ 89 90 91 b1.onClick.AddListener(() => { 92 Debug.Log("B1"); 93 faLv.showFunc(); 94 }); 95 b2.onClick.AddListener(() => { 96 Debug.Log("B2"); 97 guiZhang.showFunc(); 98 }); 99 b3.onClick.AddListener(() => { 100 Debug.Log("B3"); 101 wenJian.showFunc(); 102 }); 103 b4.onClick.AddListener(() => { 104 Debug.Log("B4"); 105 guiDing.showFunc(); 106 }); 107 b5.onClick.AddListener(() => { 108 Debug.Log("B5"); 109 qiTa.showFunc(); 110 }); 111 112 } 113 //显示5个小按钮 114 void showBtn() 115 { 116 obj1.SetActive(true); 117 obj2.SetActive(true); 118 obj3.SetActive(true); 119 obj4.SetActive(true); 120 obj5.SetActive(true); 121 /*obj1.transform.DOMove(new Vector3(549, 590, 0), 0.3f); 122 obj2.transform.DOMove(new Vector3(741, 752, 0), 0.3f); 123 obj3.transform.DOMove(new Vector3(982, 836, 0), 0.3f); 124 obj4.transform.DOMove(new Vector3(1225, 769, 0), 0.3f); 125 obj5.transform.DOMove(new Vector3(1415, 595, 0), 0.3f);*/ 126 obj1.transform.DOMove(new Vector3(398, 407, 0), 0.3f); 127 obj2.transform.DOMove(new Vector3(611, 696, 0), 0.3f); 128 obj3.transform.DOMove(new Vector3(961, 826, 0), 0.3f); 129 obj4.transform.DOMove(new Vector3(1309, 697, 0), 0.3f); 130 obj5.transform.DOMove(new Vector3(1528, 406, 0), 0.3f); 131 132 big1.transform.DOMove(new Vector3(450, 284, 0), 0.3f); 133 //big1.transform.DOScale(new Vector3(0.6f, 0.6f, 0.6f), 0.3f); 134 big1.transform.DOScale(new Vector3(0.0f, 0.0f, 0.0f), 0.3f); 135 DOTween.To(() => bigAlpha1.alpha, x => bigAlpha1.alpha = x, 0.0f, 0.3f).OnComplete(()=> { 136 jianTou.showFunc(); 137 }); 138 139 big2.transform.DOMove(new Vector3(962, 353, 0), 0.3f); 140 141 /*big3.transform.DOMove(new Vector3(1471, 284, 0), 0.3f); 142 big3.transform.DOScale(new Vector3(0.6f, 0.6f, 0.6f), 0.3f); 143 DOTween.To(() => bigAlpha3.alpha, x => bigAlpha3.alpha = x, 0.3f, 0.3f);*/ 144 } 145 //隐藏5个小按钮 146 void hideBtn() 147 { 148 jianTou.hideFunc(); 149 150 obj1.transform.DOMove(new Vector3(962, 543, 0), 0.3f); 151 obj2.transform.DOMove(new Vector3(962, 543, 0), 0.3f); 152 obj3.transform.DOMove(new Vector3(962, 543, 0), 0.3f); 153 obj4.transform.DOMove(new Vector3(962, 543, 0), 0.3f); 154 obj5.transform.DOMove(new Vector3(962, 543, 0), 0.3f); 155 156 157 //big2.transform.DOMove(new Vector3(962, 543, 0), 0.3f); 158 big2.transform.DOMove(new Vector3(1338, 543, 0), 0.3f); 159 160 161 //big1.transform.DOMove(new Vector3(450, 543, 0), 0.3f); 162 big1.transform.DOMove(new Vector3(585, 543, 0), 0.3f); 163 big1.transform.DOScale(new Vector3(1.0f, 1.0f, 1.0f), 0.3f); 164 DOTween.To(() => bigAlpha1.alpha, x => bigAlpha1.alpha = x, 1, 0.3f).OnComplete(() => { 165 obj1.SetActive(false); 166 obj2.SetActive(false); 167 obj3.SetActive(false); 168 obj4.SetActive(false); 169 obj5.SetActive(false); 170 171 }); 172 173 /*big3.transform.DOMove(new Vector3(1471, 543, 0), 0.3f); 174 big3.transform.DOScale(new Vector3(1.0f, 1.0f, 1.0f), 0.3f); 175 DOTween.To(() => bigAlpha3.alpha, x => bigAlpha3.alpha = x, 1, 0.3f).OnComplete(()=> { 176 obj1.SetActive(false); 177 obj2.SetActive(false); 178 obj3.SetActive(false); 179 obj4.SetActive(false); 180 obj5.SetActive(false); 181 });*/ 182 183 } 184 185 // Update is called once per frame 186 void Update() { 187 if (Input.GetKeyDown(KeyCode.M)) 188 { 189 if (Cursor.visible) 190 { 191 Cursor.visible = false; 192 } 193 else 194 { 195 Cursor.visible = true; 196 } 197 } 198 } 199 }