Ejemplo n.º 1
0
        private void ScanForMidiTweak()
        {
            if (Application.isPlaying)
            {
                if (MidiTweak.Instance != null)
                {
                    midiTweak = MidiTweak.Instance;
                    return;
                }
            }

            MidiTweak[] midiTweakContainers = GameObject.FindObjectsOfType <MidiTweak>();
            if (midiTweakContainers.Length > 1)
            {
                Debug.Log("More than one midi tweak instance was found within the scene. Duplicate instances have been removed.");
                midiTweak = midiTweakContainers[0];

                for (int i = 0; i < midiTweakContainers.Length; i++)
                {
                    if (i != 0)
                    {
                        GameObject.DestroyImmediate(midiTweakContainers[i].gameObject);
                    }
                }
            }
            else
            {
                if (midiTweakContainers.Length > 0)
                {
                    midiTweak = midiTweakContainers[0];
                }
            }
        }
Ejemplo n.º 2
0
        public void Init(MidiTweak _midiTweak)
        {
            midiTweak = _midiTweak;

            EditorUtility.SetDirty(this);
            EditorUtility.SetDirty(midiTweak);
            Repaint();
        }
Ejemplo n.º 3
0
        void OnPlayModeChanged()
#endif
        {
            if (midiTweakInstanceID != 0)
            {
                midiTweak = EditorUtility.InstanceIDToObject(midiTweakInstanceID) as MidiTweak;

                if (midiTweak == null)
                {
                    ScanForMidiTweak();
                }
            }

            Repaint();
        }
Ejemplo n.º 4
0
        private void Awake()
        {
            if (Instance == null)
            {
                Instance = this;
            }
            else
            {
                GameObject.Destroy(this.gameObject);
            }

            bool loadedNewScene = false;

            // Retrieve previous settings and values if scene has been reloaded
            if (configSettings.KeepChangesAfterSceneLoad && Time.time != 0)
            {
                settings = configPlayMode.settings;
                ApplyTweakedValues();
                loadedNewScene = true;
            }
            else
            {
                settings = new RuntimeSettings();
                configPlayMode.data.Clear();
            }

            if (configSettings.instantiateInGameTweakMenuOnPlay)
            {
                IntantiateTweakingUserInterface();
            }

            parameterBookMarks = CreateParameterBookmarks();

            interfaceManager.NotifyParameterLoad(parameterBookMarks.ToArray());

            interfaceManager.NotifyKeyAssignment(configKeyBindings.Bindings);

            if (loadedNewScene)
            {
                ResendInterfaceNotifications();
            }
            else
            {
                SetActiveParameter(0);
            }
        }
Ejemplo n.º 5
0
 private void Start()
 {
     midiTweak = GetComponent <MidiTweak>();
     AttachBindingsToFunction();
 }
Ejemplo n.º 6
0
 void OnEnable()
 {
     midiTweak = (MidiTweak)target;
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public abstract void Start(MidiTweak _midiTweak);
Ejemplo n.º 9
0
 private void Start()
 {
     midiTweak = GetComponent <MidiTweak>();
     bookMarks = midiTweak.ParameterBookMarks;
 }