public void OnGUI() { if (midiTweak == null) { if (!Application.isPlaying) { if (GUILayout.Button("Create new Midi Tweak controller", GUILayout.MinHeight(50))) { midiTweak = new GameObject("Midi Tweak Controller", typeof(MidiTweak)).GetComponent <MidiTweak>(); midiTweak.UpdateReferences(); ProcessorKeyBinding processorKeyBinding = midiTweak.gameObject.AddComponent <ProcessorKeyBinding>(); processorKeyBinding.hideFlags = HideFlags.HideInInspector; ProcessorMidiInput processorMidiInput = midiTweak.gameObject.AddComponent <ProcessorMidiInput>(); processorMidiInput.hideFlags = HideFlags.HideInInspector; midiTweakInstanceID = midiTweak.GetInstanceID(); EditorSceneManager.MarkSceneDirty(midiTweak.gameObject.scene); } } if (GUILayout.Button("Scan scene for Midi Tweak controller", GUILayout.MinHeight(50))) { midiTweak = GameObject.FindObjectOfType <MidiTweak>(); } activeTab = null; return; } else { midiTweakInstanceID = midiTweak.GetInstanceID(); } scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandHeight(true)); // Do not allow any changes to the UI when midi tweak is in editor update mode. if (midiTweak.EditorInputProcessor.InEditorUpdateMode) { GUI.enabled = false; } if (!Application.isPlaying) { currentTab = GUILayout.Toolbar(currentTab, new string[3] { "Add Parameter", "Stored Parameters", "Options" }); if (activeTab == null) { tabs[currentTab].OpenTab(midiTweak); activeTab = tabs[currentTab]; } else { if (activeTab != tabs[currentTab]) { activeTab.OnTabClosed(); tabs[currentTab].OpenTab(midiTweak); activeTab = tabs[currentTab]; } } activeTab.DisplayTab(); } else { if (activeTab != tweakDisplayerTab) { activeTab = tweakDisplayerTab; activeTab.OpenTab(midiTweak); } tweakDisplayerTab.DisplayTab(); // TODO: Only do a repaint when something changes. Repaint(); } if (midiTweak.EditorInputProcessor.InEditorUpdateMode) { DisplayUpdateModeInfo(); } if (midiTweak.ConfigSettings.DebugDisplayMidiInputs && currentTab == 2) { Repaint(); } GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.Label("Developed by Lowscope - Contact: [email protected] - Version 1.0", EditorStyles.miniLabel); }
void OnSceneChange(Scene _s1, Scene _s2) { ScanForMidiTweak(); activeTab = null; Repaint(); }