// Canvas間の依存関係を解消するための試みのひとつ(あるCanvasをCanvasListから削除してもエラーにならない. 部品としての独立性) // 一つのCanvasファイルに付き一つのコントローラーまでで他のレイヤーのコンポーネントにはhsLayerGetでアクセスするようにする component HUDController { public HUDController() { string ParamXShare = hsWebGetQueryParam("xshare"); bool IsXShare = (ParamXShare == "1"); hsCanvasResetToggleDefault("Toggle_X_Share"); if(IsXShare) { hsCanvasToggleChange("Toggle_X_Share"); // 移動できなくなるのでクリック移動を強制的に有効にする hsPlayerSetClickToMoveEnabled(true); hsCanvasResetToggleDefault("SettingSystem_ClickToMove_Enable_Disable"); // XShareで開いた時スマホならmain.htmlにリダイレクトする if(hel_isMobile()) { RedirectToMain(); } } } public void OnCloseLayer(string LayerName, bool IsPortrait){ if(LayerName == "HUD") { hsCanvasResetToggleDefault("Toggle_HUD_Open_Close"); hsCanvasToggleChange("Toggle_HUD_Open_Close"); } } public void OnClickedButton(string LayerName, string ButtonName) { if(LayerName == "HUD" || LayerName == "mainmenu_webxr" || LayerName == "mainmenu_side_home_webxr") { if(ButtonName == "hud_cart") // EC { LayerBundle layer = hsLayerGet("ec_window_cart_base"); if(layer !== null) { layer.CallComponentMethod("ECViewModel", "ShowCartWindow", ""); } } else if(ButtonName == "hud_voicechat_arrow_down") { { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "ClickArrowDown", ""); } } // TC if(hsCanvasIsPortrait()) { LayerBundle layer = hsLayerGet("textchat_common"); if(layer === null) return; layer.CallComponentMethod("TCViewModel", "CloseTextChat", ""); } } else if(ButtonName == "hud_voicechat_arrow_up") { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "ClickArrowUp", ""); } } else if(ButtonName == "hud_voicechat_arrow_right") { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "OpenChannelList", ""); } } else if(ButtonName == "hud_voicechat_arrow_down_conference_audience") { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "OpenUserListConference", ""); } } else if(ButtonName == "hud_voicechat_arrow_up_conference_audience") { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "CloseUserListConference", ""); } } else if(ButtonName == "hud_voicechat_arrow_down_conference_host") { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "OpenUserListConference", ""); } } else if(ButtonName == "hud_voicechat_arrow_up_conference_host") { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "CloseUserListConference", ""); } } else if(ButtonName == "hud_camera" || ButtonName == "hud_config" || ButtonName == "hud_mainmenu" || ButtonName == "hud_textchatinput") { // VCC { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer !== null) { layer.CallComponentMethod("VCCViewModel", "ClearAllVCCLayer", ""); } } // TC { LayerBundle layer = hsLayerGet("textchat_common"); if(layer !== null) { layer.CallComponentMethod("TCViewModel", "CloseTextChat", ""); } } } else if(ButtonName == "hud_open_textchat") { // TextChat { LayerBundle layer = hsLayerGet("textchat_common"); if(layer !== null) { layer.CallComponentMethod("TCViewModel", "OpenGlobalTextChat", ""); } } // VCC if(hsCanvasIsPortrait()) { LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if(layer === null) return; layer.CallComponentMethod("VCCViewModel", "ClearAllVCCLayer", ""); } } else if(ButtonName == "hud_open_textchat_on") { // TextChat { LayerBundle layer = hsLayerGet("textchat_common"); if(layer !== null) { layer.CallComponentMethod("TCViewModel", "CloseTextChat", ""); } } } else if(ButtonName == "hud_window_mode_01" || ButtonName == "hud_window_mode_02") { LayerBundle layer = hsLayerGet("genericwindow_common_middle"); if(layer !== null) { layer.CallComponentMethod("GenericWindowViewModel", "OnClickedOpenIcon", ""); } } else if(ButtonName == "hud_btn_open_window") { JsVal val = heliport.v3.api.routers.getCurrentUrl(); ReturnType result = hsLoadReturnType(val); if(!result.IsValid()) return; string CurrentUrl = result.data.GetStr(); list urlArray = CurrentUrl.Split("/"); // クエリパラメーターを取得 string ParamWorldId = hsWebGetQueryParam("worldid"); string ParamRoomId = hsWebGetQueryParam("roomid"); string ParamMulti = hsWebGetQueryParam("multi"); // 共有URLを構築 string sharedURL; sharedURL += urlArray[0] + "//"; // https:// // sharedURL += urlArray[1]; // 空文字 for(int i = 2; i < urlArray.Count - 1; i++) { sharedURL += urlArray[i] + "/"; } sharedURL += "main.html"; sharedURL += "?" + "worldid=%s" % ParamWorldId + "&roomid=%s" % ParamRoomId + "&multi=%s" % ParamMulti; // クエリパラメーター hsWebOpen(sharedURL); } } } void RedirectToMain() { JsVal val = heliport.v3.api.routers.getCurrentUrl(); ReturnType result = hsLoadReturnType(val); if(!result.IsValid()) return; string CurrentUrl = result.data.GetStr(); list urlArray = CurrentUrl.Split("/"); // クエリパラメーターを取得 string ParamWorldId = hsWebGetQueryParam("worldid"); string ParamRoomId = hsWebGetQueryParam("roomid"); string ParamMulti = hsWebGetQueryParam("multi"); // 共有URLを構築 string sharedURL; sharedURL += urlArray[0] + "//"; // https:// // sharedURL += urlArray[1]; // 空文字 for(int i = 2; i < urlArray.Count - 1; i++) { sharedURL += urlArray[i] + "/"; } sharedURL += "main.html"; sharedURL += "?" + "worldid=%s" % ParamWorldId + "&roomid=%s" % ParamRoomId + "&multi=%s" % ParamMulti; // クエリパラメーター hel_transitionToPage(sharedURL); } }