Esempio n. 1
0
    public override void OnLoad(GameObject go)
    {
        base.OnLoad(go);
        //BINDING_CODE_BEGIN
        mButtonNormal           = GetComponent <Button>("Tween/SafeArea/@Button.mButtonNormal");
        mTextNormal             = GetComponent <Text>("Tween/SafeArea/@Button.mButtonNormal/@Text.mTextNormal");
        mButtonPop              = GetComponent <Button>("Tween/SafeArea/@Button.mButtonPop");
        mButtonWidget           = GetComponent <Button>("Tween/SafeArea/@Button.mButtonWidget");
        mText                   = GetComponent <Text>("Tween/SafeArea/@Text.mText");
        mVerticalGridScrollView = GetComponent <VerticalScrollView>("Tween/SafeArea/@VerticalScrollView.mVerticalGridScrollView");
        mButtonAdd              = GetComponent <Button>("Tween/SafeArea/@Button.mButtonAdd");
        mButtonRemove           = GetComponent <Button>("Tween/SafeArea/@Button.mButtonRemove");
        mVerticalScrollView     = GetComponent <VerticalScrollView>("Tween/SafeArea/@VerticalScrollView.mVerticalScrollView");
        mHorizontalScrollView   = GetComponent <HorizontalScrollView>("Tween/SafeArea/@HorizontalScrollView.mHorizontalScrollView");
        mTab         = GetComponent <Tab>("Tween/SafeArea/@Tab.mTab");
        mProgressBar = GetComponent <ProgressBar>("Tween/SafeArea/@ProgressBar.mProgressBar");
        mTimer       = GetComponent <Timer>("Tween/SafeArea/@Timer.mTimer");
//BINDING_CODE_END

        mButtonNormal.onClick.AddListener(() => WindowManager.Instance.Open <UINormal>());
        mButtonPop.onClick.AddListener(() => WindowManager.Instance.Open <UIPop>());
        mButtonWidget.onClick.AddListener(() => WindowManager.Instance.Open <UIWidget>());

        mButtonAdd.onClick.AddListener(OnButtonAddClick);
        mButtonRemove.onClick.AddListener(OnButtonRemoveClick);

        mTab.onTabValueChanged.AddListener(OnTabValueChanged);
        mTab.onTabRegisterToggle.AddListener(OnTabRegisterToggle);
        mTab.RegisterToggle();

        mVerticalGridScrollView.onScrollItem.AddListener(OnVerticalGridScrollItem);

        for (int i = 0; i < 100; i++)
        {
            mGridScrollViewDataList.Add(Random.Range(0, 100));
        }

        mVerticalGridScrollView.totalCount = mGridScrollViewDataList.Count;
        mVerticalGridScrollView.Refill();

        mProgressBar.SetMinMax(0, 100);
        mProgressBar.onValueChanged.AddListener(OnProgessBarChanged);
        mProgressBar.AddTrigger(0, (progressBar, value) => {
            Debug.Log("Trigger at:" + value);
            mProgressBar.onValueChanged.RemoveListener(OnProgessBarChanged);
            mProgressBar.SetValue(100, 4);
        });
        mProgressBar.AddTrigger(100, (progressBar, value) =>
        {
            Debug.Log("Trigger at:" + value);
            mProgressBar.SetValue(0, 2);
        });
        mProgressBar.SetValue(100, 2);

        mTimer.TryGetComponent(out Text text);
        mTimer.onTimerValueChanged.AddListener((timer, previous) => {
            if (text)
            {
                text.text = string.Format("{0}s", timer.value);
            }
        });
        mTimer.AddTrigger(0, (timer, value) => {
            Debug.Log("timer trigger at:" + value);
        });
        mTimer.Begin(5, 0, 1, -1);
    }