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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
| using UnityEngine;
public class PlatMsgManager : SingletonPattern<PlatMsgManager> { GameObject m_PlatformObject = null; public PlatformScript m_PlatformScript = null; public void Init() { if (m_PlatformObject == null) { m_PlatformObject = new GameObject("PlatFormObject"); m_PlatformObject.hideFlags = HideFlags.HideAndDontSave; m_PlatformScript = m_PlatformObject.AddComponent<PlatformScript>();
#if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif GameObject.DontDestroyOnLoad(m_PlatformObject); } #if UNITY_ANDROID && !UNITY_EDITOR m_GameHelperJavaClass = new AndroidJavaClass("com.DefaultCompany.ResLoadPrg.GameHelper"); Debug.Log("Platform Init com.DefaultCompany.ResLoadPrg.GameHelper"); #endif }
#if UNITY_ANDROID && !UNITY_EDITOR private AndroidJavaClass m_GameHelperJavaClass = null;
public void SendUnityMessageToPlatform( int iMsgId, int iParam1 = 0, int iParam2 = 0, int iParam3 = 0, int iParam4 = 0, string strParam1 = "", string strParam2 = "", string strParam3 = "", string strParam4 = "") { if(m_GameHelperJavaClass == null) { return; }
m_GameHelperJavaClass.CallStatic( "SendUnityMessageToPlatform", iMsgId, iParam1, iParam2, iParam3, iParam4, strParam1, strParam2, strParam3, strParam4); } public int GetIntFromPlatform(int type) { if(m_GameHelperJavaClass == null) return 0; return m_GameHelperJavaClass.CallStatic<int>("GetIntFromPlatform", type); } public long GetLongFromPlatform(int type) { if (m_GameHelperJavaClass == null) return 0; return m_GameHelperJavaClass.CallStatic<long>("GetLongFromPlatform", type); } public long GetLongFromPlatform2( int type, int iParam1 = 0, int iParam2 = 0, int iParam3 = 0, int iParam4 = 0, string strParam1 = "", string strParam2 = "", string strParam3 = "", string strParam4 = "") { if (m_GameHelperJavaClass == null) return 0; return m_GameHelperJavaClass.CallStatic<long>( "GetLongFromPlatform2", type, iParam1, iParam2, iParam3, iParam4, strParam1, strParam2, strParam3, strParam4); } public string GetStringFromPlatform(int type) { if(m_GameHelperJavaClass == null) return null; return m_GameHelperJavaClass.CallStatic<string>("GetStringFromPlatform", type); } #else public void SendUnityMessageToPlatform( int iMsgId, int iParam1 = 0, int iParam2 = 0, int iParam3 = 0, int iParam4 = 0, string strParam1 = "", string strParam2 = "", string strParam3 = "", string strParam4 = "") { } public int GetIntFromPlatform(int type) { return 0; } public long GetLongFromPlatform(int type) { return 0; } public long GetLongFromPlatform2( int type, int iParam1 = 0, int iParam2 = 0, int iParam3 = 0, int iParam4 = 0, string strParam1 = "", string strParam2 = "", string strParam3 = "", string strParam4 = "") { return 0; } public string GetStringFromPlatform(int type) { return string.Empty; } #endif }
|