1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.UI;
public class GameMgr : MonoBehaviour { public Text txt; public GameObject go;
void Start() { gameObject.name = "GameMgr"; DontDestroyOnLoad(gameObject); }
public void OnNativeCall(string data) { Debug.LogFormat("--- OnNativeCall, data: {0}", data); txt.text = data; }
public void CallNative() { string msg = "hello ios-" + Random.Range(1000, 9999); #if UNITY_IPHONE || UNITY_IOS ShowTips(gameObject.name, "OnNativeCall", msg); #else Debug.LogErrorFormat("--- no implemention on platform: {0}", Application.platform.ToString()); #endif }
void Update() { go.transform.Rotate(Vector3.up * 50 * Time.deltaTime); }
#if UNITY_IPHONE || UNITY_IOS [DllImport("__Internal")] private static extern void ShowTips(string goName, string callFnName, string msg); #endif }
|