private static void UnityEditorConnect(MSDKMethodNameID methodId, string channel = "", string subChannel = "") { #if GCLOUD_MSDK_WINDOWS #else string retJson = UnityEditorData.GetLoginData((int)methodId, channel, subChannel); if (!string.IsNullOrEmpty(retJson)) { MSDKMessageCenter.OnMSDKRet((int)methodId, retJson); } else { MSDKLog.Log("Simulator data is empty. channel=" + channel); } #endif }
private static void UnityEditorLogout() { #if GCLOUD_MSDK_WINDOWS #else string retJson = UnityEditorData.GetLogoutData(); if (!string.IsNullOrEmpty(retJson)) { MSDKMessageCenter.OnMSDKRet((int)MSDKMethodNameID.MSDK_LOGIN_LOGOUT, retJson); } else { MSDKLog.Log("Simulator Logout data is empty."); } #endif }
/// <summary> /// 获取游戏配置。支持int、bool、string、long类型 /// </summary> /// <returns>The configs.</returns> /// <param name="key">Key.</param> /// <param name="defValue">Def value.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public static T GetConfig <T>(string key, T defValue) { UnityEngine.Debug.Log("GetConfig key=" + key + " defValue=" + defValue + " typeof(T)=" + typeof(T)); string val = string.Empty; #if UNITY_EDITOR val = UnityEditorData.GetConfig(key); #else val = getConfigAdapter(key); #endif UnityEngine.Debug.Log("GetConfig string val=" + val); if (string.IsNullOrEmpty(val)) { return(defValue); } if (typeof(T) == typeof(bool)) { bool boolVal = val.Equals("1"); return((T)System.Convert.ChangeType(boolVal, typeof(bool))); } return((T)System.Convert.ChangeType(val, typeof(T))); }
/// <summary> /// 获取本地登录态。同步调用 /// </summary> public static MSDKLoginRet GetLoginRet() { try { #if GCLOUD_MSDK_WINDOWS string retJson = getLoginRetAdapter(); #elif UNITY_EDITOR || UNITY_STANDALONE_WIN string retJson = UnityEditorData.GetLoginData((int)MSDKMethodNameID.MSDK_LOGIN_GETLOGINRESULT); #else string retJson = getLoginRetAdapter(); #endif MSDKLog.Log("GetLoginRet retJson= " + retJson); if (!string.IsNullOrEmpty(retJson)) { return(new MSDKLoginRet(retJson)); } } catch (Exception ex) { MSDKLog.LogError("GetLoginRet with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); } return(null); }