void CreateNewPanelGUI(int width, int height, string initUrl) { Hide(); Destroy(guiPanel); guiPanel = null; guiPanel = this.gameObject.AddComponent(typeof(HTMLPanelGUI)) as HTMLPanelGUI; guiPanel.width = width; guiPanel.height = height; guiPanel.initUrl = initUrl; guiPanel.useTransparentMaterial = false; guiPanel.browserId = CollabBrowserId.OVERLAYBROWSER; browserTextureInitialized = false; }
void CreateNewPanelGUI(int width, int height, string initUrl) { Hide(); guiPanel = this.gameObject.AddComponent(typeof(HTMLPanelGUI)) as HTMLPanelGUI; guiPanel.width = width; guiPanel.height = height; guiPanel.initUrl = initUrl; guiPanel.useTransparentMaterial = false; guiPanel.browserId = CollabBrowserId.PRIVATEBROWSER; browserTextureInitialized = false; guiPanel.RegisterNotificationCallback("Send_Guilayer", delegate(JSValue[] args) { if (args.Length > 1) { GameGUI.Inst.ExecuteJavascriptOnGui(args[1].ToString()); } }); }
// Use this for initialization void Start() { htmlPanel = this.gameObject.AddComponent(typeof(HTMLPanelGUI)) as HTMLPanelGUI; htmlPanel.width = Screen.width; htmlPanel.height = Screen.height; htmlPanel.RegisterNotificationCallback("InitComplete", delegate(JSValue[] args) { VDebug.LogError("Loading complete: " + (DateTime.Now - startLoadHTMLTime).TotalSeconds); if (loading) { Debug.LogError("JavaScript Execution started BEFORE awesomium finished loading page!!"); loading = false; } if (!skipLogin && GameManager.Inst.LevelLoaded == GameManager.Level.CONNECT) { System.Version currClientVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Debug.LogError("Client version: " + currClientVersion.ToString() + " req: " + CommunicationManager.clientVersionRequirement); if (CommunicationManager.clientVersionRequirement == "") { // no version requirement specified, hand control to the guilayer. WebHelper.ClearCache = true; HandleClientVersion(currClientVersion.ToString()); return; } System.Version clientReq = new System.Version(CommunicationManager.clientVersionRequirement); if (currClientVersion >= clientReq) { AttemptLogin(); } else { ExecuteJavascriptWithValue(SetGUIVersionJSCmd() + SetBuildTypeCmd() + SetConfigCmd() + "showUpdateDialog();"); } } else { Debug.LogError((skipLogin) ? "Login screen skipped" : "GUI Layer has been reloaded in another scene!"); skipLogin = false; } }); htmlPanel.RegisterNotificationCallback("Authentication_Success", delegate(JSValue[] args) { GameGUI.Inst.fadeOut = true; loginArgs = args[1].ToString(); loggingIn = true; }); htmlPanel.RegisterNotificationCallback("MouseUp_MouseClick", delegate(JSValue[] args) { string json = args[1].ToString(); VDebug.Log("mouseup fields: " + json); GameObject hitObject = MouseHelpers.GetCurrentGameObjectHit(); if (hitObject != null) { if (GameManager.Inst.LocalPlayer.gameObject == hitObject) { string cmd = "OnLocalPlayerClick(" + json + ");"; ExecuteJavascript(cmd); } else { PlayerController playerController = hitObject.GetComponent <PlayerController>(); if (playerController != null) { Player p = playerController.playerScript; string cmd = "OnPlayerClick(" + p.Id + ", " + p.Name + ", " + json + ");"; ExecuteJavascript(cmd); } WebPanel webPanel = hitObject.GetComponent <WebPanel>(); if (webPanel != null) { string cmd = "OnWebPanelClick(" + webPanel.browserTexture.id + ", " + json + ");"; ExecuteJavascript(cmd); } //string go = hitObject.name;// +hitObject.GetInstanceID(); //Debug.Log("We clicked something: " + go); //string cmd = "OnUnityObjectClick('" + go + "', " + json + ");"; ////Debug.Log(cmd); //ExecuteJavaScript(cmd); } } }); htmlPanel.RegisterNotificationCallback("Out_UnityDebugLog", delegate(JSValue[] args) { string json = args[1].ToString(); JSONObject jsonObject = JSONObject.Parse(json); string msg = jsonObject.GetString("msg"); Debug.Log("Out_UnitDebugLog: " + msg); }); htmlPanel.RegisterNotificationCallback("Clicked_QuitButton", delegate(JSValue[] args) { Application.Quit(); }); htmlPanel.RegisterNotificationCallback("Closed_DialogWindow", delegate(JSValue[] args) { AnnouncementManager.Inst.AnnouncementClosed(); }); htmlPanel.RegisterNotificationCallback("Clicked_AvatarButton", delegate(JSValue[] args) { GameManager.Inst.LoadLevel(GameManager.Level.AVATARSELECT); }); htmlPanel.RegisterNotificationCallback("Clicked_ToggleVoice", delegate(JSValue[] args) { VoiceManager.Inst.ToggleToTalk = !VoiceManager.Inst.ToggleToTalk; }); htmlPanel.RegisterNotificationCallback("VoicePush", delegate(JSValue[] args) { VoiceManager.Inst.PushToTalkButtonDown = args[1].ToBoolean(); }); htmlPanel.RegisterNotificationCallback("Clicked_RefreshAll", delegate(JSValue[] args) { if (GameManager.Inst.LevelLoaded == GameManager.Level.BIZSIM) { BizSimManager.Inst.ReloadAll(); } }); htmlPanel.RegisterNotificationCallback("Update_UserList", delegate(JSValue[] args) { GameGUI.Inst.userListMgr.RebuildHTMLUserList(); }); htmlPanel.RegisterNotificationCallback("Update_Timer", delegate(JSValue[] args) { UpdateTimer(); }); htmlPanel.RegisterNotificationCallback("Update_VoiceToggle", delegate(JSValue[] args) { // ask unity if the voice is toggled on or off InitVoiceToggle(); }); htmlPanel.RegisterNotificationCallback("Play_ButtonClickSound", delegate(JSValue[] args) { SoundManager.Inst.PlayClick(); }); htmlPanel.RegisterNotificationCallback("Clicked_LogoutButton", delegate(JSValue[] args) { CommunicationManager.Inst.LogOut(); }); // Tooltips htmlPanel.RegisterNotificationCallback("Set_Tooltip", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to change fixed tooltip, but didn't find an argument."); return; } GameGUI.Inst.SetFixedTooltip(args[1].ToString()); }); htmlPanel.RegisterNotificationCallback("Clear_Tooltip", delegate(JSValue[] args) { GameGUI.Inst.ClearFixedTooltip(); GameGUI.Inst.tooltipAvoidRect = new Rect(0, 0, 0, 0); // clear avoidance rectangle }); htmlPanel.RegisterNotificationCallback("Set_TooltipAvoidRect", delegate(JSValue[] args) { if (args.Length <= 4) { Debug.LogError("attempting to change fixed tooltip avoidance rectangle, but didn't find enough arguments."); return; } GameGUI.Inst.tooltipAvoidRect = new Rect(int.Parse(args[1].ToString()), int.Parse(args[2].ToString()), int.Parse(args[3].ToString()), int.Parse(args[4].ToString())); }); // Microphone selection menu htmlPanel.RegisterNotificationCallback("Open_Mic_Menu", delegate(JSValue[] args) { VoiceManager.Instance.micSelectMenuOpen = true; }); htmlPanel.RegisterNotificationCallback("Close_Mic_Menu", delegate(JSValue[] args) { VoiceManager.Instance.micSelectMenuOpen = false; }); htmlPanel.RegisterNotificationCallback("Toggle_Mic_Menu", delegate(JSValue[] args) { VoiceManager.Instance.micSelectMenuOpen = !VoiceManager.Instance.micSelectMenuOpen; }); // Seed console with text and move cursor to the front of the input. htmlPanel.RegisterNotificationCallback("Seed_Console", delegate(JSValue[] args) { if (args.Length <= 1) { GameGUI.Inst.consoleGui.SeedConsole(""); return; } GameGUI.Inst.consoleGui.SeedConsole(args[1].ToString()); }); htmlPanel.RegisterNotificationCallback("Issue_ConsoleCmd", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to issue console command, but didn't find an argument."); return; } ConsoleInterpreter.Inst.ProcCommand(args[1].ToString()); }); htmlPanel.RegisterNotificationCallback("Issue_FacConsoleCmd", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to issue console command, but didn't find an argument."); return; } ConsoleInterpreter.Inst.ProcCommand(args[1].ToString(), PlayerType.LEADER); }); htmlPanel.RegisterNotificationCallback("Write_ToConsole", delegate(JSValue[] args) { string msg = (args.Length <= 1) ? "" : args[1].ToString(); GameGUI.Inst.WriteToConsoleLog(msg); }); htmlPanel.RegisterNotificationCallback("Open_Browser", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("no url specified for Open_Browser command."); } OpenInExternalBrowser(args[1].ToString()); }); htmlPanel.RegisterNotificationCallback("Click_AvatarChangeCharacter", delegate(JSValue[] args) { if (args.Length < 2) { Debug.LogError("no url specified for Open_Browser command."); return; } int modelIdx; if (!int.TryParse(args[1].ToString(), out modelIdx)) { Debug.LogError(args[1] + " not a valid int"); return; } GameGUI.Inst.customizeAvatarGui.ChangeCharacter(modelIdx); }); htmlPanel.RegisterNotificationCallback("Click_AvatarOption", delegate(JSValue[] args) { if (args.Length < 3) { Debug.LogError("Click_AvatarOption - not enough arguments: elementName, newIndex " + args.Length); return; } int optionIdx; if (!int.TryParse(args[2].ToString(), out optionIdx)) { Debug.LogError(args[2] + " not a valid int"); return; } GameGUI.Inst.customizeAvatarGui.ChangeElement(args[1].ToString(), optionIdx); }); htmlPanel.RegisterNotificationCallback("Click_AvatarRotate", delegate(JSValue[] args) { if (args.Length < 3) { Debug.LogError("Click_AvatarRotate - not enough arguments: is_left, is_down"); return; } GameGUI.Inst.customizeAvatarGui.HandleRotateBtn(args[1].ToBoolean()); GameGUI.Inst.customizeAvatarGui.HandleRotateDown(args[2].ToBoolean()); }); htmlPanel.RegisterNotificationCallback("Click_AvatarDone", delegate(JSValue[] args) { bool save = true; if (args.Length > 1) { save = args[1].ToBoolean(); } GameGUI.Inst.customizeAvatarGui.HandleDoneBtn(save); }); htmlPanel.RegisterNotificationCallback("Confirm_Action", delegate(JSValue[] args) { string action = (args.Length > 1) ? args[1].ToString() : ""; if (GameManager.Inst.LevelLoaded == GameManager.Level.BIZSIM) { BizSimManager.Inst.HandleAction(action); } }); htmlPanel.RegisterNotificationCallback("Send_SFSRequest", delegate(JSValue[] args) { if (args.Length < 2) { Debug.LogError("Not enough arguments for Send_SFSRequest"); return; } string msg = (args.Length > 2) ? args[2].ToString() : ""; ISFSObject msgObj = new SFSObject(); msgObj.PutUtfString("msg", msg); ExtensionRequest request = new ExtensionRequest(args[1].ToString(), msgObj); CommunicationManager.SendMsg(request); }); htmlPanel.RegisterNotificationCallback("Set_InputFocus", delegate(JSValue[] args) { if (args.Length < 2) { Debug.LogError("Set_InputFocus needs true/false argument"); return; } hasInputFocus = args[1].ToString() == "true"; }); htmlPanel.RegisterNotificationCallback("Toggle_ClickOffElement", delegate(JSValue[] args) { if (args.Length < 2) { Debug.LogError("Toggle_ClickOffElement needs true/false argument"); return; } clickOffElementOpen = args[1].ToString() == "true"; }); htmlPanel.RegisterNotificationCallback("Overlay_URL", delegate(JSValue[] args) { if (args.Length < 2) { Debug.LogError("Overlay_URL needs url"); return; } string url = args[1].ToString(); int width = (args.Length > 2) ? args[2].ToInteger() : (int)(0.75f * Screen.width); int height = (args.Length > 3) ? args[3].ToInteger() : (int)(0.75f * Screen.height); GameManager.Inst.OverlayMgr.SetURL(url, width, height); }); htmlPanel.RegisterNotificationCallback("Scale_PresentTool", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to scale present tool, but didn't find an argument."); return; } GameGUI.Inst.presentToolScale = (float)args[1].ToDouble(); }); htmlPanel.RegisterNotificationCallback("Set_GameGUIGutter", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to set game gui gutter, but didn't find an argument."); return; } GameGUI.Inst.gutter = args[1].ToInteger(); }); htmlPanel.RegisterNotificationCallback("Hide_PresentUI", delegate(JSValue[] args) { GameGUI.Inst.showPresentToolButtons = false; }); htmlPanel.RegisterNotificationCallback("Open_FileDialog", delegate(JSValue[] args) { string file = NativePanels.OpenFileDialog(null); string cmd = "handleOpenFile(\"" + file + "\");"; ExecuteJavascript(cmd); }); htmlPanel.RegisterNotificationCallback("Set_Clipboard", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to set clipboard, but didn't find an argument."); return; } ClipboardHelper.Clipboard = args[1].ToString(); }); htmlPanel.RegisterNotificationCallback("Set_GUIVisibility", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to set gui visibility, but didn't find an argument."); return; } GameGUI.Inst.VisibilityFlags = args[1].ToInteger(); }); htmlPanel.RegisterNotificationCallback("Update_TutorialCode", delegate(JSValue[] args) { if (args.Length <= 1) { Debug.LogError("attempting to update tutorial code, but didn't find an argument."); return; } CommunicationManager.CurrentUserProfile.UpdateTutorial(args[1].ToInteger()); }); htmlPanel.RegisterNotificationCallback("Request_AvatarOptions", SendGuiLayerAvatarOptions); htmlPanel.RegisterNotificationCallback("Request_GameIds", SendGuiLayerNumGames); htmlPanel.RegisterNotificationCallback("Request_TeamInfo", SendGuiLayerTeamInfo); htmlPanel.RegisterNotificationCallback("Request_MicInfo", SendGuiLayerMicInfo); htmlPanel.RegisterNotificationCallback("Request_TeacherClassInfo", SendGuiLayerTeamTeacherClass); htmlPanel.RegisterNotificationCallback("Request_PanelTitle", SendGuiLayerPanelTitle); htmlPanel.RegisterNotificationCallback("Request_PanelURL", SendGuiLayerPanelURL); htmlPanel.RegisterNotificationCallback("Request_PanelSelection", SendGuiLayerPanelSelection); htmlPanel.RegisterNotificationCallback("Request_GetClipboard", SendGuiLayerClipboard); htmlPanel.RegisterNotificationCallback("Request_GUIVisibility", SendGuiLayerGUIVisibility); htmlPanel.RegisterNotificationCallback("Request_PlayerInfo", SendGuiLayerPlayerInfo); htmlPanel.RegisterNotificationCallback("Request_WorkingDir", SendGuiLayerWorkingDir); htmlPanel.RegisterNotificationCallback("Request_ReplayUpdate", SendGuiLayerReplayPosInfo); htmlPanel.RegisterNotificationCallback("Request_TutorialCode", SendGuiLayerTutorialCode); htmlPanel.RegisterNotificationCallback("Request_HardwareInfo", SendGuiLayerHardwareInfo); #if PATCHER_ENABLE //startingFile = GameManager.Inst.guipatcher.path + startingFile; Debug.LogError("HTMLGuiLayer - starting file: " + startingFile); #endif }
public void Hide() { SetActive(false); Destroy(guiPanel); guiPanel = null; }