有没有办法在 Airconsole 对象上切换 HTML 控制器?
Is there way to switch the HTML controller on the Airconsole object?
问题:
当我切换到另一个 scene.unity 文件时,我想将 controller.html 更改为 myNewController.html。
示例:
我在同一个项目中有 2 个迷你游戏。我正在玩 GAME_1 和 controller.html,我已经完成了 GAME_1 的目标,它会切换到 GAME_2,这将需要我使用不同的控制器布局,因此 myNewController.html.
我所知道的:
当场景切换时,它立即将 GAME_1 的 Airconsole 对象扔进 GAME_2 并继续使用 GAME_1 的 controller.html 文件。
代码片段:
此脚本附加了我创建的 AirConsole 对象
public class What_Level : MonoBehaviour {
AirConsole 控制台;
// Use this for initialization
void Start () {
console = GetComponent<AirConsole> ();
}
// Update is called once per frame
void Update () {
whatScene (Application.loadedLevel);
}
void whatScene(int levelNumber){
if (levelNumber == 1) {
Debug.Log ("Were in the GAME_1);
//use some code to change the HTML file for GAME_1
} else if (levelNumber == 2) {
Debug.Log("We're in GAME_2");
//use some code to change the HTML file for GAME_2
}
}
}
变量"console"唯一有意义的函数是console.controllerHtml。它在 "public Object controllerHtml"
中给出的描述
任何提示或提示将不胜感激and/or我在 AirConsole 变量上使用的选项的参考页面将不胜感激"console"。
谢谢!
关于更改控制器布局。不改变文件,只改变controller.html
中显示的内容
例如您可以为每个要显示的游戏手柄制作一个容器元素。然后在所有控制器应该更改容器的可见性时向所有控制器广播消息。
例如在你的 controller.html:
<div id="gamepad-1">Controller 1 stuff here ...</div>
<div id="gamepad-2">Controller 2 stuff here ...</div>
在javascript(也controller.html)
var container_1 = document.getElementById('gamepad-1');
var container_2 = document.getElementById('gamepad-2');
// Show or hide containers like (general function would be better :)
container_2.style.display = 'none';
container_1.style.display = 'block';
现在您只需要让您的控制器知道何时 show/hide 哪个容器。您可以通过监听 onDeviceStateChange 事件来做到这一点。
问题: 当我切换到另一个 scene.unity 文件时,我想将 controller.html 更改为 myNewController.html。
示例: 我在同一个项目中有 2 个迷你游戏。我正在玩 GAME_1 和 controller.html,我已经完成了 GAME_1 的目标,它会切换到 GAME_2,这将需要我使用不同的控制器布局,因此 myNewController.html.
我所知道的: 当场景切换时,它立即将 GAME_1 的 Airconsole 对象扔进 GAME_2 并继续使用 GAME_1 的 controller.html 文件。
代码片段: 此脚本附加了我创建的 AirConsole 对象
public class What_Level : MonoBehaviour { AirConsole 控制台;
// Use this for initialization
void Start () {
console = GetComponent<AirConsole> ();
}
// Update is called once per frame
void Update () {
whatScene (Application.loadedLevel);
}
void whatScene(int levelNumber){
if (levelNumber == 1) {
Debug.Log ("Were in the GAME_1);
//use some code to change the HTML file for GAME_1
} else if (levelNumber == 2) {
Debug.Log("We're in GAME_2");
//use some code to change the HTML file for GAME_2
}
}
}
变量"console"唯一有意义的函数是console.controllerHtml。它在 "public Object controllerHtml"
中给出的描述任何提示或提示将不胜感激and/or我在 AirConsole 变量上使用的选项的参考页面将不胜感激"console"。
谢谢!
关于更改控制器布局。不改变文件,只改变controller.html
中显示的内容例如您可以为每个要显示的游戏手柄制作一个容器元素。然后在所有控制器应该更改容器的可见性时向所有控制器广播消息。
例如在你的 controller.html:
<div id="gamepad-1">Controller 1 stuff here ...</div>
<div id="gamepad-2">Controller 2 stuff here ...</div>
在javascript(也controller.html)
var container_1 = document.getElementById('gamepad-1');
var container_2 = document.getElementById('gamepad-2');
// Show or hide containers like (general function would be better :)
container_2.style.display = 'none';
container_1.style.display = 'block';
现在您只需要让您的控制器知道何时 show/hide 哪个容器。您可以通过监听 onDeviceStateChange 事件来做到这一点。