// Process messages coming from the web view. private void ProcessMessages() { while (true) { // Poll a message or break. WebMediator.WebMediatorMessage message = WebMediator.PollMessage(); if (message == null) { break; } if (message.path == "/spawn") { GameObject prefab = null; // "spawn" message. if (message.args.ContainsKey("color")) { prefab = (message.args["color"] == "red") ? redBoxPrefab : blueBoxPrefab; } else { prefab = Random.value < 0.5 ? redBoxPrefab : blueBoxPrefab; } var box = Instantiate(prefab, redBoxPrefab.transform.position, Random.rotation) as GameObject; if (message.args.ContainsKey("scale")) { box.transform.localScale = Vector3.one * float.Parse(message.args["scale"] as string); } } else if (message.path == "/note") { // "note" message. note = message.args["text"] as string; } else if (message.path == "/print") { // "print" message. var text = message.args["line1"] as string; if (message.args.ContainsKey("line2")) { text += "\n" + message.args["line2"] as string; } Debug.Log(text); Debug.Log("(" + text.Length + " chars)"); } else if (message.path == "/close") { // "close" message. DeactivateWebView(); } } }
private void ProcessMessages() { while (true) { WebMediator.WebMediatorMessage message = WebMediator.PollMessage(); if (message == null) { break; } } }