2020-05-09 13:31:21 +08:00
|
|
|
|
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
|
|
|
|
|
|
2021-03-04 19:29:15 +08:00
|
|
|
|
|
2021-01-27 12:08:09 +08:00
|
|
|
|
function GetPreferredHeight(_transform)
|
2021-03-04 19:29:15 +08:00
|
|
|
|
ForceRebuildLayout(_transform)
|
2021-01-27 12:08:09 +08:00
|
|
|
|
return LayoutUtility.GetPreferredHeight(_transform)
|
|
|
|
|
end
|
|
|
|
|
function GetPreferredWidth(_transform)
|
2021-03-04 19:29:15 +08:00
|
|
|
|
ForceRebuildLayout(_transform)
|
2021-01-27 12:08:09 +08:00
|
|
|
|
return LayoutUtility.GetPreferredWidth(_transform)
|
|
|
|
|
end
|
2021-03-04 19:29:15 +08:00
|
|
|
|
|
2021-02-25 17:31:26 +08:00
|
|
|
|
function ForceRebuildLayout(_transform)
|
2021-03-10 14:56:53 +08:00
|
|
|
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.LayoutBuilderWrap)
|
|
|
|
|
or ServerConfigManager.GetSDKVersionCode() >= 25
|
|
|
|
|
then
|
2021-03-04 19:29:15 +08:00
|
|
|
|
if not LayoutRebuilder then
|
|
|
|
|
LayoutRebuilder = UnityEngine.UI.LayoutRebuilder
|
|
|
|
|
end
|
2021-02-25 17:31:26 +08:00
|
|
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(_transform)
|
|
|
|
|
end
|
|
|
|
|
end
|