public static void Init()
        {
            _UpdatePath   = IsolatedPrefs.GetUpdatePath();
            _IsolatedPath = IsolatedPrefs.GetIsolatedPath();
#if UNITY_ENGINE || UNITY_5_3_OR_NEWER
            _cached_Application_platform            = Application.platform.ToString();
            _cached_Application_streamingAssetsPath = Application.streamingAssetsPath;
            _cached_Application_temporaryCachePath  = Application.temporaryCachePath;
            _cached_Application_persistentDataPath  = Application.persistentDataPath;
            _cached_Application_dataPath            = Application.dataPath;
            _cached_Capid  = IsolatedPrefs.IsolatedID;
            _UnityThreadID = ThreadLocalObj.GetThreadId();
#else
#if NETCOREAPP
            _cached_Application_platform = "DotNetCore";
#else
            _cached_Application_platform = "DotNet";
#endif
            _cached_Application_streamingAssetsPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "streaming");
            _cached_Application_temporaryCachePath  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cache");
            _cached_Application_persistentDataPath  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "runtime");
            _cached_Application_dataPath            = AppDomain.CurrentDomain.BaseDirectory;
            _cached_Capid  = IsolatedPrefs.IsolatedID;
            _UnityThreadID = (ulong)System.Threading.Thread.CurrentThread.ManagedThreadId;
#endif
            _IsMainThread = true;
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR && (DEVELOPMENT_BUILD || DEBUG)
            SetWindowTitle(System.Diagnostics.Process.GetCurrentProcess().Id.ToString() + "-" + _cached_Capid);
#endif
        }
Пример #2
0
        private static void AddEvent(Action act)
        {
            ActionQueue.Enqueue(act);
            if (ThreadLocalObj.GetThreadId() == ThreadSafeValues.UnityThreadID)
            {
                HandleEvents();
                return;
            }
#if !UNITY_EDITOR
#if MOD_NATIVEUNITYTHREADDISPATCHER
            if (_Inited && !_UsingObjRunner)
            {
                NativeUnityThreadDispatcherWrapper.TrigEventInUnityThread();
            }
#endif
#endif
        }
Пример #3
0
 public static void RunInUnityThreadAndWait(Action act)
 {
     if (act != null)
     {
         if (ThreadLocalObj.GetThreadId() == ThreadSafeValues.UnityThreadID)
         {
             act();
         }
         else
         {
             System.Threading.ManualResetEvent waithandle = new System.Threading.ManualResetEvent(false);
             AddEvent(() =>
             {
                 act();
                 waithandle.Set();
             });
             waithandle.WaitOne();
             waithandle.Close();
         }
     }
 }
Пример #4
0
 public static T RunInUnityThreadAndWait <T>(Func <T> func)
 {
     if (func != null)
     {
         if (ThreadLocalObj.GetThreadId() == ThreadSafeValues.UnityThreadID)
         {
             return(func());
         }
         else
         {
             T rv = default(T);
             System.Threading.ManualResetEvent waithandle = new System.Threading.ManualResetEvent(false);
             AddEvent(() =>
             {
                 rv = func();
                 waithandle.Set();
             });
             waithandle.WaitOne();
             waithandle.Close();
             return(rv);
         }
     }
     return(default(T));
 }