Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yqian1000
Rebirth_DeckTool
提交
2179ddf7
R
Rebirth_DeckTool
项目概览
yqian1000
/
Rebirth_DeckTool
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rebirth_DeckTool
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2179ddf7
编写于
4月 20, 2023
作者:
yqian1000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化图片加载
上级
c14f7cec
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
18 deletion
+56
-18
Assets/Scripts/Logic/Data/Card.cs
Assets/Scripts/Logic/Data/Card.cs
+1
-1
Assets/Scripts/Logic/Data/Series.cs
Assets/Scripts/Logic/Data/Series.cs
+1
-1
Assets/Scripts/Logic/DownloadImage.cs
Assets/Scripts/Logic/DownloadImage.cs
+29
-16
Assets/Scripts/UI/Cards/UICardItem.cs
Assets/Scripts/UI/Cards/UICardItem.cs
+25
-0
未找到文件。
Assets/Scripts/Logic/Data/Card.cs
浏览文件 @
2179ddf7
...
...
@@ -37,7 +37,7 @@ public class Card
return
_img
;
}
}
Texture2D
_img
;
public
Texture2D
_img
;
public
Card
(
string
series
,
string
html
,
string
imgUrl
)
{
...
...
Assets/Scripts/Logic/Data/Series.cs
浏览文件 @
2179ddf7
...
...
@@ -120,7 +120,7 @@ public class Series
for
(
int
i
=
0
;
i
<
data
.
Count
;
i
++)
{
Card
card
=
new
Card
(
data
[
i
]);
//
card.CheckImgFile();
card
.
CheckImgFile
();
AddCard
(
card
);
}
}
...
...
Assets/Scripts/Logic/DownloadImage.cs
浏览文件 @
2179ddf7
...
...
@@ -8,6 +8,7 @@ using UnityEngine;
using
UnityEngine.Networking
;
using
static
Unity
.
VisualScripting
.
Member
;
using
DG.Tweening.Plugins.Core.PathCore
;
using
UnityEngine.Profiling
;
public
class
DownlaodImage
:
SingletonMono
<
DownlaodImage
>
{
...
...
@@ -25,15 +26,17 @@ public class DownlaodImage : SingletonMono<DownlaodImage>
/// <returns></returns>
public
Texture2D
GetImage
(
Card
card
)
{
//Profiler.BeginSample("GetImage");
Texture2D
texture2D
=
LoadImageInFile
(
card
);
if
(
texture2D
==
null
)
{
texture2D
=
(
RebirthBG
==
null
)
?
LoadRebirthBG
()
:
RebirthBG
;
//DownloadQueue.Enqueue(card);
//if (!downloading) StartCoroutine(DownLoadQueue());
DownloadQueue
.
Enqueue
(
card
);
//Logger.Log($"DownloadQueue.Enqueue>>{card.Name}>>{DownloadQueue.Count}");
if
(!
downloading
)
StartCoroutine
(
DownLoadQueue
());
}
//Profiler.EndSample();
return
texture2D
;
}
/// <summary>
...
...
@@ -146,23 +149,33 @@ public class DownlaodImage : SingletonMono<DownlaodImage>
downloading
=
true
;
while
(
DownloadQueue
.
TryDequeue
(
out
Card
card
))
{
//Logger.Log($"DownloadQueue:{DownloadQueue.Count}");
//尝试在Resource下加载
string
path
=
""
;
var
resq
=
Resources
.
LoadAsync
<
Texture2D
>(
path
);
while
(!
resq
.
isDone
)
if
(
card
.
_img
!=
null
)
continue
;
//跳除重复加载
//load本地
Texture2D
texture2D
=
LoadImageInFile
(
card
);
if
(
texture2D
)
{
yield
return
null
;
card
.
Img
=
texture2D
;
}
if
(
resq
.
asset
)
else
//loadResource
{
card
.
Img
=
resq
.
asset
as
Texture2D
;
EventManager
.
TriggerEvent
<
string
>(
"DownloadingImgComplete"
,
card
.
Num
);
string
folder
=
card
.
Series
.
Replace
(
"/"
,
""
);
string
path
=
$"data/
{
folder
}
/Img/
{
card
.
Num
.
Replace
(
"/"
,
"_"
)}
"
;
var
resq
=
Resources
.
Load
<
Texture2D
>(
path
);
if
(
resq
)
{
card
.
Img
=
resq
;
EventManager
.
TriggerEvent
<
string
>(
"DownloadingImgComplete"
,
card
.
Num
);
}
else
{
//没有则下载
yield
return
StartCoroutine
(
DownloadingImg
(
card
));
}
}
else
//没有则下载
yield
return
StartCoroutine
(
DownloadingImg
(
card
));
yield
return
null
;
}
...
...
@@ -218,7 +231,7 @@ public class DownlaodImage : SingletonMono<DownlaodImage>
card
.
Img
=
texture
;
SaveCard2Local
(
path
,
texture
);
//Logger.Log($"完成下载图片{card.Num}:{path}");
EventManager
.
TriggerEvent
<
string
>(
"DownloadingImgComplete"
,
card
.
Num
);
}
...
...
Assets/Scripts/UI/Cards/UICardItem.cs
浏览文件 @
2179ddf7
...
...
@@ -36,7 +36,27 @@ public class UICardItem : InfiniteElem
dr_count
.
onValueChanged
.
AddListener
(
OnDrCount
);
AddBtnClickListener
(
GetComponent
<
Button
>(),
OnClickSelf
);
EventManager
.
AddListener
<
string
>(
"DownloadingImgComplete"
,
RefreshImg
);
}
public
void
RefreshImg
(
string
num
)
{
if
(
num
==
card
.
Num
)
{
if
(
card
.
Type
==
CardType
.
Rebirth
)
{
rimg_card
.
gameObject
.
SetActive
(
false
);
rimg_rebirth
.
gameObject
.
SetActive
(
true
);
rimg_rebirth
.
texture
=
card
.
Img
;
}
else
{
rimg_card
.
gameObject
.
SetActive
(
true
);
rimg_rebirth
.
gameObject
.
SetActive
(
false
);
rimg_card
.
texture
=
card
.
Img
;
}
}
}
public
void
OnDrCount
(
int
val
)
...
...
@@ -95,6 +115,7 @@ public class UICardItem : InfiniteElem
protected
override
void
OnClose
()
{
base
.
OnClose
();
EventManager
.
RemoveListener
<
string
>(
"DownloadingImgComplete"
,
RefreshImg
);
}
public
override
void
OnSetData
(
object
[]
data
=
null
)
...
...
@@ -108,4 +129,8 @@ public class UICardItem : InfiniteElem
UICardsCtrl
.
Instance
.
OpenCardInfoView
(
new
object
[]
{
card
});
}
private
void
OnDestroy
()
{
EventManager
.
RemoveListener
<
string
>(
"DownloadingImgComplete"
,
RefreshImg
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录