private static int SetGameCamCtrlMode(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(Boolean), typeof(Boolean), typeof(Boolean), typeof(Boolean))) { var m = (int)LuaScriptMgr.GetNumber(L, 1); if (m < 0 || m > (int)CPlayerFollowCam.CTRL_MODE.FIX25D) { HobaDebuger.LogErrorFormat("SetGameCamCtrlMode: invalid mode {0}", m); return(CheckReturnNum(L, count, nRet)); } CPlayerFollowCam.CTRL_MODE mode = (CPlayerFollowCam.CTRL_MODE)m; bool bChangeYaw = LuaScriptMgr.GetBoolean(L, 2); bool bChangePitch = LuaScriptMgr.GetBoolean(L, 3); bool bChangeDist = LuaScriptMgr.GetBoolean(L, 4); bool isImmediately = LuaScriptMgr.GetBoolean(L, 5); CCamCtrlMan.Instance.GetGameCamCtrl().SetCameraCtrlMode(mode, bChangeYaw, bChangePitch, bChangeDist, isImmediately); } else { LogParamError("SetGameCamCtrlMode", count); } return(CheckReturnNum(L, count, nRet)); }
public static int loader(IntPtr L) { string fileName = String.Empty; fileName = LuaDLL.lua_tostring(L, 1); fileName = fileName.Replace('.', '/'); fileName += ".lua"; byte[] text = Load(fileName); if (text == null) { LuaDLL.lua_pushstring(L, "loader failed to read file with path: " + fileName); LuaDLL.lua_error(L); return(0); } // 0: no errors; // LUA_ERRSYNTAX: syntax error during pre-compilation; // LUA_ERRMEM: memory allocation error. if (LuaDLL.luaL_loadbuffer(L, text, text.Length, fileName) != 0) { // loadbuffer会在栈顶压入错误信息,弹出错误信息所在的最上层栈 //LuaDLL.lua_pop(L, 1); LuaDLL.lua_error(L); HobaDebuger.LogErrorFormat("Failed to call luaL_loadbuffer, file: {0}", fileName); return(0); } return(1); }
private void CamMoveFar() { try { // 设置数据 NearCamStage newStage = _StageCfg._Stage - 1; _StageCfg = _ProfCfg.GetCurStageData(newStage); _PitchDeg = ClampPitch(_PitchDeg); if (newStage == NearCamStage.Body) { _DistOffset = _ProfCfg.DefaultParams.z; } else { _DistOffset = ClampDistOffset(_DistOffset); } ApplyDirAndUp(); // 相机开始移动 float real_height_offset = GetRealHeightOffset(); var cam_dest_pos = GetRealLookAtPos(real_height_offset) - _RealDir * _DistOffset; DoCamMove(false, cam_dest_pos, real_height_offset, _StageCfg._FOV, null); } catch (System.Exception e) { HobaDebuger.LogErrorFormat("CPlayerNearCam Move Far Exception:{0}", e.Message); } }
public void SetCameraLocation(int type, LuaFunction callback) { _CtrlType = type; if (type == 1) { //进入近景模式 if (LookAtTarget == null) { HobaDebuger.LogError("CPlayerNearCam SetCameraLocation to Near failed, Host Player got null."); return; } if (_ProfCfg == null) { HobaDebuger.LogError("CPlayerNearCam SetCameraLocation failed, Prof Config got null."); return; } _OriginLookAtPos = CCamCtrlMan.Instance.GetLookAtPosOfGameModel(); _OriginFOV = Main.Main3DCamera.fieldOfView; RollSensitivity = 0.05f; _IsQuitNearCam = false; try { _StageCfg = _ProfCfg.GetCurStageData(NearCamStage.Body); InitDefaultParams(); float real_height_offset = GetRealHeightOffset(); _CurLookAtPos = GetRealLookAtPos(real_height_offset); _IsEnterNearCam = true; EnableCameraEffect(true); var cam_dest_pos = GetRealLookAtPos(real_height_offset) - _RealDir * _DistOffset; DoCamMove(true, cam_dest_pos, real_height_offset, _StageCfg._FOV, callback); } catch (System.Exception e) { HobaDebuger.LogErrorFormat("CPlayerNearCam SetCameraLocation to Near Exception:{0}", e.Message); } } else if (type == 2) { //退出近景模式 if (LookAtTarget == null) { HobaDebuger.LogError("CPlayerNearCam SetCameraLocation to Far failed, Host Player got null."); return; } LuaScriptMgr.Instance.CallLuaFunction("OpenOrCloseUIPanel", "CPanelUINearCam", false); CCamCtrlMan.Instance.GetGameCamCtrl().SetToDefaultCamera(false, false, true, true); _IsQuitNearCam = true; EnableCameraEffect(false); EnableLookIK(false); float des_height_offset = CCamCtrlMan.Instance.GetGameCamCtrl().GetHeightOffset(); var dest_game_cam_pos = GetGameCamPosAfterCollionFix(des_height_offset); DoCamMove(false, dest_game_cam_pos, des_height_offset, _OriginFOV, null); } }
//检查流程 public IEnumerable DoCheckMeshCoroutine(string prefabName, GameObject scenePrefab) { var _Config = scenePrefab.GetComponent <SceneConfig>(); if (null == _Config) { HobaDebuger.LogErrorFormat("{0} Is not a scene prefab.", prefabName); yield break; } //加载Objects if (_Config._BlockPositionList.Count > 0) //有block { foreach (var item in DoCheckMeshRendererCoroutine(prefabName, _Config)) { yield return(item); } } else //无block { foreach (var item in DoCheckMeshRendererCoroutine(prefabName, scenePrefab)) { yield return(item); } } yield return(null); }
public override void AccountConversion(LT_RESULT_NOTIFICATION_DELEGATE callback) { if (_IsLogined) { var idpProfile = KGLocalPlayer.currentPlayer.idpProfile; if (idpProfile.idpCode.Equals(KGIdpCodeString.Guest)) { //KakaoUtil.AccountConversionWithCustomUI(KGIdpCode.Kakao, (resultCode) => KakaoUtil.AccountConversion((resultCode) => { bool isSuccessful = resultCode == KGResultCode.Success; if (isSuccessful) { LogResult(_KakaoPrefix, "AccountConversion Succeeded", resultCode.ToString()); _IsLogined = KakaoUtil.IsLogined; // ͬ²½µÇ¼״̬£¨Çл»³É¹¦£¬µÇ¼״̬Ϊfalse£© } else { LogResult(_KakaoPrefix, "AccountConversion Failed", resultCode.ToString()); } if (callback != null) { callback(isSuccessful); } }); } else { HobaDebuger.LogErrorFormat("{0}AccountConversion failed, not logined as guest.", _KakaoPrefix); } } }
public static int CheckReturnNum(IntPtr L, int nTop, int nRet) { if (LuaDLL.lua_gettop(L) - nTop != nRet) { HobaDebuger.LogErrorFormat("CheckReturnNum Failed! nTop: {0}, nRet: {1}", nTop, nRet); } return(nRet); }
private void OnLowMemory() { //System.GC.Collect(); // Resources.UnloadUnusedAssets(); long luamem = LuaScriptMgr.Instance.OnLowMemory(); //在lua中处理 HobaDebuger.LogErrorFormat("Game Memory Warning!!! dev: {0} SysMem: {1}, GraphicMem: {2}, LuaMem: {3}", SystemInfo.deviceModel, SystemInfo.systemMemorySize, SystemInfo.graphicsMemorySize, luamem); }
private bool ReadServerConfigXml(string fileName) { _ServerConfigParams.DefaultValue(); try { string text = File.ReadAllText(fileName); return(_ServerConfigParams.ParseFromXmlString(text)); } catch (Exception e) { HobaDebuger.LogErrorFormat("Failed to Parse ServerConfigXml:{0}", e); } return(false); }
private bool ReadCustomServerListXml(List <ServerInfo> serverList) { try { string configsDir = Path.Combine(_ResPath, "Configs"); string path = Path.Combine(configsDir, "ServerList.xml"); string text = File.ReadAllText(path); return(ServerInfo.ParseFromXmlString(text, serverList)); } catch (Exception e) { HobaDebuger.LogErrorFormat("Failed to Parse ServerConfigXml:{0}", e); } return(false); }
//读取更新推广内容配置 private void ReadUpdatePromotionXmlFromResources() { try { TextAsset updateConfigTextAsset = (TextAsset)Resources.Load("UpdatePromotionConfig", typeof(TextAsset)); if (updateConfigTextAsset != null) { _UpdatePromotionParams.ParseFromXmlString(updateConfigTextAsset.text); Resources.UnloadAsset(updateConfigTextAsset); } } catch (Exception e) { HobaDebuger.LogErrorFormat("Failed to Parse UpdatePromotionXml:{0}", e); } }
private static int SubUnicodeString(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; if ((count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(int), typeof(int))) || (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(int)))) { string str = LuaScriptMgr.GetString(L, 1); if (string.IsNullOrEmpty(str)) { HobaDebuger.LogWarning("SubUnicodeString string is null or empty"); LuaScriptMgr.Push(L, ""); return(CheckReturnNum(L, count, nRet)); } int startIndex = (int)LuaScriptMgr.GetNumber(L, 2) - 1; try { if (count == 2) { str = str.Substring(startIndex); } else { int length = (int)LuaScriptMgr.GetNumber(L, 3); str = str.Substring(startIndex, length); } LuaScriptMgr.Push(L, str); return(CheckReturnNum(L, count, nRet)); } catch (Exception e) { HobaDebuger.LogErrorFormat("SubUnicodeString Exception: {0}", e.Message); LuaScriptMgr.Push(L, ""); return(CheckReturnNum(L, count, nRet)); } } else { LogParamError("SubUnicodeString", count); LuaScriptMgr.Push(L, ""); return(CheckReturnNum(L, count, nRet)); } }
//现在更新字符串配置需要根据语言来切换 private void ReadUpdateStringXmlFromResources(string strLanguage) { try { //read UpdateStringConfig.xml //_UpdateStringConfigParams.DefaultValue(); var ppdateConfigFileName = HobaText.Format("UpdateStringConfig{0}", strLanguage); TextAsset updateStringConfigTextAsset = (TextAsset)Resources.Load(ppdateConfigFileName, typeof(TextAsset)); if (updateStringConfigTextAsset != null) { _UpdateStringConfigParams.ParseFromXmlString(updateStringConfigTextAsset.text); Resources.UnloadAsset(updateStringConfigTextAsset); } } catch (Exception e) { HobaDebuger.LogErrorFormat("Failed to Parse UpdateStringXml:{0}", e); } }
private string GetBundleName(string assetName) { if (string.IsNullOrEmpty(assetName)) { return(null); } string bundleName = string.Empty; if (_AssetPath2BundleMap.TryGetValue(assetName, out bundleName)) { return(bundleName); } #if UNITY_EDITOR || UNITY_STANDALONE HobaDebuger.LogErrorFormat("Failed to find bundle when load asset {0}", assetName); #endif return(null); }
private bool ReadDebugSettingXml() { //read DebugSetting.xml _DebugSetting.DefaultValue(); try { string path = Path.Combine(_ResPath, "DebugSetting.xml"); if (File.Exists(path)) { string text = File.ReadAllText(path); _DebugSetting.ParseFromXmlString(text); return(true); } } catch (Exception e) { HobaDebuger.LogErrorFormat("Failed to Parse DebugSettingXml:{0}", e); } return(false); }
//读取更新配置 private void ReadConfigXmlFromResources() { string strLocale = CPlatformConfig.GetLocale(); try { //read UpdateConfig.xml _UpdateConfigParams.DefaultValue(); TextAsset updateConfigTextAsset = (TextAsset)Resources.Load("UpdateConfig", typeof(TextAsset)); if (updateConfigTextAsset != null) { _UpdateConfigParams.ParseFromXmlString(updateConfigTextAsset.text, strLocale); Resources.UnloadAsset(updateConfigTextAsset); } } catch (Exception e) { HobaDebuger.LogErrorFormat("Failed to Parse UpdateConfig:{0}", e); } }
private void CamMoveNear() { try { // 设置数据 NearCamStage newStage = _StageCfg._Stage + 1; _StageCfg = _ProfCfg.GetCurStageData(newStage); _PitchDeg = ClampPitch(_PitchDeg); _DistOffset = _StageCfg._DistanceLimit.y; ApplyDirAndUp(); // 相机开始移动 float real_height_offset = GetRealHeightOffset(); var cam_dest_pos = GetRealLookAtPos(real_height_offset) - _RealDir * _DistOffset; DoCamMove(true, cam_dest_pos, real_height_offset, _StageCfg._FOV, null); } catch (System.Exception e) { HobaDebuger.LogErrorFormat("CPlayerNearCam Move Near Exception:{0}", e.Message); } }
private static int StopGfx(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int))) { var fx = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); var fxone = fx != null?fx.GetComponent <CFxOne>() : null; if (fxone == null) { return(0); } var id = (int)LuaDLL.lua_tonumber(L, 2); if (fxone.ID == id) { fxone.Stop(); } // 按照ID生成规则,绝大多数情况下复用时ID都会增长,故以此规则添加有效性检查 if (fxone.ID < id && fxone.ID > 0) { #if UNITY_STANDALONE_WIN HobaDebuger.LogErrorFormat("logic error occurs when call StopGfx: current id = {0} old id = {1}", fxone.ID, id); #endif } //LuaScriptMgr.Push(L, fxone.ID != 0); } else { LogParamError("StopGfx", count); //LuaScriptMgr.Push(L, false); } return(0); }
public override void OnDistanceChanged(float dt) { //if (InputManager.Instance.IsMultiDragingStarted) return; try { float temp = _DistOffset + RollSensitivity * dt; if (dt < 0f) { if (_StageCfg._Stage != NearCamStage.Chest && temp <= _StageCfg._DistanceLimit.x) { CamMoveNear(); return; } } else if (dt > 0f) { if (temp >= _StageCfg._DistanceLimit.y) { if (_StageCfg._Stage == NearCamStage.Body) { SetCameraLocation(2, null); } else { CamMoveFar(); } return; } } _DistOffset = ClampDistOffset(temp); } catch (System.Exception e) { HobaDebuger.LogErrorFormat("CPlayerNearCam OnDistanceChanged Excetion:{0}", e.Message); } }
private static string ReadUserLanguageCode(string userLanFile) { if (!File.Exists(userLanFile)) { return(null); } try { var languageCode = File.ReadAllText(userLanFile, System.Text.Encoding.UTF8); if (!string.IsNullOrEmpty(languageCode)) { languageCode = languageCode.ToUpper(); } return(languageCode); } catch (Exception e) { HobaDebuger.LogErrorFormat("ReadUserLanguageCode raise an exception {0}", e); } return(null); }
private IEnumerable DoStartGame() { LuaStatic.Load = CustomLoader; LuaStatic.LoadFromAssetsPath = LoadFromAssetsPath; LuaScriptMgr sm = LuaScriptMgr.Instance; yield return(null); foreach (var item in sm.Bind()) { yield return(item); } sm.Start(); yield return(null); try { sm.DoString("require [[init]]"); sm.DoString("require [[preload]]"); } catch (LuaScriptException e) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message); yield break; } yield return(null); var luaState = sm.GetLuaState(); if (luaState.L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(luaState.L); do { LuaDLL.lua_getglobal(luaState.L, "preload"); if (LuaDLL.lua_pcall(luaState.L, 0, 1, 0) != 0) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", LuaDLL.lua_tostring(luaState.L, -1)); yield break; } bool ret = LuaDLL.lua_toboolean(luaState.L, -1); LuaDLL.lua_pop(luaState.L, 1); if (ret) { break; } yield return(null); } while (true); LuaDLL.lua_settop(luaState.L, oldTop); yield return(null); } //设置scale sm.GetDesignWidthAndHeight(ref _DesignWidth, ref _DesignHeight); if (_DesignWidth > 0 && _DesignHeight > 0) { OSUtility.SetDesignContentScale(_DesignWidth, _DesignHeight); } yield return(null); try { if (!_BeForArtTest) { sm.CallLuaFunction("StartGame"); } else { sm.CallLuaFunction("SceneTest"); } _IsInited = true; } catch (LuaScriptException e) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message); _IsInited = false; } yield return(null); ReadResPath(); //读取C#端需要的lua路径 StartCoroutine(TickCoroutine().GetEnumerator()); yield return(null); }
/// 根据角色位置,预加载周围的分块后回调 public void Preload(float posx, float posz, Action callback) { if (null == _Config) { HobaDebuger.Log("Scene Config Init Failed,Please Make Sure Scene Prefab Loaded Success ! "); return; } _CallBack = callback; var preLoadBlockList = new List <SceneConfig.CPositionSetting>(); _PreLoadBlockCounter = 0; int blockCount = _Config._BlockPositionList.Count; for (int i = 0; i < blockCount; ++i) { var currentBlock = _Config._BlockPositionList[i]; if (_SceneQuality < currentBlock._SceneQuality) { continue; } float fDistance = Util.DistanceH(currentBlock._BlockPosition, new Vector3(posx, 0, posz)); if (fDistance <= currentBlock._ShowDistance) { preLoadBlockList.Add(currentBlock); } } int nBlockCount = preLoadBlockList.Count; _PreLoadBlockCounter = nBlockCount; if (nBlockCount == 0) { AddToSpecialObjectList(_Config.gameObject); } else { for (var index = 0; index < nBlockCount; index++) { var currentPos = preLoadBlockList[index]; if (!_LoadedPoints.Contains(currentPos._BlockName)) { for (int i = 0; i < currentPos._LightIndexArray.Length; i++) { int val; if (_LightmapIdx2RefCountDic.TryGetValue(currentPos._LightIndexArray[i], out val)) { _LightmapIdx2RefCountDic[currentPos._LightIndexArray[i]] = val + 1; _IsLightmapsUpdated = true; } else { HobaDebuger.LogFormat("光照贴图索引不正确,最大索引{0},当前索引为{1},资源{2}", _LightmapIdx2RefCountDic.Count - 1, currentPos._LightIndexArray[i], currentPos._BlockName); continue; } } _LoadedPoints.Add(currentPos._BlockName); LoadBlockWithCounter(currentPos._BlockName, currentPos._EffectiveType); } else { --_PreLoadBlockCounter; HobaDebuger.LogErrorFormat("{0} 重复名字的Block! {1}", index, currentPos._BlockName); } } } ///计数加载,加载完成之后进行回调 if (0 == _PreLoadBlockCounter && _CallBack != null) { _CallBack(); _CallBack = null; } }
private void UpdateDynamicBoneInfo(OutwardPart part, DynamicBoneInfo[] prefabBones) { if (null == prefabBones || 0 == prefabBones.Length) { return; } for (int i = 0; i < prefabBones.Length; i++) { var dynamicBoneInfo = prefabBones[i]; string fullPath = dynamicBoneInfo.HangPath; if (string.IsNullOrEmpty(fullPath)) { continue; } var attachedBone = transform.Find(fullPath); if (null == attachedBone) { HobaDebuger.LogErrorFormat("DynamicBone数据中骨骼路径配置错误,{0}", fullPath); continue; } string dbRootPath = dynamicBoneInfo.rootPath; if (string.IsNullOrEmpty(dbRootPath)) { continue; } var dbRootTrans = transform.Find(dbRootPath); if (null == dbRootTrans) { continue; } #region Setup Params var targetBone = attachedBone.GetComponent <DynamicBone>(); if (null == targetBone) { targetBone = attachedBone.gameObject.AddComponent <DynamicBone>(); } targetBone.m_Root = dbRootTrans; targetBone.m_UpdateRate = dynamicBoneInfo.m_UpdateRate; targetBone.m_UpdateMode = dynamicBoneInfo.m_UpdateMode; targetBone.m_Damping = dynamicBoneInfo.m_Damping; targetBone.m_DampingDistrib = dynamicBoneInfo.m_DampingDistrib; targetBone.m_Elasticity = dynamicBoneInfo.m_Elasticity; targetBone.m_ElasticityDistrib = dynamicBoneInfo.m_ElasticityDistrib; targetBone.m_Stiffness = dynamicBoneInfo.m_Stiffness; targetBone.m_StiffnessDistrib = dynamicBoneInfo.m_StiffnessDistrib; targetBone.m_Inert = dynamicBoneInfo.m_Inert; targetBone.m_InertDistrib = dynamicBoneInfo.m_InertDistrib; targetBone.m_Radius = dynamicBoneInfo.m_Radius; targetBone.m_RadiusDistrib = dynamicBoneInfo.m_RadiusDistrib; targetBone.m_EndLength = dynamicBoneInfo.m_EndLength; targetBone.m_EndOffset = dynamicBoneInfo.m_EndOffset; targetBone.m_Gravity = dynamicBoneInfo.m_Gravity; targetBone.m_Force = dynamicBoneInfo.m_Force; targetBone.m_Colliders = dynamicBoneInfo.m_Colliders; targetBone.m_Exclusions = dynamicBoneInfo.m_Exclusions; targetBone.m_FreezeAxis = dynamicBoneInfo.m_FreezeAxis; targetBone.m_DistantDisable = dynamicBoneInfo.m_DistantDisable; targetBone.m_ReferenceObject = dynamicBoneInfo.m_ReferenceObject; //targetBone.m_DistanceToObject = sourceBone.m_DistanceToObject; targetBone.m_DistanceToObject = GFXConfig.Instance.GetDynamicBoneDistance(); targetBone.Setup(); #endregion _DynamicBonesCompList[(int)part].Add(targetBone); } }
public static void LogParamError(string methodName, int count) { HobaDebuger.LogErrorFormat("invalid arguments to method: GameUtilWrap.{0} count: {1}", methodName, count); }
public void Tick(bool global) { if (_List.Count == 0) { return; } float cur = Time.time; _IsTicking = true; IntPtr L = LuaScriptMgr.Instance.GetL(); LuaState LS = LuaScriptMgr.Instance.GetLuaState(); int i = 0; while (i < _List.Count) { Timer tm = _List[i]; if (tm.EndTime <= cur) { if (tm.LuaCallbackRef != LuaDLL.LUA_NOREF) { // tm.callback.Call(); -- LuaFunction版本 var oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, tm.LuaCallbackRef); // cb LuaDLL.lua_pushvalue(L, -1); //cb, cb if (!LS.PCall(0, 0)) //-> cb, [err] { string errorInfo = LuaDLL.lua_tostring(L, -1); if (errorInfo == null) { errorInfo = "Unknown Lua Error!"; } HobaDebuger.LogErrorFormat("LuaScriptException: {0} at {1} Timer Id:{2}, ttl:{3}, once:{4}, debug:{5}", errorInfo, global ? "Global" : "Object", tm.Id, tm.TTL, tm.IsOnce, tm.DebugInfo); } if (tm.IsOnce) { // tm.callback.Dispose(); _List.RemoveAt(i); if (tm.LuaCallbackRef != LuaDLL.LUA_NOREF) { LuaDLL.luaL_unref(L, LuaIndexes.LUA_REGISTRYINDEX, tm.LuaCallbackRef); } tm.Dispose(); //_CurActiveCount--; } else { tm.EndTime = tm.EndTime + tm.TTL; _List[i] = tm; i++; } LuaDLL.lua_settop(L, oldTop); } else if (tm.CallbackAction != null) { tm.CallbackAction(); if (tm.IsOnce) { _List.RemoveAt(i); if (tm.LuaCallbackRef != LuaDLL.LUA_NOREF) { LuaDLL.luaL_unref(L, LuaIndexes.LUA_REGISTRYINDEX, tm.LuaCallbackRef); } tm.Dispose(); //_CurActiveCount--; } else { tm.EndTime = tm.EndTime + tm.TTL; _List[i] = tm; i++; } } } else { i++; } } _IsTicking = false; if (_TempList.Count > 0) { _List.AddRange(_TempList); //_CurActiveCount += _TempList.Count; _TempList.Clear(); } if (_TempDelList.Count > 0) { for (i = 0; i < _TempDelList.Count; i++) { RemoveTimer(_TempDelList[i]); } _TempDelList.Clear(); } }
private void OnVideoError(VideoPlayer player, string message) { HobaDebuger.LogErrorFormat("VideoPlayer got error: {0}", message); StopVideo(); }
public IEnumerable Init(string gameResPath, string assetBundlePath) { StartCoroutine(TaskCoroutine()); yield return(null); // 计算所用到的路径 string platformFolderForAssetBundles = GetPlatformFolderForAssetBundles(); _GameResBasePath = gameResPath + AssetBundlesFolderName + platformFolderForAssetBundles + "/"; _BaseAssetBundleURL = assetBundlePath + AssetBundlesFolderName + platformFolderForAssetBundles + "/"; //Update #if UNITY_EDITOR //临时使用本地目录 _UpdateAssetBundleURL = _BaseAssetBundleURL + "Update/"; #else //使用更新目录, 将 AssetBundle/<Plaform> 和 AssetBundle/<Plaform>/Update 整合成AssetBundle string strLibDir = EntryPoint.Instance.LibPath; _UpdateAssetBundleURL = strLibDir + AssetBundlesFolderName; #endif //HobaDebuger.LogWarningFormat("BaseAssetBundleURL: {0}", _BaseAssetBundleURL); //HobaDebuger.LogWarningFormat("UpdateAssetBundleURL: {0}", _UpdateAssetBundleURL); yield return(null); foreach (var v in LoadPathIDDataCoroutine()) { yield return(v); } yield return(null); //base manifest { string url; string assetBundleName = platformFolderForAssetBundles; if (IsUpdateFileExist(assetBundleName)) { url = HobaText.Format("{0}{1}", _UpdateAssetBundleURL, assetBundleName); } else { url = HobaText.Format("{0}{1}", _BaseAssetBundleURL, assetBundleName); } var manifestAssetBundle = SyncLoadAssetBundle(assetBundleName); if (manifestAssetBundle != null) { var manifest = manifestAssetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); if (manifest != null) { var abs = manifest.GetAllAssetBundles(); foreach (var ab in abs) { var dependencies = manifest.GetAllDependencies(ab); if (dependencies.Length > 0 && !_Dependencies.ContainsKey(ab)) { _Dependencies.Add(ab, dependencies); } } } else { HobaDebuger.LogErrorFormat("Failed to load AssetBundleManifest file!!! {0}", url); } UnloadBundle(assetBundleName); } else { HobaDebuger.LogErrorFormat("Failed to load Base AssetBundleManifest Bundle!!! {0}", url); } } yield return(null); //update manifest { string assetBundleName = platformFolderForAssetBundles + "Update"; var manifestAssetBundle = SyncLoadAssetBundleInUpdate(assetBundleName); if (manifestAssetBundle != null) { var manifest = manifestAssetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); if (manifest != null) { var abs = manifest.GetAllAssetBundles(); foreach (var ab in abs) { var dependencies = manifest.GetAllDependencies(ab); if (dependencies.Length > 0 && !_Dependencies.ContainsKey(ab)) { _Dependencies.Add(ab, dependencies); } } } else { HobaDebuger.LogErrorFormat("Failed to load Update AssetBundleManifest file!!! {0}", assetBundleName); } UnloadBundle(assetBundleName); } else { HobaDebuger.LogWarningFormat("Failed to load Update AssetBundleManifest Bundle!!! {0}", assetBundleName); } } yield return(null); }
void OnVideoError(MediaPlayerCtrl.MEDIAPLAYER_ERROR errorCode, MediaPlayerCtrl.MEDIAPLAYER_ERROR errorCodeExtra) { HobaDebuger.LogErrorFormat("VideoPlayer got error: {0}, {1}", errorCode, errorCodeExtra); StopVideo(); }
protected void LoadFromBin(string filePathName, bool isClearOldData = true) { if (isClearOldData) { TemplateMap.Clear(); TemplateDataMap.Clear(); TemplateFileInfoList.Clear(); } TemplateFileInfo templateFileInfo = new TemplateFileInfo(); string fullPathName; if (!Template.Path.IsLocaleDataPath(filePathName)) { fullPathName = System.IO.Path.Combine(Path.GetFullBinPath(), filePathName); } else { fullPathName = System.IO.Path.Combine(Path.GetFullLocalePath(), filePathName); } #if UNITY_IPHONE fullPathName = fullPathName.Replace("file://", ""); #endif byte[] allbytes = null; try { #if UNITY_EDITOR allbytes = File.ReadAllBytes(fullPathName); #else allbytes = Util.ReadFile(fullPathName); #endif } catch (Exception e) { HobaDebuger.LogWarningFormat("Exception in LoadFromBin: {0}!", e.Message); allbytes = null; } if (allbytes == null) { return; } MemoryStream memStream = new MemoryStream(allbytes); BinaryReader br = new BinaryReader(memStream); try { var totalSize = 0; //memStream.Seek(8, SeekOrigin.Current); ReadHeader(br, out HeaderVersion, out HeaderData); totalSize = 8; while (totalSize < memStream.Length) { var tid = br.ReadInt32(); var size = br.ReadInt32(); byte[] pb = new byte[size]; memStream.Read(pb, 0, size); if (TemplateDataMap.ContainsKey(tid)) { throw new DataException(HobaText.Format("重复的 {0} ID({1})", typeof(TTemplate).Name, tid)); } TemplateDataMap.Add(tid, pb); totalSize += (pb.Length + 2 * sizeof(int)); templateFileInfo.KeyList.Add(tid); } } catch (EndOfStreamException e) { HobaDebuger.LogErrorFormat("The length of data file {0} is error, {1}", fullPathName, e.Message); } catch (IOException) { HobaDebuger.LogErrorFormat("IOException raised in file {0}!", fullPathName); } finally { br.Close(); memStream.Close(); } TemplateFileInfoList.Add(templateFileInfo); }
private bool DoLoadBankFromImage(string in_bankPath, CBankEntry bankEntry) { uint in_uInMemoryBankSize = 0; GCHandle ms_pinnedArray = new GCHandle(); IntPtr ms_pInMemoryBankPtr = IntPtr.Zero; uint ms_bankID = AkSoundEngine.AK_INVALID_BANK_ID; byte[] bytes = Util.ReadFile(in_bankPath); if (bytes == null) { Common.HobaDebuger.LogErrorFormat("WwiseUnity: AkMemBankLoader: bank loading failed: {0}", in_bankPath); return(false); } try { ms_pinnedArray = GCHandle.Alloc(bytes, GCHandleType.Pinned); ms_pInMemoryBankPtr = ms_pinnedArray.AddrOfPinnedObject(); in_uInMemoryBankSize = (uint)bytes.Length; // Array inside the WWW object is not aligned. Allocate a new array for which we can guarantee the alignment. if ((ms_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0) { byte[] alignedBytes = new byte[bytes.Length + AK_BANK_PLATFORM_DATA_ALIGNMENT]; GCHandle new_pinnedArray = GCHandle.Alloc(alignedBytes, GCHandleType.Pinned); IntPtr new_pInMemoryBankPtr = new_pinnedArray.AddrOfPinnedObject(); int alignedOffset = 0; // New array is not aligned, so we will need to use an offset inside it to align our data. if ((new_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0) { Int64 alignedPtr = (new_pInMemoryBankPtr.ToInt64() + AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) & ~AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK; alignedOffset = (int)(alignedPtr - new_pInMemoryBankPtr.ToInt64()); new_pInMemoryBankPtr = new IntPtr(alignedPtr); } // Copy the bank's bytes in our new array, at the correct aligned offset. Array.Copy(bytes, 0, alignedBytes, alignedOffset, bytes.Length); ms_pInMemoryBankPtr = new_pInMemoryBankPtr; ms_pinnedArray.Free(); ms_pinnedArray = new_pinnedArray; } } catch (Exception) { if (ms_pInMemoryBankPtr != IntPtr.Zero) { ms_pinnedArray.Free(); } return(false); } bankEntry.InMemoryBankSize = in_uInMemoryBankSize; bankEntry.PinnedArray = ms_pinnedArray; bankEntry.InMemoryBankPtr = ms_pInMemoryBankPtr; AKRESULT result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID); if (result != AKRESULT.AK_Success) { HobaDebuger.LogErrorFormat("DoLoadBankFromImage failed with result: {0} {1}", result, in_bankPath); return(false); } bankEntry.BankID = ms_bankID; return(true); }