GlobalFunctions.lua.txt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. GlobalFunctions = GlobalFunctions or {}
  2. function ShowNotice(info)
  3. local uiControllerPath = "UI/Public/SUINoticeText.lua"
  4. require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
  5. require(uiControllerPath).NoticeInfo(info)
  6. end
  7. function ShowDialogOK(tips)
  8. local uiControllerPath = "UI/Public/SUIDialogOKPanel.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/SUIDialogConfirmPanel.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. local function __TRACKBACK__(szErrorMsg)
  38. local szTrackText = debug.traceback(tostring(szErrorMsg), 6);
  39. print("---------------------------------------- TRACKBACK ----------------------------------------");
  40. print(szTrackText, "LUA ERROR");
  41. print("---------------------------------------- TRACKBACK ----------------------------------------");
  42. local szExceptionText = "LUA EXCEPTION\n" .. szTrackText;
  43. --[[Error("---------------------------------------- TRACKBACK ----------------------------------------");
  44. Error(szTrackText .. " LUA ERROR");
  45. Error("---------------------------------------- TRACKBACK ----------------------------------------");
  46. Error(szExceptionText)]]
  47. CS.UnityEngine.Debug.LogWarning(szExceptionText)
  48. return false;
  49. end
  50. function SafeCall(fnFunc, ...)
  51. local tArgs = { ... };
  52. return xpcall(function() return fnFunc(table.unpack(tArgs)) end, __TRACKBACK__);
  53. end