// sets the marker position, not the component transform public void SetPosition(float textureX, float textureY) { Init(); SetVisibility(true); mouseVisual.transform.position = TranformBrowserTextureCoordinatesToWorldSpace(textureX, textureY); if (replayMode && browserId != -1 && (mouseDown || lastMouseDown)) { Event dragEvent = new Event(); if (mouseDown && lastMouseDown != mouseDown) { dragEvent.type = EventType.MouseDown; } else if (lastMouseDown != mouseDown) { dragEvent.type = EventType.MouseUp; } else { dragEvent.type = EventType.MouseDrag; } CollabBrowserTexture browser = CollabBrowserTexture.GetAll()[browserId]; browser.HandleBrowserEvent(dragEvent, (int)((0.5f - textureX) * browser.width), (int)((textureY + 0.5f) * browser.height)); } lastMouseDown = mouseDown; }
public void UnfocusKeyInputBrowserPanels() { foreach (KeyValuePair <int, CollabBrowserTexture> cbt in CollabBrowserTexture.GetAll()) { if (cbt.Value.KeyInputEnabled && cbt.Value.Focused) { cbt.Value.Unfocus(); } } }
public bool AnyKeyInputBrowsersFocused() { bool browserFocus = false; foreach (KeyValuePair <int, CollabBrowserTexture> cbt in CollabBrowserTexture.GetAll()) { browserFocus |= (cbt.Value.KeyInputEnabled && cbt.Value.Focused); } return(browserFocus); }
public Vector3 TranformBrowserTextureCoordinatesToWorldSpace(int textureX, int textureY) { CollabBrowserTexture browser = CollabBrowserTexture.GetAll()[browserId]; if (browser != null) { return(browser.transform.TransformPoint(new Vector3(((float)textureX / 255f) - 0.5f, ((float)(textureY - 0.5f) / 255f) - 0.5f, 0f))); } return(Vector3.zero); }
public Vector3 TranformBrowserTextureCoordinatesToWorldSpace(float textureX, float textureY) { CollabBrowserTexture browser = CollabBrowserTexture.GetAll()[browserId]; if (browser != null) { return(browser.transform.TransformPoint(new Vector3(textureX, textureY, 0f))); } return(Vector3.zero); }
public void SendGuiLayerPanelSelection(JSValue[] args) { int id = args.Length > 1 ? args[1].ToInteger() : -1; CollabBrowserTexture browserTexture = null; if (CollabBrowserTexture.GetAll().TryGetValue(id, out browserTexture)) { string cmd = "webPanelSelection(" + id + ", \"" + browserTexture.GetSelectedText() + "\");"; ExecuteJavascript(cmd); } else { Debug.LogError("Could not find browser texture " + id); } }
public void Sit() { if (!isSitting) { prevNavMode = player.playerController.navMode; player.playerController.navMode = PlayerController.NavMode.locked; player.gameObject.GetComponent <AnimatorHelper>().StartAnim("Sit", true); if (player.IsLocal) { UpdatePlayerServerVariable(true); } } #if UNITY_STANDALONE_OSX bool controlDown = (Input.GetKey(KeyCode.LeftApple) || Input.GetKey(KeyCode.RightApple)); #else bool controlDown = (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)); #endif if (player.IsLocal && !controlDown) { MainCameraController.Inst.cameraType = CameraType.FIRSTPERSON; } if (!isSitting && GameGUI.Inst.guiLayer != null) { GameGUI.Inst.guiLayer.SendGuiLayerSitStart(); } if (GameManager.Inst.LevelLoaded == GameManager.Level.OFFICE) { foreach (KeyValuePair <int, CollabBrowserTexture> cbt in CollabBrowserTexture.GetAll()) { if (cbt.Key >= CollabBrowserId.TEAMWEB) { GameGUI.Inst.presenterToolCollabBrowser = cbt.Value; } } } isSitting = true; }
public void OnObjectMessage(int userID, ISFSObject msgObj) { //if player is stealth, don't show a mouse sphere to others if (GameManager.Inst.playerManager != null && GameManager.Inst.playerManager.GetPlayer(userID) != null && GameManager.Inst.playerManager.GetPlayer(userID).Type == PlayerType.STEALTH) { return; } // Light-bandwidth mouse browers index, horizontal, vertical. else if (msgObj.ContainsKey("mpx")) { PlayerMouseVisual visual = GetVisual(userID); if (visual == null) { return; } Sfs2X.Util.ByteArray mouseBytes = msgObj.GetByteArray("mpx"); int mouseBrowserID = mouseBytes.ReadByte(); int mouseBrowserCoordX = mouseBytes.ReadByte(); int mouseBrowserCoordY = mouseBytes.ReadByte(); visual.mouseDown = mouseBytes.ReadBool(); visual.browserId = mouseBrowserID; CollabBrowserTexture mouseBrowser = CollabBrowserTexture.GetAll()[mouseBrowserID]; if (mouseBrowser) { visual.SetPosition(mouseBrowserCoordX, mouseBrowserCoordY); visual.textureScaleMult = Mathf.Min(mouseBrowser.transform.lossyScale.x, mouseBrowser.transform.lossyScale.y) * 0.1f; } } else if (msgObj.ContainsKey("mp")) { PlayerMouseVisual visual = GetVisual(userID); if (visual == null) { return; } Sfs2X.Util.ByteArray mouseBytes = msgObj.GetByteArray("mp"); int mouseBrowserID = mouseBytes.ReadByte(); float mouseBrowserCoordX = mouseBytes.ReadFloat(); float mouseBrowserCoordY = mouseBytes.ReadFloat(); visual.mouseDown = mouseBytes.ReadBool(); visual.browserId = mouseBrowserID; CollabBrowserTexture mouseBrowser = CollabBrowserTexture.GetAll()[mouseBrowserID]; if (mouseBrowser) { visual.SetPosition(mouseBrowserCoordX, mouseBrowserCoordY); visual.textureScaleMult = Mathf.Min(mouseBrowser.transform.lossyScale.x, mouseBrowser.transform.lossyScale.y) * 0.1f; } } else if (msgObj.ContainsKey("me")) { PlayerMouseVisual visual = GetVisual(userID); if (visual == null) { return; } visual.SetVisibility(false); } }
void OnDestroy() { mInstance = null; CollabBrowserTexture.GetAll().Remove(CollabBrowserId.PRIVATEBROWSER); }