Exemplo n.º 1
0
    public void AfterRecompileScripts()
    {
        // check if recompile variable is null
        if (this.recompile == null)
        {
            // if yes assume recompile then create a reference to a recompile class
            this.recompile = new RecompileClass();

            // do what you need to do here after detecting a recompile
            Load();
        }

        // do regular stuff here
    }
Exemplo n.º 2
0
        void OnGUI()
        {
            if (this._recompile == null)
            {
                // if yes assume recompile then create a reference to a recompile class
                this._recompile = new RecompileClass();
                //little hack for the editor,otherwise on start we have no OSC Connections in the Editor GUI. ([InitializeOnLoad] didn't work)
                //Init();
                _GetOSCConnectionInstances();
            }


            EditorGUI.BeginChangeCheck();

            _editorWidth = position.width;
            if (_config.isOSCTracing)
            {
                _editorWidth = _editorWidth - TRACEWIDTH;
            }

            if (_config.mySkin != null)
            {
                GUI.skin = _config.mySkin;
            }

            //Rect for Learning Border
            Rect r_learn = new Rect(0f, 0f, position.width, position.height);

            EditorGUILayout.BeginHorizontal();

            #region GUI_LEFT
            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));

            if (_config == null)
            {
                Rect area = GUILayoutUtility.GetRect(500.0f, 80.0f);
                EditorGUI.HelpBox(area, "No configuration could be loaded! The Editor could not work in this state.", MessageType.Error);
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
                return;
            }

            GUILayout.Space(4);

            #region header
            #region logo
            GUILayout.BeginHorizontal();
            GUILayout.Space(4);
            UniOSCUtils.DrawTexture(_config.tex_logo);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            #endregion logo


            GUILayout.BeginHorizontal();

            GUI.backgroundColor  = _config.isOSCTracing ? Color.green : Color.white;
            _config.isOSCTracing = GUILayout.Toggle(_config.isOSCTracing, new GUIContent("Trace OSC"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f));          //OSCConnectionEditor.tex2
            GUI.backgroundColor  = Color.white;


            if (GUILayout.Button(new GUIContent("Create OSC Connection", ""), GUILayout.Width(160f), GUILayout.Height(30f)))
            {
                _CreateOSCConnection(); Init();
            }
            ;
            if (GUILayout.Button("Create OSC Mapping File", GUILayout.Height(30f), GUILayout.Width(160f)))
            {
                _CreateOSCMappingFile();
            }
            if (GUILayout.Button("Create OSC Session File", GUILayout.Height(30f), GUILayout.Width(160f)))
            {
                _CreateOSCSessionFile();
            }


            GUI.backgroundColor   = _config.isOSCLearning ? Color.green : Color.white;
            _config.isOSCLearning = GUILayout.Toggle(_config.isOSCLearning, new GUIContent("Learn OSC"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f));          //OSCConnectionEditor.tex2
            GUI.backgroundColor   = Color.white;

            if (_isOSCLearning != _config.isOSCLearning)
            {
                //Toggle was clicked
                _isOSCLearning = _config.isOSCLearning;

                OSCLearning(_config.isOSCLearning);
                //EditorUtility.SetDirty(_config);
            }

            //_config.isEditorEnabled = UniOSCConnection.isEditorEnabled;
            GUI.backgroundColor              = _config.isEditorEnabled ? Color.green : Color.white;
            _config.isEditorEnabled          = GUILayout.Toggle(_config.isEditorEnabled, new GUIContent("Editor Mode"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f));
            GUI.backgroundColor              = Color.white;
            UniOSCConnection.isEditorEnabled = _config.isEditorEnabled;

            GUILayout.EndHorizontal();
            #endregion header


            GUILayout.Space(5);
            _DrawLineH(_editorWidth - 20f);
            GUILayout.Space(5);


            #region Connection
            GUILayout.BeginHorizontal();
            GUIStyle gsCon = new GUIStyle(GUI.skin.label);
            gsCon.fontSize = 18;
            GUILayout.Label("OSC Connection", gsCon);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(3);
            OnGUI_OSCConnection();
            #endregion Connection

            #region space

            GUI.contentColor    = Color.white;
            GUI.backgroundColor = Color.white;

            GUILayout.Space(5);
            _DrawLineH(_editorWidth - 20f);
            GUILayout.Space(5);
            #endregion space

            #region toolbar
            _config.toolbarInt = GUILayout.Toolbar(_config.toolbarInt, toolbarStrings, GUILayout.Width(200 * toolbarStrings.Count()), GUILayout.Height(30f));
            #endregion toolbar

            GUILayout.Space(5);
//			_DrawLineH(_editorWidth-20f);
            GUILayout.Space(5);

            #region Mapping

            switch (_config.toolbarInt)
            {
            case 0:
                OnGUI_OSCMapping();
                break;

            case 1:
                OnGUI_OSCSessionFiles();
                break;

            default:
                OnGUI_DefaultContent();
                break;
            }

            #endregion Mapping

            #region footer
            GUI.contentColor = Color.white;

            if (_osConnectionIDList.Count > 0)
            {
                _DrawLineH(_editorWidth - 20f);
                GUILayout.Space(10f);
            }

            if (GUILayout.Button(new GUIContent("Refresh Editor", "Refresh the Editor. Reloads the available data"), GUILayout.Width(150), GUILayout.Height(30f)))
            {
                Init();
            }
            ;
            GUILayout.Space(5f);
            #endregion footer

            EditorGUILayout.EndVertical();
            #endregion GUI_LEFT


            #region GUI_RIGHT
            if (_config.isOSCTracing)
            {
                Rect r_tracing = GUILayoutUtility.GetRect(1.0f, position.height - 0f);
                GUI.Box(r_tracing, "", GUI.skin.box);              //,GUI.skin.box  GUI.skin.customStyles[1]
                OnGUI_Trace();
            }
            #endregion GUI_RIGHT
            EditorGUILayout.EndHorizontal();

            //draw Learning Border
            if (_config.isOSCLearning)
            {
                GUI.backgroundColor = Color.red;
                GUI.Box(r_learn, "", _config.learnStyle);
                GUI.backgroundColor = Color.white;
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(_config);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called by unity to draw the graphical user interface.
        /// </summary>
        public void OnGUI()
        {
            switch (Event.current.type)
            {
                case EventType.Ignore:
                    return;
            }

            // check if recompile occurred
            if (this.recompiled == null && !string.IsNullOrEmpty(this.fileName) && File.Exists(this.fileName))
            {
                this.LoadData(false);
                this.recompiled = new RecompileClass();
            }

            GUILayout.BeginVertical(); // main wrapper

            // draw the header buttons
            this.DrawHeaderButtons();

            // put some spacing between controls
            GUILayout.Space(8);

            GUILayout.BeginHorizontal(); // rule list and rule info

            // draw the rule list
            this.DrawRulesList();

            // put some spacing between controls
            GUILayout.Space(4);

            // draw information for the rule
            this.DrawRuleInfo();

            GUILayout.EndHorizontal(); // rule list and rule info

            GUILayout.EndVertical(); // main wrapper
        }