Exemple #1
0
        private void OnMsgFromPlugin(string jsonPluginMsg)
        {
            if (jsonPluginMsg == null)
            {
                return;
            }

            JsonObject jsonMsg = new JsonObject(jsonPluginMsg);

            string msg = jsonMsg.GetString("msg");

            if (msg.Equals(MSG_SHOW_KEYBOARD))
            {
                bool bShow      = jsonMsg.GetBool("show");
                int  nKeyHeight = (int)(jsonMsg.GetFloat("keyheight") * (float)Screen.height);
                //FileLog(string.Format("keyshow {0} height {1}", bShow, nKeyHeight));
                if (OnShowKeyboard != null)
                {
                    OnShowKeyboard(bShow, nKeyHeight);
                }
            }
            else
            {
                int nSenderId = jsonMsg.GetInt("senderId");

                // In some cases the receiver might be already removed, for example if a button is pressed
                // that will destoy the receiver while the input field is focused an end editing message
                // will be sent from the plugin after the receiver is already destroyed on Unity side.
                if (m_dictReceiver.ContainsKey(nSenderId))
                {
                    PluginMsgReceiver receiver = PluginMsgHandler.getInst().GetReceiver(nSenderId);
                    receiver.OnPluginMsgDirect(jsonMsg);
                }
            }
        }
Exemple #2
0
        private bool CheckErrorJsonRet(JsonObject jsonRet)
        {
            bool   bError   = jsonRet.GetBool("bError");
            string strError = jsonRet.GetString("strError");

            if (bError)
            {
                PluginMsgHandler.getInst().FileLogError(string.Format("NativeEditbox error {0}", strError));
            }
            return(bError);
        }
Exemple #3
0
 public override void OnPluginMsgDirect(JsonObject jsonMsg)
 {
     PluginMsgHandler.getInst().StartCoroutine(PluginsMessageRoutine(jsonMsg));
 }
Exemple #4
0
 protected virtual void Start()
 {
     nReceiverId = PluginMsgHandler.getInst().RegisterAndGetReceiverId(this);
 }
Exemple #5
0
 protected JsonObject SendPluginMsg(JsonObject jsonMsg)
 {
     return(PluginMsgHandler.getInst().SendMsgToPlugin(nReceiverId, jsonMsg));
 }
Exemple #6
0
 protected virtual void OnDestroy()
 {
     PluginMsgHandler.getInst().RemoveReceiver(nReceiverId);
 }