using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG.Tweening; public class SceneBtn : MonoBehaviour { public Button shopbtn; public Button Developbtn; public Button Troughbtn; public Button Herobtn; public Button Treebtn; public Sprite showtextbg; public Sprite showtextup; public Sprite removetextbg; public Sprite removetextup; private RectTransform Developpanel; private RectTransform shoppanel; private RectTransform Troughpanel; private RectTransform heropanel; private RectTransform treepanel; private Image shopimagebg; private Image shopimagerup; private Image Developimagebg; private Image Developimagerup; private Image Troughimagebg; private Image Troughmagerup; private Image Heroimagebg; private Image Heroimagerup; private Image Treeimagebg; private Image Treeimagerup; Vector3 Deflate = new Vector3(0.5f, 0.5f, 0.5f); public List Scenelist = new List(); void Start() { shopbtn.onClick.AddListener(shopClick); Developbtn.onClick.AddListener(DevelopClick); Troughbtn.onClick.AddListener(TroughClick); Herobtn.onClick.AddListener(HeroClick); Treebtn.onClick.AddListener(TreeClick); Developpanel = Developbtn.GetComponent(); shoppanel = shopbtn.GetComponent(); Troughpanel = Troughbtn.GetComponent(); heropanel = Herobtn.GetComponent(); treepanel = Treebtn.GetComponent(); shopimagebg = shopbtn.transform.Find("Bg").GetComponent(); shopimagerup= shopbtn.transform.Find("TxtBorder").GetComponent(); Developimagebg = Developbtn.transform.Find("Bg").GetComponent(); Developimagerup = Developbtn.transform.Find("TxtBorder").GetComponent(); Troughimagebg = Troughbtn.transform.Find("Bg").GetComponent(); Troughmagerup = Troughbtn.transform.Find("TxtBorder").GetComponent(); Heroimagebg =Herobtn.transform.Find("Bg").GetComponent(); Heroimagerup = Herobtn.transform.Find("TxtBorder").GetComponent(); Treeimagebg = Treebtn.transform.Find("Bg").GetComponent(); Treeimagerup = Treebtn.transform.Find("TxtBorder").GetComponent(); // BeginLoad(JumpScene.jumpbool); } private void Update() { switch (JumpScene.jumpbool) { case 0: // RemoveImage(); Showimage(shopimagebg, shopimagerup); Removlist(); Appear(); break; case 1://1 RemoveImage(); Showimage(Developimagebg, Developimagerup); Removlist(); Appear(); break; case 2://0 RemoveImage(); Showimage(Troughimagebg, Troughmagerup); Removlist(); Appear(); break; case 3://3 RemoveImage(); Showimage(Heroimagebg, Heroimagerup); Removlist(); Appear(); break; case 4://4 RemoveImage(); Showimage(Treeimagebg, Treeimagerup); Removlist(); Appear(); break; case 5: Removlist(); Appear(); break; default: break; } } void shopClick() { shoppanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(shoppanel)); JumpScene.jumpbool = 0; //SceneGuodu.instance.SlideInAndLoadScene(JumpScene.shop_scene); } void DevelopClick() { Developpanel.DOScale(Deflate,0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(Developpanel)); JumpScene.jumpbool = 1; //SceneGuodu.instance.SlideInAndLoadScene(JumpScene.develop_the_main_interface_slices); } void TroughClick() { Troughpanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(Troughpanel)); JumpScene.jumpbool = 2; //SceneGuodu.instance.SlideInAndLoadScene(JumpScene.main_scene); } void HeroClick() { heropanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(heropanel)); JumpScene.jumpbool = 3; //SceneGuodu.instance.SlideInAndLoadScene(JumpScene.heroBg); } void TreeClick() { treepanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(treepanel)); JumpScene.jumpbool = 4; //SceneGuodu.instance.SlideInAndLoadScene(JumpScene.EcoTree); } void Showimage(Image im,Image im2) { im.sprite = showtextbg; im2.sprite = showtextup; } public void RemoveImage() { shopimagebg.sprite = removetextbg; shopimagerup.sprite = removetextup; Developimagebg.sprite = removetextbg; Developimagerup.sprite = removetextup; Troughimagebg.sprite = removetextbg; Troughmagerup.sprite = removetextup; Heroimagebg.sprite = removetextbg; Heroimagerup.sprite = removetextup; Treeimagebg.sprite = removetextbg; Treeimagerup.sprite = removetextup; } IEnumerator Magnify(RectTransform allpanel) { yield return null; allpanel.DOScale(Vector3.one, 0.5f).SetEase(Ease.OutBack); } private void Removlist() { foreach (var i in Scenelist) { i.gameObject.SetActive(false); } } private void Appear() { switch (JumpScene.jumpbool) { case 0: Scenelist[0].gameObject.SetActive(true); break; case 1: Scenelist[1].gameObject.SetActive(true); break; case 2: Scenelist[2].gameObject.SetActive(true); break; case 3: Scenelist[3].gameObject.SetActive(true); break; case 4: Scenelist[4].gameObject.SetActive(true); break; case 5: Scenelist[5].gameObject.SetActive(true); break; } } }