upgrade
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user