private static void Invoke(string f, params object[] arr)
        {
            var bridge = BridgeBootstrapper.GetUWPBridge();

            //bridge = BridgeBootstrapper.GetUnityBridge();
            if (null == bridge)
            {
                Debug.Log("ERROR! UWPBridge is null");
                return;
            }
            JSONObject objP = new JSONObject(JSONObject.Type.ARRAY);

            foreach (var item in arr)
            {
                string s = item as string;
                if (null != s)
                {
                    objP.Add(s);
                }
                else if (IsNumber(item))
                {
                    objP.Add(Convert.ToInt32(item));
                }
                else if (item is bool)
                {
                    objP.Add(Convert.ToInt32((bool)item));
                }
            }
            JSONObject obj = new JSONObject(JSONObject.Type.OBJECT);

            obj.AddField("f", f);
            obj.AddField("p", objP);
            bridge.Send(obj.ToString());
        }
예제 #2
0
 public void PostMessage(string gameObject, string methodName, string message)
 {
     this.appCallbacks.InvokeOnAppThread(() =>
     {
         BridgeBootstrapper.GetIL2CPPBridge()?.onMessage(gameObject, methodName, message);
     }, false);
 }
예제 #3
0
 public UnityPlayer(AppCallbacks appCallbacks)
 {
     this.appCallbacks = appCallbacks;
     this.appCallbacks.InvokeOnAppThread(() =>
     {
         BridgeBootstrapper.SetDotNetBridge(this);
     }, true);
 }
        /// <summary>
        /// <para> init AdDeals SDK</para>
        /// </summary>
        /// <param name="appID">appID</param>
        /// <param name="appKey">appKey</param>
        public static void Init(String appID, String appKey)
        {
            if (hasInit)
            {
                RunInUnityMainThread(() =>
                {
                    AdManagerInitSDKFailed.Invoke("AdDeals just need init once");
                });
                return;
            }
            BridgeBootstrapper.SetUnityBridge(new UnityBridge());

            Invoke("Init", appID, appKey);
            hasInit = true;
        }
예제 #5
0
        public void Quit()
        {
            var tmp = this.appCallbacks;

            this.appCallbacks = null;

            if (tmp != null)
            {
                tmp.InvokeOnAppThread(() =>
                {
                    BridgeBootstrapper.SetDotNetBridge(null);
                }, true);

                tmp.Dispose();
            }
        }