Enqueue() public method

Locks the queue and adds the Action to the queue
public Enqueue ( Action, action ) : void
action Action, function that will be executed from the main thread.
return void
示例#1
0
 public static void LoadMainScene()
 {
     if (SingletonUI.Instance != null)
     {
     }
     UnityMainThreadDispatcher.Enqueue(() =>
     {
         SceneManager.LoadScene("MainScene");
     });
 }
示例#2
0
 public void StartGame(string w)
 {
     _dispatcher.Enqueue(() =>
     {
         StartButtton.SetActive(false);
         Text.gameObject.SetActive(true);
         Debug.Log("Игра началась");
         timer = true;
     });
 }
        private static void RunInUnityMainThread(System.Action action)
        {
            UnityMainThreadDispatcher dispatcher = UnityMainThreadDispatcher.Instance();

            if (null == dispatcher)
            {
                Debug.Log("UnityMainThreadDispatcher is null, please add UnityMainThreadDispatcher.prefab to your scene");
                return;
            }
            dispatcher.Enqueue(action);
        }
示例#4
0
 private void DataReceived(object sender, DataReceivedEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Data))
     {
         string results = e.Data;
         results = results.Remove(0, 2);              // remove the whitespace at the front of each result (just spaces).
         results = results.Replace("\r", "");         // remove the new line from our result as well.
         if (!string.IsNullOrEmpty(results) && !results.Contains("undefined") && !results.Contains("defined"))
         {
             UnityMainThreadDispatcher.Enqueue(log.UpdateLog("[ " + results + " ]\n"));                  // format the process the info on the unity thread.
         }
     }
 }
    private NetworkMeshAnimator()
    {
        this.listner = new UDPServer((String message) => {
            if (isAcceptingMessages)
            {
                dispatcher.Enqueue(SetBlendShapesOnMainThread(message));
            }
        });


        EditorApplication.playModeStateChanged += PlayStateChanged;

        listner.Start();
    }
 public void chat(string username, string message)
 {
     message = message.ToUpper();
     Debug.Log(username + " said, \"" + message + "\".");
     if (gm.votingOpen)
     {
         if (message.Contains("#A"))
         {
             gm.findPlayer(username).setAnswer(0);
         }
         else if (message.Contains("#B") || message.Contains("#T"))
         {
             gm.findPlayer(username).setAnswer(1);
         }
         else if (message.Contains("#C"))
         {
             gm.findPlayer(username).setAnswer(2);
         }
         else if (message.Contains("#D") || message.Contains("#F"))
         {
             gm.findPlayer(username).setAnswer(3);
         }
         Debug.Log(username + " voted " + gm.findPlayer(username).getAnswer());
     }
     else
     {
         //Debug.Log("Voting has ended, @"+username + ".");
         //irc.SendMessage("@" + username + ", Voting has ended.");
         if (message.Contains("#A") || message.Contains("#B") || message.Contains("#C") || message.Contains("#D") || message.Contains("#T") || message.Contains("#F"))
         {
             SendMsg("@" + username + ", Voting has ended.");
         }
     }
     if (message.Contains("#SCORE"))
     {
         SendMsg("@" + username + ", your score is " + gm.findPlayer(username).getScore() + ".");
     }
     if (message.Contains("#5050"))
     {
         UnityMainThreadDispatcher.Enqueue(() => send5050(username));
     }
     if (message.Contains("#HELP"))
     {
         SendMsg("Type \"#A\", \"#B\", \"#C\", or\"D\" for the answer you think is correct in the chat.  If you get the answer right, you will get 1 point.  The top 20 players will be shown at the end of every round.  To see you score at any time, type \"#score\" in the chat.");
     }
 }
示例#7
0
    public void HandlePacketIn(byte[] bytes)
    {
        MemoryStream memoryStream = new MemoryStream(bytes);

        int id = ReadShort(memoryStream);

        PacketIn packetIn = packetInObjects[id];

        if (packetIn.handleOnUnityThread)
        {
            unityMainThreadDispatcher.Enqueue(() => packetIn.HandleData(memoryStream));
        }
        else
        {
            packetIn.HandleData(memoryStream);
        }
    }
示例#8
0
 public void UpdateBoardMainThreadCall()
 {
     UnityMainThreadDispatcher.Enqueue(UpdateBoard());
 }
示例#9
0
 //Function used to run code in the main thread cuz you can't make changes in UI if you are not in the main thread.
 public static void runInMainThread(IEnumerator function)
 {
     UnityMainThreadDispatcher.Enqueue(function);
 }