public void Update() { if (mouseTouchEmulation && (Input.GetMouseButtonDown(0) || Input.GetMouseButton(0) || Input.GetMouseButtonUp(0))) { Vector2 position = new Vector3(Input.mousePosition.x / Screen.width, 1 - (Input.mousePosition.y / Screen.height)); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if (Input.GetMouseButtonDown(0)) touch.SetGesture(EventBase.Type.Down); else if (Input.GetMouseButtonUp(0)) touch.SetGesture(EventBase.Type.Up); else if (Input.GetMouseButton(0)) touch.SetGesture(EventBase.Type.Move); testTouchCanvas.OnEvent(touch); } StartCoroutine("SendEventsToClients"); CAVE2.BroadcastMessage(gameObject.name, "UpdateDebugTextRPC", connectStatus ); }
public void Update() { if( mouseTouchEmulation ) { Vector2 position = new Vector3( Input.mousePosition.x, Input.mousePosition.y ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if( Input.GetMouseButtonDown(0) ) touch.SetGesture( EventBase.Type.Down ); else if( Input.GetMouseButtonUp(0) ) touch.SetGesture( EventBase.Type.Up ); else if( Input.GetMouseButton(0) ) touch.SetGesture( EventBase.Type.Move ); GameObject[] touchObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); foreach (GameObject touchObj in touchObjects) { touchObj.BroadcastMessage("OnTouch",touch,SendMessageOptions.DontRequireReceiver); } } lock(eventList.SyncRoot) { foreach( EventData e in eventList ) { if( (EventBase.ServiceType)e.serviceType == EventBase.ServiceType.ServiceTypePointer ) { // 2D position of the touch, flipping y-coordinates Vector2 position = new Vector3( e.posx * Screen.width, Screen.height - e.posy * Screen.height ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, (int)e.sourceId); touch.SetGesture( (EventBase.Type)e.type ); GameObject[] touchObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); foreach (GameObject touchObj in touchObjects) { touchObj.BroadcastMessage("OnTouch",touch,SendMessageOptions.DontRequireReceiver); } } else { GameObject[] omicronObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); foreach (GameObject obj in omicronObjects) { obj.BroadcastMessage("OnEvent",e,SendMessageOptions.DontRequireReceiver); } } } // Clear the list (TODO: probably should set the Processed flag instead and cleanup elsewhere) eventList.Clear(); } }
public void Update() { if( mouseTouchEmulation ) { Vector2 position = new Vector3( Input.mousePosition.x, Input.mousePosition.y ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if( Input.GetMouseButtonDown(0) ) touch.SetGesture( EventBase.Type.Down ); else if( Input.GetMouseButtonUp(0) ) touch.SetGesture( EventBase.Type.Up ); else if( Input.GetMouseButton(0) ) touch.SetGesture( EventBase.Type.Move ); //GameObject[] touchObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); //foreach (GameObject touchObj in touchObjects) { // touchObj.BroadcastMessage("OnTouch",touch,SendMessageOptions.DontRequireReceiver); //} } lock(eventList.SyncRoot) { foreach( EventData e in eventList ) { ArrayList activeClients = new ArrayList(); foreach( OmicronEventClient c in omicronClients ) { if( !c.IsFlaggedForRemoval() ) { c.BroadcastMessage("OnEvent",e,SendMessageOptions.DontRequireReceiver); activeClients.Add(c); } } omicronClients = activeClients; #if USING_GETREAL3D if(getReal3D.Cluster.isMaster) { getReal3D.RpcManager.call ("AddStringEvent", OmicronConnectorClient.EventDataToString(e)); } #endif } // Clear the list (TODO: probably should set the Processed flag instead and cleanup elsewhere) eventList.Clear(); } }
public void Update() { connectionState = (ConnectionState)omicronManager.GetConnectionState(); if (mouseTouchEmulation && (Input.GetMouseButtonDown(0) || Input.GetMouseButton(0) || Input.GetMouseButtonUp(0))) { Vector2 position = new Vector3(Input.mousePosition.x / Screen.width, 1 - (Input.mousePosition.y / Screen.height)); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if (Input.GetMouseButtonDown(0)) touch.SetGesture(EventBase.Type.Down); else if (Input.GetMouseButtonUp(0)) touch.SetGesture(EventBase.Type.Up); else if (Input.GetMouseButton(0)) touch.SetGesture(EventBase.Type.Move); testTouchCanvas.OnEvent(touch); } StartCoroutine("SendEventsToClients"); // CAVE2.SendMessage(gameObject.name, "UpdateDebugTextRPC", connectStatus ); if (statusCanvasText) { statusCanvasText.text = "OmicronManager\n"; statusCanvasText.text += "Server: " + serverIP + ":" + serverMsgPort +"\n"; string statusText = "UNKNOWN"; switch (connectionState) { case (ConnectionState.NotConnected): statusText = "Not Connected"; break; case (ConnectionState.Connecting): statusText = "Connecting"; break; case (ConnectionState.Connected): statusText = "Connected"; break; case (ConnectionState.FailedToConnect): statusText = "Failed To Connect"; break; } statusCanvasText.text += "Status: " + statusText + "\n"; } }
public void Update() { if( mouseTouchEmulation && (Input.GetMouseButtonDown(0) || Input.GetMouseButton(0) || Input.GetMouseButtonUp(0)) ) { Vector2 position = new Vector3( Input.mousePosition.x / Screen.width, 1 - (Input.mousePosition.y / Screen.height) ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if( Input.GetMouseButtonDown(0) ) touch.SetGesture( EventBase.Type.Down ); else if( Input.GetMouseButtonUp(0) ) touch.SetGesture( EventBase.Type.Up ); else if( Input.GetMouseButton(0) ) touch.SetGesture( EventBase.Type.Move ); testTouchCanvas.OnEvent(touch); } StartCoroutine("SendEventsToClients"); if(statusCanvasText) { string statusText = "UNKNOWN"; switch (connectStatus) { case (0): currentStatus = idleStatus; statusText = "Not Connected"; statusCanvasText.color = Color.grey; break; case (1): currentStatus = activeStatus; statusText = "Connected"; statusCanvasText.color = Color.green; break; case (-1): currentStatus = errorStatus; statusText = "Failed to Connect"; statusCanvasText.color = Color.red; break; default: statusCanvasText.color = Color.yellow; break; } statusCanvasText.text = statusText; } }
public void Update() { if( mouseTouchEmulation ) { Vector2 position = new Vector3( Input.mousePosition.x, Input.mousePosition.y ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if( Input.GetMouseButtonDown(0) ) touch.SetGesture( EventBase.Type.Down ); else if( Input.GetMouseButtonUp(0) ) touch.SetGesture( EventBase.Type.Up ); else if( Input.GetMouseButton(0) ) touch.SetGesture( EventBase.Type.Move ); GameObject[] touchObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); foreach (GameObject touchObj in touchObjects) { touchObj.BroadcastMessage("OnTouch",touch,SendMessageOptions.DontRequireReceiver); } } lock(eventList.SyncRoot) { foreach( EventData e in eventList ) { if( (EventBase.ServiceType)e.serviceType == EventBase.ServiceType.ServiceTypePointer ) { // 2D position of the touch, flipping y-coordinates Vector2 position = new Vector3( e.posx * Screen.width, Screen.height - e.posy * Screen.height ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, (int)e.sourceId); touch.SetGesture( (EventBase.Type)e.type ); GameObject[] touchObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); foreach (GameObject touchObj in touchObjects) { touchObj.BroadcastMessage("OnTouch",touch,SendMessageOptions.DontRequireReceiver); } } else { GameObject[] omicronObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); foreach (GameObject obj in omicronObjects) { obj.BroadcastMessage("OnEvent",e,SendMessageOptions.DontRequireReceiver); } } } // Clear the list (TODO: probably should set the Processed flag instead and cleanup elsewhere) eventList.Clear(); } }
public void Update() { if( mouseTouchEmulation ) { Vector2 position = new Vector3( Input.mousePosition.x, Input.mousePosition.y ); // Ray extending from main camera into screen from touch point Ray touchRay = Camera.main.ScreenPointToRay(position); Debug.DrawRay(touchRay.origin, touchRay.direction * 10, Color.white); TouchPoint touch = new TouchPoint(position, -1); if( Input.GetMouseButtonDown(0) ) touch.SetGesture( EventBase.Type.Down ); else if( Input.GetMouseButtonUp(0) ) touch.SetGesture( EventBase.Type.Up ); else if( Input.GetMouseButton(0) ) touch.SetGesture( EventBase.Type.Move ); //GameObject[] touchObjects = GameObject.FindGameObjectsWithTag("OmicronListener"); //foreach (GameObject touchObj in touchObjects) { // touchObj.BroadcastMessage("OnTouch",touch,SendMessageOptions.DontRequireReceiver); //} } lock(eventList.SyncRoot) { foreach( EventData e in eventList ) { ArrayList activeClients = new ArrayList(); foreach( OmicronEventClient c in omicronClients ) { if( !c.IsFlaggedForRemoval() ) { c.BroadcastMessage("OnEvent",e,SendMessageOptions.DontRequireReceiver); activeClients.Add(c); } } omicronClients = activeClients; #if USING_GETREAL3D if(getReal3D.Cluster.isMaster) { getReal3D.RpcManager.call ("AddStringEvent", OmicronConnectorClient.EventDataToString(e)); } #endif } // Clear the list (TODO: probably should set the Processed flag instead and cleanup elsewhere) eventList.Clear(); } }