Klak.Wiring.Patcher.PatchManager.GetIndexOf C# (CSharp) Méthode

GetIndexOf() public méthode

public GetIndexOf ( Patch patch ) : int
patch Patch
Résultat int
        public int GetIndexOf(Patch patch)
        {
            return Array.FindIndex(
                _instances, i => patch.IsRepresentationOf(i)
            );
        }

Usage Example

Exemple #1
0
        void OnGUI()
        {
            // Disable GUI during the play mode, or when no patch is available.
            if (isPlayMode || _patch == null)
            {
                DrawNoPatchMessage();
                return;
            }

            // Tool bar
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            // - Create node menu
            _nodeFactory.CreateNodeMenuGUI(_patch);
            GUILayout.Space(100);

            // - Patch selector
            var patchIndex    = _patchManager.GetIndexOf(_patch);
            var newPatchIndex = EditorGUILayout.Popup(
                patchIndex, _patchManager.MakeNameList(),
                EditorStyles.toolbarDropDown
                );

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            // View area
            EditorGUILayout.BeginHorizontal();

            // - Main view
            DrawMainViewGUI();

            // - Side view (property editor)
            DrawSideBarGUI();

            EditorGUILayout.EndHorizontal();

            // Re-initialize the editor if the patch selection was changed.
            if (patchIndex != newPatchIndex)
            {
                _patch = _patchManager.RetrieveAt(newPatchIndex);
                _patchManager.Select(_patch);
                Repaint();
            }

            // Cancel wiring with a mouse click or hitting the esc key.
            if (_wiring != null)
            {
                var e = Event.current;
                if (e.type == EventType.MouseUp ||
                    (e.type == EventType.KeyDown && e.keyCode == KeyCode.Escape))
                {
                    _wiring = null;
                    e.Use();
                }
            }
        }
All Usage Examples Of Klak.Wiring.Patcher.PatchManager::GetIndexOf