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); 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); } void shopClick() { RemoveImage(); Showimage(shopimagebg, shopimagerup); shoppanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(shoppanel)); UIScreenMgr.instance.ShowScreen(0); } void DevelopClick() { RemoveImage(); Showimage(Developimagebg, Developimagerup); Developpanel.DOScale(Deflate,0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(Developpanel)); UIScreenMgr.instance.ShowScreen(1); } void TroughClick() { RemoveImage(); Showimage(Troughimagebg, Troughmagerup); Troughpanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(Troughpanel)); UIScreenMgr.instance.ShowScreen(2); } void HeroClick() { RemoveImage(); Showimage(Heroimagebg, Heroimagerup); heropanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack); StartCoroutine(Magnify(heropanel)); UIScreenMgr.instance.ShowScreen(3); } void TreeClick() { } 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); } public void BeginLoad(int i) { RemoveImage(); switch (i) { case 0: Showimage(shopimagebg, shopimagerup); break; case 1: Showimage(Developimagebg, Developimagerup); break; case 2: Showimage(Troughimagebg, Troughmagerup); break; case 3: Showimage(Heroimagebg, Heroimagerup); break; } } }