public void RenderOnGUI() { GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, Screen.height)); GUILayout.Label("Variables:"); GUILayout.Label("m_Init: " + m_Init); GUILayout.Label("m_HHTMLBrowser: " + m_HHTMLBrowser); GUILayout.Label("m_URL: " + m_URL); GUILayout.Label("m_Texture: " + m_Texture); GUILayout.Label("m_Width: " + m_Width); GUILayout.Label("m_Height: " + m_Height); GUILayout.Label("m_CanGoBack: " + m_CanGoBack); GUILayout.Label("m_CanGoForward: " + m_CanGoForward); GUILayout.Label("m_Rect: " + m_Rect); GUILayout.Label("m_LastMousePos: " + m_LastMousePos); GUILayout.Label("m_VerticalScrollMax: " + m_VerticalScrollMax); GUILayout.Label("m_VeritcalScrollCurrent: " + m_VeritcalScrollCurrent); GUILayout.Label("m_HorizontalScrollMax: " + m_HorizontalScrollMax); GUILayout.Label("m_HorizontalScrollCurrent: " + m_HorizontalScrollCurrent); GUILayout.Label("m_SetKeyFocus: " + m_SetKeyFocus); GUILayout.Label("m_Find: " + m_Find); GUILayout.Label("m_CurrentlyInFind: " + m_CurrentlyInFind); GUILayout.Label("m_ScaleFactor: " + m_ScaleFactor); GUILayout.Label("m_BackgroundMode: " + m_BackgroundMode); GUILayout.EndArea(); if (m_Texture) { GUI.DrawTexture(m_Rect, m_Texture); } if (!m_Init) { GUILayout.Label("SteamHTMLSurface.Init() returned false"); return; } //SteamHTMLSurface.Init() // N/A - Called in OnEnable //SteamHTMLSurface.Shutdown() // N/A - Called in OnDisable if (GUILayout.Button("CreateBrowser(\"SpaceWars Test\", null)")) { RemoveBrowser(); // Remove an old browser if it exists. SteamAPICall_t handle = SteamHTMLSurface.CreateBrowser("SpaceWars Test", null); OnHTML_BrowserReadyCallResult.Set(handle); print("SteamHTMLSurface.CreateBrowser(" + "\"SpaceWars Test\"" + ", " + null + ") : " + handle); } if (GUILayout.Button("RemoveBrowser(m_HHTMLBrowser)")) { RemoveBrowser(); } m_URL = GUILayout.TextField(m_URL); if (GUILayout.Button("LoadURL(m_HHTMLBrowser, m_URL, null)")) { SteamHTMLSurface.LoadURL(m_HHTMLBrowser, m_URL, null); print("SteamHTMLSurface.LoadURL(" + m_HHTMLBrowser + ", " + m_URL + ", " + null + ")"); } if (GUILayout.Button("SetSize(m_HHTMLBrowser, m_Width, m_Height)")) { m_Width = (uint)Screen.width - WidthOffset; m_Height = (uint)Screen.height - HeightOffset; m_Rect = new Rect(WidthOffset, m_Height + HeightOffset, m_Width, -m_Height); // This flips the viewport since Unity renders textures upside down. m_Texture = null; SteamHTMLSurface.SetSize(m_HHTMLBrowser, m_Width, m_Height); print("SteamHTMLSurface.SetSize(" + m_HHTMLBrowser + ", " + m_Width + ", " + m_Height + ")"); } if (GUILayout.Button("StopLoad(m_HHTMLBrowser)")) { SteamHTMLSurface.StopLoad(m_HHTMLBrowser); print("SteamHTMLSurface.StopLoad(" + m_HHTMLBrowser + ")"); } if (GUILayout.Button("Reload(m_HHTMLBrowser)")) { SteamHTMLSurface.Reload(m_HHTMLBrowser); print("SteamHTMLSurface.Reload(" + m_HHTMLBrowser + ")"); } GUI.enabled = m_CanGoBack; if (GUILayout.Button("GoBack(m_HHTMLBrowser)")) { SteamHTMLSurface.GoBack(m_HHTMLBrowser); print("SteamHTMLSurface.GoBack(" + m_HHTMLBrowser + ")"); } GUI.enabled = m_CanGoForward; if (GUILayout.Button("GoForward(m_HHTMLBrowser)")) { SteamHTMLSurface.GoForward(m_HHTMLBrowser); print("SteamHTMLSurface.GoForward(" + m_HHTMLBrowser + ")"); } GUI.enabled = true; if (GUILayout.Button("AddHeader(m_HHTMLBrowser, \"From\", \"[email protected]\")")) { SteamHTMLSurface.AddHeader(m_HHTMLBrowser, "From", "*****@*****.**"); print("SteamHTMLSurface.AddHeader(" + m_HHTMLBrowser + ", " + "\"From\"" + ", " + "\"[email protected]\"" + ")"); } if (GUILayout.Button("ExecuteJavascript(m_HHTMLBrowser, \"window.alert('Test');\")")) { SteamHTMLSurface.ExecuteJavascript(m_HHTMLBrowser, "window.alert('Test');"); print("SteamHTMLSurface.ExecuteJavascript(" + m_HHTMLBrowser + ", " + "\"window.alert('Test');\"" + ")"); } //SteamHTMLSurface.MouseUp() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.MouseDown() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.MouseDoubleClick() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.MouseMove() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.MouseWheel() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.KeyDown() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.KeyUp() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.KeyChar() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.SetHorizontalScroll() // All interaction calls are dealt with at the end of OnGUI //SteamHTMLSurface.SetVerticalScroll() // All interaction calls are dealt with at the end of OnGUI if (GUILayout.Button("SetKeyFocus(m_HHTMLBrowser, !m_SetKeyFocus)")) { SteamHTMLSurface.SetKeyFocus(m_HHTMLBrowser, !m_SetKeyFocus); print("SteamHTMLSurface.SetKeyFocus(" + m_HHTMLBrowser + ", " + !m_SetKeyFocus + ")"); m_SetKeyFocus = !m_SetKeyFocus; } if (GUILayout.Button("ViewSource(m_HHTMLBrowser)")) { SteamHTMLSurface.ViewSource(m_HHTMLBrowser); print("SteamHTMLSurface.ViewSource(" + m_HHTMLBrowser + ")"); } if (GUILayout.Button("CopyToClipboard(m_HHTMLBrowser)")) { SteamHTMLSurface.CopyToClipboard(m_HHTMLBrowser); print("SteamHTMLSurface.CopyToClipboard(" + m_HHTMLBrowser + ")"); } if (GUILayout.Button("PasteFromClipboard(m_HHTMLBrowser)")) { SteamHTMLSurface.PasteFromClipboard(m_HHTMLBrowser); print("SteamHTMLSurface.PasteFromClipboard(" + m_HHTMLBrowser + ")"); } m_Find = GUILayout.TextField(m_Find); if (GUILayout.Button("Find(m_HHTMLBrowser, m_Find, m_CurrentlyInFind, false)")) { SteamHTMLSurface.Find(m_HHTMLBrowser, m_Find, m_CurrentlyInFind, false); print("SteamHTMLSurface.Find(" + m_HHTMLBrowser + ", " + m_Find + ", " + m_CurrentlyInFind + ", " + false + ")"); m_CurrentlyInFind = true; } if (GUILayout.Button("StopFind(m_HHTMLBrowser)")) { SteamHTMLSurface.StopFind(m_HHTMLBrowser); print("SteamHTMLSurface.StopFind(" + m_HHTMLBrowser + ")"); m_CurrentlyInFind = false; } if (GUILayout.Button("GetLinkAtPosition(m_HHTMLBrowser, (500 - WidthOffset), (120 - HeightOffset))")) { SteamHTMLSurface.GetLinkAtPosition(m_HHTMLBrowser, (500 - WidthOffset), (120 - HeightOffset)); print("SteamHTMLSurface.GetLinkAtPosition(" + m_HHTMLBrowser + ", " + (500 - WidthOffset) + ", " + (120 - HeightOffset) + ")"); } if (GUILayout.Button("SetCookie(m_URL, \"testcookiekey\", \"testcookievalue\")")) { // Use with http://httpbin.org/cookies SteamHTMLSurface.SetCookie(m_URL, "testcookiekey", "testcookievalue"); print("SteamHTMLSurface.SetCookie(" + m_URL + ", " + "\"testcookiekey\"" + ", " + "\"testcookievalue\"" + ")"); } m_ScaleFactor = GUILayout.HorizontalScrollbar(m_ScaleFactor, 0.25f, 0f, 2f); if (GUILayout.Button("SetPageScaleFactor(m_HHTMLBrowser, m_ScaleFactor, 0, 0)")) { SteamHTMLSurface.SetPageScaleFactor(m_HHTMLBrowser, m_ScaleFactor, 0, 0); print("SteamHTMLSurface.SetPageScaleFactor(" + m_HHTMLBrowser + ", " + m_ScaleFactor + ", " + 0 + ", " + 0 + ")"); } if (GUILayout.Button("SetBackgroundMode(m_HHTMLBrowser, m_BackgroundMode)")) { SteamHTMLSurface.SetBackgroundMode(m_HHTMLBrowser, m_BackgroundMode); print("SteamHTMLSurface.SetBackgroundMode(" + m_HHTMLBrowser + ", " + m_BackgroundMode + ")"); m_BackgroundMode = !m_BackgroundMode; } if (GUILayout.Button("SetDPIScalingFactor(m_HHTMLBrowser, 1.0f)")) { SteamHTMLSurface.SetDPIScalingFactor(m_HHTMLBrowser, 1.0f); print("SteamHTMLSurface.SetDPIScalingFactor(" + m_HHTMLBrowser + ", " + 1.0f + ")"); } if (GUILayout.Button("OpenDeveloperTools(m_HHTMLBrowser)")) { SteamHTMLSurface.OpenDeveloperTools(m_HHTMLBrowser); print("SteamHTMLSurface.OpenDeveloperTools(" + m_HHTMLBrowser + ")"); } //SteamHTMLSurface.AllowStartRequest() // ['N/A - You MUST call this in response to a HTML_StartRequest_t callback'] //SteamHTMLSurface.JSDialogResponse() // [' N/A - You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback'] //SteamHTMLSurface.FileLoadDialogResponse() // N/A - You MUST call this in response to a HTML_FileOpenDialog_t callback if (m_HHTMLBrowser == HHTMLBrowser.Invalid) { return; } // We set the moust position before checking for mouse presses just incase the mouse moved in the same OnGUI frame as a mouse press. Event e = Event.current; if (e.mousePosition != m_LastMousePos) { if ((e.mousePosition.x >= WidthOffset && e.mousePosition.x <= m_Width + WidthOffset) && (e.mousePosition.y >= HeightOffset && e.mousePosition.y <= m_Height + HeightOffset)) { m_LastMousePos = e.mousePosition; SteamHTMLSurface.MouseMove(m_HHTMLBrowser, (int)(e.mousePosition.x - WidthOffset), (int)(e.mousePosition.y - HeightOffset)); } } //virtual void MouseDoubleClick( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; //TODO switch (e.type) { case EventType.MouseDown: SteamHTMLSurface.MouseDown(m_HHTMLBrowser, (EHTMLMouseButton)e.button); break; case EventType.MouseUp: SteamHTMLSurface.MouseUp(m_HHTMLBrowser, (EHTMLMouseButton)e.button); break; case EventType.ScrollWheel: SteamHTMLSurface.MouseWheel(m_HHTMLBrowser, (int)(-e.delta.y * 100)); break; case EventType.KeyDown: //print("KeyDown: " + e.keyCode + " - " + (int)e.character + " - " + e.character); EHTMLKeyModifiers modifiers = EHTMLKeyModifiers.k_eHTMLKeyModifier_None; if (e.alt) { modifiers = modifiers | EHTMLKeyModifiers.k_eHTMLKeyModifier_AltDown; } if (e.shift) { modifiers = modifiers | EHTMLKeyModifiers.k_eHTMLKeyModifier_ShiftDown; } if (e.control) { modifiers = modifiers | EHTMLKeyModifiers.k_eHTMLKeyModifier_CtrlDown; } if (e.keyCode != KeyCode.None) { SteamHTMLSurface.KeyDown(m_HHTMLBrowser, (uint)e.keyCode, modifiers); } if (e.character != 0) { SteamHTMLSurface.KeyChar(m_HHTMLBrowser, (uint)e.character, modifiers); } if (e.keyCode == KeyCode.DownArrow) { m_VeritcalScrollCurrent = System.Math.Min(m_VeritcalScrollCurrent + 100, m_VerticalScrollMax); SteamHTMLSurface.SetVerticalScroll(m_HHTMLBrowser, m_VeritcalScrollCurrent); } else if (e.keyCode == KeyCode.UpArrow) { if (m_VeritcalScrollCurrent - 100 > m_VeritcalScrollCurrent) // Underflow { m_VeritcalScrollCurrent = 0; } else { m_VeritcalScrollCurrent -= 100; } SteamHTMLSurface.SetVerticalScroll(m_HHTMLBrowser, m_VeritcalScrollCurrent); } else if (e.keyCode == KeyCode.RightArrow) { m_HorizontalScrollCurrent = System.Math.Min(m_HorizontalScrollCurrent + 100, m_HorizontalScrollMax); SteamHTMLSurface.SetHorizontalScroll(m_HHTMLBrowser, m_HorizontalScrollCurrent); } else if (e.keyCode == KeyCode.LeftArrow) { if (m_HorizontalScrollCurrent - 100 > m_HorizontalScrollCurrent) // Underflow { m_HorizontalScrollCurrent = 0; } else { m_HorizontalScrollCurrent -= 100; } SteamHTMLSurface.SetHorizontalScroll(m_HHTMLBrowser, m_HorizontalScrollCurrent); } break; case EventType.KeyUp: //print("KeyUp: " + e.keyCode + " - " + (int)e.character + " - " + e.character); modifiers = EHTMLKeyModifiers.k_eHTMLKeyModifier_None; if (e.alt) { modifiers = modifiers | EHTMLKeyModifiers.k_eHTMLKeyModifier_AltDown; } if (e.shift) { modifiers = modifiers | EHTMLKeyModifiers.k_eHTMLKeyModifier_ShiftDown; } if (e.control) { modifiers = modifiers | EHTMLKeyModifiers.k_eHTMLKeyModifier_CtrlDown; } if (e.keyCode != KeyCode.None) { SteamHTMLSurface.KeyUp(m_HHTMLBrowser, (uint)e.keyCode, modifiers); } break; } }