// we will cache view controllers for fixed orientation // auto-rotation view contoller goes to index=0 //UnityViewControllerBase* _viewControllerForOrientation[5]; UIViewController* _viewControllerForOrientation[5];
Scene 'S0' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
To add a scene to the build settings use the menu File->Build Settings...
UnityEngine.SceneManagement.SceneManager:LoadScene(String)
ButtonClickedAction:LoadMathGameS0() (at Assets/Scripts/ButtonClickedAction.cs:62)
UnityEngine.EventSystems.EventSystem:Update()
该问题由未选择场景导致,解决操作如下:
Assets中找到对应的场景(这里是S0)
选择菜单栏的File -> Build Setting...
将场景拖动到对话框的Scenes In Build中
导入unitypackage后文件重复
Assets/MathGame/Scripts/GameManager.cs(10,14): error CS0101: The namespace `global::' already contains a definition for `GameManager'
Assets/MathGame/Scripts/SoundManager.cs(4,14): error CS0101: The namespace `global::' already contains a definition for `SoundManager'
文件名冲突,解决:
让提供者修改文件名和Class名
交互封装
Unity调用原生
注:也可将第二部分内容合并到第四部分中,并将 .m 改为 .mm 即可
第一部分:Unity声名外部方法
这是 C# JavaScript ,也可使用 JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; using System.Runtime.InteropServices; //1.添加InteropServices publicclassButtonClickedAction : MonoBehaviour { //2.声名外部方法(iOS方法) [DllImport("__Internal")] //注意没有分号 externstaticpublicvoidunitySendMessageShowNativeWindow(string str ); // Use this for initialization voidStart () { Debug.Log ("ButtonClickedAction Start"); } ......