Exemplo n.º 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);
            }
        }
    }
Exemplo n.º 2
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");
            PluginMsgReceiver receiver = PluginMsgHandler.getInst().GetReceiver(nSenderId);
            receiver.OnPluginMsgDirect(jsonMsg);
        }
    }
    public int RegisterAndGetReceiverId(PluginMsgReceiver receiver)
    {
        int index = snCurReceiverIdx;

        snCurReceiverIdx++;

        m_dictReceiver[index] = receiver;
        return(index);
    }
Exemplo n.º 4
0
 public static PluginMsgHandler GetInstanceForReceiver(PluginMsgReceiver receiver)
 {
     if (_instance == null)
     {
         GameObject handlerObject = new GameObject(DEFAULT_NAME);
         _instance = handlerObject.AddComponent <PluginMsgHandler>();
     }
     return(_instance);
 }
Exemplo n.º 5
0
    public int RegisterAndGetReceiverId(PluginMsgReceiver receiver)
    {
        if (receiver == null)
        {
            throw new ArgumentNullException("MonoNativeEditBox: Receiver cannot be null while RegisterAndGetReceiverId!");
        }

        int index = _curReceiverIndex;

        _curReceiverIndex++;

        _receiverDict[index] = receiver;
        return(index);
    }
Exemplo n.º 6
0
    private void OnMsgFromPlugin(string jsonPluginMsg)
    {
        if (jsonPluginMsg == null)
        {
            return;
        }

        JsonObject jsonMsg = new JsonObject(jsonPluginMsg);

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

        int nSenderId = jsonMsg.GetInt("senderId");

        // In some cases the receiver might be already removed, for example if a button is pressed
        // that will destroy 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 (_receiverDict.ContainsKey(nSenderId))
        {
            PluginMsgReceiver receiver = GetReceiver(nSenderId);
            receiver.OnPluginMsgDirect(jsonMsg);
        }
    }
Exemplo n.º 7
0
    public int RegisterAndGetReceiverId(PluginMsgReceiver receiver)
    {
        snCurReceiverIdx++;

        m_dictReceiver[snCurReceiverIdx] = receiver;
        return snCurReceiverIdx;
    }