public static void RunOnMainThread <T>(System.Action <T> action, T arg, ETaskType type = ETaskType.task, int id = 0) { if (sInitilized && action != null) { lock (sInstance.mLock) { TaskWithArg <T> task = sInstance.GetTaskWithArg <T>(id); task.Task = action; task.mArg = arg; if (type == ETaskType.task) { sInstance.mTasks.Enqueue(task); } else if (type == ETaskType.lateTask) { sInstance.mLateTasks.Enqueue(task); } } } #if UNITY_EDITOR else if (!sInitilized && Application.isPlaying) { RTLog.LogError(LogCat.Game, "MainThread not initialized."); } #endif }
public static void RunOnMainThread<T>(System.Action<T> action, T arg) { if (sInitilized && action != null) { lock (sInstance.mLock) { TaskWithArg<T> task = sInstance.GetTaskWithArg<T>(); task.mTask = action; task.mArg = arg; sTasks.Enqueue(task); } } }