This commit is contained in:
2020-08-01 17:55:18 +08:00
parent 29a8a1dae3
commit 4435098171
160 changed files with 21247 additions and 2405 deletions

View File

@@ -1,6 +1,9 @@
DBTextures = {}
local db = {}
local dbUploadStatus = {}
local isUploading = {}
function DBTextures.init()
InvokeEx.cancelInvoke(DBTextures.releaseTimeout)
InvokeEx.invoke(DBTextures.releaseTimeout, 60)
@@ -12,6 +15,15 @@ function DBTextures.clean()
GameObject.DestroyImmediate(v)
end
db = {}
---@param v UnityEngine.UnityWebRequest
for k, www in pairs(dbUploadStatus) do
if www then
www.Dispose()
www = nil
end
end
dbUploadStatus = {}
end
function DBTextures.releaseTimeout()
@@ -50,4 +62,41 @@ function DBTextures.getByUrl(url, callback, orgs)
return request
end
function DBTextures.upload(path, uploadPath, finishCallback)
local key = joinStr(path, "_", uploadPath)
if (not dbUploadStatus[key]) and (not isUploading[key]) then
local www =
NetProto.uploadFile(
path,
uploadPath,
function(result, orgs)
isUploading[key] = nil
if result then
dbUploadStatus[key] = result
end
Utl.doCallback(finishCallback, result)
end
)
isUploading[key] = www
return www
else
if dbUploadStatus[key] then
Utl.doCallback(finishCallback, dbUploadStatus[key])
else
printe("进到这里来了,有问题!!!!!!!")
end
end
end
function DBTextures.cancelUpload(path, uploadPath)
local key = joinStr(path, "_", uploadPath)
local www = isUploading[key]
if www then
www.Dispose()
www = nil
dbUploadStatus[key] = nil
isUploading[key] = nil
end
end
return DBTextures