问题: 我想将controller.html更改为myNewController.html,当我切换到另一个scene.unity文件时。有没有办法切换Airconsole对象上的HTML控制器?
例如: 我在同一个项目中有2个迷你游戏。我正在使用controller.html来玩GAME_1,并且我完成了GAME_1的目标,并将其切换到GAME_2,这将要求我使用不同的控制器布局,因此myNewController.html。
我所知道的: 当场景切换时立即将GAME_1的Airconsole对象放入GAME_2并继续使用GAME_1的controller.html文件。
片断代码: 此脚本连接,我创建了
对象AirConsole公共类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.controllerHtml。它在“公共对象controllerHtml”中给出的说明
任何提示或提示都将不胜感激,并且/或者我在AirConsole变量“控制台”上使用的选项的参考页将不胜感激。
谢谢!
我对Airconsole仍然很陌生,所以非常感谢您的深刻反响。我明白到最后一部分: 现在你只需要让你的控制器知道什么时候显示/隐藏哪个容器。你可以通过onMessage或者监听onDeviceStateChange事件来做到这一点 你是指的是controller.html文件中的onMessage还是pong游戏中的逻辑c-sharp文件(https://github.com/AirConsole/asolesole-团结-插件/斑点/主/资产/ AirConsole /示例/乓/ ExamplePongLogic.cs)。 我可以不让,让开始按钮说,切换?或者这会导致问题? – yeungninja
基本上都是这样。您的游戏(统一代码)需要告诉控制器何时显示哪个container-div。这意味着您可以例如统一使用.setCustomDeviceState({container:“gamepad-1”}),然后在您的控制器中使用onDeviceStateChange()侦听并检查自定义数据。我目前正在建造s.t.用于处理视图(尚未完成100%):github。com/AirConsole/airconsole-view-manager,但它可以帮助你,如果你看看代码:) – Zeus
谢谢!我一定会研究它,以便彻底理解Unity与controller.html之间的交流情况。我们会在几天内看到我的表现:) – yeungninja