Ejemplo n.º 1
0
    void Update()
    {
        // HACK: Assuming that the dropdown would have more than three child
        // objects while the menu is opened. Stop updating it while visible.
        if (_dropdown.transform.childCount > 3)
        {
            return;
        }

        // Retrieve the Spout source names.
        SpoutManager.GetSourceNames(_sourceNames);

        // Update the current selection.
        var index = _sourceNames.IndexOf(_receiver.sourceName);

        if (index < 0)
        {
            // Append the current name to the list when it's not found.
            index = _sourceNames.Count;
            _sourceNames.Add(_receiver.sourceName);
        }

        // We don't like to receive callback while editing options.
        _disableCallback = true;

        // Update the menu options.
        _dropdown.ClearOptions();
        _dropdown.AddOptions(_sourceNames);
        _dropdown.value = index;
        _dropdown.RefreshShownValue();

        // Resume receiving callback.
        _disableCallback = false;
    }
Ejemplo n.º 2
0
    void Update()
    {
        // Do nothing if the menu is opened.
        if (IsOpened)
        {
            return;
        }

        // Spout source name retrieval
        _sourceNames = SpoutManager.GetSourceNames().ToList();

        // Currect selection
        var index = _sourceNames.IndexOf(_receiver.sourceName);

        // Append the current name to the list if it's not found.
        if (index < 0)
        {
            index = _sourceNames.Count;
            _sourceNames.Add(_receiver.sourceName);
        }

        // Disable the callback while updating the menu options.
        _disableCallback = true;

        // Menu option update
        _dropdown.ClearOptions();
        _dropdown.AddOptions(_sourceNames);
        _dropdown.value = index;
        _dropdown.RefreshShownValue();

        // Resume the callback.
        _disableCallback = false;
    }
Ejemplo n.º 3
0
        // Create and show the source name dropdown.
        void ShowSourceNameDropdown(Rect rect)
        {
            var menu    = new GenericMenu();
            var sources = SpoutManager.GetSourceNames();

            if (sources.Length > 0)
            {
                foreach (var name in sources)
                {
                    menu.AddItem(new GUIContent(name), false, OnSelectSource, name);
                }
            }
            else
            {
                menu.AddItem(new GUIContent("No source available"), false, null);
            }

            menu.DropDown(rect);
        }