/// <summary> /// 初始化Unity设置 /// </summary> public static void initializeUnity() { UtilTools.SetFPS(FPSLevel.Normal); //屏幕不休眠 Screen.sleepTimeout = SleepTimeout.NeverSleep; //TODO: 初始化UNITY的相关配置 #if UNITY_EDITOR QualitySettings.SetQualityLevel(2); #elif UNITY_ANDROID JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); tools.initAudioManager(); QualitySettings.SetQualityLevel(1); /* * JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent<JARUtilTools>(); * if (tools != null) * { * int maxCPUFreq = tools.getCPUMaxFreqM(); * long sysMemMB = tools.getTotalMemoryKB() / 1024; * * if (maxCPUFreq <= 1500 || sysMemMB <= 1300) * QualitySettings.SetQualityLevel(0); * else if (maxCPUFreq > 1500 && maxCPUFreq <= 2000) * QualitySettings.SetQualityLevel(1); * else if (maxCPUFreq > 2000) * QualitySettings.SetQualityLevel(2); * }*/ #elif UNITY_IOS JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); tools.initAudioManager(); QualitySettings.SetQualityLevel(1); #endif }
public override void onSuccessAbstract(string statusCode, string filePath, string msg) { _bLoadPackageComplete = true; JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { tools.startInstallAPK(filePath); } }
/// <summary> /// 发送给本地账号服务器验证 /// </summary> /// <param name="value"></param> /// <returns></returns> public IEnumerator send2LocalAccountServer(object value) { string wxCode = value as string; WWWForm dataForm = new WWWForm(); dataForm.AddField("t", "weixin"); dataForm.AddField("code", wxCode); dataForm.AddField("qid", SDKManager.Q_ID); dataForm.AddField("iid", StartUpScene._bindStrng); string devid = ""; if (sdk.SDKManager.isAppStoreVersion()) { devid = object_c.ObjectCCallback._IDFA; } else { JARUtilTools tools = Scene.GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { devid = tools.GetIMEI(); //"fdsfd2";// if (string.IsNullOrEmpty(devid)) { devid = GameDataMgr.LOGIN_DATA.GetFastLoginUUID(); } } } dataForm.AddField("devid", devid); WWW www = new WWW(SDKManager.WxLoginUrl, dataForm); //string loginUrl = BetterString.Builder(SDKManager.LoginUrl, "?code=", wxCode, "&qid=", SDKManager.Q_ID.ToString()); //WWW www = new WWW(loginUrl); yield return(www); if (www.isDone && string.IsNullOrEmpty(www.error)) { // 解析账号服务器返回的结果 bool bRlt = GameDataMgr.LOGIN_DATA.parseAccountReturn(www.text, true, false, true); if (bRlt) { GameDataMgr.LOGIN_DATA.IsLoginSuccess = true; // 验证成功直接连接游戏服务器 LoginInputController.ConnectToServer(); } } else { //TODO: process login exception } }
/// <summary> /// 检查可用内存并清理 /// </summary> void checkAndroidAvailableRAMAndClear() { JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { long sysAvailableMemMB = tools.getAvailableMemoryKB() / 1024; if (sysAvailableMemMB < 100) { regularlyClearAssets(); } } }
private void OnClickOKButton(GameObject go) { if (!_bLoadSDKManagerXML) { //下载SDKManager.xml Start(); } else { //下载version.xml VersionData.VersionType eType = _versionData.VersionTypeToUpdate; if (eType == VersionData.VersionType.Inner) { _versionData.StartUpdateVersion(); _isDownloading = true; } else if (eType == VersionData.VersionType.Program) { if (SDKManager.isAppStoreVersion()) { ObjectCInterface.openURL(SDKManager.PackageDownloadWeb); } else if (!string.IsNullOrEmpty(SDKManager.PackageDownloadWeb)) { Application.OpenURL(SDKManager.PackageDownloadWeb); } else if (!string.IsNullOrEmpty(SDKManager.PackageDownloadUrl)) { _bLoadPackageFailed = false; JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { string fileName = System.IO.Path.GetFileName(SDKManager.PackageDownloadUrl); tools.asyncHttpDownloadFile(SDKManager.PackageDownloadUrl, false, "", fileName, 1000, transform.name); _isDownloading = true; } } } else if (eType == VersionData.VersionType.Error) { //重试,跳过确认。 _versionData = new VersionData(); tfBoxChecking.gameObject.SetActive(true); tfBoxLoading.gameObject.SetActive(false); _isDownloading = true; _versionData.StartUpdateVersion(); _needCheckVersion = true; } } }
/// <summary> /// 获取本地的uuid /// </summary> /// <returns></returns> public string GetFastLoginUUID() { string _uuid = PlayerPrefs.GetString("FastLoginUUID", ""); if (string.IsNullOrEmpty(_uuid)) { //_uuid = System.Guid.NewGuid().ToString(); JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { _uuid = tools.GetDeviceUUID(); //"fdsfd2";// _uuid = _uuid.Replace("-", ""); } PlayerPrefs.SetString("FastLoginUUID", _uuid); } return(_uuid); }
public void LoginTouris() { if (winObject == null) { return; } // _mono.winBg.SetActive(true); JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { LogSys.LogWarning("LoginInputController:LoginTouris: DeviceUUID==" + tools.GetDeviceUUID()); // Login(tools.GetDeviceUUID(),"aaa"); GameDataMgr.PLAYER_DATA.IsTouris = true; } else { _mono.winBg.SetActive(true); } }
/*public JSONObject GetAllUserList() * { * * }*/ /// <summary> /// 快速登陆 /// </summary> /// <returns></returns> public IEnumerator registerToAccountServerFast() { /*string _uuid = GameDataMgr.LOGIN_DATA.GetFastLoginUUID(); * WWWForm dataForm = new WWWForm(); * string _code = _uuid + "," + GameDataMgr.LOGIN_DATA.GetFastLoginKey(); * dataForm.AddField("type", "0"); * dataForm.AddField("code", _code); * dataForm.AddField("t", "oauth");*/ string devid = ""; JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { devid = tools.GetIMEI(); //"fdsfd2";// } if (string.IsNullOrEmpty(devid)) { devid = GameDataMgr.LOGIN_DATA.GetFastLoginUUID(); } //Post数据表 WWWForm dataForm = new WWWForm(); dataForm.AddField("type", "0"); string code = GameDataMgr.LOGIN_DATA.GetFastLoginUUID() + "," + GameDataMgr.LOGIN_DATA.GetFastLoginKey(); dataForm.AddField("code", code); dataForm.AddField("t", "oauth"); dataForm.AddField("qid", SDKManager.Q_ID); dataForm.AddField("devid", devid); dataForm.AddField("simid", ""); dataForm.AddField("logintype", ClientDefine.PLAT_FORM_TYPE); WWW w = new WWW(sdk.SDKManager.FastLoginURL, dataForm); yield return(w); if (string.IsNullOrEmpty(w.error)) { if (w.isDone) { Debug.LogError(w.text); bool bRlt = GameDataMgr.LOGIN_DATA.parseAccountReturn(w.text, true); LogSys.LogWarning("----->a= print fast word ======" + bRlt); if (bRlt) { // LogSys.LogWarning("-----> print fast word ======"+w.text); GameDataMgr.LOGIN_DATA.SaveFastLoginInfo(); GameDataMgr.PLAYER_DATA.IsTouris = true; if (!ClientNetwork.Instance.IsConnected()) { ClientNetwork.Instance.Connect(); } } else { UIManager.CreateWin(UIName.LOGIN_INPUT_WIN); var versionUpdate = startUpMono.transform.Find("VersionUpdate").GetComponent <VersionUpdate>(); versionUpdate.ShowLoginBtn(); } } } else { UtilTools.HideWaitWin(); UtilTools.MessageDialog(w.error, okCallbackFunc: ReturnToLogin); } }
/// <summary> /// 同步加载指定类型的asset /// needCheckPath: true时会根据_isFirstUseStreamingAssets判断是否要转成assetbundle下的目录 /// </summary> public T loadAsset <T>(string strPath, bool needCheckPath = true) where T : Object { string asset_name = GetNameFromPath(strPath); strPath = strPath.ToLower(); strPath = strPath.Replace("\\", "/"); if (AssetManager.getInstance().IsStreamingAssets(strPath)) { if (needCheckPath) { strPath = UtilTools.PathCheck(strPath); } } Object obj = null; if (_dictAssetBundles.ContainsKey(strPath))//判断缓存中是否有 { AssetBundle bundle = _dictAssetBundles[strPath] as AssetBundle; if (bundle != null) { obj = bundle.LoadAsset <Object>(asset_name); //引用计数+1 //_dictAssetbundlesRefCount[strPath]++; } else { obj = _dictAssetBundles[strPath]; //引用计数+1 //_dictAssetbundlesRefCount[strPath]++; } } else//没有再去同步加载 { Utils.LogSys.Log("AssetManager Get Path Data 2"); string strLatesVersionpath = _objPathData.getLatestVersionPath(strPath); EAssetPathType eType = _objPathData.getAssetPathType(strPath); LogSys.Log("[AssetManager.LoadAesst]:+" + strLatesVersionpath + " eType = " + eType); if (eType == EAssetPathType.ePersistent) { if (File.Exists(strLatesVersionpath)) { string[] objDepRec = AssetManager.getInstance().getAssetBundleDependencies(strPath); for (int i = 0; i < objDepRec.Length; i++) { loadAsset <Object>(objDepRec[i], false);//依赖的资源不需要再检测路径,否则会出导致路径错误 } AssetBundle assetbundle = AssetBundle.LoadFromFile(strLatesVersionpath); if (assetbundle != null) { obj = assetbundle.LoadAsset <Object>(asset_name); _dictAssetBundles[strPath] = assetbundle; //引用计数初始化 if (!_dictAssetbundlesRefCount.ContainsKey(strPath)) { _dictAssetbundlesRefCount[strPath] = 0; } } // byte[] bytes = File.ReadAllBytes(strLatesVersionpath); // if (bytes != null && bytes.Length != 0) // { // AssetBundle assetbundle = AssetBundle.LoadFromMemory(bytes); // if (assetbundle != null) // { // obj = assetbundle.LoadAsset<Object>(asset_name); // _dictAssetBundles[strPath] = assetbundle; // //引用计数初始化 // if (!_dictAssetbundlesRefCount.ContainsKey(strPath)) // _dictAssetbundlesRefCount[strPath] = 0; // } // } } } else if (eType == EAssetPathType.eStreamingAssets) { JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { string[] objDepRec = AssetManager.getInstance().getAssetBundleDependencies(strPath); for (int i = 0; i < objDepRec.Length; i++) { loadAsset <Object>(objDepRec[i], false);//依赖的资源不需要再检测路径,否则会出导致路径错误 } string path = IPath.getPlatformName() + "/" + strPath; string stream_asset_path = IPath.getPlatformName() + "/" + strPath; #if UNITY_EDITOR stream_asset_path = strLatesVersionpath; #endif AssetBundle assetbundle = AssetBundle.LoadFromFile(strLatesVersionpath); if (assetbundle != null) { obj = assetbundle.LoadAsset <Object>(asset_name); _dictAssetBundles[strPath] = assetbundle; //引用计数初始化 if (!_dictAssetbundlesRefCount.ContainsKey(strPath)) { _dictAssetbundlesRefCount[strPath] = 0; } } // byte[] bytes = tools.GetAssetBundleBytes(stream_asset_path); // if (bytes != null && bytes.Length != 0) // { // AssetBundle assetbundle = AssetBundle.LoadFromMemory(bytes); // if (assetbundle != null) // { // obj = assetbundle.LoadAsset<Object>(asset_name); // _dictAssetBundles[strPath] = assetbundle; // //引用计数初始化 // if (!_dictAssetbundlesRefCount.ContainsKey(strPath)) // _dictAssetbundlesRefCount[strPath] = 0; // } // } } } else// (eType == EAssetPathType.eResources || (eType == EAssetPathType.eNone)) { obj = Resources.Load(strLatesVersionpath); //addAssetBundle(strPath, obj); } } return((T)obj); }
IEnumerator AutologinAccountServer_WeiXin(string md5Content) { yield return(null); Utils.LogSys.Log("+++++++++++++++自动登录微信帐号++++++++++++++++++"); WWWForm dataForm = new WWWForm(); dataForm.AddField("code", md5Content); dataForm.AddField("qid", SDKManager.Q_ID); dataForm.AddField("iid", StartUpScene._bindStrng); string devid = ""; if (sdk.SDKManager.isAppStoreVersion()) { devid = object_c.ObjectCCallback._IDFA; } else { JARUtilTools tools = Scene.GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>(); if (tools != null) { devid = tools.GetIMEI(); //"fdsfd2";// if (string.IsNullOrEmpty(devid)) { devid = GameDataMgr.LOGIN_DATA.GetFastLoginUUID(); } } } dataForm.AddField("devid", devid); WWW w = new WWW(SDKManager.AutoLoginUrl, dataForm); yield return(w); if (!string.IsNullOrEmpty(w.error)) { yield return(new WaitForSeconds(1f)); w = new WWW(SDKManager.AutoLoginUrl, dataForm); yield return(w); } if (!string.IsNullOrEmpty(w.error)) { yield return(new WaitForSeconds(1f)); w = new WWW(SDKManager.AutoLoginUrl, dataForm); yield return(w); } if (string.IsNullOrEmpty(w.error)) { if (w.isDone) { bool bRlt = GameDataMgr.LOGIN_DATA.parseAccountReturn(w.text, true, true, true); if (bRlt) { UtilTools.HideWaitWin(WaitFlag.LoginWin); //GameDataMgr.LOGIN_DATA.SavePhoneLoginInfo(); LoginInputController.ConnectToServer(); } else { var versionUpdate = transform.Find("VersionUpdate").GetComponent <VersionUpdate>(); versionUpdate.ShowLoginBtn(); UtilTools.HideWaitWin(WaitFlag.LoginWin); UIManager.CreateWin(UIName.LOGIN_INPUT_WIN);//如果登录帐号服务器失败, 显示登录界面 } } } else { var versionUpdate = transform.Find("VersionUpdate").GetComponent <VersionUpdate>(); versionUpdate.ShowLoginBtn(); UtilTools.HideWaitWin(WaitFlag.LoginWin); UIManager.CreateWin(UIName.LOGIN_INPUT_WIN);//如果登录帐号服务器失败, 显示登录界面 } }