Example #1
0
    //-------------------------------------------------------------------------------------------------

    //Here we determine which method is going to automatically be invoked when compilation ends without errors
    void AddCompilationSucceededHandler()
    {
        CSScriptEngine engine = new CSScriptEngine();

        engine.AddOnCompilationSucceededHandler(OnCompilationSucceededAction);

        engine.CompileCode("string warningCauser = \"This will result in warning, but compillation succeeds\";");

        engine.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
    }
        void OnDisable()
        {
            //OnDisable later then EventManager's OnApplicationQuit where It's Instance property gets nullified
            //That causes null reference exception, so let's add this check to prevent that
            if (EventManager.Instance != null)
            {
                _engine.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
                _engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
                _engineRemote.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
                _engineRemote.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);

                EventManager.Instance.RemoveListener <CompilationEvent>(OnCompileButton);
                EventManager.Instance.RemoveListener <ExecutionEvent>(OnExecuteButton);
                EventManager.Instance.RemoveListener <CompileTypeEvent>(OnCompileAndAddTypeButton);
                EventManager.Instance.RemoveListener <DeleteTypeEvent>(OnDeleteTypeButton);
            }
            if (Remote)
            {
                if (_engineRemote.RemoteDomain != null)
                {
                    _engineRemote.Dispose();
                }
            }
        }
 void OnDisable()
 {
     _engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
     _engine.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
 }