98 lines
2.9 KiB
Lua
98 lines
2.9 KiB
Lua
|
local require = require
|
|||
|
local string = string
|
|||
|
local table = table
|
|||
|
|
|||
|
int64.zero = int64.new(0,0)
|
|||
|
uint64.zero = uint64.new(0,0)
|
|||
|
|
|||
|
function string.split(input, delimiter)
|
|||
|
input = tostring(input)
|
|||
|
delimiter = tostring(delimiter)
|
|||
|
if (delimiter=='') then return false end
|
|||
|
local pos,arr = 0, {}
|
|||
|
-- for each divider found
|
|||
|
for st,sp in function() return string.find(input, delimiter, pos, true) end do
|
|||
|
table.insert(arr, string.sub(input, pos, st - 1))
|
|||
|
pos = sp + 1
|
|||
|
end
|
|||
|
table.insert(arr, string.sub(input, pos))
|
|||
|
return arr
|
|||
|
end
|
|||
|
|
|||
|
function import(moduleName, currentModuleName)
|
|||
|
local currentModuleNameParts
|
|||
|
local moduleFullName = moduleName
|
|||
|
local offset = 1
|
|||
|
|
|||
|
while true do
|
|||
|
if string.byte(moduleName, offset) ~= 46 then -- .
|
|||
|
moduleFullName = string.sub(moduleName, offset)
|
|||
|
if currentModuleNameParts and #currentModuleNameParts > 0 then
|
|||
|
moduleFullName = table.concat(currentModuleNameParts, ".") .. "." .. moduleFullName
|
|||
|
end
|
|||
|
break
|
|||
|
end
|
|||
|
offset = offset + 1
|
|||
|
|
|||
|
if not currentModuleNameParts then
|
|||
|
if not currentModuleName then
|
|||
|
local n,v = debug.getlocal(3, 1)
|
|||
|
currentModuleName = v
|
|||
|
end
|
|||
|
|
|||
|
currentModuleNameParts = string.split(currentModuleName, ".")
|
|||
|
end
|
|||
|
table.remove(currentModuleNameParts, #currentModuleNameParts)
|
|||
|
end
|
|||
|
|
|||
|
return require(moduleFullName)
|
|||
|
end
|
|||
|
|
|||
|
--重新require一个lua文件,替代系统文件。
|
|||
|
function reimport(name)
|
|||
|
local package = package
|
|||
|
package.loaded[name] = nil
|
|||
|
package.preload[name] = nil
|
|||
|
return require(name)
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
function GetPreferredHeight(_transform)
|
|||
|
ForceRebuildLayout(_transform)
|
|||
|
return LayoutUtility.GetPreferredHeight(_transform)
|
|||
|
end
|
|||
|
function GetPreferredWidth(_transform)
|
|||
|
ForceRebuildLayout(_transform)
|
|||
|
return LayoutUtility.GetPreferredWidth(_transform)
|
|||
|
end
|
|||
|
|
|||
|
function ForceRebuildLayout(_transform)
|
|||
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.LayoutBuilderWrap)
|
|||
|
or ServerConfigManager.GetSDKVersionCode() >= 25
|
|||
|
then
|
|||
|
if not LayoutRebuilder then
|
|||
|
LayoutRebuilder = UnityEngine.UI.LayoutRebuilder
|
|||
|
end
|
|||
|
LayoutRebuilder.ForceRebuildLayoutImmediate(_transform)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function LoadStreamingTexture(spLoader, name, func)
|
|||
|
if name and name ~= "" and func then
|
|||
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_LOAD_STREAMING) then
|
|||
|
resMgr:LoadStreamingTexture(name, function(sp)
|
|||
|
if sp then
|
|||
|
func(sp)
|
|||
|
else
|
|||
|
name = string.split(name, ".")[1]
|
|||
|
local sp = spLoader:LoadSprite(name)
|
|||
|
func(sp)
|
|||
|
end
|
|||
|
end)
|
|||
|
else
|
|||
|
name = string.split(name, ".")[1]
|
|||
|
local sp = spLoader:LoadSprite(name)
|
|||
|
func(sp)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|