GlobalFunctions.lua.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. GlobalFunctions = GlobalFunctions or {}
  2. function ShowNotice(info)
  3. local uiControllerPath = "UI/Public/ZUITextNotice.lua"
  4. require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
  5. require(uiControllerPath).NoticeInfo(info)
  6. end
  7. function ShowDialogOK(tips)
  8. local uiControllerPath = "UI/Public/ZUIPanelDialogOK.lua"
  9. require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
  10. require(uiControllerPath).SetInfo(tips)
  11. end
  12. function ShowDialogConfirm(tips, confirmFunction, cancelFunction)
  13. local uiControllerPath = "UI/Public/ZUIPanelDialogConfirm.lua"
  14. require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
  15. require(uiControllerPath).SetInfo(tips, confirmFunction, cancelFunction)
  16. end
  17. function Debug(...)
  18. CS.UnityEngine.Debug.Log(...)
  19. end
  20. function Debugf(format, ...)
  21. CS.UnityEngine.Debug.Log(string.format(format, ...))
  22. end
  23. function Warn(...)
  24. CS.UnityEngine.Debug.LogWarning(...)
  25. end
  26. function Warnf(format, ...)
  27. CS.UnityEngine.Debug.LogWarning(string.format(format, ...))
  28. end
  29. function LoadResource(resPath)
  30. --Warnf("---- ----> isEditor: %s Path: %s", tostring(CS.UnityEngine.Application.isEditor), resPath)
  31. if CS.UnityEngine.Application.isEditor == true then
  32. return CS.SFramework.SResourceManagerE.LoadResource(resPath)
  33. else
  34. return CS.SFramework.SResourceManagerR.LoadResource(resPath)
  35. end
  36. end
  37. function GetCache(key, value)
  38. local dataRelay = require("Base/DataRelay.lua")
  39. local cache = dataRelay:GetCache(dataRelay.KEY_TYPE[key], value)
  40. return cache
  41. end
  42. function SetCache(key, value)
  43. local dataRelay = require("Base/DataRelay.lua")
  44. dataRelay:SetCache(dataRelay.KEY_TYPE[key], value)
  45. end
  46. function PrintTable(tab, csp)
  47. local szTabel = require("Base/Utils.lua"):Table2String(tab, csp)
  48. print(szTabel)
  49. end
  50. local function __TRACKBACK__(szErrorMsg)
  51. local szTrackText = debug.traceback(tostring(szErrorMsg), 6);
  52. print("---------------------------------------- TRACKBACK ----------------------------------------");
  53. print(szTrackText, "LUA ERROR");
  54. print("---------------------------------------- TRACKBACK ----------------------------------------");
  55. local szExceptionText = "LUA EXCEPTION\n" .. szTrackText;
  56. --[[Error("---------------------------------------- TRACKBACK ----------------------------------------");
  57. Error(szTrackText .. " LUA ERROR");
  58. Error("---------------------------------------- TRACKBACK ----------------------------------------");
  59. Error(szExceptionText)]]
  60. CS.UnityEngine.Debug.LogWarning(szExceptionText)
  61. return false;
  62. end
  63. function SafeCall(fnFunc, ...)
  64. local tArgs = { ... };
  65. return xpcall(function() return fnFunc(table.unpack(tArgs)) end, __TRACKBACK__);
  66. end