コード例 #1
0
    private void Awake()
    {
        //ui控件赋值
        image  = transform.Find("Image").GetComponent <RawImage>();
        text   = transform.Find("Text").GetComponent <Text>();
        button = transform.Find("Button").GetComponent <Button>();

        //创建对应的mediator,并注册
        mediator = new TextPanelMediator(gameObject);
        MyFacade.Instance.RegisterMediator(mediator);
    }
コード例 #2
0
    public override void Execute(INotification notification)
    {
        mediator = MyFacade.Instance.RetrieveMediator("TextPanelMediator") as TextPanelMediator;

        if (mediator == null)
        {
            if (!HasViewExits(ref textPanel))
            {
                //还未创建TextPanelView
                textPanel.AddComponent <TextPanelView>();
            }
            //获得该view对应的mediator
            mediator = textPanel.GetComponent <TextPanelView>().Mediator;
        }

        if (!mediator.IsViewActive())
        {
            mediator.SetViewActive(true);
        }

        //将内容更新至view组件
        mediator.UpdateViewContext(notification);
    }