public static void Initialize() { bool flag = !Loom._initialized; if (flag && Loom._threadId != -1 && Loom._threadId != Thread.CurrentThread.ManagedThreadId) { return; } if (flag) { GameObject gameObject = new GameObject("Loom"); gameObject.hideFlags = HideFlags.DontSave; UnityEngine.Object.DontDestroyOnLoad(gameObject); if (Loom._current) { if (Application.isPlaying) { UnityEngine.Object.Destroy(Loom._current.gameObject); } else { UnityEngine.Object.DestroyImmediate(Loom._current.gameObject); } } Loom._current = gameObject.AddComponent<Loom>(); UnityEngine.Object.DontDestroyOnLoad(Loom._current); Loom._initialized = true; Loom._threadId = Thread.CurrentThread.ManagedThreadId; } }
void OnDisable() { if (_current == this) { _current = null; } }
void Awake() { if(_current != null && _current != this) { Destroy(gameObject); } else { _current = this; } }
static void Initialize() { if (!initialized) { if (!Application.isPlaying) return; initialized = true; var g = new GameObject ("Loom"); _current = g.AddComponent<Loom> (); } }
public static void Initialize() { var go = !_initialized; if(go && _threadId != -1 && _threadId != Thread.CurrentThread.ManagedThreadId) return; if (go) { var g = new GameObject("Loom"); g.hideFlags = HideFlags.HideAndDontSave; GameObject.DontDestroyOnLoad(g); _current = g.AddComponent<Loom>(); Component.DontDestroyOnLoad(_current); _initialized = true; _threadId = Thread.CurrentThread.ManagedThreadId; } }
void onTouchPadPos(string info) { Loom.QueueOnMainThread(() => { Debug.Log("----onTouchPadPos:" + info); Instance.getKeyCode(info); if (Instance.isTouchDown) { //Debug.Log("----isTouchDown:" + Instance.isTouchDown); Instance._aHandles[0].Update(float.Parse(Instance.key_field[0])); Instance._aHandles[1].Update(float.Parse(Instance.key_field[1])); } //else //{ // Debug.Log("----isTouchUp:" + Instance.isTouchDown); // //Instance._aHandles[0].Update(0); // //Instance._aHandles[1].Update(0); //} }); }
private void Process(byte[] data, Protocal type) { byte command = data[0]; byte[] dst = BufferUtils.RemoveFront(BufferUtils.Remove.CMD, data); if (CommandExists(command)) { Loom.QueueOnMainThread(() => commands[command](new Data(type, command, dst))); /*if (Commands[command].Async) * Commands[command].Cmd(new Data(type, command, dst)); * else * { * TaskQueue.QueueMain(() => Commands[command].Cmd(new Data(type, command, dst))); * }*/ } //Traffic traffic = new Traffic((OpCodes)command, dst); //ProcessData(traffic, type); }
public void Decompress(byte[] data) { Loom.RunAsync(new LoomBase(), delegate(LoomBase param) { try { m_result = new byte[1]; /*int size = LzmaHelper.Uncompress(data, ref m_result); * if (size == 0) * { * Error = "Compress Failed"; * }*/ } catch (Exception e) { Error = e.Message; } finally { Loom.QueueOnMainThread(param, OnDone); } }); }
private void _OnExitDownload() { Argument = new HttpClientArgument { Url = Argument.Url, Timeout = Argument.Timeout, Param1 = Argument.Param1, ThreadDecompressor = null, PostData = null, }; IsDone = true; Progress = 1f; if (_handler != null) { Loom.QueueOnMainThread(() => { CallbackTools.Handle(ref _handler, this, "[HttpClient:_OnExitDownload()]"); }); } }
private void Send(byte[] data, Protocal type = Protocal.Tcp) { if ((data.Length + 2) >= 65536) { SafeDebug.LogError(string.Format("Send data length exceeds 65,536: {0} - {1}", data.Length + 2, BitConverter.ToString(data, 0, 4))); return; } if (Thread.CurrentThread == mainThread) { Loom.QueueAsyncTask("Net", () => { DoSend(data, type); }); } else { DoSend(data, type); } }
public void OnToggleServer(UILabel buttonText) { isServerStart = !isServerStart; if (isServerStart) { broadcaster = new UDPServer(2333, maxCount); broadcaster.Start(); client = new UDPClient(2333); broadcaster.DataReceived += Broadcaster_DataReceived; connectThread = Loom.StartSingleThread(BroadCastConnect, System.Threading.ThreadPriority.Normal, true); buttonText.text = "停止监听"; } else { buttonText.text = "开始监听"; CloseServer(); client.Dispose(); } }
void Send(byte[] bytes) { try { mSocket.Send(bytes, SocketFlags.None); sendList.RemoveAt(0); } catch (SocketException ex) { if (ex.NativeErrorCode.Equals(10035)) { Send(bytes); } else { Loom.QueueOnMainThread(() => { TipManager.Instance.OpenTip(TipType.SimpleTip, "请求失败!"); }); } } }
internal void Patrolling() { // Set an appropriate speed for the NavMeshAgent. Loom.QueueOnMainThread(() => { if (core == null) { return; } core.movementSpeed = core.patrolSpeed; // If near the next waypoint or there is no destination... if (nav.destination == lastPlayerSighting.resetPosition || nav.remainingDistance < nav.stoppingDistance) { // If the timer exceeds the wait time... if (patrolTimer + patrolWaitTime < Time.time) { ergos["patrol"].ReachedGoal(); // ... increment the wayPointIndex. if (core.wayPointIndex == patrolWayPoints.Length - 1) { core.wayPointIndex = 0; } else { core.wayPointIndex++; } // Reset the timer. //patrolTimer = 0; } } // Set the destination to the patrolWayPoint. core.navDestination = patrolWayPoints[core.wayPointIndex].position; if (!V3Equal(core.navDestination, nav.destination)) { patrolTimer = Time.time; } }); }
//mChen add. for HideSeek //大厅列表 bool onSocketListLobby(byte[] data, int size) { ////更新数据 tagGameLobby tempStruct = new tagGameLobby(); int itemSize = Marshal.SizeOf(tempStruct); if (size % itemSize != 0) { return(false); } byte[] pNetInfo = new byte[itemSize]; int iItemCount = size / itemSize; for (int i = 0; i < iItemCount; i++) { Buffer.BlockCopy(data, i * itemSize, pNetInfo, 0, itemSize); tagGameLobby sGameLobby = (tagGameLobby)StructConverterByteArray.BytesToStruct(pNetInfo, typeof(tagGameLobby)); CServerListData.shared().InsertGameLobby(sGameLobby); } //Create CGPLobbyMission Loom.QueueOnMainThread(() => { if (CServerListData.shared().GetGameLobbyCount() > 0) { tagGameLobby gameLobby = CServerListData.shared().getARandGameLobby(); if (gameLobby.wLobbyPort != 0) { CGPLobbyMission kGPLobbyMission = CGPLobbyMission.CreateInstance(gameLobby.szServerAddr, gameLobby.wLobbyPort); if (kGPLobbyMission != null && !kGPLobbyMission.isAlive()) { kGPLobbyMission.SendChatData("StartChatConnect!");//只是为了连接上 } } else { Debug.LogError("onSocketListLobby: incorrect wLobbyPort=0"); } } }); return(true); }
void onBluetoothAdapterStateChanged(string state) { Loom.QueueOnMainThread(() => { switch (state) { case "12": // BluetoothAdapter.STATE_ON //MojingLog.LogTrace("Bluetooth ON"); Debug.Log("----Bluetooth ON"); break; case "10": // BluetoothAdapter.STATE_OFF //MojingLog.LogTrace("Bluetooth OFF"); Debug.Log("----Bluetooth OFF"); break; } }); }
/// <summary> /// 将接收消息 /// 查找消息好友id /// </summary> /// <param name="pack"></param> public void ReceiveMessage(DataPackage pack) { if (pack.requestType == RequestType.chat) { // 用Loom的方法在Unity主线程中调用 Loom.QueueOnMainThread((param) => { if (UI_LobbyManager.myselfInfo.user_id.Equals(pack.userInfo.user_id)) { //判断聊天面板是否存在好友聊天面板 if (ui_ChatPanels.ContainsKey(pack.friendId)) { string msg = System.Text.Encoding.UTF8.GetString(pack.data); //创建消息 ui_ChatPanels[pack.friendId].CreateFriendMsgText(msg); //插入历史聊天记录 ChatHistoryManager.GetInstance().SaveChatHistory(UI_LobbyManager.lobbyManager.friendInfos[pack.friendId], 1, msg); } else { //判断通讯录里是否有好友 if (UI_LobbyManager.lobbyManager.friendInfos.ContainsKey(pack.friendId)) { //创建面板 UI_MessageControl.setFriend(UI_LobbyManager.lobbyManager.friendInfos[pack.friendId]); /* * 加入Dictionary,但是刷新不出来,第二次接收消息时才能刷新 */ ui_ChatPanels[pack.friendId].CreateFriendMsgText(System.Text.Encoding.UTF8.GetString(pack.data)); } } } else { Debug.LogError("不是自己好友的消息"); Debug.Log("聊天:" + LitJson.JsonMapper.ToJson(pack)); } }, null); } }
/// <summary> /// 异步加载一个区块 /// </summary> /// <param name="chunk"></param> /// <param name="chunkX"></param> /// <param name="chunkZ"></param> void ThreadLoadChunk(Action onLoadComplete) { foreach (var chunk in mLoadingChunks) { chunk.LoadChunk(); } Loom.QueueOnMainThread(() => { foreach (var chunk in mLoadingChunks) { chunk.OnChunkLoaded(); } Loom.RunAsync(() => { ThreadBuildMesh(onLoadComplete); }); }); }
/*IEnumerator xml(string lbs_name){ * * * }*/ /*void Judge(string id){ * ParseObject JUDGE = new ParseObject("JUDGE"); * JUDGE ["Post_Id"] = id; * JUDGE ["Like"] = InitialAmount; * JUDGE ["DisLike"] = InitialAmount; * JUDGE.SaveAsync(); * Debug.Log (id); * }*/ void FindorSave(string UserTag, int count) { if (UserTag != "") { var query = new ParseQuery <ParseObject> ("TAG").WhereEqualTo("TagContent", UserTag).WhereEqualTo("Tag_City", city); query.FirstAsync().ContinueWith(t2 => { Loom.QueueOnMainThread(() => { if (t2.IsCanceled || t2.IsFaulted) { Debug.Log("noResult,saving." + UserTag); Save(UserTag, count); } else { ParseObject obj = t2.Result; //foreach (var test in obj) { int i = obj.Get <int> ("Tag_Count"); i++; obj ["Tag_Count"] = i; obj.SaveAsync(); //TagID[count]=obj.ObjectId; //ParseObject tag_post = new ParseObject("POST_TAG"); //tag_post["Tag_Id"]=TagID[count]; //tag_post["Post_Id"]=post_id; //tag_post.SaveAsync(); Debug.Log("find: " + UserTag); IDictionary <string, object> parms = new Dictionary <string, object> { { "tag1", UserTag }, { "tag1_city", city } }; ParseCloud.CallFunctionAsync <IDictionary <string, object> >("tag_computing", parms).ContinueWith(t => { var score = t.Result; }); UserTagInput [count].value = ""; //} } }); }); } }
/// <summary> /// 获取历史轨迹数据 /// </summary> /// <param name="ps"></param> /// <param name="startT"></param> /// <param name="end"></param> /// <param name="intervalMinute">每次获取数据的时间长度,不超过改数值</param> public List <Position> GetHistoryData(int personnelID, List <int> topoNodeIdsT, DateTime startT, DateTime endT, float intervalMinute = 10f) { List <Position> ps = new List <Position>(); double minutes = (endT - startT).TotalMinutes; float counts = (float)minutes / intervalMinute; float valueT = 0; float sum = 0; while (sum < counts) { DateTime startTemp; DateTime endTemp; if (sum + 1 <= counts) { startTemp = startT.AddMinutes(intervalMinute * sum); endTemp = startT.AddMinutes(intervalMinute * (sum + 1)); //List<Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPersonnelID(personnelID, startTemp, endTemp); List <Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPidAndTopoNodeIds(personnelID, topoNodeIdsT, startTemp, endTemp); ps.AddRange(listT); } else { startTemp = startT.AddMinutes(intervalMinute * sum); endTemp = endT; //List<Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPersonnelID(personnelID, startTemp, endTemp); List <Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPidAndTopoNodeIds(personnelID, topoNodeIdsT, startTemp, endTemp); ps.AddRange(listT); } sum += 1; valueT = sum / counts; print("valueT:" + valueT); Loom.DispatchToMainThread(() => { ProgressbarLoad.Instance.Show(valueT); }); } Loom.DispatchToMainThread(() => { ProgressbarLoad.Instance.Hide(); }); return(ps); }
void Awake() { Loom.Initialize(); if (Reference == null) { Reference = ScriptableObject.CreateInstance <StoredReferences>(); } if (Application.isEditor) { GetAllInactiveGameObjects(); } if (Instance != null && Instance != this) { Destroy(Instance.gameObject); } Instance = this; hasWoken = true; if (Application.isPlaying && !hasRun) { _cached = Reference; hasRun = true; } else if (!Application.isPlaying) { hasRun = false; if (_cached != null && _cached.Count > 0) { Reference = _cached.Alive(); } } if (_initActions.Count > 0) { foreach (var a in _initActions) { a(); } _initActions.Clear(); } //giving errors, I don't think the previous people got saving working anyway. //I'll look into why if I have time. If not, sorry to whoever has to.************ //DontDestroyOnLoad (transform.gameObject); }
/// <summary> /// 连接服务器 /// </summary> void ConnectServer(string host, int port) { client = null; Loom.QueueOnMainThread(() => { PingTool.StartPing(host, (pingTime) => { AddEvent(Protocal.PingTime, "" + pingTime); }); }); AddEvent(Protocal.ClientLog, host + ":" + port + " 开始 ConnectServer 连接服务器"); Debug.LogWarning("ConnectServer 连接服务器"); try { String newServerIp = ""; AddressFamily newAddressFamily = AddressFamily.InterNetwork; getIPType(host, "" + port, out newServerIp, out newAddressFamily); if (!string.IsNullOrEmpty(newServerIp)) { host = newServerIp; } IPAddress[] address = Dns.GetHostAddresses(host); if (address.Length == 0) { Debug.LogError("host invalid"); return; } client = new TcpClient(newAddressFamily); client.SendTimeout = 1000; client.ReceiveTimeout = 1000; client.NoDelay = true; client.BeginConnect(host, port, new AsyncCallback(OnConnect), null); } catch (Exception e) { Debug.Log("连接服务器连接服务器连接服务器连接服务器 1"); AddEvent(Protocal.ClientLog, "连接服务器 失败" + e); CloseSocketConnect(); Debug.LogError(e.Message); } }
void HttpReadCallback(IAsyncResult ar) { //Loom.QueueOnMainThread(() => { Debug.Log(123123); }); try { WebRequestBuffer rs = ar.AsyncState as WebRequestBuffer; int read = rs.OrginalStream.EndRead(ar); if (read > 0) { rs.fs.Write(rs.Buffer, 0, read); rs.fs.Flush(); rs.OrginalStream.BeginRead(rs.Buffer, 0, WebRequestBuffer.BufferSize, new AsyncCallback(HttpReadCallback), rs); } else { long length = rs.fs.Length; data = new byte[length]; rs.fs.Seek(0, SeekOrigin.Begin); rs.fs.Read(data, 0, data.Length); rs.fs.Close(); rs.OrginalStream.Close(); rs.WebResponse.Close(); using (FileStream fs = new FileStream(m_path + ".info", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { fs.Seek(0, SeekOrigin.Begin); byte[] v = BitConverter.GetBytes(m_version); fs.Write(v, 0, v.Length); byte[] c = BitConverter.GetBytes(m_crc); fs.Write(c, 0, c.Length); fs.Flush(); } } status = WebRequestStatus.OK; } catch (Exception e) { status = WebRequestStatus.Error; Loom.QueueOnMainThread(() => { Debug.LogError(e.Message); }); } }
// Use this for initialization void Start() { Application.runInBackground = true; tex = new Texture2D(0, 0); //sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(IP), port); client = new TcpClient(); //Connect to server from another Thread Loom.RunAsync(() => { Debug.Log("Connecting to server..."); // if on desktop //client.Connect(IPAddress.Parse(IP), port); // if using the IPAD client.Connect(IPAddress.Parse(IP), port); NS = client.GetStream(); SW = new StreamWriter(NS, Encoding.UTF8); Debug.Log("Connection"); string SendMessage = null; SendMessage = " "; Debug.Log("er"); SW.Write(SendMessage); // 메시지 보내기 Debug.Log("er2"); SW.Flush(); Debug.Log("er3"); //Debug.Log("Connection"); /*sck.Connect(localEndPoint); * Debug.Log("Connected!"); * string text = "get"; * byte[] data = Encoding.UTF8.GetBytes(text); * sck.Send(data);*/ imageReceiver(); }); }
public bool EstablishConnectionWithServer(string serverAddress, int serverPort) { try { if (_socket.Connected) { Debug.Log("Already connected to server"); return(true); } _socket.Connect(new IPEndPoint(IPAddress.Parse(serverAddress), serverPort)); Loom.StartSingleThread(() => { _socket.BeginReceive(_recieveBuffer, 0, _recieveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null); }); _socket.SendTimeout = 10; Debug.Log("Connect to server Successfully "); Debug.Log("Tcp Address: " + serverAddress + "TCP port: " + serverPort); if (sendQueue == null) { sendQueue = new Queue <NetworkData>(); } if (sendQueue.Count > 0 && isSendDone == true && IsConnectedToServer) { SendFirstQueuedData(); } return(true); } catch (SocketException ex) { Debug.Log(ex.ToString()); } return(false); }
//系统消息(窗口输出) public bool InsertSystemString(byte[] pszString) { string strLog = Encoding.Default.GetString(pszString); Debug.Log(strLog); String[] str = strLog.Split(new string[] { "[", "]" }, StringSplitOptions.RemoveEmptyEntries); if (str.Length != 1) { int time = int.Parse(str[1]); if (time == 200) //Play-200s { Debug.Log("Play SOUND_TIPS_START_SEEK"); Loom.QueueOnMainThread(() => { hnManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_TIPS_START_SEEK); }); } else if (time == 45 || time == 100) //Hide-45s,Play-100s,Play-45s { Debug.Log("Play SOUND_TIPS_STARTOREND"); Loom.QueueOnMainThread(() => { hnManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_TIPS_STARTOREND); }); if (time == 45) { IClientUserItem pMeItem = CServerItem.get().GetMeUserItem(); byte Gamestate = CServerItem.get().GetGameStatus(); if (Gamestate == SocketDefines.GAME_STATUS_PLAY) { if (UIManager.GetInstance() != null) { UIManager.GetInstance().ShowMiddleTips("警察进入无敌状态"); } } } } else if (time == 5 || time == 4 || time == 3 || time == 2 || time == 1) { Debug.Log("Play SOUND_TIME_SEC"); Loom.QueueOnMainThread(() => { hnManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_TIME_SEC); }); } } strLog = GlobalUserInfo.GBToUtf8(pszString); GameSceneUIHandler.ShowLog(strLog); return(true); }
// EVENTS void OnNewDepthFrame(VideoStream vs) { if (this == null) { return; } // print("OnNewDepthFrame"); var frame = vs.ReadFrame(); Marshal.Copy(frame.Data, _rawDepthMap, 0, _rawDepthMap.Length); CalculatePointPositions(); Loom.QueueOnMainThread(() => { CalculateDistancesToQuad(); // _depthMeshRenderer.UpdateMesh(_rawDepthMap); // _textureRenderer.UpdateTexture(_rawDepthMap); }); }
private void OnPluginCreated(object sender, FileSystemEventArgs e) { string filename = Path.GetFileNameWithoutExtension(e.Name); string dir = Path.GetDirectoryName(e.FullPath).Split(Path.DirectorySeparatorChar).Last(); if (filename == dir && IsAPlugin(e.Name)) { if (!TryLoadPlugin(filename, Type)) { Fougerite.Logger.Log(string.Format("[PluginWatcher] Couldn't load: {0}{3}{1}.{2}", dir, filename, Type, Path.DirectorySeparatorChar)); } else { Loom.QueueOnMainThread(() => { Logger.Log("[PluginWatcher] Detected new plugin " + filename); }); } } }
// Update is called once per frame void Update() { obj.Translate(Vector3.right * Time.deltaTime); //obj.Translate(Vector3.right * 0.02f); if (Input.GetMouseButtonDown(1)) { Debug.Log(Time.time); Loom.RunAsync(() => { var s = client.echo("aaaaaaaaaaaaaaaaaaaaaaaa"); Loom.QueueOnMainThread(() => { Debug.Log(Time.time); Debug.Log(s); var obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.transform.position = Vector3.zero; }); }); } }
void init() { ScreenSleepTime = SleepTimeout.NeverSleep; //根据progressThreadEvent判定是否启用线程处理线程上的事件 if (progressThreadEvent) { Loom.RunAsync(delegate() { while (progressThreadEvent && isRunning) { Thread.Sleep(20); EventManager.ProgressThreadEvents(); } }); } //注册LogFile事件 EventManager.AddToMain(GameDefine.STR_EVENT_LOG_EVENT, this, "LogEvent"); }
void SendMessage() { while (true) { if (sendList.Count == 0) { Thread.Sleep(50); continue; } if (!mSocket.Connected && !IsConnected()) { Loom.QueueOnMainThread(() => { StartCoroutine(Reconnect()); }); break; } else { Send(sendList[0]); } } }
public static void Initialize() { var go = !_initialized; if (go && _threadId != -1 && _threadId != Thread.CurrentThread.ManagedThreadId) { return; } if (go) { var g = new GameObject("Loom"); g.hideFlags = HideFlags.HideAndDontSave; GameObject.DontDestroyOnLoad(g); _current = g.AddComponent <Loom>(); Component.DontDestroyOnLoad(_current); _initialized = true; _threadId = Thread.CurrentThread.ManagedThreadId; } }
public void Start() { terrainMat = terrainMatToApply; waterMat = waterMatToApply; objectMat = objectMatToApply; objectMatTexture = objectMatTextureToApply; alphaObject = alphaObjectMatToApply; grassObjStatic = grassObj; deadTreeStatic = deadTree; oakTreeStatic = oakTree; standardTreeStatic = standardTree; willowTreeStatic = willowTree; mapleTreeStatic = mapleTree; yewTreeStatic = yewTree; magicTreeStatic = magicTree; Loom.StartSingleThread(() => { StartOSSocket(); }, System.Threading.ThreadPriority.Normal, false); //Loom.StartSingleThread(()=>{GameLoop();},System.Threading.ThreadPriority.Normal,false); }
public void ButtonJoin() { if (RoomIdValue > 1000000 || RoomIdValue < 100000) { return; } //int iServerID = RoomIdValue / 10000 - 10; Loom.QueueOnMainThread(() => { ShowGoldCost(true); hnGameManager.JoinRoom(RoomIdValue); });//,2.0f); //RoomIdValue = 0; //RoomId.text = ""; //mChen add, for HideSeek ///hnGameManager.LoadHideSeekSceneOfWangHu(); }
//程序入口 protected virtual void Awake() { //核心不能销毁 DontDestroyOnLoad(this.gameObject); //线程模块 Loom.Init(); //日志模块 TLogger.Instance.ToString(); TLogger.Log("基础模块开始初始化.", "MainControl", "Awake - IniMainModules"); IniMainModules(); TLogger.Log("基础模块初始化完成.", "MainControl", "Awake - IniMainModules"); TLogger.Log("边缘模块开始初始化.", "MainControl", "Awake - IniMarginalModules"); IniMarginalModules(); TLogger.Log("边缘模块初始化完成.", "MainControl", "Awake - IniMarginalModules"); TLogger.Log("游戏初始化完成.", "MainControl", "Awake"); }
void Testdo() { // 在新线程上运行的代码 Loom.RunAsync(() => { for (int i = 0; i < 50; i++) { num++; Debug.LogWarning("AKB输出第" + i + "行" + ", num = " + num); } }); //在主线程上运行一些代码 Loom.QueueOnMainThread(() => { for (int i = 0; i < 50; i++) { num -= 50; Debug.Log("SKE输出第" + i + "行" + ", num = " + num); } this.transform.position = new Vector3(0, num, 0); }, 1); }
void Awake() { if (instance == null) { //If I am the first instance, make me the Singleton instance = this; DontDestroyOnLoad (this); } else { //If a Singleton already exists and you find //another reference in scene, destroy it! if (this != instance) Destroy (this.gameObject); } }
void Awake() { _current = this; initialized = true; _actions = new List<Action>(); _delayed = new List<DelayedQueueItem>(); _currentDelayed = new List<DelayedQueueItem>(); _currentActions = new List<Action>(); }
private void Awake() { if (Instance == null) { instance = this; } else if (Instance != this) { DestroyImmediate(gameObject); } }
void Awake() { _current = this; initialized = true; }
private static void Initialize() { if (initialized == false || _current == null) { if (Application.isPlaying == false) { return; } initialized = true; var g = new GameObject("Threads"); _current = g.AddComponent<Loom>(); } }