Forráskód Böngészése

选择关卡界面增加返回按钮

lvjincheng 3 éve
szülő
commit
35e9b9fc20

+ 11 - 4
Assets/BowArrow/Scripts/Game/GameAssistUI.cs

@@ -19,12 +19,19 @@ public class GameAssistUI : MonoBehaviour
         ins = this;
     }
 
+    public void copyButtonBack(Transform parent) {
+        GameObject o = GameObject.Instantiate(this.transform.Find("Button0").gameObject, parent);
+        o.GetComponent<Button>().onClick.AddListener(onBtnBack);
+    }   
+
+    void onBtnBack() {
+        AudioMgr.ins.PlayBtn();
+        SceneManager.LoadScene("Home", LoadSceneMode.Single);
+    }
+
     void Start()
     {
-        this.transform.Find("Button0").GetComponent<Button>().onClick.AddListener(delegate(){
-            AudioMgr.ins.PlayBtn();
-            SceneManager.LoadScene("Home", LoadSceneMode.Single);
-        });
+        this.transform.Find("Button0").GetComponent<Button>().onClick.AddListener(onBtnBack);
         this.transform.Find("Button1").GetComponent<Button>().onClick.AddListener(delegate(){
             AudioMgr.ins.PlayBtn();
             GameRuleView.Create();

+ 2 - 0
Assets/BowArrow/Scripts/GameChallenge/Views/HuntGameSelectLevelView.cs

@@ -31,6 +31,8 @@ public class HuntGameSelectLevelView : MonoBehaviour
             levelTF.Find("Icon2").gameObject.SetActive(levelRecord == myPassLevel + 1);
             levelTF.Find("Icon2").GetComponent<Image>().sprite = avatarSprite;
         }
+
+        GameAssistUI.ins.copyButtonBack(this.transform);
     }
 
     void OnDestroy()

+ 2 - 0
Assets/BowArrow/Scripts/View/TimeLimitGameDistanceSelectView.cs

@@ -29,6 +29,8 @@ public class TimeLimitGameDistanceSelectView : MonoBehaviour
                 Destroy(this.gameObject);
             });
         }
+
+        GameAssistUI.ins.copyButtonBack(this.transform);
     }
 
     void OnDestroy()