public void receiveImageSize(TopicDataRecord dir) { imageSize = UbiiParser.ProtoToUnity(dir.Vector2); Debug.Log("Received Image Size"); received = true; }
public void receiveImageFormat(TopicDataRecord dir) { imageFormatIndex = (int)UbiiParser.ProtoToUnity(dir.Double) - 1; //added -1 to not send empty data (0) Debug.Log(imageFormatIndex); Debug.Log("Received Image Format"); received = true; }
//private async void reconnect() //{ // if (connected) CancelInvoke(); // await client.InitializeClient(); // Debug.Log("connected"); // connected = true; // CancelInvoke(); //} public void send_texture(Texture2D texture, string filename) { if (!connected) { return; } //send filename client.Publish(UbiiParser.UnityToProto("image name", filename)); //send size client.Publish(UbiiParser.UnityToProto("image size", new Vector2(texture.width, texture.height))); //send format int index = 0; for (; index < texture_formats.Length; index++) { if (texture_formats[index] == texture.format) { break; } } ; client.Publish(UbiiParser.UnityToProto("image format", index + 1)); // added +1 to not send empty data client.Publish(UbiiParser.UnityToProto("image", Convert.ToBase64String(texture.GetRawTextureData()))); Debug.Log("Sent texture"); }
public void send_color(Color c) { if (!connected) { return; } client.Publish(UbiiParser.UnityToProto("color", c)); Debug.Log("Sent color: " + c); }
public void send_reset_canvas() { if (!connected) { return; } client.Publish(UbiiParser.UnityToProto("reset canvas", "")); Debug.Log("Sent reset canvas"); }
public void sendUVResolution(Vector2 resolution) { if (!connected) { return; } client.Publish(UbiiParser.UnityToProto("uvimage resolution", resolution)); Debug.Log("Sent uv resolution"); }
private void Publish_TOPIC_HOST_DISCONNECTED() { LogConsole("Publish_TOPIC_HOST_DISCONNECTED"); if (ARE_EQUAL(LocalNetworkID, ENetworkID.HOST)) { Publish(UbiiParser.UnityToProto(TOPIC_HOST_DISCONNECTED, localGuid)); } }
public void send_brush_size(int size) { if (!connected) { return; } client.Publish(UbiiParser.UnityToProto("brush size", size + "")); Debug.Log("Sent brush size " + size); }
public void send_command(string command) { if (!connected) { return; } client.Publish(UbiiParser.UnityToProto("command", command)); Debug.Log("Sent command: " + command); }
public void send_position(Vector4 position_data) { if (!connected) { return; } client.Publish(UbiiParser.UnityToProto("position", position_data)); Debug.Log("Sent position: " + position_data); }
// Test function subscribing to "TestTopic" to demonstrate how topic subscription works public void SendTopicDataTestPosition() { // set some random coordinates for the cube in the test scene float x = UnityEngine.Random.Range(-7f, 7f); float y = UnityEngine.Random.Range(-3f, 5f); Vector2 v = new Vector2(x, y); // Use utility function to publish on topic with data Publish(UbiiParser.UnityToProto("TestTopicPos", v)); }
public void send_gallery_command(string filename) { if (!connected) { return; } //send filename client.Publish(UbiiParser.UnityToProto("gallery command", filename)); Debug.Log("Sent filename: " + filename); }
public void send_undo() { if (!connected) { Debug.Log("Couldn't send undo command. Not connected."); return; } client.Publish(UbiiParser.UnityToProto("undo", true)); Debug.Log("Sent undo command"); }
public void receivePositionData(TopicDataRecord dir) { position_data = UbiiParser.ProtoToUnity(dir.Vector4); mouse_button_down = mouse_button_down || position_data.z >= 999; position_data.z = position_data.z >= 999?position_data.z - 1000:position_data.z; //Debug.Log(position_data + ", " + mouse_button_down); Debug.Log("Recieved Position"); position_changed = true; received = true; }
private void SendTopicDataTestRotation() { // set some random coordinates for the cube in the test scene float x = UnityEngine.Random.Range(-7f, 7f); float y = UnityEngine.Random.Range(-3f, 5f); float z = UnityEngine.Random.Range(-7f, 7f); float w = UnityEngine.Random.Range(-3f, 5f); Quaternion q = new Quaternion(x, y, z, w); // publish topic data Publish(UbiiParser.UnityToProto("TestTopicRot", q)); }
private void Publish_TOPIC_BROADCAST_HOST_IP() { // Debug if (MotherOfManagers.Instance.DebugUbiiTopicPublish) { LogConsole("Publish_TOPIC_BROADCAST_HOST_IP"); } if (ARE_EQUAL(LocalNetworkID, ENetworkID.HOST)) { Publish(UbiiParser.UnityToProto(TOPIC_BROADCAST_HOST_IP, localGuid)); } }
private void Publish_TOPIC_CLIENT_CONNECTED(string connectedClientGuid, ENetworkID networkID) { // Debug if (MotherOfManagers.Instance.DebugUbiiTopicPublish) { LogConsole("Publish_TOPIC_CLIENT_CONNECTED"); } if (ARE_EQUAL(LocalNetworkID, ENetworkID.HOST)) { Publish(UbiiParser.UnityToProto(TOPIC_CLIENT_CONNECTED, localGuid + "|" + connectedClientGuid + "|" + networkID)); } }
private void Publish_TOPIC_CLIENT_DISCONNECTED() { // Debug if (MotherOfManagers.Instance.DebugUbiiTopicPublish) { LogConsole("Publish_TOPIC_CLIENT_DISCONNECTED"); } if (IS_TRUE(IsClient())) { Publish(UbiiParser.UnityToProto(TOPIC_CLIENT_DISCONNECTED, localGuid + '|' + joinedHostGuid + "|" + LocalNetworkID)); } }
// TODO : publish a list of all already connected clients to the host private void Publish_TOPIC_REQUEST_JOIN_HOST(int hostID) { // Debug if (MotherOfManagers.Instance.DebugUbiiTopicPublish) { LogConsole("Publish_TOPIC_REQUEST_JOIN_HOST"); } if (ARE_EQUAL(LocalNetworkID, ENetworkID.LOCAL) && (discoveredHosts.Count > hostID)) { string hostGuid = discoveredHosts[hostID]; Publish(UbiiParser.UnityToProto(TOPIC_REQUEST_JOIN_HOST, localGuid + "|" + hostGuid)); } }
private void Publish_TOPIC_BROADCAST_BEVENT(AbstractBEHandle bEHandle, ENetworkID targetNetworkID) { // Debug if (MotherOfManagers.Instance.DebugUbiiTopicPublish) { LogConsole("Publish_TOPIC_BROADCAST_BEVENT"); } if (ARE_NOT_EQUAL(LocalNetworkID, targetNetworkID)) { string serializedBEHandle = BUtils.SerializeObject(bEHandle); Publish(UbiiParser.UnityToProto(TOPIC_BROADCAST_BEVENT, joinedHostGuid + "|" + targetNetworkID + "|" + serializedBEHandle)); } }
// SPACE moves Cube, RETURN rotates cube private void Update() { // Only for testing and demonstration purposes // Sends a random vector on subscribed topic, that the client also publishes to; vector moves the cube in the "Test" scene if (Input.GetKeyDown(KeyCode.Space) && subscribed) { Debug.Log("Send example topic data for position"); SendTopicDataTestPosition(); } // Sends a random Quaternion on subscribed topic, that the client also publishes to; Quaternion rotates the cube in the "Test" scene if (Input.GetKeyDown(KeyCode.Return) && subscribed) { Debug.Log("Send example topic data for rotation"); SendTopicDataTestRotation(); } if (Input.GetAxis("Fire1") != 0 && subscribed) { Publish(UbiiParser.UnityToProto("MoveCubeH", new Vector3(Input.GetAxis("Fire1"), 0, 0))); } else { newMoveH = Vector3.zero; } if (Input.GetAxis("Fire2") != 0 && subscribed) { Publish(UbiiParser.UnityToProto("MoveCubeV", new Vector3(0, Input.GetAxis("Fire2"), 0))); } else { newMoveV = Vector3.zero; } if (Input.GetButton("Fire3") && subscribed) { Publish(UbiiParser.UnityToProto("SayWazza", "a")); } //cube.transform.position = newPos; cube.transform.rotation = newRot; cube.transform.position = Vector3.Lerp(cube.transform.position, cube.transform.position + newMoveH + newMoveV, Time.deltaTime * 10f); if (wazzaText) { wazzaText.text = wazzaString; } }
private void MoveCubeV(TopicDataRecord obj) { newMoveV = UbiiParser.ProtoToUnity(obj.Vector3); }
public void TestTopicDataSubRot(TopicDataRecord topicDataRecord) { // rotation cannot be directly set as this does not run from main thread, so save position to global variable which will be applied in Update() in main thread newRot = UbiiParser.ProtoToUnity(topicDataRecord.Quaternion); }
public void Publish_TOPIC_TEST_INT(int integer) { LogConsole("Publish_TOPIC_TEST_INT : " + integer + " - " + BUtils.GetTimeAsString()); Publish(UbiiParser.UnityToProto(TOPIC_TEST_INT, integer)); }
public void receiveColor(TopicDataRecord dir) { color = UbiiParser.ProtoToUnity(dir.Color); Debug.Log("received color " + color); received = true; }
public void receiveUVImage_resolution(TopicDataRecord dir) { uv_resolution = UbiiParser.ProtoToUnity(dir.Vector2); Debug.Log("received uv image resolution " + uv_resolution); received = true; }