Example #1
0
    void Start()
    {
        UIScrollList scrollList = FindControlByName <UIScrollList> ("Scroll View");

        scrollList.SetLayout(UIScrollList.UILayoutDirection.HORIZONTAL_LEFT);
        scrollList.ItemSize    = new Vector2(120, 120);
        scrollList.ContentSize = new Vector2(180, 180);
        scrollList.SetPadding(new RectOffset(20, 20, 0, 0));
        scrollList.SetSpacing(30);

        foreach (KeyValuePair <string, string> item in _Images)
        {
            scrollList.AddItem(CreateButton(item.Key, item.Key, (UIControl ui) => {
                UIButton btn = (UIButton)ui;
                if (_LastTouchUI != null)
                {
                    _LastTouchUI.Label.Color      = Color.white;
                    _LastTouchUI.Background.Alpha = 1;
                }

                btn.Label.Color      = Color.red;
                btn.Background.Alpha = 0.5f;
                SetImageUrl(item.Value);
                _LastTouchUI = btn;
            }));
        }

        _Image = FindControlByName <UIImage> ("Image");

        KeyboardListener.Instance.AddDispatch(this.gameObject, KeyCode.Delete, (TouchPhase phase) => {
            if (phase != TouchPhase.Began)
            {
                return;
            }
            if (_LastTouchUI != null)
            {
                _LastTouchUI.Label.Color      = Color.white;
                _LastTouchUI.Background.Alpha = 1;
            }


            SetImageUrl("");

            _LastTouchUI = null;
        });

        SetImageUrl("");

        UIDropdown dropDown = FindControlByName <UIDropdown> ("Dropdown");

        dropDown.RemoveAllOptions();
        dropDown.AddOption("地块层");
        dropDown.AddOption("建筑层");
        dropDown.AddOption("角色层");

        dropDown.OnValueChanged.AddListener((int arg0) => {
            SetEnableLayer(arg0);
        });
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        UIDropdown dropDown = FindControlByName <UIDropdown> ("DTeam");

        dropDown.RemoveAllOptions();
        dropDown.AddOption("红队");
        dropDown.AddOption("绿队");
        dropDown.OnValueChanged.AddListener((int arg0) => {
            SetTeamID(arg0);
        });

        dropDown.EnableOption(0);

        dropDown = FindControlByName <UIDropdown> ("DUnit");
        dropDown.RemoveAllOptions();
        dropDown.AddOption("战士");
        dropDown.AddOption("骑兵");
        dropDown.AddOption("射手");
        dropDown.AddOption("投石车");
        dropDown.OnValueChanged.AddListener((int arg0) => {
            SetUnitID(arg0);
        });

        dropDown.EnableOption(0);

        dropDown = FindControlByName <UIDropdown> ("DFormation");
        dropDown.RemoveAllOptions();
        for (int i = 0; i < _Formations.Count; i++)
        {
            dropDown.AddOption(_Formations [i].Key);
        }
        dropDown.OnValueChanged.AddListener((int arg0) => {
            SetFormationID(arg0);
        });

        dropDown.EnableOption(0);

        UIButton button = FindControlByName <UIButton> ("Button");

        button.OnClick.AddListener(() => {
            RemoveAllChildren(Field);
            _Team = CreateTeam();
        });

        TouchListener.Instance.AddDispatch(Field.gameObject, OnTouchHandler);
    }
    void Start()
    {
        Resolution res;

        // Add resolutions list (higher ones on top)
        for (int i = 0; i < Screen.resolutions.Length; i++)
        {
            res = Screen.resolutions[Screen.resolutions.Length - i - 1];

            dropdownResolution.AddOption(res.width + " x " + res.height, res.width + "x" + res.height);
        }

        dropdownResolution.SetValues(Screen.width + " x " + Screen.height, Screen.width + "x" + Screen.height);

        // Populate Graphics Quality Dropdown (higher quality on top)
        int qualityLevelIndex = 0;

        for (int i = 0; i < QualitySettings.names.Length; i++)
        {
            qualityLevelIndex = QualitySettings.names.Length - i - 1;
            string quality = QualitySettings.names[qualityLevelIndex];

            dropdownGraphicsQualitySettings.AddOption(quality, qualityLevelIndex.ToString());
        }

        int    indexQualityLevel = QualitySettings.GetQualityLevel();
        string qualityName       = QualitySettings.names[indexQualityLevel];

        dropdownGraphicsQualitySettings.SetValues(qualityName, indexQualityLevel.ToString());

        // Tell the Fullscreen toggle if we are in fullscreen mode
        toggleFullscreen.isOn = Screen.fullScreen;

        // Bloom effect
        string bloomEffect = "high";

        if (PlayerPrefs.HasKey("bloomEffect"))
        {
            bloomEffect = PlayerPrefs.GetString("bloomEffect");
        }

        dropdownBloomEffect.SetValues(LangManager.Instance.GetString(bloomEffect), bloomEffect);

        // SSAO effect
        bool useSSAO = true;

        if (PlayerPrefs.HasKey("SSAOEffect"))
        {
            useSSAO = PlayerPrefs.GetInt("SSAOEffect") > 0;
        }

        toggleSSAO.isOn = useSSAO;

        // Reflections
        string reflectionsQuality = "high";

        if (PlayerPrefs.HasKey("reflectionsQuality"))
        {
            reflectionsQuality = PlayerPrefs.GetString("reflectionsQuality");
        }

        dropdownReflections.SetValues(LangManager.Instance.GetString(reflectionsQuality), reflectionsQuality);
    }