コード例 #1
0
    private void OnPresetSelect(object value, int[] route)
    {
        var floatValue = (float)value * (Engine.unitType == Units.Type.Metric ? Units.k_MToCm : Units.k_MToIn);

        // Setting value here will trigger a change event
        inputView.GetComponentInChildren <SettingNumeric>(true).value = floatValue;

        // Close & Destroy the Preset Modal
        m_presetModal.Close(true);
        Destroy(m_presetModal.gameObject);
        m_presetModal = null;
    }
コード例 #2
0
    private void OpenPresetModal(KeyFloatSet[] presets)
    {
        if (m_presetModal != null)
        {
            Destroy(m_presetModal.gameObject);
        }
        // Instantiate Modal from prefab
        var modal = (SelectionModal)Instantiate(selectionModalPrefab, transform, false);

        // OPT: All this casting, pretty inefficient...
        // Convert to KeyValueSet
        var selections = Array.ConvertAll(presets, (p) => {
            return((KeyValueSet <object>)p);
        });

        // Set Preset Selections
        modal.SetSelections(selections);
        modal.onSelect += OnPresetSelect;
        modal.transform.SetAsLastSibling();
        modal.gameObject.SetActive(true);

        m_presetModal = modal;
    }