Ejemplo n.º 1
0
    // Use this for initialization
    IEnumerator Start()
    {
        if (Debug.isDebugBuild)
        {
            Debug.Log("BookLoaderScript Start assetBundleName=" + assetBundleName);
        }

        uiEventHandler = gameObject.GetComponent <UiEventHandler>();
        if (assetBundleName == null || assetBundleName == "")
        {
            //assetBundleName = "test_book";
            assetBundleName = "solar_system_book";
        }
        metadataAssetBundleName = assetBundleName + ".metadata";
        // Add DisplayTextUiController
        displayTextUiController = gameObject.AddComponent <DisplayTextUiController>();

        displayTextUiController.mainCanvas = mainCanvas;
        displayTextUiController.metadataAssetBundleName = metadataAssetBundleName;
        //end
        //DontDestroyOnLoad(gameObject);
        yield return(StartCoroutine(AssetBundleHelper.getInstance().InitializeAssetBunder(assetBundleName)));

        yield return(StartCoroutine(loadAssetBundleMetaData()));

        string jsonFileName = jsonSceneDataFileName + currentSceneIdx.ToString();

        yield return(StartCoroutine(loadSceneMetaData(jsonFileName)));

        //SceneInfo sceneInfo = new SceneInfo();
        //sceneInfo.name = "page1";
        // yield return StartCoroutine(LoadScence(sceneInfo));
        // Load level.
        //yield return StartCoroutine(InitializeLevelAsync("page1", true));
    }
Ejemplo n.º 2
0
    public static void BindEvent(GameObject obj, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click)
    {
        UiEventHandler eventHandler = Util.GetOrAddComponent <UiEventHandler>(obj);

        switch (type)
        {
        case Define.UiEvent.Click:
            if (action != null)
            {
                eventHandler.OnClickHandler -= action;
                eventHandler.OnClickHandler += action;
            }

            break;

        case Define.UiEvent.Drag:
            if (action != null)
            {
                eventHandler.OnDragHandler -= action;
                eventHandler.OnDragHandler += action;
            }

            break;
        }
    }
Ejemplo n.º 3
0
    public static GameObject BindEvent(GameObject go, Action <PointerEventData> action, Define.UiEvent type = Define.UiEvent.Click)
    {
        UiEventHandler evt = go.GetOrAddComponent <UiEventHandler>();

        switch (type)
        {
        case Define.UiEvent.Click:
            evt.OnClickHandler -= action;
            evt.OnClickHandler += action;
            break;

        case Define.UiEvent.Drag:
            evt.OnDragHandler -= action;
            evt.OnDragHandler += action;
            break;

        default:
            break;
        }

        return(go);
    }
Ejemplo n.º 4
0
        public GetDateDialog()
            : base(string.Empty, string.Empty, MessageBoxButtons.OkCancel, MessageBoxIcons.Information, DesktopManager.ScreenWidth / 2, 170)
        {
            int availableWidth = _mWidth - margin * 4;

            const int dayRatio   = 2;
            const int monthRatio = 3;
            const int yearRatio  = 2;
            const int totalRatio = dayRatio + monthRatio + yearRatio;

            int dayWidth   = availableWidth * dayRatio / totalRatio;
            int monthWidth = availableWidth * monthRatio / totalRatio;
            int yearWidth  = availableWidth * yearRatio / totalRatio;

            AddChild(new Label("Day", margin, 55 + 15 - Fonts.ArialBold.Height / 2, dayWidth, 25)
            {
                CenterText = true, Font = Fonts.ArialBold
            });
            AddChild(new Label("Month", margin * 2 + dayWidth, 55 + 15 - Fonts.Arial.Height / 2, monthWidth, 25)
            {
                CenterText = true, Font = Fonts.ArialBold
            });
            AddChild(new Label("Year", margin * 3 + dayWidth + monthWidth, 55 + 15 - Fonts.Arial.Height / 2, yearWidth, 25)
            {
                CenterText = true, Font = Fonts.ArialBold
            });

            AddChild(cmbDay   = new ComboBox(margin, 85, dayWidth, 30));
            AddChild(cmbMonth = new ComboBox(margin * 2 + dayWidth, 85, monthWidth, 30));
            AddChild(cmbYear  = new ComboBox(margin * 3 + dayWidth + monthWidth, 85, yearWidth, 30));

            for (int i = 2009; i <= 2030; i++)
            {
                cmbYear.AddItem(i);
            }
            for (int i = 1; i <= 12; i++)
            {
                cmbMonth.AddItem(_monthNames[i]);
            }

            UiEventHandler remakeDaysEvent = (s) =>
            {
                int prevSelected = cmbDay.SelectedIndex;
                cmbDay.ClearItems();
                for (int i = 1; i <= DateTime.DaysInMonth((int)cmbYear.SelectedItem, (int)cmbMonth.SelectedIndex + 1); i++)
                {
                    cmbDay.AddItem(i);
                }
                if (prevSelected != -1 && prevSelected < cmbDay.ItemsCount)
                {
                    cmbDay.SelectedIndex = prevSelected;
                }
                else
                {
                    cmbDay.SelectedIndex = cmbDay.ItemsCount - 1;
                }
            };

            cmbMonth.OnSelectedItemChanged += remakeDaysEvent;
            cmbYear.OnSelectedItemChanged  += remakeDaysEvent;
        }
 public void SetupOptionButton(EventOption eventOption)
 {
     Description.text = eventOption.OptionDescription;
     Button.onClick.AddListener(() => UiEventHandler.FireOptionSelectedEvent(eventOption));
 }