예제 #1
0
    void BuildPanel()
    {
        //从res中获取预制体
        _gameObject = GameObject.Instantiate(Resources.Load <GameObject>(_panelResName));
        if (!_gameObject)
        {
            Debug.Log($"{_panelResName},Resources中找不到");
        }

        //加入管理
        MyGUIManager.GetInstance().AddPanelObject(this);
        canvas             = gameObject.GetComponent <Canvas>();
        canvas.renderMode  = RenderMode.ScreenSpaceCamera;
        canvas.worldCamera = Camera.main;
        InitPanel();


        if (_listener == null)
        {
            _listener = new MyPanelEventListener();
        }
        var eventBase = _gameObject.AddComponent <IUIEvent>();

        _listener.OnInit(this, eventBase);
    }
예제 #2
0
    void BuildPanel()
    {
        //从res中获取预制体
        _gameObject = GameObject.Instantiate(Resources.Load <GameObject>("ui\\panel\\" + _panelResName));
        if (!_gameObject)
        {
            Debug.Log($"{_panelResName},Resources中找不到");
        }
        _gameObject.name = this._panelResName;
        _gameObject.transform.position = Vector3.zero;
        //加入管理
        MyGUIManager.GetInstance().AddPanelObject(this);

        if (_listener == null)
        {
            _listener = new MyPanelEventListener();
        }
        var eventBase = _gameObject.AddComponent <IUIEvent>();

        _listener.OnInit(this, eventBase);
    }