12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class UIManager : MonoBehaviour {
- //单例
- public static UIManager instance;
- private GameObject canvas;
- // Use this for initialization
- private void Awake()
- {
- instance = this;
- }
- void Start () {
- canvas = GameObject.Find("Canvas");
- // CreatePanel("PanelStart");
- //点击开始按钮 界面跳转 生成飞机、石头、道具
- UIManager.instance.CreatePanel("PanelGame");
- // UIManager.instance.DestroyPanel("PanelStart");
- PlaneManager.instance.CreateAirPlane();
- CreateStone.instance.InvokeRepeating("createStone", 1f, 1f);
- CreateStone.instance.InvokeRepeating("createProp", 1f, 3f);
- }
- //生成panel界面
- public void CreatePanel(string _name)
- {
- GameObject panel = Resources.Load<GameObject>("Prefabs/"+_name);
- GameObject go = Instantiate(panel);
- go.name = _name;
-
- go.transform.SetParent(canvas.transform);
- //go.transform.localScale = Vector3.one;
- //go.transform.position = Vector3.zero;
-
- }
- //摧毁panel界面
- public void DestroyPanel(string _name)
- {
- GameObject go = canvas.transform.Find(_name).gameObject;
- Destroy(go);
- }
- // Update is called once per frame
- void Update () {
-
- }
- }
|