| | |
| | | |
| | | import com.secondworld.sdk.command.CmdInit; |
| | | import com.secondworld.sdk.command.ICommand; |
| | | import com.secondworld.sdk.utils.CodeA2U; |
| | | import com.secondworld.sdk.utils.LogUtil; |
| | | import com.secondworld.sdk.utils.StaticDefine; |
| | | import com.unity3d.player.UnityPlayer; |
| | |
| | | int code = _json.getInt("code"); |
| | | ICommand command = allCommand.get(code); |
| | | if (command == null) |
| | | LogUtil.w("onUnityMessage", "未知命令" + code); |
| | | LogUtil.e("onUnityMessage", "未知命令" + code); |
| | | else |
| | | command.process(_json); |
| | | } catch (Exception e) { |
| | |
| | | return classNameList; |
| | | } |
| | | |
| | | public static void sendMessageToUnity(int code) { |
| | | UnityMsgHandler.sendMessageToUnity(code,null); |
| | | } |
| | | |
| | | /** |
| | | * 发送消息到unity |
| | | * |
| | | * @param jsonMap |
| | | * @param args |
| | | */ |
| | | public static void sendMessageToUnity(Map<String, Object> jsonMap) { |
| | | if (jsonMap == null || jsonMap.isEmpty()) { |
| | | return; |
| | | } |
| | | JSONObject jsonObject = new JSONObject(jsonMap); |
| | | public static void sendMessageToUnity(int code, Map<String, Object> args) { |
| | | if (args == null) |
| | | args = new HashMap<>(); |
| | | args.put("code", code); |
| | | JSONObject jsonObject = new JSONObject(args); |
| | | if (GameApp.I.isDemo()) { |
| | | LogUtil.debug("发送消息到unity", jsonObject.toString()); |
| | | return; |