Exemplo n.º 1
0
        // Start is called before the first frame update
        void Start()
        {
            //メインカメラを取得
            UnityEngine.Camera mainCamera = UnityEngine.Camera.main;

            //メインカメラのTransformのクローンを生成して子オブジェクトにまとめる
            Transform mainCameraTransform = new GameObject("MainCamera").transform;

            mainCameraTransform.parent     = this.transform;
            mainCameraTransform.position   = mainCamera.transform.position;
            mainCameraTransform.rotation   = mainCamera.transform.rotation;
            mainCameraTransform.localScale = mainCamera.transform.localScale;

            //子オブジェクトのTransform(CameraSwitch対象のTransform)を列挙
            IReadOnlyList <Transform> cameraPoss = this.transform.Cast <Transform>().ToList();

            //DropDownの項目に追加
            m_cameraCombobox.options = cameraPoss.Select(tr => new Dropdown.OptionData(tr.name)).ToList();

            //DropDownのOnChangedイベントを設定
            var ddEvent = new Dropdown.DropdownEvent();

            //DropDownが変更されたら、そのTransformにカメラを移動させる
            ddEvent.AddListener(index => mainCamera.transform.DOMove(cameraPoss[index].position, 0.5f)
                                .SetEase(Ease.OutCirc));
            m_cameraCombobox.onValueChanged = ddEvent;
        }
Exemplo n.º 2
0
    void Awake()
    {
#if UNITY_EDITOR
#endif
        m_OnValueChanged = GetComponentInChildren <Dropdown>().onValueChanged;
        m_OnValueChanged.AddListener((val) => {
            m_VisualsDirty = true;
        });
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        m_Dropdown = GetComponentInChildren <Dropdown>();

        // Event
        var e = new Dropdown.DropdownEvent();

        e.AddListener(DropdownCallback);
        m_Dropdown.onValueChanged = e;

        // Set Placeholder
        switch (Setting)
        {
        case Settings.SpriteSources:
            SetPlaceholder(scr_InputManager.SpriteSource.ToString());
            break;

        default:
            break;
        }
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        m_Dropdown = GetComponent <Dropdown>();

        // Set Dropdown values to Race names
        var raceNames = new List <string>();
        int optionNr  = 0;

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i)
        {
            string path     = SceneUtility.GetScenePathByBuildIndex(i);
            string fullName = path.Substring(path.LastIndexOf('/') + 1);
            if (!fullName.Contains("Race_"))
            {
                continue;
            }
            string name = fullName.Substring(5, fullName.LastIndexOf('.') - 5);

            raceNames.Add(name);
            m_RaceBuildIndices.Add(optionNr, i);
            m_RaceNames.Add(optionNr, name);
            ++optionNr;
        }

        m_Dropdown.ClearOptions();
        m_Dropdown.AddOptions(raceNames);

        // Add Dropdown select event
        var dropdownEvent = new Dropdown.DropdownEvent();

        dropdownEvent.AddListener(DropdownCallback);
        m_Dropdown.onValueChanged = dropdownEvent;

        // Load Race Info
        LoadRaceInfo();

        // Show Race
        ShowRace();
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        //initialization for dropdown menu
        var de = new Dropdown.DropdownEvent();

        de.AddListener(selectSong);
        dropdownSongList.onValueChanged = de;
        dropdownSongList.ClearOptions();

        //Adds the names of the songs to the dropdown menu
        List <string> clipsString = new List <string>();

        foreach (AudioClip clip in clips)
        {
            clipsString.Add(clip.name);
        }
        dropdownSongList.AddOptions(clipsString);
        audioSource = GetComponent <AudioSource>();
        selectSong(0);

        endGameScreen.SetActive(false);
    }
Exemplo n.º 6
0
 public static void Add(this Dropdown.DropdownEvent dropdownEvent, Action action)
 {
     dropdownEvent.AddListener((index) => { action(); });
 }