public void Initialize()
        {
            var initTimer = System.Diagnostics.Stopwatch.StartNew();

            DllManipulator.Initialize(Options, Thread.CurrentThread.ManagedThreadId, Application.dataPath);

            initTimer.Stop();
            InitializationTime = initTimer.Elapsed;
        }
        /// <summary>
        /// Will reset the DllManipulator and Initialize it again.
        /// Note: Unloads all Dlls, may be a dangerous operation if using preloaded
        /// </summary>
        public void Reinitialize()
        {
            DllManipulator.Reset();

#if UNITY_EDITOR
            if (EditorApplication.isPlaying || Options.enableInEditMode)
#endif
            Initialize();
        }
        private void Reset()
        {
            //Note on threading: Because we don't wait for other threads to finish, we might be stealing function delegates from under their nose if Unity doesn't happen to close them yet.
            //On Preloaded mode this leads to NullReferenceException, but on Lazy mode the DLL and function would be just reloaded so we would up with loaded DLL after game exit.
            //Thankfully thread safety with Lazy mode is not implemented yet.

            if (DllManipulator.Options != null) // Check that we have initialized
            {
                DllManipulator.Reset();
            }
            _singletonInstance = null;
        }
示例#4
0
        private void OnDestroy()
        {
            if (_singletonInstance == this)
            {
                //Note on threading: Because we don't wait for other threads to finish, we might be stealing function delegates from under their nose if Unity doesn't happen to close them yet.
                //On Preloaded mode this leads to NullReferenceException, but on Lazy mode the DLL and function would be just reloaded so we would up with loaded DLL after game exit.
                //Thankfully thread safety with Lazy mode is not implemented yet.

                DllManipulator.UnloadAll();
                DllManipulator.ForgetAllDlls();
                DllManipulator.ClearCrashLogs();
                _singletonInstance = null;
            }
        }