Compare commits

..

336 Commits

Author SHA1 Message Date
e8953e593e Merge pull request 'master' (#56) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #56
2024-11-21 17:41:16 +08:00
ALIENJACK\alien
d907913bfc 新建一个Initer monobehaviour,用来提前加载app.init 2024-11-21 17:40:01 +08:00
ALIENJACK\alien
ecde8f6682 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
# Conflicts:
#	AxibugEmuOnline.Client/Assets/Script/App.cs
2024-11-21 17:19:11 +08:00
ALIENJACK\alien
38a825f49e 123 2024-11-21 17:18:51 +08:00
25375047e2 打包前归档 2024-11-21 17:18:15 +08:00
ALIENJACK\alien
88ba7c189c 添加preserve 2024-11-21 17:08:44 +08:00
ALIENJACK\alien
912ad6b045 修复背景颜色未设置时,返回默认颜色的代码错误
rename BgSetting_Color.cs->UI_BgSettingItem_Color.cs
2024-11-21 17:03:06 +08:00
ALIENJACK\alien
34e9090446 修复一些奇怪的命名空间引用 移除冗余的package 2024-11-21 16:53:05 +08:00
6faa42c767 Merge pull request '修改destroy回调警告' (#55) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #55
2024-11-21 16:22:27 +08:00
ALIENJACK\alien
797ab0c843 修改destroy回调警告 2024-11-21 16:12:54 +08:00
a91d404944 Merge pull request 'master' (#54) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #54
2024-11-20 19:37:05 +08:00
ALIENJACK\alien
5dae909fa2 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-20 19:33:25 +08:00
b4680b74a3 注释 2024-11-19 13:54:23 +08:00
3ec227f690 注释 2024-11-19 13:52:37 +08:00
ALIENJACK\alien
b54de1e162 状态栏显示帧数 2024-11-19 13:09:53 +08:00
ALIENJACK\alien
36c461562e 修复bug 2024-11-19 12:08:21 +08:00
ALIENJACK\alien
6b30c73c30 修复uint*作为模拟器核心屏幕数据时,一些批量赋值的bug 2024-11-19 11:59:37 +08:00
8452be9fc8 服务器被动追帧+优化广播 2024-11-18 23:46:02 +08:00
e0e756b67c Merge pull request 'Rom列表搜索功能实现' (#53) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #53
2024-11-15 10:53:56 +08:00
ALIENJACK\alien
3249a0b642 UI调整 2024-11-15 10:53:19 +08:00
ALIENJACK\alien
7db6220c30 XMB shader现在是一个完备的ugui shader 2024-11-15 09:49:15 +08:00
ALIENJACK\alien
d3f1f76e70 动效调整 2024-11-14 20:23:51 +08:00
ALIENJACK\alien
56f2953a99 颜色预览shader修改 2024-11-14 20:10:01 +08:00
ALIENJACK\alien
2c36f91725 颜色选择加入渐变 2024-11-14 20:07:24 +08:00
ALIENJACK\alien
df32ff6a3a 优化背景shader表现 2024-11-14 19:25:44 +08:00
ALIENJACK\alien
4ca053f624 实现背景颜色切换 2024-11-14 17:14:52 +08:00
ALIENJACK\alien
2a846aaf4e UI资源微调 2024-11-14 14:19:28 +08:00
ALIENJACK\alien
a064078d0d 完美像素! 2024-11-14 12:02:11 +08:00
ALIENJACK\alien
43e7ba8332 ppu lpScreen改为指针版本 2024-11-14 11:17:17 +08:00
ALIENJACK\alien
3913595b18 移除debug代码 2024-11-13 19:25:46 +08:00
ALIENJACK\alien
ae9fee30ef 修复存档问题 2024-11-13 18:42:30 +08:00
ALIENJACK\alien
e9dd949c10 移除操作 2024-11-13 14:03:11 +08:00
ALIENJACK\alien
2493cd8520 Rom列表搜索功能实现 2024-11-13 13:55:36 +08:00
c75ee229d4 log 2024-11-12 17:48:12 +08:00
58a432eb3c Merge pull request 'master' (#52) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #52
2024-11-12 16:51:31 +08:00
ALIENJACK\alien
4afcc2f1f1 添加动态追帧机制 2024-11-12 14:55:45 +08:00
ALIENJACK\alien
46a404f40b Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-12 14:49:39 +08:00
ALIENJACK\alien
bddb84c57d 微调追帧策略 2024-11-12 14:47:57 +08:00
264d3609f1 Merge pull request 'master' (#51) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #51
2024-11-12 12:51:53 +08:00
ALIENJACK\alien
0dd21f6d50 同步bug修复 2024-11-12 12:49:58 +08:00
ALIENJACK\alien
c6d3ac4aea Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-12 09:59:46 +08:00
0e96b4619a NetReplay 2024-11-12 09:59:09 +08:00
ALIENJACK\alien
c311772589 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-12 09:58:43 +08:00
ALIENJACK\alien
edc84fc3cf 开放模拟器核心帧序号 2024-11-12 09:58:30 +08:00
36787e1018 NetReplay 2024-11-12 09:56:07 +08:00
4dac834555 Merge pull request 'master' (#50) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #50
2024-11-11 20:21:01 +08:00
ALIENJACK\alien
11d7f681b0 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-11 20:19:59 +08:00
ALIENJACK\alien
195afdafb8 增加追帧机制 2024-11-11 20:19:50 +08:00
3d2e9e1f0a Merge pull request 'master' (#49) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #49
2024-11-11 20:18:22 +08:00
ALIENJACK\alien
9324e185ef 修复bug 2024-11-11 20:09:54 +08:00
ALIENJACK\alien
5e94eb4d16 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-11 19:42:19 +08:00
5c0730c8f9 NetFix 2024-11-11 19:21:35 +08:00
ALIENJACK\alien
7a7e089542 主界面UI调整 2024-11-11 18:18:59 +08:00
ALIENJACK\alien
bca708282b Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-11 17:26:00 +08:00
ALIENJACK\alien
0aefa7f8ad 修复Room列表颜色问题 2024-11-11 17:25:43 +08:00
ALIENJACK\alien
0887c62424 修复OptionUI找寻一个可以被选中的Item时的死循环报错 2024-11-11 17:23:44 +08:00
ALIENJACK\alien
45539f3b92 为二级UI增加左方向键返回功能,修复Room列表初始时的位置错误 2024-11-11 17:11:15 +08:00
73f1f858fd frame test 2024-11-11 16:39:41 +08:00
abd61b4da1 fix 2024-11-11 16:31:19 +08:00
d0d5655681 log 2024-11-11 16:12:54 +08:00
a4f8a382ac netreplay 2024-11-11 15:40:21 +08:00
ea2e63cb58 NetReplay 2024-11-11 13:58:27 +08:00
960aad4831 recvInput 2024-11-11 11:39:38 +08:00
4606a57157 Merge pull request '修复bug' (#48) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #48
2024-11-11 11:06:46 +08:00
ALIENJACK\alien
9c4d57bdef 修复bug 2024-11-11 10:48:30 +08:00
6ad26bba8e Merge pull request '修复bug' (#47) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #47
2024-11-11 10:10:39 +08:00
ALIENJACK\alien
a18d52e0c7 修复bug 2024-11-11 10:09:11 +08:00
5bd858e1a5 Merge pull request 'master' (#46) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #46
2024-11-11 09:34:24 +08:00
ALIENJACK\alien
eefde2e9b6 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-11 09:32:30 +08:00
ALIENJACK\alien
87d954bb71 移除debug代码 2024-11-11 09:32:13 +08:00
a09e2e86ab Merge pull request 'master' (#45) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #45
2024-11-08 17:18:01 +08:00
ALIENJACK\alien
357936866d 修复bug 2024-11-08 16:23:26 +08:00
ALIENJACK\alien
4bba088077 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-08 16:23:10 +08:00
ALIENJACK\alien
9ff8879c9c shader参数开放 2024-11-08 14:56:33 +08:00
469031dabc Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-08 13:53:18 +08:00
1c0094d836 room 2024-11-08 13:53:13 +08:00
c498ea7967 Merge pull request 'master' (#44) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #44
2024-11-08 13:49:32 +08:00
ALIENJACK\alien
d87d2da55a 修复联机流程bug 2024-11-08 13:48:53 +08:00
ALIENJACK\alien
1f8f5c2773 事件异常日志优化,XMBshader优化 2024-11-08 12:01:16 +08:00
7971b4a4ba Merge pull request '完善一些网络状态判断' (#43) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #43
2024-11-08 11:51:30 +08:00
ALIENJACK\alien
6c8e2133ca 完善一些网络状态判断 2024-11-08 11:49:33 +08:00
0323836ed2 Merge pull request '修复bug' (#42) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #42
2024-11-08 11:39:21 +08:00
ALIENJACK\alien
5f74e2892e 修复bug 2024-11-08 11:38:32 +08:00
5863a6798f Merge pull request 'master' (#41) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #41
2024-11-08 11:34:30 +08:00
ALIENJACK\alien
814cc5ed5e 进入房间相关代码流程实现 2024-11-08 11:31:12 +08:00
ALIENJACK\alien
46a62ca9f7 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-11-08 10:03:17 +08:00
43a7cca091 test flag 2024-11-08 10:00:57 +08:00
1fa61bb5a0 fix 2024-11-08 09:59:35 +08:00
eb73b30732 完善房间 2024-11-08 09:41:09 +08:00
ALIENJACK\alien
323f7a44df 迭代 2024-11-07 20:33:44 +08:00
ALIENJACK\alien
7b85fd8ce8 迭代 2024-11-07 20:20:53 +08:00
1c589ac3be Merge pull request 'master' (#40) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #40
2024-11-07 19:42:12 +08:00
ALIENJACK\alien
12716c77c8 房间列表事件监听 2024-11-07 19:38:48 +08:00
ALIENJACK\alien
dfee4fa002 Room列表迭代 2024-11-07 19:23:59 +08:00
ALIENJACK\alien
9f732c7719 房间列表获取,调用实装 2024-11-07 19:18:50 +08:00
ALIENJACK\alien
88313eee6b IEmuCore接口增加获取gameObject的方法,完善游戏中和UI操作的操作集切换功能 2024-11-07 17:58:20 +08:00
b66df94086 Merge pull request 'master' (#39) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #39
2024-09-24 18:01:58 +08:00
ALIENJACK\alien
ad021664db NesGamingScheme实现 2024-09-23 18:31:05 +08:00
ALIENJACK\alien
d5be477dd8 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
# Conflicts:
#	AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandDispatcher.cs
2024-09-23 18:16:03 +08:00
ALIENJACK\alien
7eac4e7586 抽象EmuCore和键位集 2024-09-23 18:15:34 +08:00
def785b3a3 PSVitaKey 2024-09-23 13:21:51 +08:00
23db5358fb room mgr fix 2024-09-20 18:27:13 +08:00
ALIENJACK\alien
e1fb708d6e RemoteRoms文件夹中的Rom文件现在会和服务器提供的hash进行比较,以确定该文件是否合法,不合法会被移除 2024-09-20 17:16:30 +08:00
ALIENJACK\alien
abc68f68c3 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-20 17:10:44 +08:00
ALIENJACK\alien
c47b241e42 稍微重构,以支持加载用户自己提供的Rom文件 2024-09-20 17:10:32 +08:00
2b051b7a27 hash | PSVita dir 2024-09-20 17:10:18 +08:00
ALIENJACK\alien
f4adf4e20f Room列表菜单添加 2024-09-18 15:53:58 +08:00
68f121df60 单个rom 信息查询 webapi 2024-09-18 12:54:13 +08:00
68f19925d6 Merge pull request 'master' (#38) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #38
2024-09-18 11:56:41 +08:00
ALIENJACK\alien
1df264be3b Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-18 11:52:02 +08:00
46fdfee412 是否画面提供者 2024-09-18 11:37:43 +08:00
8d432ddcd4 离开房间 2024-09-18 11:35:53 +08:00
ALIENJACK\alien
1899fcdcd9 主界面菜单尺寸调整 2024-09-18 10:58:38 +08:00
ALIENJACK\alien
11739c11c5 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-18 10:45:07 +08:00
935518a2e1 png 2024-09-18 10:44:41 +08:00
1e32a111b5 获取单个房间画面快照 2024-09-18 10:21:06 +08:00
ALIENJACK\alien
181ce9a420 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-18 10:02:35 +08:00
1d283f5d20 Room 列表 2024-09-18 10:01:54 +08:00
e438fd6b29 .. 2024-09-14 18:13:46 +08:00
5347a81356 merge 2024-09-14 17:50:39 +08:00
bb93b43ba8 netinput 2024-09-14 17:43:08 +08:00
ALIENJACK\alien
6e34b02c29 修bug 2024-09-14 17:40:01 +08:00
7aa07500b2 Merge pull request 'master' (#37) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #37
2024-09-14 17:38:09 +08:00
ALIENJACK\alien
0babeed270 联网代码上传 2024-09-14 17:22:01 +08:00
ALIENJACK\alien
fa8c642a69 进入房间create rom 2024-09-14 15:56:15 +08:00
ALIENJACK\alien
3aa6f7a951 修改Nes进入游戏流程 2024-09-14 15:32:29 +08:00
ALIENJACK\alien
2771e887e1 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-14 09:47:00 +08:00
ALIENJACK\alien
dc16d85ae9 快照机制完善 2024-09-14 09:46:49 +08:00
e0d6e0542d 房间逻辑推进 2024-09-13 18:07:27 +08:00
3ca7b6a0c7 Merge pull request 'master' (#36) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #36
2024-09-13 18:05:29 +08:00
ALIENJACK\alien
16b3d92ca9 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-13 18:04:09 +08:00
ALIENJACK\alien
7834ae0d82 删除多余 2024-09-13 18:02:38 +08:00
ALIENJACK\alien
12c02781a0 实现NesCore LoadState和SaveState 2024-09-13 17:39:48 +08:00
01c3aff056 场景 2024-09-13 16:44:33 +08:00
2fe789686a 电量 2024-09-13 16:26:26 +08:00
ALIENJACK\alien
fea833734d 优化shader性能 2024-09-13 14:24:18 +08:00
ALIENJACK\alien
e4bbc5eee1 XMB背景shader移除自己声明的lerp方法,使用系统lerp方法 2024-09-13 13:57:02 +08:00
3eb8059389 fixed netreplay 2024-09-13 13:52:37 +08:00
42b3a7995c 远端差异帧 2024-09-13 13:46:04 +08:00
841fff9be2 服务器当前帧 2024-09-13 13:41:04 +08:00
3927b897a2 Merge pull request 'master' (#35) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #35
2024-09-13 13:30:20 +08:00
ALIENJACK\alien
e9099ea49a 添加游戏内UI,以及呼出侧边菜单栏的功能 2024-09-13 13:28:33 +08:00
ALIENJACK\alien
233e38e921 侧边栏菜单迭代 2024-09-13 10:28:02 +08:00
d567cd9e71 服务端逻辑修改 2024-09-13 10:10:14 +08:00
5b8ed639f3 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-13 10:08:02 +08:00
a4caf1d3ad 新增ping 2024-09-13 10:07:24 +08:00
c27b8d514c Merge pull request 'master' (#34) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #34
2024-09-13 10:05:03 +08:00
ALIENJACK\alien
b2d22a503d Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-12 17:48:07 +08:00
ALIENJACK\alien
ec8f01065b 删一下命名空间 2024-09-12 17:47:55 +08:00
ALIENJACK\alien
7209b52c93 UI迭代 2024-09-12 17:47:05 +08:00
ALIENJACK\alien
040c23e001 UI调整,事件派发机制抽象结构调整 2024-09-12 16:20:11 +08:00
ALIENJACK\alien
f8fc518a44 目录结构调整 2024-09-12 15:10:48 +08:00
ALIENJACK\alien
7d7b864c1b 重构UI菜单继承结构 2024-09-12 15:08:48 +08:00
9fcd5d3c3e WebApi 检查版本和获取服务器IP 2024-09-12 14:35:44 +08:00
ALIENJACK\alien
d2f48a56e7 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-12 13:43:07 +08:00
ALIENJACK\alien
d38a653280 OptionUI迭代 2024-09-12 13:42:57 +08:00
299d825f4a Server合并画面同步到RoomMgr 2024-09-12 13:42:24 +08:00
caaac4a202 新增服务器P3 P4 | Protobuff | 顶部预制体 2024-09-12 13:41:19 +08:00
ALIENJACK\alien
e6dd0ec952 Game_NES 改名RomListMenuItem 更通用 2024-09-12 11:34:32 +08:00
ALIENJACK\alien
e90d74e63c 调整主场景结构 2024-09-12 11:19:40 +08:00
ALIENJACK\alien
86ec353733 修复UI表现 2024-09-12 11:02:30 +08:00
8e61551d3d Merge pull request '重构一下' (#33) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #33
2024-09-11 18:32:23 +08:00
ALIENJACK\alien
828e87c3d0 重构一下 2024-09-11 18:31:25 +08:00
bf028d6302 Merge pull request 'master' (#32) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #32
2024-09-11 18:12:50 +08:00
ALIENJACK\alien
95bcf0e5bf Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
# Conflicts:
#	AxibugEmuOnline.Client/Assets/Plugins/Demigiant/DOTween/DOTween.dll.meta
2024-09-11 18:12:08 +08:00
ALIENJACK\alien
8dea4ccee1 dotween dll 提交 2024-09-11 18:11:23 +08:00
9e427d1532 完成基础房间逻辑封装 | NetRePlay 2024-09-11 18:10:47 +08:00
ALIENJACK\alien
c3804940a9 增加了移除Cache和Rom文件的api 2024-09-11 16:48:23 +08:00
ALIENJACK\alien
f36ec11af8 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-09-11 16:34:01 +08:00
ALIENJACK\alien
c0585283a7 UI迭代 2024-09-11 16:33:48 +08:00
a66835c091 补充Mapper from VirtuaNESex 2024-09-11 16:04:55 +08:00
ALIENJACK\alien
8f23ef3b19 dotween dll meta 2024-09-04 11:39:22 +08:00
2510b2b7e3 Merge pull request 'master' (#31) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #31
2024-08-30 18:18:44 +08:00
ALIENJACK\alien
9c80ed0a26 修复Rom列表,对象池复用,状态未回转的bug 2024-08-30 16:28:05 +08:00
ALIENJACK\alien
96d0df5348 UI迭代 2024-08-30 16:23:27 +08:00
ALIENJACK\alien
fc94396dfa Ui迭代 2024-08-29 18:31:36 +08:00
ALIENJACK\alien
5064465c2a Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-08-29 17:31:07 +08:00
ALIENJACK\alien
273015f95b 补充State 2024-08-29 17:30:56 +08:00
ALIENJACK\alien
5ce82c9406 NEScore StateSave机制 实现 2024-08-29 17:20:01 +08:00
6a5393d9bc 补充Mapper 即时存档代码 | EEROM代码补充实现 2024-08-28 17:38:01 +08:00
ALIENJACK\alien
2f5b5d9841 UI 迭代 2024-08-22 17:25:00 +08:00
ALIENJACK\alien
4ca885d9fc Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-08-22 15:17:15 +08:00
ALIENJACK\alien
0290ebbd06 UI迭代 2024-08-22 15:16:58 +08:00
94d03a3b04 Merge pull request 'master' (#30) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #30
2024-08-22 14:26:10 +08:00
6a9ce55af8 web Api 2024-08-22 14:24:11 +08:00
aef3d2045b 服务器房间准备流程,即时存档,准备,帧提前,等逻辑 基本编写 2024-08-21 17:59:55 +08:00
ALIENJACK\alien
71b4bdef6b UI 迭代 2024-08-21 16:28:23 +08:00
ALIENJACK\alien
4e5fa23425 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-08-21 13:02:14 +08:00
a13669dc57 服务器逻辑帧驱动实现,房间protobuf定义 2024-08-21 11:04:53 +08:00
ALIENJACK\alien
3c16932e0f XMB Shader! 2024-08-16 18:19:12 +08:00
ALIENJACK\alien
2a18dc593a XBM迭代 2024-08-16 17:26:28 +08:00
ALIENJACK\alien
41e415dc46 调整目录结构
XMB UI控件迭代
2024-08-16 14:45:44 +08:00
ALIENJACK\alien
5467ecb012 XMB 主菜单Item选中动画实现 2024-08-16 10:53:43 +08:00
c30df0b284 Fix texture channel for psvita 2024-08-16 10:39:51 +08:00
ALIENJACK\alien
bb9ddfb22c 统一入口管理PersistentDataPath目录 2024-08-16 10:36:00 +08:00
ALIENJACK\alien
72a1b76ba0 Rom从RomLib读取后,一些Rom信息获取入口的善后工作 2024-08-16 10:29:51 +08:00
ALIENJACK\alien
417bc25fe4 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-08-16 10:25:09 +08:00
ALIENJACK\alien
b1da41756a 引入Dotween插件
实现XMB主菜单效果
2024-08-16 10:24:40 +08:00
2d701d414d 考虑PSV Unity低版本 修改代码 2024-08-16 10:20:00 +08:00
b9efbbf1d2 fixed web api 2024-08-16 10:09:45 +08:00
ALIENJACK\alien
4d3ddcf4a6 移除meta 2024-08-15 16:10:16 +08:00
ALIENJACK\alien
d8095eaa84 移除AlienUI Core 子模块 弃坑了 2024-08-15 16:09:35 +08:00
ALIENJACK\alien
7191f27cb0 优化内存拷贝耗时 2024-08-15 11:07:54 +08:00
ALIENJACK\alien
c7445147b4 优化数组拷贝的性能 2024-08-15 10:33:29 +08:00
ALIENJACK\alien
8f683b0c3c 包管理器增加了EditorCoroutine包 2024-08-14 16:46:57 +08:00
1a1e5026f8 Merge pull request 'master' (#29) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #29
2024-08-14 15:59:07 +08:00
ALIENJACK\alien
0d609a0c06 引入AlienUICore作为子模块,用于以后制作UI 2024-08-14 15:24:37 +08:00
ALIENJACK\alien
2e67b7ccd9 url解码 2024-08-14 13:20:52 +08:00
ALIENJACK\alien
360ea2f579 支持Http Rom仓库下载 2024-08-14 13:09:22 +08:00
0eccfd3e6d api 2024-08-14 10:36:59 +08:00
ALIENJACK\alien
62377ab9d4 shader修改 2024-08-14 09:42:47 +08:00
ALIENJACK\alien
fe6c427603 Rom下载系统 2024-08-13 18:35:20 +08:00
ALIENJACK\alien
209c31fd72 完成APU_FME7 2024-08-13 17:24:42 +08:00
680a8d4eee Merge pull request 'virtuaNES core 产生的屏幕数据现在使用Shader进行转换' (#28) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #28
2024-08-09 15:48:54 +08:00
ALIENJACK\alien
4da4a243cb virtuaNES core 产生的屏幕数据现在使用Shader进行转换 2024-08-09 15:47:44 +08:00
73e3a744ae Merge pull request 'master' (#27) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #27
2024-08-08 10:00:59 +08:00
ALIENJACK\alien
70b6014fdb 实现APU_N106 2024-08-07 18:31:11 +08:00
ALIENJACK\alien
b812a854aa Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
# Conflicts:
#	References/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.c
#	References/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.h
2024-08-07 17:55:52 +08:00
ALIENJACK\alien
8bbe264f24 Emu2413 库实现 2024-08-07 17:45:38 +08:00
1e914679bb References 2024-08-07 12:07:20 +08:00
06647adda3 md 2024-08-07 11:32:03 +08:00
ALIENJACK\alien
d668f7d8df APU_MMC5移植完成,nes20db.xml移到工程根目录,避免打包 2024-08-07 11:30:18 +08:00
46946d4430 fixed 2024-08-07 11:23:39 +08:00
8af94c51f8 fixed 2024-08-07 11:23:06 +08:00
913ba1a791 归档一次 2024-08-07 11:21:10 +08:00
20f28469b2 Merge pull request 'master' (#26) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #26
2024-08-07 11:19:45 +08:00
ALIENJACK\alien
8952b842b1 APU补全中 2024-08-06 19:50:33 +08:00
ALIENJACK\alien
b8c116aa28 键位配置持久化 2024-08-06 18:52:11 +08:00
ALIENJACK\alien
580de2d245 实现输入 2024-08-06 18:09:32 +08:00
ed93542f48 readme 2024-08-06 17:52:29 +08:00
82e0275b5e Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-08-06 17:50:54 +08:00
2eb1cf1e97 merge 2024-08-06 17:50:51 +08:00
44311f075b changed 163 175 176 178 192 2024-08-06 17:49:14 +08:00
ALIENJACK\alien
aad4c1775a 优化音频读取方式 2024-08-06 16:03:17 +08:00
ALIENJACK\alien
66f0cc5bd7 添加忽略,添加PatternViewer的性能開關,当ROMDB转换了一个Mapper时,写日志 2024-08-06 14:24:55 +08:00
ALIENJACK\alien
e4da00136d ROMDB提交,Mapper修復 2024-08-06 13:49:24 +08:00
c7f32874ae Merge pull request '移除RenderTexutre,调整Resources和StreamAssets目录结构,加上"NES"父目录,以区分不同模拟器,加入ROMDB机制,修改ROM Mapper信息' (#25) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #25
2024-08-05 23:27:30 +08:00
16adace210 fixed 2024-08-05 23:25:40 +08:00
250b230914 addon 2024-08-05 23:19:00 +08:00
bb42d3f3bd transfer Mapper 000~015 2024-08-05 23:16:39 +08:00
ALIENJACK\alien
e27c970d45 移除RenderTexutre,调整Resources和StreamAssets目录结构,加上"NES"父目录,以区分不同模拟器,加入ROMDB机制,修改ROM Mapper信息 2024-08-05 18:42:58 +08:00
ba1ac5d5c2 Merge pull request 'dev_4VirtualNes' (#24) from dev_4VirtualNes into master
Reviewed-on: #24
2024-08-05 18:01:41 +08:00
dc5f55c003 Merge branch 'dev_4VirtualNes' of http://git.axibug.com/sin365/AxibugEmuOnline into dev_4VirtualNes 2024-08-05 17:59:57 +08:00
8b39e9aa02 readme + references 2024-08-05 17:58:53 +08:00
e4b2d67d5e Merge pull request 'dev_4VirtualNes' (#23) from dev_4VirtualNes into master
Reviewed-on: #23
2024-08-05 17:49:41 +08:00
5189cf0053 Merge pull request 'Mapper199修改' (#22) from Alienjack/AxibugEmuOnline:dev_4VirtualNes into dev_4VirtualNes
Reviewed-on: #22
2024-08-05 17:47:46 +08:00
ALIENJACK\alien
81920874cc Mapper199修改 2024-08-05 17:46:33 +08:00
8961831f69 Merge pull request 'Mapper补全' (#21) from Alienjack/AxibugEmuOnline:dev_4VirtualNes into dev_4VirtualNes
Reviewed-on: #21
2024-08-05 11:55:06 +08:00
ALIENJACK\alien
ba8b656914 Mapper补全 2024-08-05 11:52:43 +08:00
4e78287c69 Add Mapper Change case 2024-08-05 10:38:27 +08:00
715e8160e8 Addon Special Lost Mapper 35 111 2024-08-05 10:28:41 +08:00
a6cbe6df74 transfer 016-018 2024-08-05 01:44:13 +08:00
c0e29193f7 transfer Mapper 18-43 2024-08-05 01:33:07 +08:00
f82237b7a5 transfer Mapper 43-68 2024-08-05 00:44:30 +08:00
25c1546ff0 transfer Mapper 69~85 2024-08-05 00:05:15 +08:00
923e41a1ba transfer Mapper 86~113 2024-08-04 23:37:02 +08:00
8617d095b8 readme 2024-08-04 22:38:21 +08:00
d5c8b8dc83 Addon Special Lost Mapper 162,163,175,176,178,192,195,199,216 2024-08-04 22:31:39 +08:00
f39ceedb0f transfer Mapper114~164 2024-08-04 00:32:14 +08:00
cb66081f2c transfer mapper 165-198 2024-08-03 23:15:19 +08:00
f924708dd2 transfer Mapper 200-255.cs 2024-08-03 22:26:53 +08:00
c465f1a66e Merge pull request '优化模拟器提交过来的元素转换为Unity Texture2D数据的代码' (#20) from Alienjack/AxibugEmuOnline:dev_4VirtualNes into dev_4VirtualNes
Reviewed-on: #20
2024-08-02 16:55:26 +08:00
ALIENJACK\alien
0a27237a17 音频 internal 翻译完毕 2024-08-02 16:50:16 +08:00
ALIENJACK\alien
090322a60a 优化模拟器提交过来的元素转换为Unity Texture2D数据的代码 2024-08-02 10:58:04 +08:00
507ef45d3a Merge pull request 'dev_4VirtualNes' (#19) from Alienjack/AxibugEmuOnline:dev_4VirtualNes into dev_4VirtualNes
Reviewed-on: #19
2024-07-31 21:39:54 +08:00
ALIENJACK\alien
8dc535e874 图像出现了 2024-07-31 17:40:32 +08:00
ALIENJACK\alien
4de4291a24 123 2024-07-30 18:53:36 +08:00
ALIENJACK\alien
1a371955f3 提交一个可以在vs2022中编译通过的virtuaNes cpp项目 2024-07-30 12:00:24 +08:00
ALIENJACK\alien
e5fa62d209 迭代中 2024-07-30 11:57:09 +08:00
ALIENJACK\alien
d7846c7182 123 2024-07-29 09:25:19 +08:00
69aa14ca67 Merge pull request 'dev_4VirtualNes' (#18) from Alienjack/AxibugEmuOnline:dev_4VirtualNes into dev_4VirtualNes
Reviewed-on: #18
2024-07-27 00:57:58 +08:00
ALIENJACK\alien
323e8c66a2 迭代 2024-07-26 17:52:33 +08:00
ALIENJACK\alien
88214310d7 迭代 2024-07-25 18:34:52 +08:00
ALIENJACK\alien
652616663c 翻译中 2024-07-25 14:03:52 +08:00
ALIENJACK\alien
51aca30cf7 翻译中 2024-07-25 11:03:58 +08:00
52f5dfa8d8 MyNes Standard2.0 核心归档 2024-07-24 15:03:33 +08:00
625d71c2b9 readme 2024-07-24 14:59:15 +08:00
f4a2d8b876 Merge pull request 'dev_4VirtualNes' (#17) from Alienjack/AxibugEmuOnline:dev_4VirtualNes into dev_4VirtualNes
Reviewed-on: #17
2024-07-24 14:51:31 +08:00
ALIENJACK\alien
0e25114e9c 翻译迭代中 2024-07-24 14:27:10 +08:00
ALIENJACK\alien
2d47b306f4 VirtuaNesCore翻译中 2024-07-23 18:31:59 +08:00
275f2c419f Merge pull request 'master' (#15) from master into dev_4VirtualNes
Reviewed-on: #15
2024-07-22 14:23:56 +08:00
9e5114a9aa Merge pull request 'master' (#14) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #14
2024-07-22 14:23:05 +08:00
ALIENJACK\alien
ab1381423e Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-07-22 13:10:00 +08:00
ALIENJACK\alien
c3c9d97f7d Il2CppSetOptionAttribute 2024-07-22 13:09:42 +08:00
ALIENJACK\alien
e83beaa813 增加il2cppSetOption 2024-07-22 13:09:27 +08:00
f9f348f77f Merge pull request '123' (#13) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #13
2024-07-19 15:35:41 +08:00
ALIENJACK\alien
f22be7a346 123 2024-07-19 15:17:26 +08:00
1a3294d3a3 Merge pull request 'master' (#12) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #12
2024-07-19 12:59:29 +08:00
ALIENJACK\alien
31f3182e35 LoadGame接口提到AppEmu 2024-07-18 16:24:14 +08:00
ALIENJACK\alien
27479341c7 显示canvas 2024-07-18 15:35:14 +08:00
ALIENJACK\alien
68f687b207 移除多余代码 2024-07-18 15:31:15 +08:00
ALIENJACK\alien
2a20131e00 重构一下,让KeyMapper支持各种输入设备 2024-07-18 15:26:43 +08:00
ALIENJACK\alien
8b3b54f731 控制器输入实现 2024-07-18 15:14:45 +08:00
ALIENJACK\alien
34286f4263 删除不要的代码 2024-07-18 13:59:42 +08:00
215058d9e8 Merge pull request 'master' (#11) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #11
2024-07-17 14:33:17 +08:00
ALIENJACK\alien
1fe5204014 迭代 2024-07-17 13:18:45 +08:00
ALIENJACK\alien
57d75cfdcb Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2024-07-17 12:50:34 +08:00
ALIENJACK\alien
1770e2fc45 核心模拟器做成prefab 2024-07-17 12:50:18 +08:00
ALIENJACK\alien
cad555d7ab 完美音效! 2024-07-17 12:43:43 +08:00
584609eecd Merge pull request 'master' (#10) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: #10
2024-07-16 18:00:05 +08:00
ALIENJACK\alien
5f6687d8fc gitignore setting 2024-07-16 17:51:00 +08:00
ALIENJACK\alien
4366ef00f9 android平台兼容性 2024-07-16 17:46:07 +08:00
52cf4e6d65 Merge pull request 'dev_basemynes' (#9) from dev_basemynes into master
Reviewed-on: #9
2024-07-16 16:33:39 +08:00
80872bd78c Merge pull request 'dev_basemynes' (#8) from Alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes
Reviewed-on: #8
2024-07-16 16:32:27 +08:00
ALIENJACK\alien
a6a90929e0 改到resources中读取rom 2024-07-16 16:30:20 +08:00
ALIENJACK\alien
d7f57adca2 Merge branch 'dev_basemynes' of http://git.axibug.com/sin365/AxibugEmuOnline into dev_basemynes 2024-07-16 16:29:46 +08:00
67569e7971 Merge branch 'dev_basemynes' of http://git.axibug.com/sin365/AxibugEmuOnline into dev_basemynes 2024-07-16 10:59:07 +08:00
e0223a38b3 nes游戏数据库 2024-07-16 10:59:01 +08:00
ac4315b3cd . 2024-07-15 16:48:11 +08:00
08fec2ef9d Merge pull request 'master' (#7) from master into dev_basemynes
Reviewed-on: #7
2024-07-15 16:44:23 +08:00
af972e31dc readme 2024-07-15 16:41:43 +08:00
9b1a5c8f7b Merge pull request 'readme' (#6) from dev_basemynes into master
Reviewed-on: #6
2024-07-15 16:37:47 +08:00
bcebfc53ad .gitignore 2024-07-15 16:16:25 +08:00
fe076d5077 Merge pull request 'dev_basemynes' (#5) from dev_basemynes into master
Reviewed-on: #5
2024-07-15 16:14:30 +08:00
83fc3878b7 新增WebApi 2024-07-15 16:12:09 +08:00
5bcf6c5dea webapi 2024-07-15 16:07:36 +08:00
ALIENJACK\alien
1fd27d7fb7 优化音频流数据不够时的数据设置 2024-07-10 17:04:55 +08:00
65978580be Merge pull request 'dev_basemynes' (#4) from alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes
Reviewed-on: #4
2024-07-10 15:06:15 +08:00
ALIENJACK\alien
4644b7022f 流式音频采用DSP实现,VideoProvider和audioProvider改为monobehaviour 2024-07-10 15:02:14 +08:00
1c3d5ac6cf readme 2024-07-09 17:27:36 +08:00
b394410ab0 服务端房间功能 2024-07-09 17:22:09 +08:00
ALIENJACK\alien
b8386bb3c9 忽略配置提交 2024-07-05 11:52:56 +08:00
ALIENJACK\alien
7b3142861f 移除不必要的sln文件 2024-07-05 11:49:51 +08:00
ALIENJACK\alien
2c12958eb8 绘制性能优化 2024-07-05 11:48:35 +08:00
90a64b85fe Merge pull request 'dev_basemynes' (#3) from alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes
Reviewed-on: #3
2024-07-05 11:30:21 +08:00
ALIENJACK\alien
e8152500fd Merge branch 'dev_basemynes' of http://git.axibug.com/sin365/AxibugEmuOnline into dev_basemynes 2024-07-05 11:25:16 +08:00
ALIENJACK\alien
2868c02c16 音频解决(缺少追赶机制) 2024-07-05 11:24:59 +08:00
ALIENJACK\alien
28e0071191 迭代 2024-07-04 21:06:41 +08:00
495ac68a84 加协议 2024-07-04 17:39:47 +08:00
ALIENJACK\alien
4a7b6c1458 迭代 2024-07-04 10:41:48 +08:00
37b297dff6 Merge pull request 'dev_basemynes' (#2) from alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes
Reviewed-on: #2
2024-07-03 18:24:03 +08:00
ALIENJACK\alien
63f65b89c9 修复语法错误 2024-07-03 18:22:22 +08:00
ALIENJACK\alien
d84b221e81 Merge branch 'dev_basemynes' of http://git.axibug.com/sin365/AxibugEmuOnline into dev_basemynes 2024-07-03 18:19:30 +08:00
ALIENJACK\alien
ed4af60268 core替换为7.7版本 2024-07-03 18:15:28 +08:00
08830263e3 Merge pull request 'mynes.core dll改代码' (#1) from alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes
Reviewed-on: #1
2024-07-03 15:46:20 +08:00
ALIENJACK\alien
7b2b0f3d20 mynes.core dll改代码 2024-07-03 15:40:13 +08:00
6984 changed files with 47259 additions and 1325315 deletions

56
.gitignore vendored
View File

@ -9,59 +9,11 @@
/AxibugEmuOnline.Client/obj/
/AxibugEmuOnline.Client/log/
/AxibugEmuOnline.Client/ProjectSettings/Packages/
/AxibugEmuOnline.Client.Switch/*.vsconfig
/AxibugEmuOnline.Client.Switch/Library/
/AxibugEmuOnline.Client.Switch/Temp/
/AxibugEmuOnline.Client.Switch/UserSettings/
/AxibugEmuOnline.Client.Switch/.vs/
/AxibugEmuOnline.Client.Switch/*.csproj
/AxibugEmuOnline.Client.Switch/*.sln
/AxibugEmuOnline.Client.Switch/*.sln
/AxibugEmuOnline.Client.Switch/obj/
/AxibugEmuOnline.Client.Switch/Logs/
/AxibugEmuOnline.Client.Switch/ProjectSettings/Packages/
/AxibugEmuOnline.Web/config.cfg
/AxibugEmuOnline.Client/ProjectSettings/ProjectVersion.txt
/AxibugEmuOnline.Client/ProjectSettings/AutoStreamingSettings.asset
/AxibugEmuOnline.Client/Logs
**/switch_keys/*.keys
**/switch_keys/*.keys.meta
**/NintendoSDKPlugin/
**/NintendoSDKPlugin.meta
/virtuanessrc097-master
/AxibugEmuOnline.Server/config.cfg
/AxibugEmuOnline.Server/bin/
/AxibugEmuOnline.Client/.editorconfig
/AxibugEmuOnline.Client/*.user
/AxibugEmuOnline.Client/.idea
/Tools/HtmlTable/.vs/
/Tools/HtmlTable/bin/
/Tools/HtmlTable/obj/
/Tools/MAMEHashTool/bin/
/Tools/MAMEHashTool/obj/
/AxibugEmuOnline.Web/bin/
/AxibugEmuOnline.Web/obj/
/Tools/CheckFilesExist/bin/
/Tools/CheckFilesExist/obj/
/OtherCore/MyNes.Standard2/bin/
/OtherCore/MyNes.Standard2/obj/
/Core/VirtualNes.Core/bin/
/Core/VirtualNes.Core/obj/
/AxibugEmuOnline.Server/obj/
AxibugEmuOnline.GameScreenConvert/bin/
AxibugEmuOnline.GameScreenConvert/obj/
/.vs/
AxibugEmuOnline.Client/ProjectSettings/PackageManagerSettings.asset
/virtuanessrc097-master/save
/virtuanessrc097-master/.vs
/virtuanessrc097-master/Debug
/virtuanessrc097-master/VirtuaNES.ini

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 43be319af7abfac409964f3b557a7558
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiCanvasScaler : UnityEngine.UI.CanvasScaler {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 473ebc56afd3a42478d4384e874c37fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiContentSizeFitter : UnityEngine.UI.ContentSizeFitter {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8caea8d1f9c876b4f881e5f0b786490a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiEventSystem : UnityEngine.EventSystems.EventSystem {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1a44ffc6225f2f94e96923be40838c6b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiGraphicRaycaster : UnityEngine.UI.GraphicRaycaster {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1945ac5245ba5af46afb0b2c1176e625
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiHorizontalLayoutGroup : UnityEngine.UI.HorizontalLayoutGroup {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 250a43c57c3dd7743b159142e0e972dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiImage : UnityEngine.UI.Image {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 51fcfe4c344a349498d3e605566e449c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiInputField : UnityEngine.UI.InputField {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c06c5945ce05264419dd9baf5052c6d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiLayoutElement : UnityEngine.UI.LayoutElement {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 662c10b55acd55b41a61b98b4e6dbdae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiRawImage : UnityEngine.UI.RawImage {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e197a80ecc5234d41a58d206698ab683
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiScrollRect : UnityEngine.UI.ScrollRect {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 0bacff8c6cfbc6f4ea2f41852d636203
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiShadow : UnityEngine.UI.Shadow {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5397b0dcf716afa45b892bb200561edb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiSlider : UnityEngine.UI.Slider {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: bd0459cd2daa17e4bbbce2a219502891
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiStandaloneInputModule : UnityEngine.EventSystems.StandaloneInputModule {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c4e4880eab24b7e49b7db61357d9fbd2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiText : UnityEngine.UI.Text {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d1e4d2ce69fe5c345903d4219ba84715
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
namespace AxibugCom { public class AxiVerticalLayoutGroup : UnityEngine.UI.VerticalLayoutGroup {} }

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c6cc678483f4f2849bc6bbbcc66481a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,120 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 47ae96bfd5393694da28c22ab2ccfb7c, type: 3}
m_Name: AxiComToolCache
m_EditorClassIdentifier:
caches:
- SrcFullName: UnityEngine.EventSystems.EventSystem
SrcName: EventSystem
GUID: 76c392e42b5098c458856cdf6ecaaaa1
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.EventSystems.StandaloneInputModule
SrcName: StandaloneInputModule
GUID: 4f231c4fb786f3946a6b90b886c48677
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.CanvasScaler
SrcName: CanvasScaler
GUID: 0cd44c1031e13a943bb63640046fad76
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.GraphicRaycaster
SrcName: GraphicRaycaster
GUID: dc42784cf147c0c48a680349fa168899
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.Image
SrcName: Image
GUID: fe87c0e1cc204ed48ad3b37840f39efc
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.RawImage
SrcName: RawImage
GUID: 1344c3c82d62a2a41a3576d8abb8e3ea
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.HorizontalLayoutGroup
SrcName: HorizontalLayoutGroup
GUID: 30649d3a9faa99c48a7b1166b86bf2a0
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.ContentSizeFitter
SrcName: ContentSizeFitter
GUID: 3245ec927659c4140ac4f8d17403cc18
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.LayoutElement
SrcName: LayoutElement
GUID: 306cc8c2b49d7114eaa3623786fc2126
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.Text
SrcName: Text
GUID: 5f7201a12d95ffc409449d95f23cf332
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.Shadow
SrcName: Shadow
GUID: cfabb0440166ab443bba8876756fdfa9
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.ScrollRect
SrcName: ScrollRect
GUID: 1aa08ab6e0800fa44ae55d278d1423e3
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.VerticalLayoutGroup
SrcName: VerticalLayoutGroup
GUID: 59f8146938fff824cb5fd77236b75775
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.Slider
SrcName: Slider
GUID: 67db9e8f0e2ae9c40bc1e2b64352a6b4
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}
- SrcFullName: UnityEngine.UI.InputField
SrcName: InputField
GUID: d199490a83bb2b844b9695cbf13b01ef
ToName:
ToPATH:
ToGUID:
monoScript: {fileID: 0}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: d8f9e9475a806e04bb9d6946f20f4d0f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 113d55ba3dc10674b9bc51fc07159850
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 236513027b5ebe041b0e5b86aec0db42
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,436 +0,0 @@
using UnityEngine;
using System.Collections.Generic;
using System;
using UnityEngine.Profiling;
public class Debugger : MonoBehaviour
{
/// <summary>
/// 是否允许调试
/// </summary>
public bool AllowDebugging = true;
private DebugType _debugType = DebugType.Console;
private List<LogData> _logInformations = new List<LogData>();
private int _currentLogIndex = -1;
private int _infoLogCount = 0;
private int _warningLogCount = 0;
private int _errorLogCount = 0;
private int _fatalLogCount = 0;
private bool _showInfoLog = true;
private bool _showWarningLog = true;
private bool _showErrorLog = true;
private bool _showFatalLog = true;
private Vector2 _scrollLogView = Vector2.zero;
private Vector2 _scrollCurrentLogView = Vector2.zero;
private Vector2 _scrollSystemView = Vector2.zero;
private bool _expansion = false;
private Rect _windowRect = new Rect(0, 0, 100, 60);
private int _fps = 0;
private Color _fpsColor = Color.white;
private int _frameNumber = 0;
private float _lastShowFPSTime = 0f;
private void Start()
{
DontDestroyOnLoad(this.gameObject);
if (AllowDebugging)
{
Application.logMessageReceived += LogHandler;
}
}
private void Update()
{
if (AllowDebugging)
{
_frameNumber += 1;
float time = Time.realtimeSinceStartup - _lastShowFPSTime;
if (time >= 1)
{
_fps = (int)(_frameNumber / time);
_frameNumber = 0;
_lastShowFPSTime = Time.realtimeSinceStartup;
}
}
}
private void OnDestory()
{
if (AllowDebugging)
{
Application.logMessageReceived -= LogHandler;
}
}
bool bUnityWaterFrist = false;
private void LogHandler(string condition, string stackTrace, LogType type)
{
if (condition.Contains("UnityWater") || stackTrace.Contains("UnityWater"))
{
if(bUnityWaterFrist)
return;
bUnityWaterFrist = true;
}
LogData log = new LogData();
log.time = DateTime.Now.ToString("HH:mm:ss");
log.message = condition;
log.stackTrace = stackTrace;
if (type == LogType.Assert)
{
log.type = "Fatal";
_fatalLogCount += 1;
}
else if (type == LogType.Exception || type == LogType.Error)
{
log.type = "Error";
_errorLogCount += 1;
}
else if (type == LogType.Warning)
{
log.type = "Warning";
_warningLogCount += 1;
}
else if (type == LogType.Log)
{
log.type = "Info";
_infoLogCount += 1;
}
_logInformations.Add(log);
if (_warningLogCount > 0)
{
_fpsColor = Color.yellow;
}
if (_errorLogCount > 0)
{
_fpsColor = Color.red;
}
}
private void OnGUI()
{
if (AllowDebugging)
{
if (_expansion)
{
_windowRect = GUI.Window(0, _windowRect, ExpansionGUIWindow, "DEBUGGER");
}
else
{
_windowRect = GUI.Window(0, _windowRect, ShrinkGUIWindow, "DEBUGGER");
}
}
}
private void ExpansionGUIWindow(int windowId)
{
GUI.DragWindow(new Rect(0, 0, 10000, 20));
#region title
GUILayout.BeginHorizontal();
GUI.contentColor = _fpsColor;
if (GUILayout.Button("FPS:" + _fps, GUILayout.Height(30)))
{
_expansion = false;
_windowRect.width = 100;
_windowRect.height = 60;
}
GUI.contentColor = (_debugType == DebugType.Console ? Color.white : Color.gray);
if (GUILayout.Button("Console", GUILayout.Height(30)))
{
_debugType = DebugType.Console;
}
GUI.contentColor = (_debugType == DebugType.Memory ? Color.white : Color.gray);
if (GUILayout.Button("Memory", GUILayout.Height(30)))
{
_debugType = DebugType.Memory;
}
GUI.contentColor = (_debugType == DebugType.System ? Color.white : Color.gray);
if (GUILayout.Button("System", GUILayout.Height(30)))
{
_debugType = DebugType.System;
}
GUI.contentColor = (_debugType == DebugType.Screen ? Color.white : Color.gray);
if (GUILayout.Button("Screen", GUILayout.Height(30)))
{
_debugType = DebugType.Screen;
}
GUI.contentColor = (_debugType == DebugType.Quality ? Color.white : Color.gray);
if (GUILayout.Button("Quality", GUILayout.Height(30)))
{
_debugType = DebugType.Quality;
}
GUI.contentColor = (_debugType == DebugType.Environment ? Color.white : Color.gray);
if (GUILayout.Button("Environment", GUILayout.Height(30)))
{
_debugType = DebugType.Environment;
}
GUI.contentColor = Color.white;
GUILayout.EndHorizontal();
#endregion
#region console
if (_debugType == DebugType.Console)
{
GUILayout.BeginHorizontal();
if (GUILayout.Button("Clear"))
{
_logInformations.Clear();
_fatalLogCount = 0;
_warningLogCount = 0;
_errorLogCount = 0;
_infoLogCount = 0;
_currentLogIndex = -1;
_fpsColor = Color.white;
}
GUI.contentColor = (_showInfoLog ? Color.white : Color.gray);
_showInfoLog = GUILayout.Toggle(_showInfoLog, "Info [" + _infoLogCount + "]");
GUI.contentColor = (_showWarningLog ? Color.white : Color.gray);
_showWarningLog = GUILayout.Toggle(_showWarningLog, "Warning [" + _warningLogCount + "]");
GUI.contentColor = (_showErrorLog ? Color.white : Color.gray);
_showErrorLog = GUILayout.Toggle(_showErrorLog, "Error [" + _errorLogCount + "]");
GUI.contentColor = (_showFatalLog ? Color.white : Color.gray);
_showFatalLog = GUILayout.Toggle(_showFatalLog, "Fatal [" + _fatalLogCount + "]");
GUI.contentColor = Color.white;
GUILayout.EndHorizontal();
_scrollLogView = GUILayout.BeginScrollView(_scrollLogView, "Box", GUILayout.Height(165));
for (int i = 0; i < _logInformations.Count; i++)
{
bool show = false;
Color color = Color.white;
switch (_logInformations[i].type)
{
case "Fatal":
show = _showFatalLog;
color = Color.red;
break;
case "Error":
show = _showErrorLog;
color = Color.red;
break;
case "Info":
show = _showInfoLog;
color = Color.white;
break;
case "Warning":
show = _showWarningLog;
color = Color.yellow;
break;
default:
break;
}
if (show)
{
GUILayout.BeginHorizontal();
if (GUILayout.Toggle(_currentLogIndex == i, ""))
{
_currentLogIndex = i;
}
GUI.contentColor = color;
GUILayout.Label("[" + _logInformations[i].type + "] ");
GUILayout.Label("[" + _logInformations[i].time + "] ");
GUILayout.Label(_logInformations[i].message);
GUILayout.FlexibleSpace();
GUI.contentColor = Color.white;
GUILayout.EndHorizontal();
}
}
GUILayout.EndScrollView();
_scrollCurrentLogView = GUILayout.BeginScrollView(_scrollCurrentLogView, "Box", GUILayout.Height(100));
if (_currentLogIndex != -1)
{
GUILayout.Label(_logInformations[_currentLogIndex].message + "\r\n\r\n" + _logInformations[_currentLogIndex].stackTrace);
}
GUILayout.EndScrollView();
}
#endregion
#region memory
else if (_debugType == DebugType.Memory)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Memory Information");
GUILayout.EndHorizontal();
GUILayout.BeginVertical("Box");
#if UNITY_5
GUILayout.Label("总内存:" + Profiler.GetTotalReservedMemory() / 1000000 + "MB");
GUILayout.Label("已占用内存:" + Profiler.GetTotalAllocatedMemory() / 1000000 + "MB");
GUILayout.Label("空闲中内存:" + Profiler.GetTotalUnusedReservedMemory() / 1000000 + "MB");
GUILayout.Label("总Mono堆内存" + Profiler.GetMonoHeapSize() / 1000000 + "MB");
GUILayout.Label("已占用Mono堆内存" + Profiler.GetMonoUsedSize() / 1000000 + "MB");
#endif
#if UNITY_7
GUILayout.Label("总内存:" + Profiler.GetTotalReservedMemoryLong() / 1000000 + "MB");
GUILayout.Label("已占用内存:" + Profiler.GetTotalAllocatedMemoryLong() / 1000000 + "MB");
GUILayout.Label("空闲中内存:" + Profiler.GetTotalUnusedReservedMemoryLong() / 1000000 + "MB");
GUILayout.Label("总Mono堆内存" + Profiler.GetMonoHeapSizeLong() / 1000000 + "MB");
GUILayout.Label("已占用Mono堆内存" + Profiler.GetMonoUsedSizeLong() / 1000000 + "MB");
#endif
GUILayout.EndVertical();
GUILayout.BeginHorizontal();
if (GUILayout.Button("卸载未使用的资源"))
{
Resources.UnloadUnusedAssets();
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button("使用GC垃圾回收"))
{
GC.Collect();
}
GUILayout.EndHorizontal();
}
#endregion
#region system
else if (_debugType == DebugType.System)
{
GUILayout.BeginHorizontal();
GUILayout.Label("System Information");
GUILayout.EndHorizontal();
_scrollSystemView = GUILayout.BeginScrollView(_scrollSystemView, "Box");
GUILayout.Label("操作系统:" + SystemInfo.operatingSystem);
GUILayout.Label("系统内存:" + SystemInfo.systemMemorySize + "MB");
GUILayout.Label("处理器:" + SystemInfo.processorType);
GUILayout.Label("处理器数量:" + SystemInfo.processorCount);
GUILayout.Label("显卡:" + SystemInfo.graphicsDeviceName);
GUILayout.Label("显卡类型:" + SystemInfo.graphicsDeviceType);
GUILayout.Label("显存:" + SystemInfo.graphicsMemorySize + "MB");
GUILayout.Label("显卡标识:" + SystemInfo.graphicsDeviceID);
GUILayout.Label("显卡供应商:" + SystemInfo.graphicsDeviceVendor);
GUILayout.Label("显卡供应商标识码:" + SystemInfo.graphicsDeviceVendorID);
GUILayout.Label("设备模式:" + SystemInfo.deviceModel);
GUILayout.Label("设备名称:" + SystemInfo.deviceName);
GUILayout.Label("设备类型:" + SystemInfo.deviceType);
GUILayout.Label("设备标识:" + SystemInfo.deviceUniqueIdentifier);
GUILayout.EndScrollView();
}
#endregion
#region screen
else if (_debugType == DebugType.Screen)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Screen Information");
GUILayout.EndHorizontal();
GUILayout.BeginVertical("Box");
GUILayout.Label("DPI" + Screen.dpi);
GUILayout.Label("分辨率:" + Screen.currentResolution.ToString());
GUILayout.EndVertical();
GUILayout.BeginHorizontal();
if (GUILayout.Button("全屏"))
{
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, !Screen.fullScreen);
}
GUILayout.EndHorizontal();
}
#endregion
#region Quality
else if (_debugType == DebugType.Quality)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Quality Information");
GUILayout.EndHorizontal();
GUILayout.BeginVertical("Box");
string value = "";
if (QualitySettings.GetQualityLevel() == 0)
{
value = " [最低]";
}
else if (QualitySettings.GetQualityLevel() == QualitySettings.names.Length - 1)
{
value = " [最高]";
}
GUILayout.Label("图形质量:" + QualitySettings.names[QualitySettings.GetQualityLevel()] + value);
GUILayout.EndVertical();
GUILayout.BeginHorizontal();
if (GUILayout.Button("降低一级图形质量"))
{
QualitySettings.DecreaseLevel();
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button("提升一级图形质量"))
{
QualitySettings.IncreaseLevel();
}
GUILayout.EndHorizontal();
}
#endregion
#region Environment
else if (_debugType == DebugType.Environment)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Environment Information");
GUILayout.EndHorizontal();
GUILayout.BeginVertical("Box");
GUILayout.Label("项目名称:" + Application.productName);
#if UNITY_5
GUILayout.Label("项目ID" + Application.bundleIdentifier);
#endif
#if UNITY_7
GUILayout.Label("项目ID" + Application.identifier);
#endif
GUILayout.Label("项目版本:" + Application.version);
GUILayout.Label("Unity版本" + Application.unityVersion);
GUILayout.Label("公司名称:" + Application.companyName);
GUILayout.EndVertical();
GUILayout.BeginHorizontal();
if (GUILayout.Button("退出程序"))
{
Application.Quit();
}
GUILayout.EndHorizontal();
}
#endregion
}
private void ShrinkGUIWindow(int windowId)
{
GUI.DragWindow(new Rect(0, 0, 10000, 20));
GUI.contentColor = _fpsColor;
if (GUILayout.Button("FPS:" + _fps, GUILayout.Width(80), GUILayout.Height(30)))
{
_expansion = true;
_windowRect.width = 600;
_windowRect.height = 360;
}
GUI.contentColor = Color.white;
}
}
public struct LogData
{
public string time;
public string type;
public string message;
public string stackTrace;
}
public enum DebugType
{
Console,
Memory,
System,
Screen,
Quality,
Environment
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c8eba012c3ef41a4bb9f3bfa27a8ea21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,123 +0,0 @@
using AxibugEmuOnline.Client.ClientCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using static AxibugEmuOnline.Client.HttpAPI;
public class PSVLauncher : MonoBehaviour
{
public UnityEngine.UI.Button btnInfo;
public UnityEngine.UI.Button InitAPP;
public UnityEngine.UI.Button btnHttpTest;
public UnityEngine.UI.Button btnHttpTest10;
public UnityEngine.UI.Button btnTaskTest;
public UnityEngine.UI.Button btnTaskTest2;
public UnityEngine.UI.Button btnPSVHUD;
public UnityEngine.UI.Button btnStart;
void Awake()
{
DontDestroyOnLoad(this);
btnInfo.onClick.AddListener(() =>
{
Debug.Log($"SystemInfo.deviceUniqueIdentifier ->" + SystemInfo.deviceUniqueIdentifier);
Debug.Log($"systemLanguage ->" + UnityEngine.PSVita.Utility.systemLanguage);
Debug.Log($"skuFlags ->" + UnityEngine.PSVita.Utility.skuFlags);
}
);
InitAPP.onClick.AddListener(() =>
{
App.Init(new AxibugEmuOnline.Client.Initer());
});
btnHttpTest.onClick.AddListener(() => StartCoroutine(StartNetInit()));
btnHttpTest10.onClick.AddListener(() =>
{
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
StartCoroutine(StartNetInit());
}
);
btnTaskTest.onClick.AddListener(() =>
{
PSVThread.DoTask(() => DoWork(null));
//Task task = new Task(() =>
//{
// Thread.Sleep(1000);
// Debug.Log($"{Thread.CurrentThread.ManagedThreadId}->{1000}");
// Thread.Sleep(1000);
// Debug.Log($"{Thread.CurrentThread.ManagedThreadId}->{2000}");
//});
//task.Start();
});
btnPSVHUD.onClick.AddListener(() => {
UnityEngine.PSVita.Diagnostics.enableHUD = true;
});
btnTaskTest2.onClick.AddListener(() =>
{
ThreadPool.QueueUserWorkItem(DoWork);
}
);
btnStart.onClick.AddListener(()
=>
{
SceneManager.LoadScene("AxibugEmuOnline.Client");
});
}
static void DoWork(object state)
{
// 这里是线程池中的工作代码
Debug.Log($"thread id: {Thread.CurrentThread.ManagedThreadId} start");
// 模拟一些工作
Thread.Sleep(2000);
Debug.Log($"thread id: {Thread.CurrentThread.ManagedThreadId} end");
}
static IEnumerator StartNetInit()
{
int platform = 0;
AxiHttpProxy.SendWebRequestProxy request = AxiHttpProxy.Get($"{"http://emu.axibug.com/api"}/CheckStandInfo?platform={platform}&version={Application.version}");
yield return request.SendWebRequest;
if (!request.downloadHandler.isDone)
yield break;
if (request.downloadHandler.Err != null)
{
Debug.LogError(request.downloadHandler.Err);
yield break;
}
AxiHttpProxy.ShowAxiHttpDebugInfo(request.downloadHandler);
Resp_CheckStandInfo resp = JsonUtility.FromJson<Resp_CheckStandInfo>(request.downloadHandler.text);
//需要更新
if (resp.needUpdateClient == 1)
{
//TODO
}
yield return null;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f98de16d25b8f5148866d0c02a514502
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!84 &8400000
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: VideoTexture
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_Width: 960
m_Height: 544
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 20
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3d77df0fa731c3b458e8a1d50eb1a1b3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e745b95dbce117b48b4bd17df06ed302
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 292b282919a768c4fa6b8adb858daa95
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,26 +0,0 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CreateAssetMenu(fileName = "CrossMapCfg", menuName = "Tools/AxiPrefabCachec", order = 0)]
public class AxiPrefabCache : ScriptableObject
{
public List<AxiPrefabCache_Com2GUID> caches = new List<AxiPrefabCache_Com2GUID>();
}
[Serializable]
public class AxiPrefabCache_Com2GUID
{
public string SrcFullName;
public string SrcName;
public string GUID;
public string ToName;
public string ToPATH;
public string ToGUID;
public MonoScript monoScript;
}
#endif

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 47ae96bfd5393694da28c22ab2ccfb7c

View File

@ -1,416 +0,0 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
public class AxiProjectTools : EditorWindow
{
static string cachecfgPath = "Assets/AxiComToolCache.asset";
static string toolSenceName = "AxiProjectTools";
static string outCsDir = Application.dataPath + "/AxiCom/";
static Dictionary<string, AxiPrefabCache_Com2GUID> ComType2GUID = new Dictionary<string, AxiPrefabCache_Com2GUID>();
static void GoTAxiProjectToolsSence()
{
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
{
EditorSceneManager.OpenScene(path);
return;
}
}
}
[MenuItem("Axibug移植工具/[1]UGUI组件")]
public static void Part1()
{
GoTAxiProjectToolsSence();
ComType2GUID.Clear();
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
continue;
EditorSceneManager.OpenScene(path);
// 创建一个列表来存储根节点
List<GameObject> rootNodes = new List<GameObject>();
// 遍历场景中的所有对象
GameObject[] allObjects = FindObjectsOfType<GameObject>();
foreach (GameObject obj in allObjects)
{
// 检查对象是否有父对象
if (obj.transform.parent == null)
{
// 如果没有父对象,则它是一个根节点
rootNodes.Add(obj);
}
}
foreach (var node in rootNodes)
LoopPrefabNode(path, node, 0);
}
string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab");
foreach (string guid in prefabGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
GetPrefab(path);
}
AxiPrefabCache cache = ScriptableObject.CreateInstance<AxiPrefabCache>();
foreach (var data in ComType2GUID)
cache.caches.Add(data.Value);
AssetDatabase.CreateAsset(cache, cachecfgPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
GoTAxiProjectToolsSence();
Debug.Log("<Color=#FFF333>处理完毕 [1]采集所有预制体和场景下的UGUI组件</color>");
}
static void GetPrefab(string path)
{
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
LoopPrefabNode(path, prefab.gameObject, 0);
}
static void LoopPrefabNode(string rootPath, GameObject trans, int depth)
{
string nodename = $"{rootPath}>{trans.name}";
#if UNITY_2018_4_OR_NEWER
GameObject prefabRoot = trans.gameObject;
int comCount = prefabRoot.GetComponentCount();
for (int i = 0; i < comCount; i++)
{
var com = prefabRoot.GetComponentAtIndex(i);
if (com == null)
continue;
MonoBehaviour monoCom = com as MonoBehaviour;
if (monoCom == null)
continue;
Type monoType = monoCom.GetType();
if (!monoType.Assembly.FullName.Contains("UnityEngine.UI"))
continue;
// 获取MonoScript资源
MonoScript monoScript = MonoScript.FromMonoBehaviour(monoCom);
if (monoScript != null)
{
// 获取MonoScript资源的GUID
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript));
Debug.Log($"{nodename} | <color=#FFF333>[{monoType.Name}]</color> <color=#FF0000>{guid}</color><color=#00FF00>({monoType.FullName})</color>");
ComType2GUID[monoType.FullName] =
new AxiPrefabCache_Com2GUID()
{
SrcFullName = monoType.FullName,
SrcName = monoType.Name,
GUID = guid,
};
}
else
{
Debug.LogError("!!!! 没得");
}
}
//遍历
foreach (Transform child in trans.transform)
LoopPrefabNode(nodename, child.gameObject, depth + 1);
#else
Debug.Log("低版本不要执行本函数");
#endif
}
[MenuItem("Axibug移植工具/[2]")]
public static void Part2()
{
if (UnityEngine.Windows.Directory.Exists(outCsDir))
UnityEngine.Windows.Directory.Delete(outCsDir);
Directory.CreateDirectory(outCsDir);
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
foreach (var data in cache.caches)
{
string toName = "Axi" + data.SrcName;
string toPath = outCsDir + toName + ".cs";
string codeStr = "namespace AxibugCom { public class " + toName + " : " + data.SrcFullName + " {} }";
try
{
System.IO.File.WriteAllText(toPath, codeStr);
data.ToName = toName;
data.ToPATH = toPath;
}
catch (Exception ex)
{
Debug.LogError("写入失败" + ex.ToString());
}
}
Debug.Log("写入完毕");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Debug.Log("<Color=#FFF333>处理完毕 [2]生成中间脚本代码</color>");
}
[MenuItem("Axibug移植工具/[3]")]
public static void Part3()
{
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
List<MonoScript> allMonoScripts = FindAllAssetsOfType<MonoScript>();
foreach (var data in cache.caches)
{
MonoScript monoScript = allMonoScripts.FirstOrDefault(w => w.name == data.ToName);
if (monoScript == null)
{
Debug.LogError("没找到" + data.ToName);
continue;
}
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript));
data.ToGUID = guid;
data.monoScript = monoScript;
}
Debug.Log("写入完毕");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Debug.Log("<Color=#FFF333>处理完毕 [3]收集生成的脚本</color>");
}
static List<T> FindAllAssetsOfType<T>() where T : UnityEngine.Object
{
List<T> assets = new List<T>();
string[] allGuids = AssetDatabase.FindAssets("");
foreach (string guid in allGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.EndsWith(".cs") || path.EndsWith(".js") || path.EndsWith(".boo")) // Unity支持多种脚本语言但现代Unity主要使用C#
{
T asset = AssetDatabase.LoadAssetAtPath<T>(path);
if (asset != null)
{
assets.Add(asset);
}
}
}
return assets;
}
[MenuItem("Axibug移植工具/[4]")]
public static void Part4()
{
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
Dictionary<string, string> tempReplaceDict = new Dictionary<string, string>();
foreach (var data in cache.caches)
{
tempReplaceDict[data.GUID] = data.ToGUID;
}
ProcessAllPrefabs("*.prefab", tempReplaceDict);
ProcessAllPrefabs("*.unity", tempReplaceDict);
ProcessAllPrefabs("*.anim", tempReplaceDict);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Debug.Log("<Color=#FFF333>处理完毕 [4]替换所有预制体和场景中的组件</color>");
}
static void ProcessAllPrefabs(string form, Dictionary<string, string> tempReplaceDict, bool reverse = false)
{
List<GameObject> prefabs = new List<GameObject>();
var resourcesPath = Application.dataPath;
var absolutePaths = Directory.GetFiles(resourcesPath, form, SearchOption.AllDirectories);
for (int i = 0; i < absolutePaths.Length; i++)
{
Debug.Log("prefab name: " + absolutePaths[i]);
foreach (var VARIABLE in tempReplaceDict)
{
string oldValue = reverse ? VARIABLE.Value : VARIABLE.Key;
string newValue = reverse ? VARIABLE.Key : VARIABLE.Value;
ReplaceValue(absolutePaths[i], oldValue, newValue);
}
EditorUtility.DisplayProgressBar("处理预制体……", "处理预制体中……", (float)i / absolutePaths.Length);
}
EditorUtility.ClearProgressBar();
}
/// <summary>
/// 替换值
/// </summary>
/// <param name="strFilePath">文件路径</param>
static void ReplaceValue(string strFilePath, string oldLine, string newLine)
{
if (File.Exists(strFilePath))
{
string[] lines = File.ReadAllLines(strFilePath);
for (int i = 0; i < lines.Length; i++)
{
lines[i] = lines[i].Replace(oldLine, newLine);
}
File.WriteAllLines(strFilePath, lines);
}
}
[MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")]
public static void UnpackPrefabs()
{
#if UNITY_2018_4_OR_NEWER
GoTAxiProjectToolsSence();
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
int prefabCount = 0;
foreach (string path in allAssetPaths)
{
if (Path.GetExtension(path).Equals(".prefab"))
{
Debug.Log($"Unpacking {path}");
UnpackPrefab(path);
prefabCount++;
}
}
Debug.Log($"{prefabCount}个预制体Unpack");
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
continue;
EditorSceneManager.OpenScene(path);
Scene currentScene = SceneManager.GetActiveScene();
GameObject[] rootObjects = currentScene.GetRootGameObjects();
foreach (GameObject rootObj in rootObjects)
{
// 遍历场景中的所有对象
TraverseHierarchy(rootObj);
}
// Save the scene // 获取当前打开的场景
currentScene = EditorSceneManager.GetActiveScene();
// 保存场景到文件(默认路径和名称)
bool success = EditorSceneManager.SaveScene(currentScene, currentScene.path);
Debug.Log($"{currentScene.name}场景中 所有物体Unpack");
}
GoTAxiProjectToolsSence();
Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
#else
Debug.Log("低版本不要执行本函数");
#endif
}
static void UnpackPrefab(string prefabPath)
{
#if UNITY_2018_4_OR_NEWER
GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
if (prefabInstance == null)
{
Debug.LogError($"Failed to load prefab at path: {prefabPath}");
return;
}
var obj = GameObject.Instantiate(prefabInstance, null);
TraverseHierarchy(obj);
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
GameObject.DestroyImmediate(obj);
#else
Debug.Log("低版本不要执行本函数");
#endif
}
static void TraverseHierarchy(GameObject obj)
{
#if UNITY_2018_4_OR_NEWER
// 检查该对象是否是预制体的实例
if (PrefabUtility.IsPartOfPrefabInstance(obj))
{
// 将预制体实例转换为普通游戏对象
PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
Debug.Log("Prefab instance converted to game object: " + obj.name);
}
// 递归遍历子对象
for (int i = 0; i < obj.transform.childCount; i++)
{
TraverseHierarchy(obj.transform.GetChild(i).gameObject);
}
#else
Debug.Log("低版本不要执行本函数");
#endif
}
[MenuItem("Axibug移植工具/[6]Sprite")]
public static void FixMultipleMaterialSprites()
{
string[] guids = AssetDatabase.FindAssets("t:sprite");
List<Sprite> spritesToFix = new List<Sprite>();
foreach (string guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
// 检查是否有多个材质
if (IsUsingMultipleMaterials(sprite))
{
spritesToFix.Add(sprite);
Debug.Log("Found sprite with multiple materials: " + path);
}
}
// 修复每个找到的Sprite
foreach (var sprite in spritesToFix)
{
FixSprite(sprite);
}
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Debug.Log("<Color=#FFF333>处理完毕 [6]修复Sprite</color>");
}
private static bool IsUsingMultipleMaterials(Sprite sprite)
{
if (sprite == null) return false;
// 获取精灵的材质
var textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(sprite)) as TextureImporter;
return textureImporter != null && textureImporter.spriteImportMode == SpriteImportMode.Multiple;
}
private static void FixSprite(Sprite sprite)
{
// 获取Sprite的路径
string path = AssetDatabase.GetAssetPath(sprite);
var textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
if (textureImporter != null)
{
// 保存当前切割信息
SpriteMetaData[] originalMetaData = textureImporter.spritesheet;
// 临时禁用Sprite导入
textureImporter.spriteImportMode = SpriteImportMode.None;
textureImporter.SaveAndReimport();
// 重新启用Sprite导入并保持原样切割参数
textureImporter.spriteImportMode = SpriteImportMode.Multiple;
textureImporter.spritesheet = originalMetaData; // 恢复原来的切割信息
// 重新导入以应用更改
textureImporter.SaveAndReimport();
}
}
}
#endif

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 01c95f5e03a338749b54784eb6420d04

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 11a59d59d152c214bb99a09f4d795c21
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,316 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 10
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 13
m_BakeOnSceneLoad: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 1
m_PVRFilteringGaussRadiusAO: 1
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1760378052
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1760378055}
- component: {fileID: 1760378054}
- component: {fileID: 1760378053}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1760378053
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1760378052}
m_Enabled: 1
--- !u!20 &1760378054
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1760378052}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1760378055
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1760378052}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1948026923
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1948026925}
- component: {fileID: 1948026924}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1948026924
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1948026923}
m_Enabled: 1
serializedVersion: 11
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ForceVisible: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
m_LightUnit: 1
m_LuxAtDistance: 1
m_EnableSpotReflector: 1
--- !u!4 &1948026925
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1948026923}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 1760378055}
- {fileID: 1948026925}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: f578c65afd0d1c84b9b59664106fab66
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: fd41663b74cbfcc45a028bc891a8c4fc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,18 +0,0 @@
{
"name": "AxibugEmuOnline.Editor",
"rootNamespace": "AxibugEmuOnline.Editors",
"references": [
"AxibugEmuOnline.Client"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: a37804d4d608e1e4bb8204f442ab0e60
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,50 +0,0 @@
using AxibugEmuOnline.Client;
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
namespace AxibugEmuOnline.Editors
{
[CustomEditor(typeof(CommandDispatcher))]
public class CommandDispatcherEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (!Application.isPlaying) return;
var dispacather = target as CommandDispatcher;
IReadOnlyList<CommandExecuter> normal; IReadOnlyList<CommandExecuter> solo;
dispacather.GetRegisters(out normal, out solo);
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("NORMAL");
foreach (var item in normal)
{
Draw(item);
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("SOLO");
foreach (var item in solo)
{
Draw(item);
}
EditorGUILayout.EndVertical();
EditorGUILayout.LabelField(dispacather.Current.Name);
Repaint();
}
private void Draw(CommandExecuter item)
{
EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
using (new EditorGUI.DisabledGroupScope(!item.Enable))
EditorGUILayout.ObjectField(item.gameObject, typeof(GameObject), false);
EditorGUILayout.EndHorizontal();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 57378be70cec95341aea522ad2d8e30d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 69eb869b06dab98439f07da4549fb7cb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 86a02c697fd26264cb5ee552b582449b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +0,0 @@
{
"name": "AxiReplay"
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 0a45db2096af23647aaafe5b70ccb4d7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,11 +0,0 @@
using System;
namespace AxiReplay
{
internal interface IReplayReader : IDisposable
{
bool NextFrame(out ReplayStep data);
bool TakeFrame(int addFrame, out ReplayStep data);
bool NextFramebyFrameIdx(int FrameID, out ReplayStep data);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 896ff07370157db46b612575616020ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,12 +0,0 @@
using System;
namespace AxiReplay
{
internal interface IReplayWriter : IDisposable
{
void NextFrame(UInt64 frameInput);
void NextFramebyFrameIdx(int FrameID, UInt64 frameInput);
void TakeFrame(int addFrame, UInt64 frameInput);
void SaveData(string path, bool bNeedDump = false, string dumpFilePath = null);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6a8fcda365e5a7f428f88bc130eb913b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,147 +0,0 @@
using System.Collections.Generic;
namespace AxiReplay
{
public class NetReplay
{
/// <summary>
/// 客户端当前帧
/// </summary>
public int mCurrClientFrameIdx = 0;
/// <summary>
/// 服务器远端当前帧
/// </summary>
public int mRemoteFrameIdx { get; private set; }
/// <summary>
/// 服务器远端当前提前量
/// </summary>
public int mRemoteForwardCount { get; private set; }
/// <summary>
/// Remote 2 Client Frame Gap
/// </summary>
public int mDiffFrameCount => mRemoteFrameIdx - mCurrClientFrameIdx;
/// <summary>
/// 网络数据队列
/// </summary>
Queue<ReplayStep> mNetReplayQueue = new Queue<ReplayStep>();
/// <summary>
/// 当前数据
/// </summary>
ReplayStep mCurrReplay;
/// <summary>
/// 下一个数据数据
/// </summary>
ReplayStep mNextReplay;
bool bNetInit = false;
public NetReplay()
{
ResetData();
}
public void ResetData()
{
mNetReplayQueue.Clear();
mCurrReplay = default(ReplayStep);
mCurrReplay.FrameStartID = int.MinValue;
bNetInit = false;
}
public void InData(ReplayStep inputData, int ServerFrameIdx)
{
mNetReplayQueue.Enqueue(inputData);
mRemoteFrameIdx = inputData.FrameStartID;
if (!bNetInit)
{
bNetInit = true;
mNextReplay = mNetReplayQueue.Dequeue();
}
}
public bool TryGetNextFrame(out ReplayStep data, out int frameDiff, out bool inputDiff)
{
if (!bNetInit)
{
data = default(ReplayStep);
frameDiff = default(int);
inputDiff = false;
return false;
}
TakeFrame(1, out data, out frameDiff, out inputDiff);
return frameDiff > 0;
}
public bool TryGetNextFrame(int targetFrame, out ReplayStep data, out int frameDiff, out bool inputDiff)
{
if (!bNetInit)
{
data = default(ReplayStep);
frameDiff = default(int);
inputDiff = false;
return false;
}
return TakeFrameToTargetFrame(targetFrame, out data, out frameDiff, out inputDiff);
}
void TakeFrame(int addFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
{
int targetFrame = mCurrClientFrameIdx + addFrame;
TakeFrameToTargetFrame(targetFrame, out data, out bFrameDiff, out inputDiff);
}
bool TakeFrameToTargetFrame(int targetFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
{
bool result;
inputDiff = false;
if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0)
{
//当前帧追加
mCurrClientFrameIdx = targetFrame;
ulong oldInput = mCurrReplay.InPut;
mCurrReplay = mNextReplay;
if (oldInput != mCurrReplay.InPut)
inputDiff = true;
mNextReplay = mNetReplayQueue.Dequeue();
result = true;
}
else
result = false;
bFrameDiff = mRemoteFrameIdx - mCurrClientFrameIdx;
data = mCurrReplay;
return result;
}
public int GetSkipFrameCount()
{
if(!bNetInit)
return 0;
//本地队列差异高于服务器提前量的值
int moreNum = mDiffFrameCount - mRemoteForwardCount;
//if (mDiffFrameCount < 0 || mDiffFrameCount > 10000)
// return 0;
////游戏刚开始的一小段时间,直接追满
//if (mCurrClientFrameIdx < 60)
// return moreNum;
int skip = 0;
if (mDiffFrameCount > short.MaxValue) skip = 0;
else if (moreNum <= 1) skip = 0;
else if (moreNum <= 3) skip = 2;
else if (moreNum <= 6) skip = 2;
else if (moreNum <= 20) skip = moreNum / 2; //20帧以内平滑跳帧数
else skip = moreNum;//完全追上
return skip;
//var frameGap = mDiffFrameCount;
//if (frameGap > 10000) return 0;
//if (frameGap <= 2) skip = 0;
//if (frameGap > 2 && frameGap < 6) skip = 1 + 1;
//else if (frameGap > 7 && frameGap < 12) skip = 2 + 1;
//else if (frameGap > 13 && frameGap < 20) skip = 3 + 1;
//else skip = frameGap - 2;
//return skip;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 452b58ff73a0853449845fd9e1134cc2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,101 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace AxiReplay
{
[StructLayout(LayoutKind.Explicit, Size = 44)]
public struct ReplayHandler
{
[FieldOffset(0)]
public int Format;
[FieldOffset(sizeof(int) * 1)]
public int RomID;
[FieldOffset(sizeof(int) * 2)]
public int RomType;
[FieldOffset(sizeof(int) * 3)]
public int DataOffset;
[FieldOffset(sizeof(int) * 4)]
public int TitleOffset;
[FieldOffset(sizeof(int) * 5)]
public int NoteOffset;
[FieldOffset(sizeof(int) * 6)]
public int AllFrame;
[FieldOffset(sizeof(int) * 7)]
public int AllTime;
[FieldOffset(sizeof(int) * 8)]
public int SingleLenght;
[FieldOffset(sizeof(int) * 9)]
public long CreateTime;
}
[StructLayout(LayoutKind.Explicit)]
public struct ReplayStep
{
[FieldOffset(0)]
public UInt64 All64Data;
[FieldOffset(0)]
public Int32 FrameStartID;
[FieldOffset(4)]
public UInt64 InPut;
}
public static class ReplayData
{
public static int HandlerLenght = sizeof(int) * 9 + sizeof(long);
public enum ReplayFormat : byte
{
None = 0,
FM32IPBYTE,
FM32IP16,
FM32IP32,
FM32IP64,
}
public static void GetStringByteData(string str, out byte[] data, out int lenghtWithEnd, Encoding encoding)
{
data = encoding.GetBytes(str);
lenghtWithEnd = data.Length + 1;
}
public static byte[] GetHandlerData(ReplayHandler replayhandler)
{
int size = Marshal.SizeOf(typeof(ReplayHandler));
byte[] arr = new byte[size];
IntPtr ptr = Marshal.AllocHGlobal(size);
try
{
Marshal.StructureToPtr(replayhandler, ptr, false);
Marshal.Copy(ptr, arr, 0, size);
}
finally
{
Marshal.FreeHGlobal(ptr);
}
return arr;
}
public static ReplayHandler GetReplayHandlerFromData(byte[] data)
{
if (data == null || data.Length < ReplayData.HandlerLenght)
{
throw new ArgumentException("Invalid data length or null data.");
}
IntPtr ptr = Marshal.AllocHGlobal(ReplayData.HandlerLenght);
try
{
// 将byte数组的内容复制到非托管内存中
Marshal.Copy(data, 0, ptr, ReplayData.HandlerLenght);
// 从非托管内存将内容转换回ReplayHandler结构体
return (ReplayHandler)Marshal.PtrToStructure(ptr, typeof(ReplayHandler));
}
finally
{
// 释放非托管内存
Marshal.FreeHGlobal(ptr);
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 42df5a138f4f4ae488815f35d8e748da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,174 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using static AxiReplay.ReplayData;
namespace AxiReplay
{
public class ReplayReader : IReplayReader
{
public ReplayData.ReplayFormat mFormat { get; private set; }
public Encoding TexEncoding { get; private set; }
ReplayHandler handler;
string mTitle;
string mNote;
int mAllFrame;
int mAllTime;
long mData;
int mSingleInputLenght;
int mSingleDataLenght;
FileStream mStream;
BinaryReader mBinaryReader;
int mCurrFrame = -1;
byte[] mNextOutbytes;
public ReplayStep currStep;
public ReplayStep nextStep;
bool bEnd;
List<string> dbgList = new List<string>();
bool bdbg = false;
string dumpPath;
public ReplayReader(string path, bool bWithDump = false, string dumppath = null)
{
dbgList.Clear();
bdbg = bWithDump;
dumpPath = dumppath;
mStream = new FileStream(path, FileMode.Open, FileAccess.Read);
mBinaryReader = new BinaryReader(mStream);
byte[] Outbytes;
Outbytes = mBinaryReader.ReadBytes(ReplayData.HandlerLenght);
handler = ReplayData.GetReplayHandlerFromData(Outbytes);
mFormat = (ReplayFormat)handler.Format;
switch (mFormat)
{
case ReplayData.ReplayFormat.FM32IP64: mSingleInputLenght = sizeof(UInt64); break;
case ReplayData.ReplayFormat.FM32IP32: mSingleInputLenght = sizeof(UInt32); break;
case ReplayData.ReplayFormat.FM32IP16: mSingleInputLenght = sizeof(UInt16); break;
case ReplayData.ReplayFormat.FM32IPBYTE: mSingleInputLenght = sizeof(byte); break;
}
//Frame+Lenght
mSingleDataLenght = (sizeof(UInt32)) + mSingleInputLenght;
nextStep = new ReplayStep();
nextStep.FrameStartID = -1;
bEnd = false;
dbgList.Add($"Format => {handler.Format}");
dbgList.Add($"DataOffset => {handler.DataOffset}");
dbgList.Add($"CreateTime => {handler.CreateTime}");
dbgList.Add($"AllFrame => {handler.AllFrame}");
dbgList.Add($"SingleLenght => {handler.SingleLenght}");
mNextOutbytes = new byte[mSingleDataLenght];
if (bWithDump)
{
int TestFrameIdx = -1;
while (!bEnd)
{
UpdateNextFrame(TestFrameIdx++);
}
File.WriteAllLines(dumppath, dbgList);
}
else
{
UpdateNextFrame(0);
}
}
void UpdateNextFrame(int targetFrame)
{
//如果已经超过
while (targetFrame >= nextStep.FrameStartID)
{
if (nextStep.FrameStartID >= handler.AllFrame)
{
bEnd = true;
break;
}
mBinaryReader.Read(mNextOutbytes, 0, mSingleDataLenght);
switch (mFormat)
{
case ReplayFormat.FM32IP64:
{
nextStep.FrameStartID = BitConverter.ToInt32(mNextOutbytes, 0);
nextStep.InPut = BitConverter.ToUInt64(mNextOutbytes, sizeof(UInt32));
}
break;
case ReplayFormat.FM32IP32:
{
nextStep.All64Data = BitConverter.ToUInt64(mNextOutbytes, 0);
}
break;
case ReplayFormat.FM32IP16:
{
nextStep.All64Data = BitConverter.ToUInt64(mNextOutbytes, 0);
}
break;
case ReplayFormat.FM32IPBYTE:
{
nextStep.All64Data = BitConverter.ToUInt64(mNextOutbytes, 0);
}
break;
}
dbgList.Add($"{nextStep.FrameStartID} | {nextStep.InPut}");
targetFrame++;
}
}
int byFrameIdx = 0;
/// <summary>
/// 往前推进1帧的Input(返回是否变化)
/// </summary>
public bool NextFrame(out ReplayStep data)
{
return TakeFrame(1, out data);
}
/// <summary>
/// 往前推进指定帧数量的Input (返回是否变化)
/// </summary>
/// <param name="addFrame"></param>
public bool TakeFrame(int addFrame, out ReplayStep data)
{
bool Changed = false;
mCurrFrame += addFrame;
if (mCurrFrame >= nextStep.FrameStartID)
{
Changed = currStep.InPut != nextStep.InPut;
currStep = nextStep;
data = currStep;
UpdateNextFrame(mCurrFrame);
}
else
{
data = currStep;
}
return Changed;
}
/// <summary>
/// 往前推进帧的,指定帧下标
/// </summary>
public bool NextFramebyFrameIdx(int FrameID, out ReplayStep data)
{
bool res = TakeFrame(FrameID - byFrameIdx, out data);
byFrameIdx = FrameID;
return res;
}
public void Dispose()
{
mStream.Dispose();
mBinaryReader.Dispose();
//TODO
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 66e0e18d1f5981745a3078e8460cb0e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,158 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace AxiReplay
{
public class ReplayWriter : IReplayWriter
{
public ReplayData.ReplayFormat mFormat { get; private set; }
public Encoding TexEncoding { get; private set; }
ReplayHandler handler;
string mTitle;
string mNote;
int mAllFrame;
int mAllTime;
long mData;
int mSingleInputLenght;
int mSingleDataLenght;
MemoryStream mStream;
BinaryWriter mBinaryWriter;
int mCurrFrame;
UInt64 mCurrInput;
ReplayStep wirteStep;
List<string> dbgList = new List<string>();
public ReplayWriter(string Title, string Note, ReplayData.ReplayFormat format, Encoding encoding)
{
mTitle = Title;
mNote = Note;
TexEncoding = encoding;
mFormat = format;
switch (mFormat)
{
case ReplayData.ReplayFormat.FM32IP64: mSingleInputLenght = sizeof(UInt64); break;
case ReplayData.ReplayFormat.FM32IP32: mSingleInputLenght = sizeof(UInt32); break;
case ReplayData.ReplayFormat.FM32IP16: mSingleInputLenght = sizeof(UInt16); break;
case ReplayData.ReplayFormat.FM32IPBYTE: mSingleInputLenght = sizeof(byte); break;
}
mSingleDataLenght = (sizeof(UInt32)) + mSingleInputLenght;
mStream = new MemoryStream();
mBinaryWriter = new BinaryWriter(mStream);
mCurrFrame = -1;
mCurrInput = int.MaxValue;
wirteStep = new ReplayStep();
dbgList.Clear();
}
int byFrameIdx = 0;
/// <summary>
/// 往前推进帧的,指定帧下标
/// </summary>
/// <param name="frameInput"></param>
public void NextFramebyFrameIdx(int FrameID, UInt64 frameInput)
{
TakeFrame(FrameID - byFrameIdx, frameInput);
byFrameIdx = FrameID;
}
/// <summary>
/// 往前推进1帧的Input
/// </summary>
/// <param name="frameInput"></param>
public void NextFrame(UInt64 frameInput)
{
TakeFrame(1, frameInput);
}
/// <summary>
/// 往前推进指定帧数量的Input
/// </summary>
/// <param name="frameInput"></param>
public void TakeFrame(int addFrame, UInt64 frameInput)
{
if (addFrame < 0)
{
}
mCurrFrame += addFrame;
if (mCurrInput == frameInput)
return;
mCurrInput = frameInput;
wirteStep.FrameStartID = mCurrFrame;
wirteStep.InPut = mCurrInput;
dbgList.Add($"{mCurrFrame} | {mCurrInput}");
switch (mFormat)
{
case ReplayData.ReplayFormat.FM32IP64:
mBinaryWriter.Write(wirteStep.FrameStartID);
mBinaryWriter.Write(wirteStep.InPut);
break;
case ReplayData.ReplayFormat.FM32IP32:
mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 4);
break;
case ReplayData.ReplayFormat.FM32IP16:
mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 2);
break;
case ReplayData.ReplayFormat.FM32IPBYTE:
mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 1);
break;
}
}
public void SaveData(string path, bool bWithDump = false, string dumppath = null)
{
byte[] titleData; int titleLenghtWithEnd;
ReplayData.GetStringByteData(mTitle, out titleData, out titleLenghtWithEnd, TexEncoding);
byte[] noteData; int noteLenghtWithEnd;
ReplayData.GetStringByteData(mNote, out noteData, out noteLenghtWithEnd, TexEncoding);
ReplayHandler handler = new ReplayHandler();
handler.Format = (int)this.mFormat;
handler.DataOffset = ReplayData.HandlerLenght;
handler.CreateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
handler.AllFrame = wirteStep.FrameStartID;
handler.SingleLenght = mSingleDataLenght;
using (FileStream fs = new FileStream(path, FileMode.Create))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
//写入Handler
bw.Write(ReplayData.GetHandlerData(handler));
//写入Data
bw.Write(mStream.ToArray());
}
}
if (bWithDump)
{
List<string> temp = new List<string>();
temp.Add($"Format => {handler.Format}");
temp.Add($"DataOffset => {handler.DataOffset}");
temp.Add($"CreateTime => {handler.CreateTime}");
temp.Add($"AllFrame => {handler.AllFrame}");
temp.Add($"SingleLenght => {handler.SingleLenght}");
dbgList.InsertRange(0, temp);
File.WriteAllLines(dumppath, dbgList);
}
}
public void Dispose()
{
mStream.Dispose();
mBinaryWriter.Dispose();
//TODO
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: dc53a3d9a3e1749438b6ad1cef7b39bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,565 +0,0 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
#if TMP_PRESENT
using System.Collections.Generic;
using TMPro;
#if UNITY_EDITOR
using UnityEditor;
using System.IO;
using System.Linq;
#endif
#endif
namespace Coffee.UIExtensions
{
/// <summary>
/// Base class for effects that modify the generated Mesh.
/// It works well not only for standard Graphic components (Image, RawImage, Text, etc.) but also for TextMeshPro and TextMeshProUGUI.
/// </summary>
[ExecuteInEditMode]
public abstract class BaseMeshEffect : UIBehaviour, IMeshModifier
{
//################################
// Constant or Static Members.
//################################
#if TMP_PRESENT
static readonly List<Vector2> s_Uv0 = new List<Vector2> (4096);
static readonly List<Vector2> s_Uv1 = new List<Vector2> (4096);
#if UNITY_2017_1_OR_NEWER
static readonly List<Vector2> s_Uv2 = new List<Vector2> (4096);
static readonly List<Vector2> s_Uv3 = new List<Vector2> (4096);
#endif
static readonly List<Vector3> s_Vertices = new List<Vector3> (4096);
static readonly List<int> s_Indices = new List<int> (4096);
static readonly List<Vector3> s_Normals = new List<Vector3> (4096);
static readonly List<Vector4> s_Tangents = new List<Vector4> (4096);
static readonly List<Color32> s_Colors = new List<Color32> (4096);
static readonly VertexHelper s_VertexHelper = new VertexHelper ();
static readonly List<TMP_SubMeshUI> s_SubMeshUIs = new List<TMP_SubMeshUI> (4096);
static readonly List<Mesh> s_Meshes = new List<Mesh> (4096);
static readonly List<UIVertex> s_UIVertices = new List<UIVertex> (4096);
static readonly List<BaseMeshEffect> s_TmpEffects = new List<BaseMeshEffect>(4);
#endif
static readonly Material[] s_EmptyMaterials = new Material[0];
//################################
// Public Members.
//################################
/// <summary>
/// The Graphic attached to this GameObject.
/// </summary>
public Graphic graphic { get { Initialize(); return _graphic; } }
/// <summary>
/// The CanvasRenderer attached to this GameObject.
/// </summary>
public CanvasRenderer canvasRenderer { get { Initialize(); return _canvasRenderer; } }
#if TMP_PRESENT
/// <summary>
/// The TMP_Text attached to this GameObject.
/// </summary>
public TMP_Text textMeshPro { get { Initialize (); return _textMeshPro; } }
#endif
/// <summary>
/// The RectTransform attached to this GameObject.
/// </summary>
public RectTransform rectTransform { get { Initialize(); return _rectTransform; } }
#if UNITY_5_6_OR_NEWER
/// <summary>
/// Additional canvas shader channels to use this component.
/// </summary>
public virtual AdditionalCanvasShaderChannels requiredChannels { get { return AdditionalCanvasShaderChannels.None; } }
#endif
/// <summary>
/// Is TextMeshPro or TextMeshProUGUI attached to this GameObject?
/// </summary>
public bool isTMPro
{
get
{
#if TMP_PRESENT
return textMeshPro != null;
#else
return false;
#endif
}
}
/// <summary>
/// The material for rendering.
/// </summary>
public virtual Material material
{
get
{
#if TMP_PRESENT
if (textMeshPro)
{
return textMeshPro.fontSharedMaterial;
}
else
#endif
if (graphic)
{
return graphic.material;
}
else
{
return null;
}
}
set
{
#if TMP_PRESENT
if (textMeshPro)
{
textMeshPro.fontSharedMaterial = value;
}
else
#endif
if (graphic)
{
graphic.material = value;
}
}
}
public virtual Material[] materials
{
get
{
#if TMP_PRESENT
if (textMeshPro)
{
return textMeshPro.fontSharedMaterials ?? s_EmptyMaterials;
}
else
#endif
if (graphic)
{
_materials[0] = graphic.material;
return _materials;
}
else
{
return s_EmptyMaterials;
}
}
}
/// <summary>
/// Call used to modify mesh. (legacy)
/// </summary>
/// <param name="mesh">Mesh.</param>
public virtual void ModifyMesh(Mesh mesh)
{
}
/// <summary>
/// Call used to modify mesh.
/// </summary>
/// <param name="vh">VertexHelper.</param>
public virtual void ModifyMesh(VertexHelper vh)
{
}
/// <summary>
/// Mark the vertices as dirty.
/// </summary>
public virtual void SetVerticesDirty()
{
#if TMP_PRESENT
if (textMeshPro)
{
foreach (var info in textMeshPro.textInfo.meshInfo)
{
var mesh = info.mesh;
if (mesh)
{
mesh.Clear ();
mesh.vertices = info.vertices;
mesh.uv = info.uvs0;
mesh.uv2 = info.uvs2;
mesh.colors32 = info.colors32;
mesh.normals = info.normals;
mesh.tangents = info.tangents;
mesh.triangles = info.triangles;
}
}
if (canvasRenderer)
{
canvasRenderer.SetMesh (textMeshPro.mesh);
GetComponentsInChildren (false, s_SubMeshUIs);
foreach (var sm in s_SubMeshUIs)
{
sm.canvasRenderer.SetMesh (sm.mesh);
}
s_SubMeshUIs.Clear ();
}
textMeshPro.havePropertiesChanged = true;
}
else
#endif
if (graphic)
{
graphic.SetVerticesDirty();
}
}
public void ShowTMProWarning(Shader shader, Shader mobileShader, Shader spriteShader, System.Action<Material> onCreatedMaterial)
{
#if UNITY_EDITOR && TMP_PRESENT
if(!textMeshPro || !textMeshPro.fontSharedMaterial)
{
return;
}
// Is the material preset for dissolve?
Material m = textMeshPro.fontSharedMaterial;
if (m.shader != shader && m.shader != mobileShader)
{
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.HelpBox (string.Format("{0} requires '{1}' or '{2}' as a shader for material preset.", GetType().Name, shader.name, mobileShader.name), MessageType.Warning);
if(GUILayout.Button ("Fix"))
{
var correctShader = m.shader.name.Contains ("Mobile") ? mobileShader : shader;
textMeshPro.fontSharedMaterial = ModifyTMProMaterialPreset (m, correctShader, onCreatedMaterial);
}
EditorGUILayout.EndHorizontal ();
return;
}
// Is the sprite asset for dissolve?
TMP_SpriteAsset spriteAsset = textMeshPro.spriteAsset ?? TMP_Settings.GetSpriteAsset ();
// Sprite asset might not exist at all
if(spriteAsset == null) {
return;
}
m = spriteAsset.material;
if (m && m.shader != spriteShader && textMeshPro.richText && textMeshPro.text.Contains("<sprite="))
{
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.HelpBox (string.Format ("{0} requires '{1}' as a shader for sprite asset.", GetType().Name,spriteShader.name), MessageType.Warning);
if (GUILayout.Button ("Fix"))
{
GetComponentsInChildren<TMP_SubMesh> ().Select (x => x.gameObject).ToList ().ForEach (DestroyImmediate);
GetComponentsInChildren<TMP_SubMeshUI> ().Select (x => x.gameObject).ToList ().ForEach (DestroyImmediate);
textMeshPro.spriteAsset = ModifyTMProSpriteAsset (m, spriteShader, onCreatedMaterial);
}
EditorGUILayout.EndHorizontal ();
return;
}
}
Material ModifyTMProMaterialPreset (Material baseMaterial, Shader shader, System.Action<Material> onCreatedMaterial)
{
string path = AssetDatabase.GetAssetPath (baseMaterial);
string filename = Path.GetFileNameWithoutExtension (path) + " (" + GetType ().Name + ")";
Material mat = Resources.Load<Material> (TMP_Settings.defaultFontAssetPath + filename);
if (!mat)
{
mat = new Material (baseMaterial)
{
shaderKeywords = baseMaterial.shaderKeywords,
shader = shader,
};
onCreatedMaterial (mat);
AssetDatabase.CreateAsset (mat, Path.GetDirectoryName (path) + "/" + filename + ".mat");
EditorUtility.FocusProjectWindow ();
EditorGUIUtility.PingObject (mat);
}
else
{
mat.shader = shader;
}
EditorUtility.SetDirty (mat);
return mat;
}
TMP_SpriteAsset ModifyTMProSpriteAsset (Material baseMaterial, Shader shader, System.Action<Material> onCreatedMaterial)
{
string path = AssetDatabase.GetAssetPath (baseMaterial);
string filename = Path.GetFileNameWithoutExtension (path) + " (" + this.GetType ().Name + ")";
TMP_SpriteAsset spriteAsset = Resources.Load<TMP_SpriteAsset> (TMP_Settings.defaultSpriteAssetPath + filename);
if (!spriteAsset)
{
AssetDatabase.CopyAsset (path, Path.GetDirectoryName (path) + "/" + filename + ".mat");
spriteAsset = Resources.Load<TMP_SpriteAsset> (TMP_Settings.defaultSpriteAssetPath + filename);
spriteAsset.material.shader = shader;
spriteAsset.material.name = shader.name;
onCreatedMaterial (spriteAsset.material);
EditorUtility.FocusProjectWindow ();
EditorGUIUtility.PingObject (spriteAsset);
}
else
{
spriteAsset.material.shader = shader;
}
EditorUtility.SetDirty (spriteAsset);
return spriteAsset;
#endif
}
//################################
// Protected Members.
//################################
/// <summary>
/// Should the effect modify the mesh directly for TMPro?
/// </summary>
protected virtual bool isLegacyMeshModifier { get { return false; } }
protected virtual void Initialize()
{
if (!_initialized)
{
_initialized = true;
_graphic = _graphic ?? GetComponent<Graphic>();
_canvasRenderer = _canvasRenderer ?? GetComponent<CanvasRenderer>();
_rectTransform = _rectTransform ?? GetComponent<RectTransform>();
#if TMP_PRESENT
_textMeshPro = _textMeshPro ?? GetComponent<TMP_Text> ();
#endif
}
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
_initialized = false;
SetVerticesDirty();
#if TMP_PRESENT
if (textMeshPro)
{
TMPro_EventManager.TEXT_CHANGED_EVENT.Add (OnTextChanged);
}
#endif
#if UNITY_EDITOR && TMP_PRESENT
if (graphic && textMeshPro)
{
GraphicRebuildTracker.TrackGraphic (graphic);
}
#endif
#if UNITY_5_6_OR_NEWER
if (graphic)
{
AdditionalCanvasShaderChannels channels = requiredChannels;
var canvas = graphic.canvas;
if (canvas && (canvas.additionalShaderChannels & channels) != channels)
{
Debug.LogWarningFormat(this, "Enable {1} of Canvas.additionalShaderChannels to use {0}.", GetType().Name, channels);
}
}
#endif
}
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
protected override void OnDisable()
{
#if TMP_PRESENT
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove (OnTextChanged);
#endif
SetVerticesDirty();
#if UNITY_EDITOR && TMP_PRESENT
if (graphic && textMeshPro)
{
GraphicRebuildTracker.UnTrackGraphic (graphic);
}
#endif
}
/// <summary>
/// LateUpdate is called every frame, if the Behaviour is enabled.
/// </summary>
protected virtual void LateUpdate()
{
#if TMP_PRESENT
if (textMeshPro)
{
if (textMeshPro.havePropertiesChanged || _isTextMeshProActive != textMeshPro.isActiveAndEnabled)
{
SetVerticesDirty ();
}
_isTextMeshProActive = textMeshPro.isActiveAndEnabled;
}
#endif
}
/// <summary>
/// Callback for when properties have been changed by animation.
/// </summary>
protected override void OnDidApplyAnimationProperties()
{
SetVerticesDirty();
}
#if UNITY_EDITOR
/// <summary>
/// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
/// </summary>
protected override void OnValidate()
{
SetVerticesDirty();
}
#endif
//################################
// Private Members.
//################################
bool _initialized;
CanvasRenderer _canvasRenderer;
RectTransform _rectTransform;
Graphic _graphic;
Material[] _materials = new Material[1];
#if TMP_PRESENT
bool _isTextMeshProActive;
TMP_Text _textMeshPro;
/// <summary>
/// Called when any TextMeshPro generated the mesh.
/// </summary>
/// <param name="obj">TextMeshPro object.</param>
void OnTextChanged (Object obj)
{
// Skip if the object is different from the current object or the text is empty.
var textInfo = textMeshPro.textInfo;
if (textMeshPro != obj || textInfo.characterCount - textInfo.spaceCount <= 0)
{
return;
}
GetComponents<BaseMeshEffect>(s_TmpEffects);
for (int i = 0; i < s_TmpEffects.Count; i++)
{
if (s_TmpEffects[i].enabled)
{
if (s_TmpEffects[i] == this)
break;
else
return;
}
}
// Collect the meshes.
s_Meshes.Clear ();
foreach (var info in textInfo.meshInfo)
{
s_Meshes.Add (info.mesh);
}
// Modify the meshes.
foreach (var e in s_TmpEffects)
{
if (!e.enabled)
continue;
if (e.isLegacyMeshModifier)
{
// Legacy mode: Modify the meshes directly.
foreach (var m in s_Meshes)
{
if (m)
{
e.ModifyMesh(m);
}
}
}
else
{
// Convert meshes to VertexHelpers and modify them.
foreach (var m in s_Meshes)
{
if (m)
{
FillVertexHelper(s_VertexHelper, m);
e.ModifyMesh(s_VertexHelper);
s_VertexHelper.FillMesh(m);
}
}
}
}
// Set the modified meshes to the CanvasRenderers (for UI only).
if (canvasRenderer)
{
canvasRenderer.SetMesh (textMeshPro.mesh);
GetComponentsInChildren (false, s_SubMeshUIs);
foreach (var sm in s_SubMeshUIs)
{
sm.canvasRenderer.SetMesh (sm.mesh);
}
s_SubMeshUIs.Clear ();
}
// Clear.
s_Meshes.Clear ();
}
void FillVertexHelper (VertexHelper vh, Mesh mesh)
{
vh.Clear ();
mesh.GetVertices (s_Vertices);
mesh.GetColors (s_Colors);
mesh.GetUVs (0, s_Uv0);
mesh.GetUVs (1, s_Uv1);
mesh.GetNormals (s_Normals);
mesh.GetTangents (s_Tangents);
mesh.GetIndices (s_Indices, 0);
#if UNITY_2017_1_OR_NEWER
mesh.GetUVs (2, s_Uv2);
mesh.GetUVs (3, s_Uv3);
bool useUv2 = 0 < s_Uv2.Count;
bool useUv3 = 0 < s_Uv3.Count;
#endif
s_UIVertices.Clear();
UIVertex v = default(UIVertex);
for (int i = 0; i < s_Vertices.Count; i++)
{
v.position = s_Vertices[i];
v.color = s_Colors[i];
v.uv0 = s_Uv0[i];
v.uv1 = s_Uv1[i];
#if UNITY_2017_1_OR_NEWER
if (useUv2 && i < s_Uv2.Count)
v.uv2 = s_Uv2[i];
if (useUv3 && i < s_Uv3.Count)
v.uv3 = s_Uv3[i];
#endif
v.normal = s_Normals[i];
v.tangent = s_Tangents[i];
s_UIVertices.Add(v);
}
s_VertexHelper.AddUIVertexStream(s_UIVertices, s_Indices);
}
#endif
}
}

View File

@ -1,13 +0,0 @@
namespace Coffee.UIExtensions
{
/// <summary>
/// Blur effect mode.
/// </summary>
public enum BlurMode
{
None = 0,
FastBlur = 1,
MediumBlur = 2,
DetailBlur = 3,
}
}

View File

@ -1,13 +0,0 @@
namespace Coffee.UIExtensions
{
/// <summary>
/// Color effect mode.
/// </summary>
public enum ColorMode
{
Multiply = 0,
Fill = 1,
Add = 2,
Subtract = 3,
}
}

View File

@ -1,112 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
/// <summary>
/// Area for effect.
/// </summary>
public enum EffectArea
{
RectTransform,
Fit,
Character,
}
public static class EffectAreaExtensions
{
static readonly Rect rectForCharacter = new Rect(0, 0, 1, 1);
static readonly Vector2[] splitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
/// <summary>
/// Gets effect for area.
/// </summary>
public static Rect GetEffectArea(this EffectArea area, VertexHelper vh, Rect rectangle, float aspectRatio = -1)
{
Rect rect = default(Rect);
switch (area)
{
case EffectArea.RectTransform:
rect = rectangle;
break;
case EffectArea.Character:
rect = rectForCharacter;
break;
case EffectArea.Fit:
// Fit to contents.
UIVertex vertex = default(UIVertex);
float xMin = float.MaxValue;
float yMin = float.MaxValue;
float xMax = float.MinValue;
float yMax = float.MinValue;
for (int i = 0; i < vh.currentVertCount; i++)
{
vh.PopulateUIVertex(ref vertex, i);
float x = vertex.position.x;
float y = vertex.position.y;
xMin = Mathf.Min(xMin, x);
yMin = Mathf.Min(yMin, y);
xMax = Mathf.Max(xMax, x);
yMax = Mathf.Max(yMax, y);
}
rect.Set(xMin, yMin, xMax - xMin, yMax - yMin);
break;
default:
rect = rectangle;
break;
}
if (0 < aspectRatio)
{
if (rect.width < rect.height)
{
rect.width = rect.height * aspectRatio;
}
else
{
rect.height = rect.width / aspectRatio;
}
}
return rect;
}
/// <summary>
/// Gets position factor for area.
/// </summary>
public static void GetPositionFactor(this EffectArea area, int index, Rect rect, Vector2 position, bool isText, bool isTMPro, out float x, out float y)
{
if (isText && area == EffectArea.Character)
{
index = isTMPro ? (index + 3) % 4 : index % 4;
x = splitedCharacterPosition[index].x;
y = splitedCharacterPosition[index].y;
}
else if (area == EffectArea.Fit)
{
x = Mathf.Clamp01((position.x - rect.xMin) / rect.width);
y = Mathf.Clamp01((position.y - rect.yMin) / rect.height);
}
else
{
x = Mathf.Clamp01(position.x / rect.width + 0.5f);
y = Mathf.Clamp01(position.y / rect.height + 0.5f);
}
}
/// <summary>
/// Normalize vertex position by local matrix.
/// </summary>
public static void GetNormalizedFactor(this EffectArea area, int index, Matrix2x3 matrix, Vector2 position, bool isText, out Vector2 nomalizedPos)
{
if (isText && area == EffectArea.Character)
{
nomalizedPos = matrix * splitedCharacterPosition[(index + 3) % 4];
}
else
{
nomalizedPos = matrix * position;
}
}
}
}

View File

@ -1,156 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Coffee.UIExtensions
{
/// <summary>
/// Effect player.
/// </summary>
[Serializable]
public class EffectPlayer
{
//################################
// Public Members.
//################################
/// <summary>
/// Gets or sets a value indicating whether is playing.
/// </summary>
[Header("Effect Player")]
[Tooltip("Playing.")]
public bool play = false;
/// <summary>
/// Gets or sets the delay before looping.
/// </summary>
[Tooltip("Initial play delay.")]
[Range(0f, 10f)]
public float initialPlayDelay = 0;
/// <summary>
/// Gets or sets the duration.
/// </summary>
[Tooltip("Duration.")]
[Range(0.01f, 10f)]
public float duration = 1;
/// <summary>
/// Gets or sets a value indicating whether can loop.
/// </summary>
[Tooltip("Loop.")]
public bool loop = false;
/// <summary>
/// Gets or sets the delay before looping.
/// </summary>
[Tooltip("Delay before looping.")]
[Range(0f, 10f)]
public float loopDelay = 0;
/// <summary>
/// Gets or sets the update mode.
/// </summary>
[Tooltip("Update mode")]
public AnimatorUpdateMode updateMode = AnimatorUpdateMode.Normal;
static List<Action> s_UpdateActions;
/// <summary>
/// Register player.
/// </summary>
public void OnEnable(Action<float> callback = null)
{
if (s_UpdateActions == null)
{
s_UpdateActions = new List<Action>();
Canvas.willRenderCanvases += () =>
{
var count = s_UpdateActions.Count;
for (int i = 0; i < count; i++)
{
s_UpdateActions[i].Invoke();
}
};
}
s_UpdateActions.Add(OnWillRenderCanvases);
if (play)
{
_time = -initialPlayDelay;
}
else
{
_time = 0;
}
_callback = callback;
}
/// <summary>
/// Unregister player.
/// </summary>
public void OnDisable()
{
_callback = null;
s_UpdateActions.Remove(OnWillRenderCanvases);
}
/// <summary>
/// Start playing.
/// </summary>
public void Play(bool reset, Action<float> callback = null)
{
if (reset)
{
_time = 0;
}
play = true;
if (callback != null)
{
_callback = callback;
}
}
/// <summary>
/// Stop playing.
/// </summary>
public void Stop(bool reset)
{
if (reset)
{
_time = 0;
if (_callback != null)
{
_callback(_time);
}
}
play = false;
}
//################################
// Private Members.
//################################
float _time = 0;
Action<float> _callback;
void OnWillRenderCanvases()
{
if (!play || !Application.isPlaying || _callback == null)
{
return;
}
_time += updateMode == AnimatorUpdateMode.UnscaledTime
? Time.unscaledDeltaTime
: Time.deltaTime;
var current = _time / duration;
if (duration <= _time)
{
play = loop;
_time = loop ? -loopDelay : 0;
}
_callback(current);
}
}
}

View File

@ -1,95 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Coffee.UIExtensions
{
public class MaterialCache
{
public ulong hash { get; private set; }
public int referenceCount { get; private set; }
public Texture texture { get; private set; }
public Material material { get; private set; }
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoadMethod]
static void ClearCache()
{
foreach (var cache in materialCaches)
{
cache.material = null;
}
materialCaches.Clear();
}
#endif
public static List<MaterialCache> materialCaches = new List<MaterialCache>();
public static MaterialCache Register(ulong hash, Texture texture, System.Func<Material> onCreateMaterial)
{
var cache = materialCaches.FirstOrDefault(x => x.hash == hash);
if (cache != null && cache.material)
{
if (cache.material)
{
cache.referenceCount++;
}
else
{
materialCaches.Remove(cache);
cache = null;
}
}
if (cache == null)
{
cache = new MaterialCache()
{
hash = hash,
material = onCreateMaterial(),
referenceCount = 1,
};
materialCaches.Add(cache);
}
return cache;
}
public static MaterialCache Register(ulong hash, System.Func<Material> onCreateMaterial)
{
var cache = materialCaches.FirstOrDefault(x => x.hash == hash);
if (cache != null)
{
cache.referenceCount++;
}
if (cache == null)
{
cache = new MaterialCache()
{
hash = hash,
material = onCreateMaterial(),
referenceCount = 1,
};
materialCaches.Add(cache);
}
return cache;
}
public static void Unregister(MaterialCache cache)
{
if (cache == null)
{
return;
}
cache.referenceCount--;
if (cache.referenceCount <= 0)
{
MaterialCache.materialCaches.Remove(cache);
cache.material = null;
}
}
}
}

View File

@ -1,126 +0,0 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions
{
public class MaterialResolver
{
static readonly StringBuilder s_StringBuilder = new StringBuilder();
static readonly Dictionary<string, Material> s_MaterialMap = new Dictionary<string, Material>();
public static Material GetOrGenerateMaterialVariant(Shader shader, params object[] append)
{
if (!shader)
{
return null;
}
Material mat = null;
string variantName = GetVariantName(shader, append);
if (s_MaterialMap.TryGetValue(variantName, out mat) && mat)
{
return mat;
}
string[] keywords = append.Where(x => 0 < (int)x)
.Select(x => x.ToString().ToUpper())
.ToArray();
mat = GetMaterial(shader, append);
if (mat)
{
if (!mat.shaderKeywords.OrderBy(x => x).SequenceEqual(keywords.OrderBy(x => x)))
{
mat.shaderKeywords = keywords;
EditorUtility.SetDirty(mat);
if (!Application.isPlaying)
{
EditorApplication.delayCall += AssetDatabase.SaveAssets;
}
}
return mat;
}
if (s_MaterialMap.TryGetValue(variantName, out mat) && mat)
{
return mat;
}
Debug.Log("Generate material : " + variantName);
mat = new Material(shader);
mat.shaderKeywords = keywords;
mat.name = variantName;
mat.hideFlags |= HideFlags.NotEditable;
s_MaterialMap[variantName] = mat;
bool isMainAsset = append.Cast<int>().All(x => x == 0);
EditorApplication.delayCall += () => SaveMaterial(mat, shader, isMainAsset);
return mat;
}
static void SaveMaterial(Material mat, Shader shader, bool isMainAsset)
{
string materialPath = GetDefaultMaterialPath(shader);
#if UIEFFECT_SEPARATE
string dir = Path.GetDirectoryName(materialPath);
materialPath = Path.Combine(Path.Combine(dir, "Separated"), mat.name + ".mat");
isMainAsset = true;
#endif
if (isMainAsset)
{
Directory.CreateDirectory(Path.GetDirectoryName(materialPath));
AssetDatabase.CreateAsset(mat, materialPath);
}
else
{
GetOrGenerateMaterialVariant(shader);
mat.hideFlags |= HideFlags.HideInHierarchy;
AssetDatabase.AddObjectToAsset(mat, materialPath);
}
AssetDatabase.SaveAssets();
}
public static Material GetMaterial(Shader shader, params object[] append)
{
string variantName = GetVariantName(shader, append);
return AssetDatabase.FindAssets("t:Material " + Path.GetFileName(shader.name))
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x))
.OfType<Material>()
.FirstOrDefault(x => x.name == variantName);
}
public static string GetDefaultMaterialPath(Shader shader)
{
var name = Path.GetFileName(shader.name);
return AssetDatabase.FindAssets("t:Material " + name)
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x) == name)
?? ("Assets/" + name + ".mat");
}
public static string GetVariantName(Shader shader, params object[] append)
{
s_StringBuilder.Length = 0;
#if UIEFFECT_SEPARATE
s_StringBuilder.Append("[Separated] ");
#endif
s_StringBuilder.Append(Path.GetFileName(shader.name));
foreach (object mode in append.Where(x => 0 < (int)x))
{
s_StringBuilder.Append("-");
s_StringBuilder.Append(mode.ToString());
}
return s_StringBuilder.ToString();
}
}
}
#endif

View File

@ -1,33 +0,0 @@
using UnityEngine;
namespace Coffee.UIExtensions
{
/// <summary>
/// Matrix2x3.
/// </summary>
public struct Matrix2x3
{
public float m00, m01, m02, m10, m11, m12;
public Matrix2x3(Rect rect, float cos, float sin)
{
const float center = 0.5f;
float dx = -rect.xMin / rect.width - center;
float dy = -rect.yMin / rect.height - center;
m00 = cos / rect.width;
m01 = -sin / rect.height;
m02 = dx * cos - dy * sin + center;
m10 = sin / rect.width;
m11 = cos / rect.height;
m12 = dx * sin + dy * cos + center;
}
public static Vector2 operator *(Matrix2x3 m, Vector2 v)
{
return new Vector2(
(m.m00 * v.x) + (m.m01 * v.y) + m.m02,
(m.m10 * v.x) + (m.m11 * v.y) + m.m12
);
}
}
}

View File

@ -1,58 +0,0 @@
using UnityEngine;
public static class Packer
{
/// <summary>
/// Pack 4 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 64 steps(6 bits).
/// </summary>
public static float ToFloat(float x, float y, float z, float w)
{
x = x < 0 ? 0 : 1 < x ? 1 : x;
y = y < 0 ? 0 : 1 < y ? 1 : y;
z = z < 0 ? 0 : 1 < z ? 1 : z;
w = w < 0 ? 0 : 1 < w ? 1 : w;
const int PRECISION = (1 << 6) - 1;
return (Mathf.FloorToInt(w * PRECISION) << 18)
+ (Mathf.FloorToInt(z * PRECISION) << 12)
+ (Mathf.FloorToInt(y * PRECISION) << 6)
+ Mathf.FloorToInt(x * PRECISION);
}
/// <summary>
/// Pack 4 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 64 steps(6 bits).
/// </summary>
public static float ToFloat(Vector4 factor)
{
return ToFloat(Mathf.Clamp01(factor.x), Mathf.Clamp01(factor.y), Mathf.Clamp01(factor.z), Mathf.Clamp01(factor.w));
}
/// <summary>
/// Pack 1 middle-precision & 2 low-precision [0-1] floats values to a float.
/// z value [0-1] has 4096 steps(12 bits) and xy value [0-1] has 64 steps(6 bits).
/// </summary>
public static float ToFloat(float x, float y, float z)
{
x = x < 0 ? 0 : 1 < x ? 1 : x;
y = y < 0 ? 0 : 1 < y ? 1 : y;
z = z < 0 ? 0 : 1 < z ? 1 : z;
const int PRECISION = (1 << 8) - 1;
return (Mathf.FloorToInt(z * PRECISION) << 16)
+ (Mathf.FloorToInt(y * PRECISION) << 8)
+ Mathf.FloorToInt(x * PRECISION);
}
/// <summary>
/// Pack 2 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 4096 steps(12 bits).
/// </summary>
public static float ToFloat(float x, float y)
{
x = x < 0 ? 0 : 1 < x ? 1 : x;
y = y < 0 ? 0 : 1 < y ? 1 : y;
const int PRECISION = (1 << 12) - 1;
return (Mathf.FloorToInt(y * PRECISION) << 12)
+ Mathf.FloorToInt(x * PRECISION);
}
}

View File

@ -1,188 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Coffee.UIExtensions
{
public interface IParameterTexture
{
int parameterIndex { get; set; }
ParameterTexture ptex { get; }
}
/// <summary>
/// Parameter texture.
/// </summary>
[System.Serializable]
public class ParameterTexture
{
//################################
// Public Members.
//################################
/// <summary>
/// Initializes a new instance of the <see cref="Coffee.UIExtensions.ParameterTexture"/> class.
/// </summary>
/// <param name="channels">Channels.</param>
/// <param name="instanceLimit">Instance limit.</param>
/// <param name="propertyName">Property name.</param>
public ParameterTexture(int channels, int instanceLimit, string propertyName)
{
_propertyName = propertyName;
_channels = ((channels - 1) / 4 + 1) * 4;
_instanceLimit = ((instanceLimit - 1) / 2 + 1) * 2;
_data = new byte[_channels * _instanceLimit];
_stack = new Stack<int>(_instanceLimit);
for (int i = 1; i < _instanceLimit + 1; i++)
{
_stack.Push(i);
}
}
/// <summary>
/// Register the specified target.
/// </summary>
/// <param name="target">Target.</param>
public void Register(IParameterTexture target)
{
Initialize();
if (target.parameterIndex <= 0 && 0 < _stack.Count)
{
target.parameterIndex = _stack.Pop();
// Debug.LogFormat("<color=green>@@@ Register {0} : {1}</color>", target, target.parameterIndex);
}
}
/// <summary>
/// Unregister the specified target.
/// </summary>
/// <param name="target">Target.</param>
public void Unregister(IParameterTexture target)
{
if (0 < target.parameterIndex)
{
// Debug.LogFormat("<color=red>@@@ Unregister {0} : {1}</color>", target, target.parameterIndex);
_stack.Push(target.parameterIndex);
target.parameterIndex = 0;
}
}
/// <summary>
/// Sets the data.
/// </summary>
/// <param name="target">Target.</param>
/// <param name="channelId">Channel identifier.</param>
/// <param name="value">Value.</param>
public void SetData(IParameterTexture target, int channelId, byte value)
{
int index = (target.parameterIndex - 1) * _channels + channelId;
if (0 < target.parameterIndex && _data[index] != value)
{
_data[index] = value;
_needUpload = true;
}
}
/// <summary>
/// Sets the data.
/// </summary>
/// <param name="target">Target.</param>
/// <param name="channelId">Channel identifier.</param>
/// <param name="value">Value.</param>
public void SetData(IParameterTexture target, int channelId, float value)
{
SetData(target, channelId, (byte)(Mathf.Clamp01(value) * 255));
}
/// <summary>
/// Registers the material.
/// </summary>
/// <param name="mat">Mat.</param>
public void RegisterMaterial(Material mat)
{
if (_propertyId == 0)
{
_propertyId = Shader.PropertyToID(_propertyName);
}
if (mat)
{
mat.SetTexture(_propertyId, _texture);
}
}
/// <summary>
/// Gets the index of the normalized.
/// </summary>
/// <returns>The normalized index.</returns>
/// <param name="target">Target.</param>
public float GetNormalizedIndex(IParameterTexture target)
{
return ((float)target.parameterIndex - 0.5f) / _instanceLimit;
}
//################################
// Private Members.
//################################
Texture2D _texture;
bool _needUpload;
int _propertyId;
readonly string _propertyName;
readonly int _channels;
readonly int _instanceLimit;
readonly byte[] _data;
readonly Stack<int> _stack;
static List<Action> updates;
/// <summary>
/// Initialize this instance.
/// </summary>
void Initialize()
{
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
{
return;
}
#endif
if (updates == null)
{
updates = new List<Action>();
Canvas.willRenderCanvases += () =>
{
var count = updates.Count;
for (int i = 0; i < count; i++)
{
updates[i].Invoke();
}
};
}
if (!_texture)
{
bool isLinear = QualitySettings.activeColorSpace == ColorSpace.Linear;
_texture = new Texture2D(_channels / 4, _instanceLimit, TextureFormat.RGBA32, false, isLinear);
_texture.filterMode = FilterMode.Point;
_texture.wrapMode = TextureWrapMode.Clamp;
updates.Add(UpdateParameterTexture);
_needUpload = true;
}
}
void UpdateParameterTexture()
{
if (_needUpload && _texture)
{
_needUpload = false;
_texture.LoadRawTextureData(_data);
_texture.Apply(false, false);
}
}
}
}

View File

@ -1,14 +0,0 @@
namespace Coffee.UIExtensions
{
/// <summary>
/// Shadow effect style.
/// </summary>
public enum ShadowStyle
{
None = 0,
Shadow,
Outline,
Outline8,
Shadow3,
}
}

View File

@ -1,14 +0,0 @@
namespace Coffee.UIExtensions
{
/// <summary>
/// Effect mode.
/// </summary>
public enum EffectMode
{
None = 0,
Grayscale = 1,
Sepia = 2,
Nega = 3,
Pixel = 4,
}
}

View File

@ -1,165 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
/// <summary>
/// Abstract effect base for UI.
/// </summary>
[DisallowMultipleComponent]
public abstract class UIEffectBase : BaseMeshEffect, IParameterTexture
#if UNITY_EDITOR
, ISerializationCallbackReceiver
#endif
{
protected static readonly Vector2[] splitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
protected static readonly List<UIVertex> tempVerts = new List<UIVertex>();
[HideInInspector]
[SerializeField] int m_Version;
[SerializeField] protected Material m_EffectMaterial;
/// <summary>
/// Gets or sets the parameter index.
/// </summary>
public int parameterIndex { get; set; }
/// <summary>
/// Gets the parameter texture.
/// </summary>
public virtual ParameterTexture ptex { get { return null; } }
/// <summary>
/// Gets target graphic for effect.
/// </summary>
public Graphic targetGraphic { get { return graphic; } }
/// <summary>
/// Gets material for effect.
/// </summary>
public Material effectMaterial { get { return m_EffectMaterial; } }
#if UNITY_EDITOR
protected override void Reset()
{
m_Version = 300;
OnValidate();
}
/// <summary>
/// Raises the validate event.
/// </summary>
protected override void OnValidate()
{
base.OnValidate();
var mat = GetMaterial();
if (m_EffectMaterial != mat)
{
m_EffectMaterial = mat;
UnityEditor.EditorUtility.SetDirty(this);
}
ModifyMaterial();
SetVerticesDirty();
SetDirty();
}
public void OnBeforeSerialize()
{
}
public void OnAfterDeserialize()
{
UnityEditor.EditorApplication.delayCall += UpgradeIfNeeded;
}
protected bool IsShouldUpgrade(int expectedVersion)
{
if (m_Version < expectedVersion)
{
Debug.LogFormat(gameObject, "<b>{0}({1})</b> has been upgraded: <i>version {2} -> {3}</i>", name, GetType().Name, m_Version, expectedVersion);
m_Version = expectedVersion;
//UnityEditor.EditorApplication.delayCall += () =>
{
UnityEditor.EditorUtility.SetDirty(this);
if (!Application.isPlaying && gameObject && gameObject.scene.IsValid())
{
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(gameObject.scene);
}
}
;
return true;
}
return false;
}
protected virtual void UpgradeIfNeeded()
{
}
/// <summary>
/// Gets the material.
/// </summary>
/// <returns>The material.</returns>
protected virtual Material GetMaterial()
{
return null;
}
#endif
/// <summary>
/// Modifies the material.
/// </summary>
public virtual void ModifyMaterial()
{
targetGraphic.material = isActiveAndEnabled ? m_EffectMaterial : null;
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
if (ptex != null)
{
ptex.Register(this);
}
ModifyMaterial();
SetVerticesDirty();
SetDirty();
}
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
protected override void OnDisable()
{
base.OnDisable();
ModifyMaterial();
SetVerticesDirty();
if (ptex != null)
{
ptex.Unregister(this);
}
}
/// <summary>
/// Mark the UIEffect as dirty.
/// </summary>
protected virtual void SetDirty()
{
SetVerticesDirty();
}
protected override void OnDidApplyAnimationProperties()
{
SetDirty();
}
}
}

View File

@ -1,85 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
public class BaseMeshEffectEditor : Editor
{
List<MaterialEditor> _materialEditors = new List<MaterialEditor>();
protected virtual void OnEnable()
{
ClearMaterialEditors();
}
protected virtual void OnDisable()
{
ClearMaterialEditors();
}
void ClearMaterialEditors()
{
foreach (var e in _materialEditors)
{
if (e)
{
DestroyImmediate(e);
}
}
_materialEditors.Clear();
}
protected void ShowMaterialEditors(Material[] materials, int startIndex, int count)
{
for (int i = 0; i < count; i++)
{
if (_materialEditors.Count == i)
{
_materialEditors.Add(null);
}
var mat = materials[startIndex + i];
var editor = _materialEditors[i];
if (editor && editor.target != mat)
{
DestroyImmediate(editor);
editor = null;
}
if (!editor)
{
editor = _materialEditors[i] = Editor.CreateEditor(mat) as MaterialEditor;
}
editor.DrawHeader();
editor.OnInspectorGUI();
}
}
protected void ShowCanvasChannelsWarning()
{
BaseMeshEffect effect = target as BaseMeshEffect;
if (!effect || !effect.graphic)
{
return;
}
#if UNITY_5_6_OR_NEWER
AdditionalCanvasShaderChannels channels = effect.requiredChannels;
var canvas = effect.graphic.canvas;
if (canvas && (canvas.additionalShaderChannels & channels) != channels)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox(string.Format("Enable {1} of Canvas.additionalShaderChannels to use {0}.", effect.GetType().Name, channels), MessageType.Warning);
if (GUILayout.Button("Fix"))
{
canvas.additionalShaderChannels |= channels;
}
EditorGUILayout.EndHorizontal();
}
#endif
}
}
}

View File

@ -1,51 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// Remove deprecated files in old .unitypackage, after compiling.
/// </summary>
public class DeprecatedRemover
{
/// <summary>
/// GUIDs of deprecated files.
/// </summary>
static readonly List<string> DeprecatedFiles = new List<string>()
{
"156b57fee6ef941958e66a129ce387e2", // UICustomEffect.cs
"a4961e148a8cd4fe0b84dddc2741894a", // UICustomEffectEditor.cs
"7b1ed09bdf5e54042b5cd1fbe69361bf", // MaterialBundle.cs
};
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoadMethod]
static void RemoveFiles()
{
// The deprecated file path that exists.
var files = DeprecatedFiles.Select(x => AssetDatabase.GUIDToAssetPath(x))
.Where(x => File.Exists(x))
.ToArray();
if (files.Any())
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<b><color=orange>[{0}]</color></b> {1} files have been removed.\n", typeof(DeprecatedRemover).Name, files.Length);
foreach (var path in files)
{
AssetDatabase.DeleteAsset(path);
sb.AppendFormat(" - {0}\n", path);
}
AssetDatabase.Refresh();
UnityEngine.Debug.Log(sb);
}
}
#endif
}
}

View File

@ -1,179 +0,0 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIDissolve))]
[CanEditMultipleObjects]
public class UIDissolveEditor : BaseMeshEffectEditor
{
static int s_NoiseTexId;
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spWidth = serializedObject.FindProperty("m_Width");
_spColor = serializedObject.FindProperty("m_Color");
_spSoftness = serializedObject.FindProperty("m_Softness");
_spColorMode = serializedObject.FindProperty("m_ColorMode");
_spNoiseTexture = serializedObject.FindProperty("m_NoiseTexture");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spReverse = serializedObject.FindProperty("m_Reverse");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
_spLoop = player.FindPropertyRelative("loop");
_spLoopDelay = player.FindPropertyRelative("loopDelay");
_spUpdateMode = player.FindPropertyRelative("updateMode");
s_NoiseTexId = Shader.PropertyToID("_NoiseTex");
_shader = Shader.Find("TextMeshPro/Distance Field (UIDissolve)");
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UIDissolve)");
_spriteShader = Shader.Find("TextMeshPro/Sprite (UIDissolve)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
foreach (var d in targets.Cast<UIDissolve>())
{
var mat = d.material;
if (d.isTMPro && mat && mat.HasProperty(s_NoiseTexId))
{
ColorMode colorMode =
mat.IsKeywordEnabled("ADD") ? ColorMode.Add
: mat.IsKeywordEnabled("SUBTRACT") ? ColorMode.Subtract
: mat.IsKeywordEnabled("FILL") ? ColorMode.Fill
: ColorMode.Multiply;
Texture noiseTexture = mat.GetTexture(s_NoiseTexId);
if (d.colorMode != colorMode || d.noiseTexture != noiseTexture)
{
var so = new SerializedObject(d);
so.FindProperty("m_ColorMode").intValue = (int)colorMode;
so.FindProperty("m_NoiseTexture").objectReferenceValue = noiseTexture;
so.ApplyModifiedProperties();
}
}
}
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
EditorGUILayout.PropertyField(_spEffectFactor);
EditorGUILayout.PropertyField(_spWidth);
EditorGUILayout.PropertyField(_spSoftness);
EditorGUILayout.PropertyField(_spColor);
bool isAnyTMPro = targets.Cast<UIDissolve>().Any(x => x.isTMPro);
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
{
EditorGUILayout.PropertyField(_spColorMode);
EditorGUILayout.PropertyField(_spNoiseTexture);
}
//================
// Advanced option.
//================
EditorGUILayout.PropertyField(_spEffectArea);
EditorGUILayout.PropertyField(_spKeepAspectRatio);
//================
// Effect player.
//================
EditorGUILayout.PropertyField(_spPlay);
EditorGUILayout.PropertyField(_spDuration);
EditorGUILayout.PropertyField(_spInitialPlayDelay);
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
EditorGUILayout.PropertyField(_spReverse);
// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Play", "ButtonLeft"))
{
(target as UIDissolve).Play();
}
if (GUILayout.Button("Stop", "ButtonRight"))
{
(target as UIDissolve).Stop();
}
}
var c = target as UIDissolve;
c.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat =>
{
if (mat.shader == _spriteShader)
{
mat.shaderKeywords = c.material.shaderKeywords;
mat.SetTexture("_NoiseTex", c.material.GetTexture("_NoiseTex"));
}
});
ShowCanvasChannelsWarning();
ShowMaterialEditors(c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spEffectFactor;
SerializedProperty _spWidth;
SerializedProperty _spColor;
SerializedProperty _spSoftness;
SerializedProperty _spColorMode;
SerializedProperty _spNoiseTexture;
SerializedProperty _spEffectArea;
SerializedProperty _spKeepAspectRatio;
SerializedProperty _spReverse;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
SerializedProperty _spDuration;
SerializedProperty _spInitialPlayDelay;
SerializedProperty _spUpdateMode;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}

View File

@ -1,188 +0,0 @@
using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using DesamplingRate = Coffee.UIExtensions.UIEffectCapturedImage.DesamplingRate;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffectCapturedImage editor.
/// </summary>
[CustomEditor(typeof(UIEffectCapturedImage))]
[CanEditMultipleObjects]
public class UIEffectCapturedImageEditor : RawImageEditor
{
//################################
// Constant or Static Members.
//################################
public enum QualityMode : int
{
Fast = (DesamplingRate.x2 << 0) + (DesamplingRate.x2 << 4) + (FilterMode.Bilinear << 8) + (2 << 10),
Medium = (DesamplingRate.x1 << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (3 << 10),
Detail = (DesamplingRate.None << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (5 << 10),
Custom = -1,
}
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spTexture = serializedObject.FindProperty("m_Texture");
_spColor = serializedObject.FindProperty("m_Color");
_spRaycastTarget = serializedObject.FindProperty("m_RaycastTarget");
_spDesamplingRate = serializedObject.FindProperty("m_DesamplingRate");
_spReductionRate = serializedObject.FindProperty("m_ReductionRate");
_spFilterMode = serializedObject.FindProperty("m_FilterMode");
_spIterations = serializedObject.FindProperty("m_BlurIterations");
_spKeepSizeToRootCanvas = serializedObject.FindProperty("m_FitToScreen");
_spBlurMode = serializedObject.FindProperty("m_BlurMode");
_spCaptureOnEnable = serializedObject.FindProperty("m_CaptureOnEnable");
_customAdvancedOption = (qualityMode == QualityMode.Custom);
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
var graphic = (target as UIEffectCapturedImage);
serializedObject.Update();
//================
// Basic properties.
//================
EditorGUILayout.PropertyField(_spTexture);
EditorGUILayout.PropertyField(_spColor);
EditorGUILayout.PropertyField(_spRaycastTarget);
//================
// Capture effect.
//================
GUILayout.Space(10);
EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
UIEffectEditor.DrawEffectProperties(serializedObject, "m_EffectColor");
//================
// Advanced option.
//================
GUILayout.Space(10);
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_spCaptureOnEnable);// CaptureOnEnable.
EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas);// Keep Graphic Size To RootCanvas.
EditorGUI.BeginChangeCheck();
QualityMode quality = qualityMode;
quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
if (EditorGUI.EndChangeCheck())
{
_customAdvancedOption = (quality == QualityMode.Custom);
qualityMode = quality;
}
// When qualityMode is `Custom`, show advanced option.
if (_customAdvancedOption)
{
if (_spBlurMode.intValue != 0)
{
EditorGUILayout.PropertyField(_spIterations);// Iterations.
}
DrawDesamplingRate(_spReductionRate);// Reduction rate.
EditorGUILayout.Space();
EditorGUILayout.LabelField("Result Texture Setting", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_spFilterMode);// Filter Mode.
DrawDesamplingRate(_spDesamplingRate);// Desampling rate.
}
serializedObject.ApplyModifiedProperties();
// Debug.
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Capture", "ButtonLeft"))
{
graphic.Release();
EditorApplication.delayCall += graphic.Capture;
}
EditorGUI.BeginDisabledGroup(!(target as UIEffectCapturedImage).capturedTexture);
if (GUILayout.Button("Release", "ButtonRight"))
{
graphic.Release();
}
EditorGUI.EndDisabledGroup();
}
}
//################################
// Private Members.
//################################
const int Bits4 = (1 << 4) - 1;
const int Bits2 = (1 << 2) - 1;
bool _customAdvancedOption = false;
SerializedProperty _spTexture;
SerializedProperty _spColor;
SerializedProperty _spRaycastTarget;
SerializedProperty _spDesamplingRate;
SerializedProperty _spReductionRate;
SerializedProperty _spFilterMode;
SerializedProperty _spBlurMode;
SerializedProperty _spIterations;
SerializedProperty _spKeepSizeToRootCanvas;
SerializedProperty _spCaptureOnEnable;
QualityMode qualityMode
{
get
{
if (_customAdvancedOption)
return QualityMode.Custom;
int qualityValue = (_spDesamplingRate.intValue << 0)
+ (_spReductionRate.intValue << 4)
+ (_spFilterMode.intValue << 8)
+ (_spIterations.intValue << 10);
return System.Enum.IsDefined(typeof(QualityMode), qualityValue) ? (QualityMode)qualityValue : QualityMode.Custom;
}
set
{
if (value != QualityMode.Custom)
{
int qualityValue = (int)value;
_spDesamplingRate.intValue = (qualityValue >> 0) & Bits4;
_spReductionRate.intValue = (qualityValue >> 4) & Bits4;
_spFilterMode.intValue = (qualityValue >> 8) & Bits2;
_spIterations.intValue = (qualityValue >> 10) & Bits4;
}
}
}
/// <summary>
/// Draws the desampling rate.
/// </summary>
void DrawDesamplingRate(SerializedProperty sp)
{
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(sp);
int w, h;
(target as UIEffectCapturedImage).GetDesamplingSize((UIEffectCapturedImage.DesamplingRate)sp.intValue, out w, out h);
GUILayout.Label(string.Format("{0}x{1}", w, h), EditorStyles.miniLabel);
}
}
}
}

View File

@ -1,256 +0,0 @@
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIEffect))]
[CanEditMultipleObjects]
public class UIEffectEditor : BaseMeshEffectEditor
{
static readonly GUIContent contentEffectColor = new GUIContent("Effect Color");
//################################
// Public/Protected Members.
//################################
/// <summary>
/// Draw effect properties.
/// </summary>
public static void DrawEffectProperties(SerializedObject serializedObject, string colorProperty = "m_Color")
{
//================
// Effect material.
//================
var spMaterial = serializedObject.FindProperty("m_EffectMaterial");
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
var spToneMode = serializedObject.FindProperty("m_EffectMode");
EditorGUILayout.PropertyField(spToneMode);
// When tone is enable, show parameters.
if (spToneMode.intValue != (int)EffectMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
EditorGUI.indentLevel--;
}
//================
// Color setting.
//================
var spColorMode = serializedObject.FindProperty("m_ColorMode");
EditorGUILayout.PropertyField(spColorMode);
// When color is enable, show parameters.
//if (spColorMode.intValue != (int)ColorMode.Multiply)
{
EditorGUI.indentLevel++;
SerializedProperty spColor = serializedObject.FindProperty(colorProperty);
if (spColor == null && serializedObject.targetObject is UIEffect)
{
spColor = new SerializedObject(serializedObject.targetObjects.Select(x => (x as UIEffect).targetGraphic).ToArray()).FindProperty(colorProperty);
}
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
#if UNITY_2018_1_OR_NEWER
spColor.colorValue = EditorGUILayout.ColorField(contentEffectColor, spColor.colorValue, true, false, false);
#else
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
#endif
if (EditorGUI.EndChangeCheck())
{
spColor.serializedObject.ApplyModifiedProperties();
}
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
EditorGUI.indentLevel--;
}
//================
// Blur setting.
//================
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
EditorGUILayout.PropertyField(spBlurMode);
// When blur is enable, show parameters.
if (spBlurMode.intValue != (int)BlurMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
if (spAdvancedBlur != null)
{
EditorGUILayout.PropertyField(spAdvancedBlur);
}
EditorGUI.indentLevel--;
}
}
int GetEnum<T>(Material mat)
{
Type type = typeof(T);
string[] names = System.Enum.GetNames(type);
int[] values = System.Enum.GetValues(type) as int[];
int mode = 0;
for (int i = 0; i < names.Length; i++)
{
if (mat.IsKeywordEnabled(names[i].ToUpper()))
mode = values[i];
}
return mode;
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
foreach (var d in targets.Cast<UIEffect>())
{
var mat = d.material;
if (d.isTMPro && mat)
{
var so = new SerializedObject(d);
EffectMode eMode = (EffectMode)GetEnum<EffectMode>(mat);
ColorMode cMode = (ColorMode)GetEnum<ColorMode>(mat);
BlurMode bMode = (BlurMode)GetEnum<BlurMode>(mat);
bool aBlur = mat.IsKeywordEnabled("EX");
if (d.effectMode != eMode || d.colorMode != cMode || d.blurMode != bMode || so.FindProperty("m_AdvancedBlur").boolValue != aBlur)
{
so.FindProperty("m_EffectMode").intValue = (int)eMode;
so.FindProperty("m_ColorMode").intValue = (int)cMode;
so.FindProperty("m_BlurMode").intValue = (int)bMode;
so.FindProperty("m_AdvancedBlur").boolValue = aBlur;
so.ApplyModifiedProperties();
}
}
}
serializedObject.Update();
bool isAnyTMPro = targets.Cast<UIEffect>().Any(x => x.isTMPro);
var c = target as UIEffect;
//================
// Effect material.
//================
var spMaterial = serializedObject.FindProperty("m_EffectMaterial");
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
var spToneMode = serializedObject.FindProperty("m_EffectMode");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spToneMode);
// When tone is enable, show parameters.
if (spToneMode.intValue != (int)EffectMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
EditorGUI.indentLevel--;
}
//================
// Color setting.
//================
var spColorMode = serializedObject.FindProperty("m_ColorMode");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spColorMode);
// When color is enable, show parameters.
//if (spColorMode.intValue != (int)ColorMode.Multiply)
{
EditorGUI.indentLevel++;
SerializedProperty spColor = serializedObject.FindProperty("m_Color");
if (spColor == null && serializedObject.targetObject is UIEffect)
{
spColor = new SerializedObject(serializedObject.targetObjects.Select(x => (x as UIEffect).targetGraphic).ToArray()).FindProperty(!isAnyTMPro ? "m_Color" : "m_fontColor");
}
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
#if UNITY_2018_1_OR_NEWER
spColor.colorValue = EditorGUILayout.ColorField(contentEffectColor, spColor.colorValue, true, false, false);
#else
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
#endif
if (EditorGUI.EndChangeCheck())
{
spColor.serializedObject.ApplyModifiedProperties();
}
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
EditorGUI.indentLevel--;
}
//================
// Blur setting.
//================
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spBlurMode);
// When blur is enable, show parameters.
if (spBlurMode.intValue != (int)BlurMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spAdvancedBlur);
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
c.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat => { });
ShowCanvasChannelsWarning();
ShowMaterialEditors(c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_shader = Shader.Find("TextMeshPro/Distance Field (UIEffect)");
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UIEffect)");
_spriteShader = Shader.Find("TextMeshPro/Sprite (UIEffect)");
}
//################################
// Private Members.
//################################
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}

View File

@ -1,101 +0,0 @@
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIGradient))]
[CanEditMultipleObjects]
public class UIGradientEditor : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Direction.
//================
var spDirection = serializedObject.FindProperty("m_Direction");
EditorGUILayout.PropertyField(spDirection);
//================
// Color.
//================
var spColor1 = serializedObject.FindProperty("m_Color1");
var spColor2 = serializedObject.FindProperty("m_Color2");
var spColor3 = serializedObject.FindProperty("m_Color3");
var spColor4 = serializedObject.FindProperty("m_Color4");
switch ((UIGradient.Direction)spDirection.intValue)
{
case UIGradient.Direction.Horizontal:
EditorGUILayout.PropertyField(spColor1, new GUIContent("Left"));
EditorGUILayout.PropertyField(spColor2, new GUIContent("Right"));
break;
case UIGradient.Direction.Vertical:
EditorGUILayout.PropertyField(spColor1, new GUIContent("Top"));
EditorGUILayout.PropertyField(spColor2, new GUIContent("Bottom"));
break;
case UIGradient.Direction.Angle:
EditorGUILayout.PropertyField(spColor1, new GUIContent("Color 1"));
EditorGUILayout.PropertyField(spColor2, new GUIContent("Color 2"));
break;
case UIGradient.Direction.Diagonal:
Rect r = EditorGUILayout.GetControlRect(false, 34);
r = EditorGUI.PrefixLabel(r, new GUIContent("Diagonal Color"));
float w = r.width / 2;
EditorGUI.PropertyField(new Rect(r.x, r.y, w, 16), spColor3, GUIContent.none);
EditorGUI.PropertyField(new Rect(r.x + w, r.y, w, 16), spColor4, GUIContent.none);
EditorGUI.PropertyField(new Rect(r.x, r.y + 18, w, 16), spColor1, GUIContent.none);
EditorGUI.PropertyField(new Rect(r.x + w, r.y + 18, w, 16), spColor2, GUIContent.none);
break;
}
//================
// Angle.
//================
if ((int)UIGradient.Direction.Angle <= spDirection.intValue)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Rotation"));
}
//================
// Offset.
//================
if ((int)UIGradient.Direction.Diagonal == spDirection.intValue)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset1"), new GUIContent("Vertical Offset"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset2"), new GUIContent("Horizontal Offset"));
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset1"), new GUIContent("Offset"));
}
//================
// Advanced options.
//================
EditorGUILayout.Space();
EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
{
//if ((target as UIGradient).targetGraphic is Text)
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_GradientStyle"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorSpace"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_IgnoreAspectRatio"));
}
EditorGUI.indentLevel--;
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@ -1,82 +0,0 @@
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIHsvModifier))]
[CanEditMultipleObjects]
public class UIHsvModifierEditor : BaseMeshEffectEditor
{
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spTargetColor = serializedObject.FindProperty("m_TargetColor");
_spRange = serializedObject.FindProperty("m_Range");
_spHue = serializedObject.FindProperty("m_Hue");
_spSaturation = serializedObject.FindProperty("m_Saturation");
_spValue = serializedObject.FindProperty("m_Value");
_shader = Shader.Find("TextMeshPro/Distance Field (UIHsvModifier)");
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UIHsvModifier)");
_spriteShader = Shader.Find("TextMeshPro/Sprite (UIHsvModifier)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
EditorGUILayout.PropertyField(_spTargetColor);
EditorGUILayout.PropertyField(_spRange);
EditorGUILayout.PropertyField(_spHue);
EditorGUILayout.PropertyField(_spSaturation);
EditorGUILayout.PropertyField(_spValue);
var c = target as UIHsvModifier;
c.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat => { });
ShowCanvasChannelsWarning();
ShowMaterialEditors(c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spTargetColor;
SerializedProperty _spRange;
SerializedProperty _spHue;
SerializedProperty _spSaturation;
SerializedProperty _spValue;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}

View File

@ -1,52 +0,0 @@
using UnityEditor;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIShadow editor.
/// </summary>
[CustomEditor(typeof(UIShadow))]
[CanEditMultipleObjects]
public class UIShadowEditor : Editor
{
UIEffect uiEffect;
void OnEnable()
{
uiEffect = (target as UIShadow).GetComponent<UIEffect>();
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Shadow setting.
//================
var spShadowMode = serializedObject.FindProperty("m_Style");
EditorGUILayout.PropertyField(spShadowMode);
// When shadow is enable, show parameters.
if (spShadowMode.intValue != (int)ShadowStyle.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectDistance"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseGraphicAlpha"));
if (uiEffect && uiEffect.blurMode != BlurMode.None)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
}
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@ -1,133 +0,0 @@
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIShiny))]
[CanEditMultipleObjects]
public class UIShinyEditor : BaseMeshEffectEditor
{
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
_spWidth = serializedObject.FindProperty("m_Width");
_spRotation = serializedObject.FindProperty("m_Rotation");
_spSoftness = serializedObject.FindProperty("m_Softness");
_spBrightness = serializedObject.FindProperty("m_Brightness");
_spGloss = serializedObject.FindProperty("m_Gloss");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
_spLoop = player.FindPropertyRelative("loop");
_spLoopDelay = player.FindPropertyRelative("loopDelay");
_spUpdateMode = player.FindPropertyRelative("updateMode");
_shader = Shader.Find("TextMeshPro/Distance Field (UIShiny)");
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UIShiny)");
_spriteShader = Shader.Find("TextMeshPro/Sprite (UIShiny)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
EditorGUILayout.PropertyField(_spEffectFactor);
EditorGUILayout.PropertyField(_spWidth);
EditorGUILayout.PropertyField(_spRotation);
EditorGUILayout.PropertyField(_spSoftness);
EditorGUILayout.PropertyField(_spBrightness);
EditorGUILayout.PropertyField(_spGloss);
//================
// Advanced option.
//================
EditorGUILayout.PropertyField(_spEffectArea);
//================
// Effect player.
//================
EditorGUILayout.PropertyField(_spPlay);
EditorGUILayout.PropertyField(_spDuration);
EditorGUILayout.PropertyField(_spInitialPlayDelay);
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Play", "ButtonLeft"))
{
(target as UIShiny).Play();
}
if (GUILayout.Button("Stop", "ButtonRight"))
{
(target as UIShiny).Stop();
}
}
var c = target as UIShiny;
c.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat => { });
ShowCanvasChannelsWarning();
ShowMaterialEditors(c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spEffectFactor;
SerializedProperty _spWidth;
SerializedProperty _spRotation;
SerializedProperty _spSoftness;
SerializedProperty _spBrightness;
SerializedProperty _spGloss;
SerializedProperty _spEffectArea;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
SerializedProperty _spDuration;
SerializedProperty _spInitialPlayDelay;
SerializedProperty _spUpdateMode;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}

View File

@ -1,189 +0,0 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UITransitionEffect))]
[CanEditMultipleObjects]
public class UITransitionEffectEditor : BaseMeshEffectEditor
{
static int s_NoiseTexId;
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spEffectMode = serializedObject.FindProperty("m_EffectMode");
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spDissolveWidth = serializedObject.FindProperty("m_DissolveWidth");
_spDissolveSoftness = serializedObject.FindProperty("m_DissolveSoftness");
_spDissolveColor = serializedObject.FindProperty("m_DissolveColor");
_spTransitionTexture = serializedObject.FindProperty("m_TransitionTexture");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
_spLoop = player.FindPropertyRelative("loop");
_spLoopDelay = player.FindPropertyRelative("loopDelay");
_spUpdateMode = player.FindPropertyRelative("updateMode");
_spPassRayOnHidden = serializedObject.FindProperty("m_PassRayOnHidden");
s_NoiseTexId = Shader.PropertyToID("_NoiseTex");
_shader = Shader.Find("TextMeshPro/Distance Field (UITransition)");
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UITransition)");
_spriteShader = Shader.Find("TextMeshPro/Sprite (UITransition)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
foreach (var d in targets.Cast<UITransitionEffect>())
{
var mat = d.material;
if (d.isTMPro && mat && mat.HasProperty(s_NoiseTexId))
{
Texture noiseTexture = mat.GetTexture(s_NoiseTexId);
UITransitionEffect.EffectMode mode =
mat.IsKeywordEnabled("CUTOFF") ? UITransitionEffect.EffectMode.Cutoff
: mat.IsKeywordEnabled("FADE") ? UITransitionEffect.EffectMode.Fade
: mat.IsKeywordEnabled("DISSOLVE") ? UITransitionEffect.EffectMode.Dissolve
: (UITransitionEffect.EffectMode)0;
if (mode == (UITransitionEffect.EffectMode)0)
{
mode = UITransitionEffect.EffectMode.Cutoff;
mat.EnableKeyword("CUTOFF");
}
bool hasChanged = d.transitionTexture != noiseTexture || d.effectMode != mode;
if (hasChanged)
{
var so = new SerializedObject(d);
so.FindProperty("m_TransitionTexture").objectReferenceValue = noiseTexture;
so.FindProperty("m_EffectMode").intValue = (int)mode;
so.ApplyModifiedProperties();
}
}
}
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
bool isAnyTMPro = targets.Cast<UITransitionEffect>().Any(x => x.isTMPro);
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(_spEffectMode);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_spEffectFactor);
if (_spEffectMode.intValue == (int)UITransitionEffect.EffectMode.Dissolve)
{
EditorGUILayout.PropertyField(_spDissolveWidth);
EditorGUILayout.PropertyField(_spDissolveSoftness);
EditorGUILayout.PropertyField(_spDissolveColor);
}
EditorGUI.indentLevel--;
//================
// Advanced option.
//================
EditorGUILayout.PropertyField(_spEffectArea);
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(_spTransitionTexture);
EditorGUILayout.PropertyField(_spKeepAspectRatio);
EditorGUILayout.PropertyField(_spPassRayOnHidden);
//================
// Effect player.
//================
EditorGUILayout.PropertyField(_spPlay);
EditorGUILayout.PropertyField(_spDuration);
EditorGUILayout.PropertyField(_spInitialPlayDelay);
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Show", "ButtonLeft"))
{
(target as UITransitionEffect).Show();
}
if (GUILayout.Button("Hide", "ButtonRight"))
{
(target as UITransitionEffect).Hide();
}
}
var current = target as UITransitionEffect;
current.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat =>
{
if (mat.shader == _spriteShader)
{
mat.shaderKeywords = current.material.shaderKeywords;
mat.SetTexture(s_NoiseTexId, current.material.GetTexture(s_NoiseTexId));
}
});
ShowCanvasChannelsWarning();
ShowMaterialEditors(current.materials, 1, current.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spEffectMode;
SerializedProperty _spEffectFactor;
SerializedProperty _spEffectArea;
SerializedProperty _spKeepAspectRatio;
SerializedProperty _spDissolveWidth;
SerializedProperty _spDissolveSoftness;
SerializedProperty _spDissolveColor;
SerializedProperty _spTransitionTexture;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
SerializedProperty _spDuration;
SerializedProperty _spInitialPlayDelay;
SerializedProperty _spUpdateMode;
SerializedProperty _spPassRayOnHidden;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}

View File

@ -1,434 +0,0 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
/// <summary>
/// Dissolve effect for uGUI.
/// </summary>
[AddComponentMenu("UI/UIEffect/UIDissolve", 3)]
public class UIDissolve : UIEffectBase
{
//################################
// Constant or Static Members.
//################################
public const string shaderName = "UI/Hidden/UI-Effect-Dissolve";
static readonly ParameterTexture _ptex = new ParameterTexture(8, 128, "_ParamTex");
//################################
// Serialize Members.
//################################
[Tooltip("Current location[0-1] for dissolve effect. 0 is not dissolved, 1 is completely dissolved.")]
[FormerlySerializedAs("m_Location")]
[SerializeField][Range(0, 1)] float m_EffectFactor = 0.5f;
[Tooltip("Edge width.")]
[SerializeField][Range(0, 1)] float m_Width = 0.5f;
[Tooltip("Edge softness.")]
[SerializeField][Range(0, 1)] float m_Softness = 0.5f;
[Tooltip("Edge color.")]
[SerializeField][ColorUsage(false)] Color m_Color = new Color(0.0f, 0.25f, 1.0f);
[Tooltip("Edge color effect mode.")]
[SerializeField] ColorMode m_ColorMode = ColorMode.Add;
[Tooltip("Noise texture for dissolving (single channel texture).")]
[SerializeField] Texture m_NoiseTexture;
[Header("Advanced Option")]
[Tooltip("The area for effect.")]
[SerializeField] protected EffectArea m_EffectArea;
[Tooltip("Keep effect aspect ratio.")]
[SerializeField] bool m_KeepAspectRatio;
[Header("Effect Player")]
[SerializeField] EffectPlayer m_Player;
[Tooltip("Reverse the dissolve effect.")]
[FormerlySerializedAs("m_ReverseAnimation")]
[SerializeField] bool m_Reverse = false;
#pragma warning disable 0414
[Obsolete]
[HideInInspector]
[SerializeField][Range(0.1f, 10)] float m_Duration = 1;
[Obsolete]
[HideInInspector]
[SerializeField] AnimatorUpdateMode m_UpdateMode = AnimatorUpdateMode.Normal;
#pragma warning restore 0414
//################################
// Public Members.
//################################
/// <summary>
/// Effect factor between 0(start) and 1(end).
/// </summary>
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
public float location
{
get { return m_EffectFactor; }
set
{
value = Mathf.Clamp(value, 0, 1);
if (!Mathf.Approximately(m_EffectFactor, value))
{
m_EffectFactor = value;
SetDirty();
}
}
}
/// <summary>
/// Effect factor between 0(start) and 1(end).
/// </summary>
public float effectFactor
{
get { return m_EffectFactor; }
set
{
value = Mathf.Clamp(value, 0, 1);
if (!Mathf.Approximately(m_EffectFactor, value))
{
m_EffectFactor = value;
SetDirty();
}
}
}
/// <summary>
/// Edge width.
/// </summary>
public float width
{
get { return m_Width; }
set
{
value = Mathf.Clamp(value, 0, 1);
if (!Mathf.Approximately(m_Width, value))
{
m_Width = value;
SetDirty();
}
}
}
/// <summary>
/// Edge softness.
/// </summary>
public float softness
{
get { return m_Softness; }
set
{
value = Mathf.Clamp(value, 0, 1);
if (!Mathf.Approximately(m_Softness, value))
{
m_Softness = value;
SetDirty();
}
}
}
/// <summary>
/// Edge color.
/// </summary>
public Color color
{
get { return m_Color; }
set
{
if (m_Color != value)
{
m_Color = value;
SetDirty();
}
}
}
/// <summary>
/// Noise texture.
/// </summary>
public Texture noiseTexture
{
get { return m_NoiseTexture ?? material.GetTexture("_NoiseTex"); }
set
{
if (m_NoiseTexture != value)
{
m_NoiseTexture = value;
if (graphic)
{
ModifyMaterial();
}
}
}
}
/// <summary>
/// The area for effect.
/// </summary>
public EffectArea effectArea
{
get { return m_EffectArea; }
set
{
if (m_EffectArea != value)
{
m_EffectArea = value;
SetVerticesDirty();
}
}
}
/// <summary>
/// Keep aspect ratio.
/// </summary>
public bool keepAspectRatio
{
get { return m_KeepAspectRatio; }
set
{
if (m_KeepAspectRatio != value)
{
m_KeepAspectRatio = value;
SetVerticesDirty();
}
}
}
/// <summary>
/// Color effect mode.
/// </summary>
public ColorMode colorMode { get { return m_ColorMode; } }
/// <summary>
/// Play effect on enable.
/// </summary>
[System.Obsolete("Use Play/Stop method instead")]
public bool play { get { return _player.play; } set { _player.play = value; } }
/// <summary>
/// Play effect loop.
/// </summary>
[System.Obsolete]
public bool loop { get { return _player.loop; } set { _player.loop = value; } }
/// <summary>
/// The duration for playing effect.
/// </summary>
public float duration { get { return _player.duration; } set { _player.duration = Mathf.Max(value, 0.1f); } }
/// <summary>
/// Delay on loop effect.
/// </summary>
[System.Obsolete]
public float loopDelay { get { return _player.loopDelay; } set { _player.loopDelay = Mathf.Max(value, 0); } }
/// <summary>
/// Update mode for playing effect.
/// </summary>
public AnimatorUpdateMode updateMode { get { return _player.updateMode; } set { _player.updateMode = value; } }
/// <summary>
/// Reverse the dissolve effect.
/// </summary>
public bool reverse { get { return m_Reverse; } set { m_Reverse = value; } }
/// <summary>
/// Gets the parameter texture.
/// </summary>
public override ParameterTexture ptex { get { return _ptex; } }
/// <summary>
/// Modifies the material.
/// </summary>
public override void ModifyMaterial()
{
if (isTMPro)
{
return;
}
ulong hash = (m_NoiseTexture ? (uint)m_NoiseTexture.GetInstanceID() : 0) + ((ulong)1 << 32) + ((ulong)m_ColorMode << 36);
if (_materialCache != null && (_materialCache.hash != hash || !isActiveAndEnabled || !m_EffectMaterial))
{
MaterialCache.Unregister(_materialCache);
_materialCache = null;
}
if (!isActiveAndEnabled || !m_EffectMaterial)
{
material = null;
}
else if (!m_NoiseTexture)
{
material = m_EffectMaterial;
}
else if (_materialCache != null && _materialCache.hash == hash)
{
material = _materialCache.material;
}
else
{
_materialCache = MaterialCache.Register(hash, m_NoiseTexture, () =>
{
var mat = new Material(m_EffectMaterial);
mat.name += "_" + m_NoiseTexture.name;
mat.SetTexture("_NoiseTex", m_NoiseTexture);
return mat;
});
material = _materialCache.material;
}
}
/// <summary>
/// Modifies the mesh.
/// </summary>
public override void ModifyMesh(VertexHelper vh)
{
if (!isActiveAndEnabled)
return;
bool isText = isTMPro || graphic is Text;
float normalizedIndex = ptex.GetNormalizedIndex(this);
// rect.
var tex = noiseTexture;
var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1;
Rect rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect, aspectRatio);
// Calculate vertex position.
UIVertex vertex = default(UIVertex);
float x, y;
int count = vh.currentVertCount;
for (int i = 0; i < count; i++)
{
vh.PopulateUIVertex(ref vertex, i);
m_EffectArea.GetPositionFactor(i, rect, vertex.position, isText, isTMPro, out x, out y);
vertex.uv0 = new Vector2(
Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
Packer.ToFloat(x, y, normalizedIndex)
);
// if(!isTMPro)
// {
// vertex.uv0 = new Vector2(
// Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
// Packer.ToFloat(x, y, normalizedIndex)
// );
// }
// #if UNITY_5_6_OR_NEWER
// else
// {
// vertex.uv2 = new Vector2 (
// Packer.ToFloat (x, y, normalizedIndex),
// 0
// );
// }
// #endif
vh.SetUIVertex(vertex, i);
}
}
protected override void SetDirty()
{
foreach (var m in materials)
{
ptex.RegisterMaterial(m);
}
ptex.SetData(this, 0, m_EffectFactor); // param1.x : location
ptex.SetData(this, 1, m_Width); // param1.y : width
ptex.SetData(this, 2, m_Softness); // param1.z : softness
ptex.SetData(this, 4, m_Color.r); // param2.x : red
ptex.SetData(this, 5, m_Color.g); // param2.y : green
ptex.SetData(this, 6, m_Color.b); // param2.z : blue
}
/// <summary>
/// Play effect.
/// </summary>
public void Play(bool reset = true)
{
_player.Play(reset);
}
/// <summary>
/// Stop effect.
/// </summary>
public void Stop(bool reset = true)
{
_player.Stop(reset);
}
//################################
// Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_player.OnEnable((f) =>
{
effectFactor = m_Reverse ? 1f - f : f;
});
}
protected override void OnDisable()
{
base.OnDisable();
MaterialCache.Unregister(_materialCache);
_materialCache = null;
_player.OnDisable();
}
#if UNITY_EDITOR
/// <summary>
/// Gets the material.
/// </summary>
/// <returns>The material.</returns>
protected override Material GetMaterial()
{
if (isTMPro)
{
return null;
}
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_ColorMode);
}
#pragma warning disable 0612
protected override void UpgradeIfNeeded()
{
// Upgrade for v3.0.0
if (IsShouldUpgrade(300))
{
_player.play = false;
_player.duration = m_Duration;
_player.loop = false;
_player.loopDelay = 1;
_player.updateMode = m_UpdateMode;
}
}
#pragma warning restore 0612
#endif
//################################
// Private Members.
//################################
MaterialCache _materialCache = null;
EffectPlayer _player { get { return m_Player ?? (m_Player = new EffectPlayer()); } }
}
}

View File

@ -1,494 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Serialization;
#if UNITY_EDITOR
using System.Linq;
using UnityEditor;
#endif
namespace Coffee.UIExtensions
{
/// <summary>
/// UIEffect.
/// </summary>
[ExecuteInEditMode]
[RequireComponent(typeof(Graphic))]
[DisallowMultipleComponent]
[AddComponentMenu("UI/UIEffect/UIEffect", 1)]
public class UIEffect : UIEffectBase
{
//################################
// Constant or Static Members.
//################################
public const string shaderName = "UI/Hidden/UI-Effect";
static readonly ParameterTexture _ptex = new ParameterTexture(4, 1024, "_ParamTex");
//################################
// Serialize Members.
//################################
[FormerlySerializedAs("m_ToneLevel")]
[Tooltip("Effect factor between 0(no effect) and 1(complete effect).")]
[SerializeField][Range(0, 1)] float m_EffectFactor = 1;
[Tooltip("Color effect factor between 0(no effect) and 1(complete effect).")]
[SerializeField][Range(0, 1)] float m_ColorFactor = 1;
[FormerlySerializedAs("m_Blur")]
[Tooltip("How far is the blurring from the graphic.")]
[SerializeField][Range(0, 1)] float m_BlurFactor = 1;
[FormerlySerializedAs("m_ToneMode")]
[Tooltip("Effect mode")]
[SerializeField] EffectMode m_EffectMode = EffectMode.None;
[Tooltip("Color effect mode")]
[SerializeField] ColorMode m_ColorMode = ColorMode.Multiply;
[Tooltip("Blur effect mode")]
[SerializeField] BlurMode m_BlurMode = BlurMode.None;
[Tooltip("Advanced blurring remove common artifacts in the blur effect for uGUI.")]
[SerializeField] bool m_AdvancedBlur = false;
#pragma warning disable 0414
[Obsolete]
[HideInInspector]
[SerializeField][Range(0, 1)] float m_ShadowBlur = 1;
[Obsolete]
[HideInInspector]
[SerializeField] ShadowStyle m_ShadowStyle;
[Obsolete]
[HideInInspector]
[SerializeField] Color m_ShadowColor = Color.black;
[Obsolete]
[HideInInspector]
[SerializeField] Vector2 m_EffectDistance = new Vector2(1f, -1f);
[Obsolete]
[HideInInspector]
[SerializeField] bool m_UseGraphicAlpha = true;
[Obsolete]
[HideInInspector]
[SerializeField] Color m_EffectColor = Color.white;
[Obsolete]
[HideInInspector]
[SerializeField] List<UIShadow.AdditionalShadow> m_AdditionalShadows = new List<UIShadow.AdditionalShadow>();
#pragma warning restore 0414
public enum BlurEx
{
None = 0,
Ex = 1,
}
//################################
// Public Members.
//################################
#if UNITY_2017_1_OR_NEWER
public override AdditionalCanvasShaderChannels requiredChannels
{
get
{
if (advancedBlur)
{
return isTMPro
? AdditionalCanvasShaderChannels.TexCoord1 | AdditionalCanvasShaderChannels.TexCoord2
: AdditionalCanvasShaderChannels.TexCoord1;
}
return AdditionalCanvasShaderChannels.None;
}
}
#endif
/// <summary>
/// Effect factor between 0(no effect) and 1(complete effect).
/// </summary>
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
public float toneLevel
{
get { return m_EffectFactor; }
set
{
m_EffectFactor = Mathf.Clamp(value, 0, 1);
SetDirty();
}
}
/// <summary>
/// Effect factor between 0(no effect) and 1(complete effect).
/// </summary>
public float effectFactor
{
get { return m_EffectFactor; }
set
{
m_EffectFactor = Mathf.Clamp(value, 0, 1);
SetDirty();
}
}
/// <summary>
/// Color effect factor between 0(no effect) and 1(complete effect).
/// </summary>
public float colorFactor
{
get { return m_ColorFactor; }
set
{
m_ColorFactor = Mathf.Clamp(value, 0, 1);
SetDirty();
}
}
/// <summary>
/// How far is the blurring from the graphic.
/// </summary>
[System.Obsolete("Use blurFactor instead (UnityUpgradable) -> blurFactor")]
public float blur
{
get { return m_BlurFactor; }
set
{
m_BlurFactor = Mathf.Clamp(value, 0, 1);
SetDirty();
}
}
/// <summary>
/// How far is the blurring from the graphic.
/// </summary>
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
public float blurFactor
{
get { return m_BlurFactor; }
set
{
m_BlurFactor = Mathf.Clamp(value, 0, 1);
SetDirty();
}
}
/// <summary>
/// Effect mode(readonly).
/// </summary>
[System.Obsolete("Use effectMode instead (UnityUpgradable) -> effectMode")]
public EffectMode toneMode { get { return m_EffectMode; } }
/// <summary>
/// Effect mode(readonly).
/// </summary>
public EffectMode effectMode { get { return m_EffectMode; } }
/// <summary>
/// Color effect mode(readonly).
/// </summary>
public ColorMode colorMode { get { return m_ColorMode; } }
/// <summary>
/// Blur effect mode(readonly).
/// </summary>
public BlurMode blurMode { get { return m_BlurMode; } }
/// <summary>
/// Color for the color effect.
/// </summary>
public Color effectColor
{
get { return graphic.color; }
set
{
graphic.color = value;
SetDirty();
}
}
/// <summary>
/// Gets the parameter texture.
/// </summary>
public override ParameterTexture ptex { get { return _ptex; } }
/// <summary>
/// Advanced blurring remove common artifacts in the blur effect for uGUI.
/// </summary>
public bool advancedBlur { get { return isTMPro ? (material && material.IsKeywordEnabled("EX")) : m_AdvancedBlur; } }
/// <summary>
/// Modifies the mesh.
/// </summary>
public override void ModifyMesh(VertexHelper vh)
{
if (!isActiveAndEnabled)
{
return;
}
float normalizedIndex = ptex.GetNormalizedIndex(this);
if (m_BlurMode != BlurMode.None && advancedBlur)
{
vh.GetUIVertexStream(tempVerts);
vh.Clear();
var count = tempVerts.Count;
// Bundle
int bundleSize = (targetGraphic is Text || isTMPro) ? 6 : count;
Rect posBounds = default(Rect);
Rect uvBounds = default(Rect);
Vector3 size = default(Vector3);
Vector3 tPos = default(Vector3);
Vector3 tUV = default(Vector3);
float expand = (float)blurMode * 6 * 2;
for (int i = 0; i < count; i += bundleSize)
{
// min/max for bundled-quad
GetBounds(tempVerts, i, bundleSize, ref posBounds, ref uvBounds, true);
// Pack uv mask.
Vector2 uvMask = new Vector2(Packer.ToFloat(uvBounds.xMin, uvBounds.yMin), Packer.ToFloat(uvBounds.xMax, uvBounds.yMax));
// Quad
for (int j = 0; j < bundleSize; j += 6)
{
Vector3 cornerPos1 = tempVerts[i + j + 1].position;
Vector3 cornerPos2 = tempVerts[i + j + 4].position;
// Is outer quad?
bool hasOuterEdge = (bundleSize == 6)
|| !posBounds.Contains(cornerPos1)
|| !posBounds.Contains(cornerPos2);
if (hasOuterEdge)
{
Vector3 cornerUv1 = tempVerts[i + j + 1].uv0;
Vector3 cornerUv2 = tempVerts[i + j + 4].uv0;
Vector3 centerPos = (cornerPos1 + cornerPos2) / 2;
Vector3 centerUV = (cornerUv1 + cornerUv2) / 2;
size = (cornerPos1 - cornerPos2);
size.x = 1 + expand / Mathf.Abs(size.x);
size.y = 1 + expand / Mathf.Abs(size.y);
size.z = 1 + expand / Mathf.Abs(size.z);
tPos = centerPos - Vector3.Scale(size, centerPos);
tUV = centerUV - Vector3.Scale(size, centerUV);
}
// Vertex
for (int k = 0; k < 6; k++)
{
UIVertex vt = tempVerts[i + j + k];
Vector3 pos = vt.position;
Vector2 uv0 = vt.uv0;
if (hasOuterEdge && (pos.x < posBounds.xMin || posBounds.xMax < pos.x))
{
pos.x = pos.x * size.x + tPos.x;
uv0.x = uv0.x * size.x + tUV.x;
}
if (hasOuterEdge && (pos.y < posBounds.yMin || posBounds.yMax < pos.y))
{
pos.y = pos.y * size.y + tPos.y;
uv0.y = uv0.y * size.y + tUV.y;
}
vt.uv0 = new Vector2(Packer.ToFloat((uv0.x + 0.5f) / 2f, (uv0.y + 0.5f) / 2f), normalizedIndex);
vt.position = pos;
if (isTMPro)
{
#if UNITY_2017_1_OR_NEWER
vt.uv2 = uvMask;
#endif
}
else
{
vt.uv1 = uvMask;
}
tempVerts[i + j + k] = vt;
}
}
}
vh.AddUIVertexTriangleStream(tempVerts);
tempVerts.Clear();
}
else
{
int count = vh.currentVertCount;
UIVertex vt = default(UIVertex);
for (int i = 0; i < count; i++)
{
vh.PopulateUIVertex(ref vt, i);
Vector2 uv0 = vt.uv0;
vt.uv0 = new Vector2(
Packer.ToFloat((uv0.x + 0.5f) / 2f, (uv0.y + 0.5f) / 2f),
normalizedIndex
);
vh.SetUIVertex(vt, i);
}
}
}
protected override void SetDirty()
{
foreach (var m in materials)
{
ptex.RegisterMaterial(m);
}
ptex.SetData(this, 0, m_EffectFactor); // param.x : effect factor
ptex.SetData(this, 1, m_ColorFactor); // param.y : color factor
ptex.SetData(this, 2, m_BlurFactor); // param.z : blur factor
}
#if UNITY_EDITOR
/// <summary>
/// Gets the material.
/// </summary>
/// <returns>The material.</returns>
protected override Material GetMaterial()
{
if (isTMPro)
{
return null;
}
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_EffectMode, m_ColorMode, m_BlurMode, m_AdvancedBlur ? BlurEx.Ex : BlurEx.None);
}
#pragma warning disable 0612
protected override void UpgradeIfNeeded()
{
// Upgrade for v3.0.0
if (IsShouldUpgrade(300))
{
if (m_ColorMode != ColorMode.Multiply)
{
Color col = targetGraphic.color;
col.r = m_EffectColor.r;
col.g = m_EffectColor.g;
col.b = m_EffectColor.b;
targetGraphic.color = col;
m_ColorFactor = m_EffectColor.a;
}
if (m_ShadowStyle != ShadowStyle.None || m_AdditionalShadows.Any(x => x.style != ShadowStyle.None))
{
if (m_ShadowStyle != ShadowStyle.None)
{
var shadow = gameObject.GetComponent<UIShadow>() ?? gameObject.AddComponent<UIShadow>();
shadow.style = m_ShadowStyle;
shadow.effectDistance = m_EffectDistance;
shadow.effectColor = m_ShadowColor;
shadow.useGraphicAlpha = m_UseGraphicAlpha;
shadow.blurFactor = m_ShadowBlur;
}
foreach (var s in m_AdditionalShadows)
{
if (s.style == ShadowStyle.None)
{
continue;
}
var shadow = gameObject.AddComponent<UIShadow>();
shadow.style = s.style;
shadow.effectDistance = s.effectDistance;
shadow.effectColor = s.effectColor;
shadow.useGraphicAlpha = s.useGraphicAlpha;
shadow.blurFactor = s.blur;
}
m_ShadowStyle = ShadowStyle.None;
m_AdditionalShadows = null;
if (m_EffectMode == EffectMode.None && m_ColorMode == ColorMode.Multiply && m_BlurMode == BlurMode.None)
{
DestroyImmediate(this, true);
}
}
int tone = (int)m_EffectMode;
const int Mono = 5;
const int Cutoff = 6;
const int Hue = 7;
if (tone == Hue)
{
var go = gameObject;
var hue = m_EffectFactor;
DestroyImmediate(this, true);
var hsv = go.GetComponent<UIHsvModifier>() ?? go.AddComponent<UIHsvModifier>();
hsv.hue = hue;
hsv.range = 1;
}
// Cutoff/Mono
if (tone == Cutoff || tone == Mono)
{
var go = gameObject;
var factor = m_EffectFactor;
var transitionMode = tone == Cutoff
? UITransitionEffect.EffectMode.Cutoff
: UITransitionEffect.EffectMode.Fade;
DestroyImmediate(this, true);
var trans = go.GetComponent<UITransitionEffect>() ?? go.AddComponent<UITransitionEffect>();
trans.effectFactor = factor;
var sp = new SerializedObject(trans).FindProperty("m_EffectMode");
sp.intValue = (int)transitionMode;
sp.serializedObject.ApplyModifiedProperties();
}
}
}
#pragma warning restore 0612
#endif
//################################
// Private Members.
//################################
static void GetBounds(List<UIVertex> verts, int start, int count, ref Rect posBounds, ref Rect uvBounds, bool global)
{
Vector2 minPos = new Vector2(float.MaxValue, float.MaxValue);
Vector2 maxPos = new Vector2(float.MinValue, float.MinValue);
Vector2 minUV = new Vector2(float.MaxValue, float.MaxValue);
Vector2 maxUV = new Vector2(float.MinValue, float.MinValue);
for (int i = start; i < start + count; i++)
{
UIVertex vt = verts[i];
Vector2 uv = vt.uv0;
Vector3 pos = vt.position;
// Left-Bottom
if (minPos.x >= pos.x && minPos.y >= pos.y)
{
minPos = pos;
}
// Right-Top
else if (maxPos.x <= pos.x && maxPos.y <= pos.y)
{
maxPos = pos;
}
// Left-Bottom
if (minUV.x >= uv.x && minUV.y >= uv.y)
{
minUV = uv;
}
// Right-Top
else if (maxUV.x <= uv.x && maxUV.y <= uv.y)
{
maxUV = uv;
}
}
// Shrink coordinate for detect edge
posBounds.Set(minPos.x + 0.001f, minPos.y + 0.001f, maxPos.x - minPos.x - 0.002f, maxPos.y - minPos.y - 0.002f);
uvBounds.Set(minUV.x, minUV.y, maxUV.x - minUV.x, maxUV.y - minUV.y);
}
}
}

View File

@ -1,552 +0,0 @@
using System.Collections;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
/// <summary>
/// UIEffectCapturedImage
/// </summary>
[AddComponentMenu("UI/UIEffect/UIEffectCapturedImage", 200)]
public class UIEffectCapturedImage : RawImage
#if UNITY_EDITOR
, ISerializationCallbackReceiver
#endif
{
//################################
// Constant or Static Members.
//################################
public const string shaderName = "UI/Hidden/UI-EffectCapture";
/// <summary>
/// Desampling rate.
/// </summary>
public enum DesamplingRate
{
None = 0,
x1 = 1,
x2 = 2,
x4 = 4,
x8 = 8,
}
//################################
// Serialize Members.
//################################
[Tooltip("Effect factor between 0(no effect) and 1(complete effect).")]
[FormerlySerializedAs("m_ToneLevel")]
[SerializeField][Range(0, 1)] float m_EffectFactor = 1;
[Tooltip("Color effect factor between 0(no effect) and 1(complete effect).")]
[SerializeField][Range(0, 1)] float m_ColorFactor = 1;
[Tooltip("How far is the blurring from the graphic.")]
[FormerlySerializedAs("m_Blur")]
[SerializeField][Range(0, 1)] float m_BlurFactor = 1;
[Tooltip("Effect mode.")]
[FormerlySerializedAs("m_ToneMode")]
[SerializeField] EffectMode m_EffectMode = EffectMode.None;
[Tooltip("Color effect mode.")]
[SerializeField] ColorMode m_ColorMode = ColorMode.Multiply;
[Tooltip("Blur effect mode.")]
[SerializeField] BlurMode m_BlurMode = BlurMode.DetailBlur;
[Tooltip("Color for the color effect.")]
[SerializeField] Color m_EffectColor = Color.white;
[Tooltip("Desampling rate of the generated RenderTexture.")]
[SerializeField] DesamplingRate m_DesamplingRate = DesamplingRate.x1;
[Tooltip("Desampling rate of reduction buffer to apply effect.")]
[SerializeField] DesamplingRate m_ReductionRate = DesamplingRate.x1;
[Tooltip("FilterMode for capturing.")]
[SerializeField] FilterMode m_FilterMode = FilterMode.Bilinear;
[Tooltip("Effect material.")]
[SerializeField] Material m_EffectMaterial = null;
[Tooltip("Blur iterations.")]
[FormerlySerializedAs("m_Iterations")]
[SerializeField][Range(1, 8)] int m_BlurIterations = 3;
[Tooltip("Fits graphic size to screen on captured.")]
[FormerlySerializedAs("m_KeepCanvasSize")]
[SerializeField] bool m_FitToScreen = true;
[Tooltip("Capture automatically on enable.")]
[SerializeField] bool m_CaptureOnEnable = false;
//################################
// Public Members.
//################################
/// <summary>
/// Effect factor between 0(no effect) and 1(complete effect).
/// </summary>
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
public float toneLevel { get { return m_EffectFactor; } set { m_EffectFactor = Mathf.Clamp(value, 0, 1); } }
/// <summary>
/// Effect factor between 0(no effect) and 1(complete effect).
/// </summary>
public float effectFactor { get { return m_EffectFactor; } set { m_EffectFactor = Mathf.Clamp(value, 0, 1); } }
/// <summary>
/// Color effect factor between 0(no effect) and 1(complete effect).
/// </summary>
public float colorFactor { get { return m_ColorFactor; } set { m_ColorFactor = Mathf.Clamp(value, 0, 1); } }
/// <summary>
/// How far is the blurring from the graphic.
/// </summary>
[System.Obsolete("Use blurFactor instead (UnityUpgradable) -> blurFactor")]
public float blur { get { return m_BlurFactor; } set { m_BlurFactor = Mathf.Clamp(value, 0, 4); } }
/// <summary>
/// How far is the blurring from the graphic.
/// </summary>
public float blurFactor { get { return m_BlurFactor; } set { m_BlurFactor = Mathf.Clamp(value, 0, 4); } }
/// <summary>
/// Tone effect mode.
/// </summary>
[System.Obsolete("Use effectMode instead (UnityUpgradable) -> effectMode")]
public EffectMode toneMode { get { return m_EffectMode; } }
/// <summary>
/// Effect mode.
/// </summary>
public EffectMode effectMode { get { return m_EffectMode; } }
/// <summary>
/// Color effect mode.
/// </summary>
public ColorMode colorMode { get { return m_ColorMode; } }
/// <summary>
/// Blur effect mode.
/// </summary>
public BlurMode blurMode { get { return m_BlurMode; } }
/// <summary>
/// Color for the color effect.
/// </summary>
public Color effectColor { get { return m_EffectColor; } set { m_EffectColor = value; } }
/// <summary>
/// Effect material.
/// </summary>
public virtual Material effectMaterial { get { return m_EffectMaterial; } }
/// <summary>
/// Desampling rate of the generated RenderTexture.
/// </summary>
public DesamplingRate desamplingRate { get { return m_DesamplingRate; } set { m_DesamplingRate = value; } }
/// <summary>
/// Desampling rate of reduction buffer to apply effect.
/// </summary>
public DesamplingRate reductionRate { get { return m_ReductionRate; } set { m_ReductionRate = value; } }
/// <summary>
/// FilterMode for capturing.
/// </summary>
public FilterMode filterMode { get { return m_FilterMode; } set { m_FilterMode = value; } }
/// <summary>
/// Captured texture.
/// </summary>
public RenderTexture capturedTexture { get { return _rt; } }
/// <summary>
/// Blur iterations.
/// </summary>
[System.Obsolete("Use blurIterations instead (UnityUpgradable) -> blurIterations")]
public int iterations { get { return m_BlurIterations; } set { m_BlurIterations = value; } }
/// <summary>
/// Blur iterations.
/// </summary>
public int blurIterations { get { return m_BlurIterations; } set { m_BlurIterations = value; } }
/// <summary>
/// Fits graphic size to screen.
/// </summary>
[System.Obsolete("Use fitToScreen instead (UnityUpgradable) -> fitToScreen")]
public bool keepCanvasSize { get { return m_FitToScreen; } set { m_FitToScreen = value; } }
/// <summary>
/// Fits graphic size to screen on captured.
/// </summary>
public bool fitToScreen { get { return m_FitToScreen; } set { m_FitToScreen = value; } }
/// <summary>
/// Target RenderTexture to capture.
/// </summary>
[System.Obsolete]
public RenderTexture targetTexture { get { return null; } set { } }
/// <summary>
/// Capture automatically on enable.
/// </summary>
public bool captureOnEnable { get { return m_CaptureOnEnable; } set { m_CaptureOnEnable = value; } }
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
if (m_CaptureOnEnable && Application.isPlaying)
{
Capture();
}
}
protected override void OnDisable()
{
base.OnDisable();
if (m_CaptureOnEnable && Application.isPlaying)
{
_Release(false);
texture = null;
}
}
/// <summary>
/// This function is called when the MonoBehaviour will be destroyed.
/// </summary>
protected override void OnDestroy()
{
Release();
base.OnDestroy();
}
/// <summary>
/// Callback function when a UI element needs to generate vertices.
/// </summary>
protected override void OnPopulateMesh(VertexHelper vh)
{
// When not displaying, clear vertex.
if (texture == null || color.a < 1 / 255f || canvasRenderer.GetAlpha() < 1 / 255f)
{
vh.Clear();
}
else
{
base.OnPopulateMesh(vh);
int count = vh.currentVertCount;
UIVertex vt = default(UIVertex);
Color c = color;
for (int i = 0; i < count; i++)
{
vh.PopulateUIVertex(ref vt, i);
vt.color = c;
vh.SetUIVertex(vt, i);
}
}
}
/// <summary>
/// Gets the size of the desampling.
/// </summary>
public void GetDesamplingSize(DesamplingRate rate, out int w, out int h)
{
#if UNITY_EDITOR
if (!Application.isPlaying)
{
var res = UnityEditor.UnityStats.screenRes.Split('x');
w = int.Parse(res[0]);
h = int.Parse(res[1]);
}
else
#endif
{
w = Screen.width;
h = Screen.height;
}
if (rate == DesamplingRate.None)
return;
float aspect = (float)w / h;
if (w < h)
{
h = Mathf.ClosestPowerOfTwo(h / (int)rate);
w = Mathf.CeilToInt(h * aspect);
}
else
{
w = Mathf.ClosestPowerOfTwo(w / (int)rate);
h = Mathf.CeilToInt(w / aspect);
}
}
/// <summary>
/// Capture rendering result.
/// </summary>
public void Capture()
{
// Fit to screen.
var rootCanvas = canvas.rootCanvas;
if (m_FitToScreen)
{
var rootTransform = rootCanvas.transform as RectTransform;
var size = rootTransform.rect.size;
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x);
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y);
rectTransform.position = rootTransform.position;
}
// Cache some ids.
if (s_CopyId == 0)
{
s_CopyId = Shader.PropertyToID("_UIEffectCapturedImage_ScreenCopyId");
s_EffectId1 = Shader.PropertyToID("_UIEffectCapturedImage_EffectId1");
s_EffectId2 = Shader.PropertyToID("_UIEffectCapturedImage_EffectId2");
s_EffectFactorId = Shader.PropertyToID("_EffectFactor");
s_ColorFactorId = Shader.PropertyToID("_ColorFactor");
s_CommandBuffer = new CommandBuffer();
}
// If size of result RT has changed, release it.
int w, h;
GetDesamplingSize(m_DesamplingRate, out w, out h);
if (_rt && (_rt.width != w || _rt.height != h))
{
_Release(ref _rt);
}
// Generate RT for result.
if (_rt == null)
{
_rt = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
_rt.filterMode = m_FilterMode;
_rt.useMipMap = false;
_rt.wrapMode = TextureWrapMode.Clamp;
_rtId = new RenderTargetIdentifier(_rt);
}
SetupCommandBuffer();
}
void SetupCommandBuffer()
{
// Material for effect.
Material mat = m_EffectMaterial;
if (s_CommandBuffer == null)
{
s_CommandBuffer = new CommandBuffer();
}
// [1] Capture from back buffer (back buffer -> copied screen).
int w, h;
GetDesamplingSize(DesamplingRate.None, out w, out h);
s_CommandBuffer.GetTemporaryRT(s_CopyId, w, h, 0, m_FilterMode);
#if UNITY_EDITOR
s_CommandBuffer.Blit(Resources.FindObjectsOfTypeAll<RenderTexture>().FirstOrDefault(x => x.name == "GameView RT"), s_CopyId);
#else
s_CommandBuffer.Blit(BuiltinRenderTextureType.BindableTexture, s_CopyId);
#endif
// Set properties for effect.
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(m_EffectFactor, 0));
s_CommandBuffer.SetGlobalVector(s_ColorFactorId, new Vector4(m_EffectColor.r, m_EffectColor.g, m_EffectColor.b, m_EffectColor.a));
// [2] Apply base effect with reduction buffer (copied screen -> effect1).
GetDesamplingSize(m_ReductionRate, out w, out h);
s_CommandBuffer.GetTemporaryRT(s_EffectId1, w, h, 0, m_FilterMode);
s_CommandBuffer.Blit(s_CopyId, s_EffectId1, mat, 0);
s_CommandBuffer.ReleaseTemporaryRT(s_CopyId);
// Iterate blurring operation.
if (m_BlurMode != BlurMode.None)
{
s_CommandBuffer.GetTemporaryRT(s_EffectId2, w, h, 0, m_FilterMode);
for (int i = 0; i < m_BlurIterations; i++)
{
// [3] Apply blurring with reduction buffer (effect1 -> effect2, or effect2 -> effect1).
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(m_BlurFactor, 0));
s_CommandBuffer.Blit(s_EffectId1, s_EffectId2, mat, 1);
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(0, m_BlurFactor));
s_CommandBuffer.Blit(s_EffectId2, s_EffectId1, mat, 1);
}
s_CommandBuffer.ReleaseTemporaryRT(s_EffectId2);
}
// [4] Copy to result RT.
s_CommandBuffer.Blit(s_EffectId1, _rtId);
s_CommandBuffer.ReleaseTemporaryRT(s_EffectId1);
#if UNITY_EDITOR
if (!Application.isPlaying)
{
Graphics.ExecuteCommandBuffer(s_CommandBuffer);
UpdateTexture();
return;
}
#endif
// Execute command buffer.
canvas.rootCanvas.GetComponent<CanvasScaler>().StartCoroutine(_CoUpdateTextureOnNextFrame());
}
/// <summary>
/// Release captured image.
/// </summary>
public void Release()
{
_Release(true);
texture = null;
_SetDirty();
}
#if UNITY_EDITOR
protected override void Reset()
{
// Set parameters as 'Medium'.
m_BlurIterations = 3;
m_FilterMode = FilterMode.Bilinear;
m_DesamplingRate = DesamplingRate.x1;
m_ReductionRate = DesamplingRate.x1;
base.Reset();
}
/// <summary>
/// Raises the before serialize event.
/// </summary>
public void OnBeforeSerialize()
{
}
/// <summary>
/// Raises the after deserialize event.
/// </summary>
public void OnAfterDeserialize()
{
UnityEditor.EditorApplication.delayCall += () => UpdateMaterial(true);
}
/// <summary>
/// Raises the validate event.
/// </summary>
protected override void OnValidate()
{
base.OnValidate();
UnityEditor.EditorApplication.delayCall += () => UpdateMaterial(false);
}
/// <summary>
/// Updates the material.
/// </summary>
/// <param name="ignoreInPlayMode">If set to <c>true</c> ignore in play mode.</param>
protected void UpdateMaterial(bool ignoreInPlayMode)
{
if (!this || ignoreInPlayMode && Application.isPlaying)
{
return;
}
var mat = MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_EffectMode, m_ColorMode, m_BlurMode);
if (m_EffectMaterial != mat)
{
material = null;
m_EffectMaterial = mat;
_SetDirty();
}
}
#endif
//################################
// Private Members.
//################################
RenderTexture _rt;
RenderTargetIdentifier _rtId;
static int s_CopyId;
static int s_EffectId1;
static int s_EffectId2;
static int s_EffectFactorId;
static int s_ColorFactorId;
static CommandBuffer s_CommandBuffer;
/// <summary>
/// Release genarated objects.
/// </summary>
/// <param name="releaseRT">If set to <c>true</c> release cached RenderTexture.</param>
void _Release(bool releaseRT)
{
if (releaseRT)
{
texture = null;
_Release(ref _rt);
}
if (s_CommandBuffer != null)
{
s_CommandBuffer.Clear();
if (releaseRT)
{
s_CommandBuffer.Release();
s_CommandBuffer = null;
}
}
}
[System.Diagnostics.Conditional("UNITY_EDITOR")]
void _SetDirty()
{
#if UNITY_EDITOR
if (!Application.isPlaying)
{
UnityEditor.EditorUtility.SetDirty(this);
}
#endif
}
void _Release(ref RenderTexture obj)
{
if (obj)
{
obj.Release();
RenderTexture.ReleaseTemporary(obj);
obj = null;
}
}
/// <summary>
/// Set texture on next frame.
/// </summary>
IEnumerator _CoUpdateTextureOnNextFrame()
{
yield return new WaitForEndOfFrame();
UpdateTexture();
}
void UpdateTexture()
{
#if !UNITY_EDITOR
// Execute command buffer.
Graphics.ExecuteCommandBuffer (s_CommandBuffer);
#endif
_Release(false);
texture = capturedTexture;
_SetDirty();
}
}
}

Some files were not shown because too many files have changed in this diff Show More