mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
1332 Commits
1.2.4
...
6b23927f71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b23927f71 | ||
|
|
dfa9ff6954 | ||
|
|
4c717b69db | ||
|
|
d64997a0df | ||
|
|
a265b85d37 | ||
|
|
5b81269090 | ||
|
|
d228e41df7 | ||
|
|
23032cc269 | ||
|
|
72f02bd73f | ||
|
|
a37663a8c2 | ||
|
|
f375d45bd6 | ||
|
|
3dd3d4ef76 | ||
|
|
f0563cce0b | ||
|
|
9b83dcf723 | ||
|
|
ee67a55c0f | ||
|
|
454afc9ba6 | ||
|
|
539ca3523e | ||
|
|
c87efdb509 | ||
|
|
1884fab0c2 | ||
|
|
e5d0a856a5 | ||
|
|
5da8c6baf8 | ||
|
|
33356cb270 | ||
|
|
4b6a8ca406 | ||
|
|
c8e45a6cae | ||
|
|
1fbc9d26a6 | ||
|
|
abb087b02e | ||
|
|
aeaf03011f | ||
|
|
78d24ad3a6 | ||
|
|
aab2c4625e | ||
|
|
079ef75605 | ||
|
|
75881b55f6 | ||
|
|
2020c7d508 | ||
|
|
088d939346 | ||
|
|
fa50e91c9f | ||
|
|
2e7b992a4b | ||
|
|
29fbbd97ff | ||
|
|
abb150e33f | ||
|
|
78e20f434e | ||
|
|
304222b788 | ||
|
|
101236db8a | ||
|
|
37de007b3f | ||
|
|
d570ba8d74 | ||
|
|
2a956099ae | ||
|
|
74037a5a29 | ||
|
|
861f850a32 | ||
|
|
8b1b5f988a | ||
|
|
efafd1173f | ||
|
|
03e49ff1fb | ||
|
|
ea34be1f00 | ||
|
|
831a9981e3 | ||
|
|
9de4aaa658 | ||
|
|
3579a23bd5 | ||
|
|
c865ddc7f2 | ||
|
|
0bde506aec | ||
|
|
15005b3d30 | ||
|
|
4caf733ac6 | ||
|
|
014b17f5cb | ||
|
|
f3ebda0c04 | ||
|
|
5602addaca | ||
|
|
c4ae67aa8e | ||
|
|
bbcc3bf971 | ||
|
|
8b0e75b9b3 | ||
|
|
b1f02049cc | ||
|
|
512886cdf6 | ||
|
|
0c3ccc5c2f | ||
|
|
b0ea03170f | ||
|
|
2c3b890329 | ||
|
|
0f39cb9444 | ||
|
|
8acc16d3f6 | ||
|
|
fd1715a89b | ||
|
|
0934c813d1 | ||
|
|
be71d38cd8 | ||
|
|
4cdfde31da | ||
|
|
0133549ef8 | ||
|
|
81d9eb47c8 | ||
|
|
5fde689f1f | ||
|
|
5d51bfe751 | ||
|
|
ed86edd2b0 | ||
|
|
f627b5b59a | ||
|
|
549ec74519 | ||
|
|
247ee31348 | ||
|
|
90d3a53bc3 | ||
|
|
19f1d67a61 | ||
|
|
a71c46d1c4 | ||
|
|
82d7bc8fef | ||
|
|
cc85099253 | ||
|
|
d392b02bd4 | ||
|
|
a5138b9846 | ||
|
|
e1b6458c26 | ||
|
|
0f73dc3047 | ||
|
|
a85e49c22a | ||
|
|
6b291de922 | ||
|
|
a4b1300195 | ||
|
|
6f34951a74 | ||
|
|
c798250258 | ||
|
|
6fc82bb55a | ||
|
|
c22cf5ffeb | ||
|
|
36bc24f9fd | ||
|
|
addb0ecdfe | ||
|
|
89e23e0df8 | ||
|
|
e2f582834e | ||
|
|
d2c2844f61 | ||
|
|
1de64278ad | ||
|
|
227f2332a9 | ||
|
|
131614687c | ||
|
|
b8ec902f60 | ||
|
|
eb3e29b6ad | ||
|
|
11ed9d391a | ||
|
|
9cd50bc7f3 | ||
|
|
e92505ba88 | ||
|
|
06a670730c | ||
|
|
ccd21e56cb | ||
|
|
522bcc529a | ||
|
|
2254ac9f5e | ||
|
|
956b3db71d | ||
|
|
fb56959c61 | ||
|
|
b9b9f4e37d | ||
|
|
c050d6d172 | ||
|
|
baf76a454b | ||
|
|
385d343262 | ||
|
|
1f5ad24d44 | ||
|
|
fefc0043cf | ||
|
|
f49143d4f7 | ||
|
|
fd760b12a3 | ||
|
|
14cf8e9ca3 | ||
|
|
3595219a71 | ||
|
|
a4c7d4b8f5 | ||
|
|
43c5c7fb53 | ||
|
|
48d2b36d4e | ||
|
|
2fd87f4d4b | ||
|
|
0fd75b835a | ||
|
|
4489ca570b | ||
|
|
268792b576 | ||
|
|
33907ea967 | ||
|
|
5d7afff3e4 | ||
|
|
fa15f83d85 | ||
|
|
1801974c8a | ||
|
|
bfd476d59c | ||
|
|
7dd08e9634 | ||
|
|
b2776b933a | ||
|
|
9f09b6c526 | ||
|
|
01f6103b48 | ||
|
|
053b4a00d7 | ||
|
|
db159428c6 | ||
|
|
ac7ee16017 | ||
|
|
c2fb7c3cbb | ||
|
|
e70b0d37cd | ||
|
|
53db012fc8 | ||
|
|
b3622167da | ||
|
|
dd6fab46f9 | ||
|
|
f0796dccc9 | ||
|
|
f383c59327 | ||
|
|
e34b9270d2 | ||
|
|
b90ab01fe9 | ||
|
|
236468b4a8 | ||
|
|
6f5fcd55b1 | ||
|
|
4b8f2e3acc | ||
|
|
090e4f4b15 | ||
|
|
53163a75ae | ||
|
|
273401cb20 | ||
|
|
97fe3b0681 | ||
|
|
d401086fd1 | ||
|
|
e3a12ef361 | ||
|
|
1b0288fcd0 | ||
|
|
3ee94fb3b9 | ||
|
|
a0ea80c158 | ||
|
|
264415b362 | ||
|
|
6a76d44c38 | ||
|
|
cebfd57851 | ||
|
|
60eb1c3522 | ||
|
|
40c82835bf | ||
|
|
a13913f572 | ||
|
|
150b46a0a7 | ||
|
|
ebde5a52d3 | ||
|
|
e57466e9e2 | ||
|
|
6f7fca7b34 | ||
|
|
756331fe0b | ||
|
|
5139e2f3a7 | ||
|
|
1c4aba6db5 | ||
|
|
44faa0c5e6 | ||
|
|
72c97341b1 | ||
|
|
9acc240b5a | ||
|
|
ed89e73d26 | ||
|
|
9e33df0375 | ||
|
|
6c98f9a09d | ||
|
|
9ed85afb29 | ||
|
|
560a395173 | ||
|
|
8bce963588 | ||
|
|
f8a3fe47e5 | ||
|
|
48356a4f9e | ||
|
|
d2a28bd801 | ||
|
|
3949abb53f | ||
|
|
06a50a049e | ||
|
|
6f049e2427 | ||
|
|
01c08a46ab | ||
|
|
31dc5b494d | ||
|
|
18e74e906e | ||
|
|
4f62b249b4 | ||
|
|
fe7f9bff08 | ||
|
|
e71077f294 | ||
|
|
eabebf3d8f | ||
|
|
4ef789520a | ||
|
|
4322f3c58c | ||
|
|
c40a796170 | ||
|
|
32841d4773 | ||
|
|
e469b32d94 | ||
|
|
c0e5315953 | ||
|
|
7b5f366533 | ||
|
|
e674d5bf97 | ||
|
|
9b0bebd981 | ||
|
|
dc46462bfa | ||
|
|
51c9943cf2 | ||
|
|
3db9b750e3 | ||
|
|
1b57a0b7df | ||
|
|
bd5ce1e6bd | ||
|
|
7eb74d4dd1 | ||
|
|
a384ca1f18 | ||
|
|
c7253a3f23 | ||
|
|
b296abb27e | ||
|
|
999ede6bab | ||
|
|
bd1569c34d | ||
|
|
3c265c1ab4 | ||
|
|
570a3a817c | ||
|
|
7a8f344927 | ||
|
|
b2c9cb3a7e | ||
|
|
06a5c90b23 | ||
|
|
dcd8ced42a | ||
|
|
76b31bd3cf | ||
|
|
009e8ece79 | ||
|
|
4e257ab27d | ||
|
|
927400b669 | ||
|
|
c0d42e79d8 | ||
|
|
b843c6b0ed | ||
|
|
9fb7f8bbfe | ||
|
|
b0382afad0 | ||
|
|
1ab7689174 | ||
|
|
29d456c065 | ||
|
|
b0dc829b04 | ||
|
|
b3ead90832 | ||
|
|
7bf00d4ff6 | ||
|
|
030e94d8ff | ||
|
|
cf05254121 | ||
|
|
3f786bca3b | ||
|
|
98719d212f | ||
|
|
3409f7ce4d | ||
|
|
f57b354e9b | ||
|
|
974493f88d | ||
|
|
69a69988a1 | ||
|
|
4e9c1955eb | ||
|
|
b6c68a533e | ||
|
|
38aa1c3509 | ||
|
|
eb2f783417 | ||
|
|
8556e071fa | ||
|
|
6155256fb6 | ||
|
|
0d4f2bc893 | ||
|
|
600e928ab4 | ||
|
|
4599ff098c | ||
|
|
4d2df5b705 | ||
|
|
79a7732cfd | ||
|
|
79467bbf13 | ||
|
|
c7d678282b | ||
|
|
d376afc217 | ||
|
|
a62f808591 | ||
|
|
b334a4986b | ||
|
|
a4111349a0 | ||
|
|
bdcf95384f | ||
|
|
d910af589d | ||
|
|
0531864534 | ||
|
|
72b1278f5c | ||
|
|
875cd24cba | ||
|
|
fcc729a0bf | ||
|
|
d10e54248b | ||
|
|
b84800a905 | ||
|
|
8ccd7e552c | ||
|
|
772ba484eb | ||
|
|
cdbedee705 | ||
|
|
10cce48e71 | ||
|
|
13e8410d80 | ||
|
|
6f07faf4da | ||
|
|
e3228d406e | ||
|
|
daf2133535 | ||
|
|
9bcbc10862 | ||
|
|
e6958d205e | ||
|
|
b03d9db2b0 | ||
|
|
30853b6d62 | ||
|
|
a7cafcb328 | ||
|
|
d03bca5512 | ||
|
|
af3fc50188 | ||
|
|
b71eeeb855 | ||
|
|
317c42521a | ||
|
|
064d69269e | ||
|
|
9e6401d3c0 | ||
|
|
2aaba328ee | ||
|
|
62fdc93a82 | ||
|
|
408f0942ee | ||
|
|
ddda9e29db | ||
|
|
c2b33f5ec4 | ||
|
|
e58999e484 | ||
|
|
ed9692574c | ||
|
|
f7e078e064 | ||
|
|
b74a44dc36 | ||
|
|
6b36cdb5ee | ||
|
|
56ae1a8f95 | ||
|
|
3069b1d1f1 | ||
|
|
e7d346e4e1 | ||
|
|
7d9e00a574 | ||
|
|
7382afe535 | ||
|
|
af7d4774d6 | ||
|
|
520a8a0623 | ||
|
|
fbd0d8ec40 | ||
|
|
3fea98ce4c | ||
|
|
7c561ce254 | ||
|
|
522ddb5115 | ||
|
|
47f5790507 | ||
|
|
0cdcfe7f52 | ||
|
|
e4d69d869b | ||
|
|
61afb70cb9 | ||
|
|
79580697a1 | ||
|
|
6cb74760b0 | ||
|
|
c758aa81ff | ||
|
|
400c2ccefe | ||
|
|
64e9734bbe | ||
|
|
f6244885be | ||
|
|
82c57c382f | ||
|
|
7eacb46555 | ||
|
|
d9c911d89b | ||
|
|
a3ceb3dcb6 | ||
|
|
a5b68b28b2 | ||
|
|
bd285faf37 | ||
|
|
8a4960b560 | ||
|
|
83c6ae2057 | ||
|
|
b71563e889 | ||
|
|
79e0cf85f9 | ||
|
|
e996eaa008 | ||
|
|
5088c9e985 | ||
|
|
610b3c6d32 | ||
|
|
cc7290f10e | ||
|
|
576b842368 | ||
|
|
d23c0ba715 | ||
|
|
98e19baebd | ||
|
|
f5947db44a | ||
|
|
e978164329 | ||
|
|
966c8f2efa | ||
|
|
a57fec3d71 | ||
|
|
84844eda20 | ||
|
|
698cdcba61 | ||
|
|
1d6c9393d4 | ||
|
|
b654ac156d | ||
|
|
d133a9a692 | ||
|
|
d55db19f0e | ||
|
|
e3fc3df32c | ||
|
|
f2334da72d | ||
|
|
2902b6c2cf | ||
|
|
dfa95b57b9 | ||
|
|
33a2cf66d0 | ||
|
|
5f52cf5b51 | ||
|
|
9d07905f2d | ||
|
|
26dbe9dfdd | ||
|
|
98c5851071 | ||
|
|
a6ee571d65 | ||
|
|
a138701afe | ||
|
|
e52bdea255 | ||
|
|
068a712a30 | ||
|
|
80a5300648 | ||
|
|
0c36e458f7 | ||
|
|
b2fa52e4c4 | ||
|
|
151e978e5b | ||
|
|
9e806861ec | ||
|
|
a9a9368b9b | ||
|
|
7936ba31ea | ||
|
|
afc456de9a | ||
|
|
a98db0ba83 | ||
|
|
fb8720edd3 | ||
|
|
2aa2a0ac3a | ||
|
|
0531b6ef3a | ||
|
|
24142de11f | ||
|
|
7fad6eb70b | ||
|
|
f60227abdf | ||
|
|
18d6a74c53 | ||
|
|
03d06ba657 | ||
|
|
07086b68c8 | ||
|
|
0a85f3126f | ||
|
|
efa4180340 | ||
|
|
fb06f2aa11 | ||
|
|
ce023cedb8 | ||
|
|
3d1a28a50e | ||
|
|
5d2d0b4168 | ||
|
|
fa985a5a93 | ||
|
|
40f9937b60 | ||
|
|
c543c629c3 | ||
|
|
f861279c49 | ||
|
|
ee89f81d46 | ||
|
|
6d216561f8 | ||
|
|
0a96e583d3 | ||
|
|
c9d263c60d | ||
|
|
2d6488abf4 | ||
|
|
7dfbac4a24 | ||
|
|
7cfe4cb2c9 | ||
|
|
30cba8ca5f | ||
|
|
e9261a0ec0 | ||
|
|
89ee22837d | ||
|
|
939f3747cd | ||
|
|
f72814a51b | ||
|
|
94ee2ba5c1 | ||
|
|
fd9533d63f | ||
|
|
6571faae4e | ||
|
|
e031498d5b | ||
|
|
31a0017351 | ||
|
|
6e8cb0366d | ||
|
|
a02b3fbf6e | ||
|
|
37a663e0e1 | ||
|
|
e925d9892f | ||
|
|
e7907eeaa7 | ||
|
|
644e6655ff | ||
|
|
20c07af504 | ||
|
|
38471cdd6c | ||
|
|
0b5d16bd0e | ||
|
|
203b9994df | ||
|
|
e76bbb6a85 | ||
|
|
4e6c146bde | ||
|
|
7e1dc7ef24 | ||
|
|
698d81a433 | ||
|
|
012f9b9f03 | ||
|
|
12bd282ace | ||
|
|
31a89fa1a3 | ||
|
|
57d1e92e59 | ||
|
|
377fca20d9 | ||
|
|
415f844982 | ||
|
|
cbb8472153 | ||
|
|
c85ced89ef | ||
|
|
d5b8c90c94 | ||
|
|
9bcfb04f91 | ||
|
|
ae0fbd4b10 | ||
|
|
ef4f011cf6 | ||
|
|
7cc985205a | ||
|
|
a38b76eb8f | ||
|
|
9f844912cf | ||
|
|
d72b0b10d4 | ||
|
|
655f756d56 | ||
|
|
912e2c28a3 | ||
|
|
9add447566 | ||
|
|
7c435f6dc0 | ||
|
|
5e2fc84ebf | ||
|
|
793a57647d | ||
|
|
c32e7bc525 | ||
|
|
20fac33efc | ||
|
|
8cf356cadb | ||
|
|
17d2c8bf0a | ||
|
|
3dec5ac004 | ||
|
|
cf2ada8f2b | ||
|
|
c801f601d3 | ||
|
|
6a97704dab | ||
|
|
ee6c8301c4 | ||
|
|
de35f4308d | ||
|
|
3d4ed38f17 | ||
|
|
a84f981147 | ||
|
|
b70d821384 | ||
|
|
bc7c6c1f33 | ||
|
|
2a8761c29e | ||
|
|
0c732755ec | ||
|
|
5c638d713e | ||
|
|
8ff16f7205 | ||
|
|
6bf8e3643b | ||
|
|
6ab704bb77 | ||
|
|
41329f3bbc | ||
|
|
a59ebd69b4 | ||
|
|
278b6e3cc8 | ||
|
|
1d0c0ee7cb | ||
|
|
a8bf0a62fa | ||
|
|
fc58fb27e2 | ||
|
|
b1abeb4ec2 | ||
|
|
d9b7f33bde | ||
|
|
c0a1061204 | ||
|
|
7cbdfeec51 | ||
|
|
381c16d574 | ||
|
|
3e6be2f293 | ||
|
|
1bd62c4673 | ||
|
|
04aa4067cd | ||
|
|
499fb8239e | ||
|
|
fe75491024 | ||
|
|
8803003cf7 | ||
|
|
5a850aef07 | ||
|
|
d1d6e023c4 | ||
|
|
4370ed544f | ||
|
|
42c87519e1 | ||
|
|
769134eaf9 | ||
|
|
51b688bbdd | ||
|
|
748e74e515 | ||
|
|
d1d3ad9869 | ||
|
|
f9b72a22ae | ||
|
|
766cf90a19 | ||
|
|
8a2dc86cf7 | ||
|
|
5ca54b88fa | ||
|
|
7257c8778d | ||
|
|
dc21696ae1 | ||
|
|
7f566e5388 | ||
|
|
fe352ceb84 | ||
|
|
10750a0123 | ||
|
|
f2e6da649b | ||
|
|
9737cd06dd | ||
|
|
df8cf4d9ca | ||
|
|
36b4cbb8c2 | ||
|
|
bae84f65da | ||
|
|
313ec2d100 | ||
|
|
bfda5ec952 | ||
|
|
248bdba839 | ||
|
|
75dd3d0e5e | ||
|
|
8944ec0e02 | ||
|
|
25c5683a09 | ||
|
|
069e29ac07 | ||
|
|
942e4bf672 | ||
|
|
dca37a3794 | ||
|
|
f84419b7a6 | ||
|
|
aa3a049985 | ||
|
|
3f8c7bd91f | ||
|
|
11984d6972 | ||
|
|
31b0a3fb54 | ||
|
|
666d0b53a6 | ||
|
|
df77df4854 | ||
|
|
4f75248f5b | ||
|
|
2b56f4469d | ||
|
|
8d1f0d2010 | ||
|
|
16117b67f1 | ||
|
|
4fc0d06908 | ||
|
|
6254d00bb5 | ||
|
|
6d6fd3af2c | ||
|
|
16344393a1 | ||
|
|
36f561a595 | ||
|
|
f5f024b1d6 | ||
|
|
429f68ff64 | ||
|
|
f9074518dd | ||
|
|
bda803761b | ||
|
|
d3c1c5acb0 | ||
|
|
dcaafedabb | ||
|
|
985c76d8ce | ||
|
|
8c532798cb | ||
|
|
17aed56270 | ||
|
|
1f07411dde | ||
|
|
906e0e3554 | ||
|
|
22958923ad | ||
|
|
a5f94198c0 | ||
|
|
8a2bac8770 | ||
|
|
3fd24f6f19 | ||
|
|
c30292013b | ||
|
|
edd6db731f | ||
|
|
19e0c7b01a | ||
|
|
58fc76b8d2 | ||
|
|
1638bb301d | ||
|
|
f0ed677d86 | ||
|
|
4b0c52d2dd | ||
|
|
5f4e1d0b2f | ||
|
|
a98a48a58d | ||
|
|
763054884b | ||
|
|
376088e63c | ||
|
|
c614ba4705 | ||
|
|
14ea408fec | ||
|
|
038a52f7fc | ||
|
|
341bd5947f | ||
|
|
b5d857d2f1 | ||
|
|
97f9a3d4b1 | ||
|
|
9607d7135b | ||
|
|
b1338a9ffd | ||
|
|
bf1e3da298 | ||
|
|
a91cbee50c | ||
|
|
15fbbf3873 | ||
|
|
f73abba79f | ||
|
|
5fa9ebee80 | ||
|
|
d890ccd5e6 | ||
|
|
e76a782a80 | ||
|
|
0f7c5b2564 | ||
|
|
fcf0f34d5a | ||
|
|
acf2301028 | ||
|
|
9bc0577423 | ||
|
|
d037ce5b86 | ||
|
|
02250c3352 | ||
|
|
cdaa45e163 | ||
|
|
2b9014f4d8 | ||
|
|
75a013d961 | ||
|
|
27563fa58e | ||
|
|
55f958266c | ||
|
|
d980b55997 | ||
|
|
7232caa5c0 | ||
|
|
c0df366676 | ||
|
|
8e7a43275f | ||
|
|
d3567d8dd5 | ||
|
|
e9539636ac | ||
|
|
093dd25e0f | ||
|
|
e0427d3062 | ||
|
|
9e2030c83d | ||
|
|
0627641845 | ||
|
|
4bbcc3c73d | ||
|
|
945842c0e7 | ||
|
|
02ba98f120 | ||
|
|
688f8ec26c | ||
|
|
7652de0129 | ||
|
|
3f027e5456 | ||
|
|
6a17335231 | ||
|
|
ebf0dd9e46 | ||
|
|
04bd352a05 | ||
|
|
fa4ebfe3be | ||
|
|
87421bb391 | ||
|
|
c35e22fbd7 | ||
|
|
94623d8dc0 | ||
|
|
50eed2be10 | ||
|
|
e9b7336146 | ||
|
|
fbec06fa81 | ||
|
|
9fe8dad72d | ||
|
|
3046bbe697 | ||
|
|
7089952895 | ||
|
|
737d2a796b | ||
|
|
e25fd14675 | ||
|
|
c55dc713f4 | ||
|
|
40ef17edcd | ||
|
|
418536ded1 | ||
|
|
c156b5c0a7 | ||
|
|
ae454b72dc | ||
|
|
d34d1117a0 | ||
|
|
a5f3767cbc | ||
|
|
3bdb339f54 | ||
|
|
22cb3c3942 | ||
|
|
e5f5241879 | ||
|
|
79ac231df2 | ||
|
|
b7b375092f | ||
|
|
f86ea04521 | ||
|
|
738c02f58f | ||
|
|
d017688416 | ||
|
|
6b56275f87 | ||
|
|
b89f00130e | ||
|
|
4f58c54eff | ||
|
|
9001be21ac | ||
|
|
be3fa0b688 | ||
|
|
b421e7d2f8 | ||
|
|
0e7c14abde | ||
|
|
caf072ed9b | ||
|
|
51f2709956 | ||
|
|
0d5558f29f | ||
|
|
c6377ce544 | ||
|
|
07d34891ef | ||
|
|
ddce031ee5 | ||
|
|
6680a6450b | ||
|
|
dc119b26c7 | ||
|
|
2cbfca4f3b | ||
|
|
7d8fce6f46 | ||
|
|
13ad50aef5 | ||
|
|
30245b3668 | ||
|
|
589eea7cf3 | ||
|
|
24c5108ce1 | ||
|
|
21fbb01ce4 | ||
|
|
e664f20d34 | ||
|
|
b0ce14dc0e | ||
|
|
d2b38cbc1b | ||
|
|
a6d978090c | ||
|
|
f9d40987eb | ||
|
|
cab710493e | ||
|
|
9970cf704b | ||
|
|
260867b588 | ||
|
|
25231ecd32 | ||
|
|
b282515c39 | ||
|
|
bafd15571a | ||
|
|
481711fd75 | ||
|
|
d09b52301a | ||
|
|
0c77ef628f | ||
|
|
54f585c67a | ||
|
|
a9e5e7fdd3 | ||
|
|
b151f968d7 | ||
|
|
86ef93caa3 | ||
|
|
75511397d6 | ||
|
|
db8d09d0d6 | ||
|
|
02d70a476d | ||
|
|
9420f8561f | ||
|
|
d43eb821b9 | ||
|
|
b82ede8bde | ||
|
|
ff02da5c54 | ||
|
|
2987d356b6 | ||
|
|
dc5f0b151b | ||
|
|
dd5bcc3d9d | ||
|
|
80188ae6e6 | ||
|
|
05e77dc166 | ||
|
|
b9b8f8e170 | ||
|
|
c9cc09cbed | ||
|
|
bef90bf3b8 | ||
|
|
a369efa429 | ||
|
|
370329b07d | ||
|
|
e743a15fbc | ||
|
|
10c8b52092 | ||
|
|
1461b91a94 | ||
|
|
b5ffd5005a | ||
|
|
f06bd83dc3 | ||
|
|
a1450ee78a | ||
|
|
4c619778c3 | ||
|
|
4e8840cd93 | ||
|
|
0a709f741a | ||
|
|
ef8229981e | ||
|
|
2a5a2626a4 | ||
|
|
f4ddaedbf4 | ||
|
|
42104eb944 | ||
|
|
fadc8e6fd6 | ||
|
|
81747462b1 | ||
|
|
c01adad2a0 | ||
|
|
e598d60439 | ||
|
|
929cd23f35 | ||
|
|
d1aca5b675 | ||
|
|
b67868868d | ||
|
|
af3bf8448c | ||
|
|
4170c60f0c | ||
|
|
0a7a883aae | ||
|
|
88a1184877 | ||
|
|
c7329fcab5 | ||
|
|
6eb9a90a03 | ||
|
|
7586882a97 | ||
|
|
6f13c021b9 | ||
|
|
5f30c92d44 | ||
|
|
3e6c55d981 | ||
|
|
de36f984d7 | ||
|
|
95328fe1a6 | ||
|
|
1fb78185ff | ||
|
|
58f9aea979 | ||
|
|
4d4bb1e34f | ||
|
|
6e1978ec10 | ||
|
|
d8a8afba5e | ||
|
|
6e6f425bdd | ||
|
|
9ebe92f832 | ||
|
|
cbdb84a69f | ||
|
|
67b2b886a8 | ||
|
|
2838289650 | ||
|
|
4b68362fb8 | ||
|
|
e8e7696a4d | ||
|
|
82b2a5cc20 | ||
|
|
2332765932 | ||
|
|
552d689317 | ||
|
|
5e2d82d071 | ||
|
|
727f356eea | ||
|
|
544832c46a | ||
|
|
5c1d316d67 | ||
|
|
267ec77c37 | ||
|
|
c2a7106221 | ||
|
|
0e29e9823d | ||
|
|
47962424eb | ||
|
|
505d23ca07 | ||
|
|
d4fcb868d8 | ||
|
|
6dd1f43445 | ||
|
|
2626cb6750 | ||
|
|
81a98ded8a | ||
|
|
930f02765d | ||
|
|
a4ffa580b7 | ||
|
|
506612527d | ||
|
|
74f9f2b0e6 | ||
|
|
4119f02c60 | ||
|
|
bc9a4e07e2 | ||
|
|
9418544264 | ||
|
|
460ea091bd | ||
|
|
64681db027 | ||
|
|
992957e1e9 | ||
|
|
ce62dbc27f | ||
|
|
e2df967aa9 | ||
|
|
5b4a188c0b | ||
|
|
e8b5a58a90 | ||
|
|
c3d5c13a80 | ||
|
|
d30a8aefa4 | ||
|
|
194afe435a | ||
|
|
82ef993d83 | ||
|
|
6d7177a3b5 | ||
|
|
205dd58afd | ||
|
|
d5d5063453 | ||
|
|
f63fcf1227 | ||
|
|
0c70f27560 | ||
|
|
db889366ac | ||
|
|
9476bbe562 | ||
|
|
1313e05d5d | ||
|
|
8817b35517 | ||
|
|
cfe8a77dd5 | ||
|
|
a874d17798 | ||
|
|
5d9ef12577 | ||
|
|
b3a135e1a2 | ||
|
|
a25d03f073 | ||
|
|
589c0d3ce5 | ||
|
|
8457705807 | ||
|
|
ce7aefb744 | ||
|
|
499d7766db | ||
|
|
988327c9bd | ||
|
|
d0d0bf2b63 | ||
|
|
feb34761ce | ||
|
|
0ceeeb8c5b | ||
|
|
0c7289bbc8 | ||
|
|
e02fe2331d | ||
|
|
6877900ac2 | ||
|
|
45dbe2a0e6 | ||
|
|
4234885f94 | ||
|
|
bae55ca511 | ||
|
|
f804e8405e | ||
|
|
3c9c61c346 | ||
|
|
d560d8a2e8 | ||
|
|
054ee93360 | ||
|
|
eb98eaeb3b | ||
|
|
8fe2fa7bc6 | ||
|
|
95894f92db | ||
|
|
61e06dee4c | ||
|
|
e207d834bd | ||
|
|
e358bbf46c | ||
|
|
9c0f9557e8 | ||
|
|
006d4c6f09 | ||
|
|
6fb5a4b946 | ||
|
|
6687d75090 | ||
|
|
01cf9ccd54 | ||
|
|
880b6d429d | ||
|
|
070db961fc | ||
|
|
96ef379668 | ||
|
|
697a87721f | ||
|
|
09cf93d852 | ||
|
|
8725821a27 | ||
|
|
7ad8651ca0 | ||
|
|
a2e57c6e90 | ||
|
|
6d37bca2a9 | ||
|
|
8471bb0f9a | ||
|
|
05cb57db09 | ||
|
|
064e9a1aa3 | ||
|
|
a618b6cf9e | ||
|
|
e3e810e702 | ||
|
|
b4f0d6bab8 | ||
|
|
44cb4168cf | ||
|
|
559ed95999 | ||
|
|
b766df1d31 | ||
|
|
057ff6b22b | ||
|
|
995b0c8050 | ||
|
|
a2d4691f04 | ||
|
|
ab2d7d4724 | ||
|
|
9b4abf86b6 | ||
|
|
0331b7b6e3 | ||
|
|
e31799e78b | ||
|
|
a8405eea6d | ||
|
|
c11f072c50 | ||
|
|
bd080eb19b | ||
|
|
ef231e213e | ||
|
|
a5900b5f99 | ||
|
|
b22bbd4e27 | ||
|
|
664866b627 | ||
|
|
ad9bdc6574 | ||
|
|
b93b993951 | ||
|
|
cb2cb4e556 | ||
|
|
ab32bd390d | ||
|
|
b34374adfa | ||
|
|
b53b6a4246 | ||
|
|
191fbff768 | ||
|
|
e8a4ddf331 | ||
|
|
aee6e2d2f8 | ||
|
|
b737b20602 | ||
|
|
b5df539392 | ||
|
|
36c53e5d94 | ||
|
|
15ce6b8c8c | ||
|
|
19aa82c131 | ||
|
|
92ed6e7d1c | ||
|
|
b9a45a58a8 | ||
|
|
0c1efe7420 | ||
|
|
9dd7680457 | ||
|
|
087216b9da | ||
|
|
ecb6f71f81 | ||
|
|
ffffff16e9 | ||
|
|
0311d976bb | ||
|
|
120c07cc2e | ||
|
|
ed5ae40cb3 | ||
|
|
5931d91b5f | ||
|
|
472a5ae97a | ||
|
|
829ea66d0e | ||
|
|
ba39291ee7 | ||
|
|
d3d15fc59f | ||
|
|
8a3358c990 | ||
|
|
8eadba3aa6 | ||
|
|
b0917623b6 | ||
|
|
a7d9a4ecbc | ||
|
|
2643ab81ed | ||
|
|
c5314c72f0 | ||
|
|
fbb48ba330 | ||
|
|
4e6879e34f | ||
|
|
09c3d4e479 | ||
|
|
1e88bad73e | ||
|
|
9a2ed64b4e | ||
|
|
60e93f9809 | ||
|
|
f5c72e913f | ||
|
|
3ca300d956 | ||
|
|
d1087aa74c | ||
|
|
43c40e4bbe | ||
|
|
d9c4e5336b | ||
|
|
772198255a | ||
|
|
19c46a2f60 | ||
|
|
f54c8d6da4 | ||
|
|
84f9d1985e | ||
|
|
0b2a2bf97d | ||
|
|
561cf411ef | ||
|
|
f24ae6eb2a | ||
|
|
3bb3d4382c | ||
|
|
43db19c257 | ||
|
|
1d5663d93a | ||
|
|
b98d4cb091 | ||
|
|
14ee95615f | ||
|
|
8ccddce0f8 | ||
|
|
9dde15ac41 | ||
|
|
95111ef1e1 | ||
|
|
dc33abde46 | ||
|
|
aae7b08dd1 | ||
|
|
f70582af1a | ||
|
|
f04d84bb93 | ||
|
|
78693deed6 | ||
|
|
f1a5965b4c | ||
|
|
cd43d0775d | ||
|
|
cf532a84ef | ||
|
|
651b65d148 | ||
|
|
895dde1cc8 | ||
|
|
f6e94c9514 | ||
|
|
da4ba4453c | ||
|
|
53ea8c8002 | ||
|
|
d4549b1228 | ||
|
|
fcf9eff2f6 | ||
|
|
93b58149d2 | ||
|
|
c91c49465b | ||
|
|
e9fa3ead04 | ||
|
|
eff2f1d968 | ||
|
|
cd0a6579b8 | ||
|
|
18c2e232cf | ||
|
|
ad680638ac | ||
|
|
0764061d8f | ||
|
|
d448026250 | ||
|
|
34f553b9e3 | ||
|
|
25d1e32ce9 | ||
|
|
8686c32ada | ||
|
|
f043c6710a | ||
|
|
acd27e36fa | ||
|
|
37f0d1e5a1 | ||
|
|
e6397559ff | ||
|
|
812c46adeb | ||
|
|
4d7fb6301a | ||
|
|
f0951f2a25 | ||
|
|
7d2defedb7 | ||
|
|
17ab618bed | ||
|
|
0f9e932616 | ||
|
|
20b0bd26ae | ||
|
|
3b395861d9 | ||
|
|
d5d1f851ab | ||
|
|
c2e2a33af1 | ||
|
|
9a729f921e | ||
|
|
1b75f4b6e9 | ||
|
|
aaab6692c3 | ||
|
|
70fc85e456 | ||
|
|
29358a7b4b | ||
|
|
b1b0563d84 | ||
|
|
21b1e5bee7 | ||
|
|
c02eeef846 | ||
|
|
e84e50708b | ||
|
|
1471ca06f3 | ||
|
|
60b04c19dc | ||
|
|
4490c99eee | ||
|
|
9a84cdef9f | ||
|
|
62bbf110fb | ||
|
|
fd282d96d1 | ||
|
|
4e4da4440b | ||
|
|
5651d6dd9d | ||
|
|
e0499993a4 | ||
|
|
5c59cfe983 | ||
|
|
396ec7121c | ||
|
|
e403c80d51 | ||
|
|
aac315826e | ||
|
|
567c34d4d1 | ||
|
|
896681df87 | ||
|
|
e278883958 | ||
|
|
0d57565cae | ||
|
|
513c71398d | ||
|
|
a22c80a199 | ||
|
|
16e3001e51 | ||
|
|
3943850bc1 | ||
|
|
4fc41a449e | ||
|
|
f945508625 | ||
|
|
beaa77832c | ||
|
|
d0480edda6 | ||
|
|
de43495af5 | ||
|
|
c60cc1e84f | ||
|
|
82c83fcdf7 | ||
|
|
19221480a0 | ||
|
|
290e139346 | ||
|
|
923b0751e5 | ||
|
|
334b96f90e | ||
|
|
7ae8a6c247 | ||
|
|
18830544a6 | ||
|
|
37cab30ed7 | ||
|
|
91fe51d10a | ||
|
|
027ae02aa0 | ||
|
|
49e0d9729d | ||
|
|
15c667b043 | ||
|
|
4820d2a54a | ||
|
|
58a40ad1d1 | ||
|
|
1877a373d6 | ||
|
|
192b60f037 | ||
|
|
c40224b454 | ||
|
|
6508bf6851 | ||
|
|
96b8ced64f | ||
|
|
254da59b7a | ||
|
|
c9b775d8ff | ||
|
|
d60b0ea0ea | ||
|
|
20061983d6 | ||
|
|
ff8f8623d9 | ||
|
|
1ce1a6f0ff | ||
|
|
67d09d95fa | ||
|
|
10e04c7645 | ||
|
|
9c05ac8cc2 | ||
|
|
55d1eb145e | ||
|
|
c8cdeb2ae1 | ||
|
|
9891ab23a2 | ||
|
|
9739fe2b79 | ||
|
|
c976221cbb | ||
|
|
8267904155 | ||
|
|
ef8a8ff497 | ||
|
|
2384921477 | ||
|
|
985b05f29d | ||
|
|
5254fb65ef | ||
|
|
8ff666d5e2 | ||
|
|
ed77d6dc1f | ||
|
|
7b41fd82a4 | ||
|
|
ac0112199d | ||
|
|
ef5e1e65f9 | ||
|
|
b330d26b4f | ||
|
|
93d7c34454 | ||
|
|
0bd5677e26 | ||
|
|
22e2e978ef | ||
|
|
65c2651105 | ||
|
|
ef13e19c48 | ||
|
|
39ffad6da6 | ||
|
|
13924fca13 | ||
|
|
438f006d1d | ||
|
|
6fb5626230 | ||
|
|
ab29069af5 | ||
|
|
fc3ed28eda | ||
|
|
46c9110b85 | ||
|
|
06b033ed36 | ||
|
|
ab96f3f28c | ||
|
|
295238cbb6 | ||
|
|
69125e967f | ||
|
|
4f0f0e54ac | ||
|
|
a9a01b08dc | ||
|
|
c27a3e105c | ||
|
|
3cfc084e62 | ||
|
|
7c1873e861 | ||
|
|
c57c313dbe | ||
|
|
19cf9c0129 | ||
|
|
ebcb05cc55 | ||
|
|
7c4dbb1f38 | ||
|
|
091b46ccaf | ||
|
|
4da2bf441f | ||
|
|
365ed560f6 | ||
|
|
bcf6372602 | ||
|
|
a5e24be5d4 | ||
|
|
cdaf6f0dca | ||
|
|
e38d0bc6d0 | ||
|
|
eb16ba8365 | ||
|
|
3beb4f53d6 | ||
|
|
f8ba0c9753 | ||
|
|
0232e5adec | ||
|
|
a0bc521903 | ||
|
|
071a84d9ef | ||
|
|
aa40b5336e | ||
|
|
157402bb39 | ||
|
|
5a98a68c27 | ||
|
|
f6bc52fd59 | ||
|
|
d1f2712e5f | ||
|
|
8958317f61 | ||
|
|
fdf27cbc1a | ||
|
|
26ffb829d0 | ||
|
|
521e3e2587 | ||
|
|
17c6158478 | ||
|
|
fa0dc48993 | ||
|
|
826bdaab5c | ||
|
|
7d21da76fb | ||
|
|
70465a49d7 | ||
|
|
acca74dce7 | ||
|
|
d8e7892ab7 | ||
|
|
e887bf1fd7 | ||
|
|
145ca936e7 | ||
|
|
69c7a51215 | ||
|
|
c4875d4f80 | ||
|
|
eed3c9768b | ||
|
|
2c650f2bdf | ||
|
|
71e8392359 | ||
|
|
cfbf6e23ec | ||
|
|
9be5ec0f31 | ||
|
|
a8a0c3831b | ||
|
|
ef31d5a938 | ||
|
|
812db6dafe | ||
|
|
66fe2f0995 | ||
|
|
3b40cc7833 | ||
|
|
5a01ca061a | ||
|
|
ef0cc05f5c | ||
|
|
c5c6e4ae23 | ||
|
|
1c2bbfea93 | ||
|
|
8893317f59 | ||
|
|
ca8b5c85dd | ||
|
|
a64d485278 | ||
|
|
2612764922 | ||
|
|
8ce8e81792 | ||
|
|
fbba2ddec9 | ||
|
|
33a1b9d4bf | ||
|
|
03abac082c | ||
|
|
3672a7e1fa | ||
|
|
df27e7ba75 | ||
|
|
423655e1ca | ||
|
|
f620223613 | ||
|
|
365a94d7b7 | ||
|
|
a98efd83b6 | ||
|
|
6488e96127 | ||
|
|
cc75594747 | ||
|
|
e5de104933 | ||
|
|
954e76ab33 | ||
|
|
82bda518c9 | ||
|
|
cdc5bcd31f | ||
|
|
61f6d480ae | ||
|
|
df6df3548c | ||
|
|
ac839450e2 | ||
|
|
4fa01e1a29 | ||
|
|
db2a45ec35 | ||
|
|
76c6f5cc1c | ||
|
|
339b519881 | ||
|
|
de2fab1370 | ||
|
|
fd4b6794cc | ||
|
|
f3e3f7cf85 | ||
|
|
dd824254a9 | ||
|
|
16943d4590 | ||
|
|
a95697088b | ||
|
|
f771a98f25 | ||
|
|
3b1a8beadf | ||
|
|
209e9d7705 | ||
|
|
de09a042e6 | ||
|
|
66cd491493 | ||
|
|
4a158319e5 | ||
|
|
b322a848ba | ||
|
|
4e759134bd | ||
|
|
5c16171781 | ||
|
|
08ad68d4a2 | ||
|
|
2ace30acd8 | ||
|
|
fc55b1be82 | ||
|
|
b287dfedcf | ||
|
|
d6984f0ad4 | ||
|
|
85cb1ed3f6 | ||
|
|
32b5240fcc | ||
|
|
7b9fda2298 | ||
|
|
15a605b677 | ||
|
|
f4a3fcece8 | ||
|
|
d67fc31c26 | ||
|
|
889000d8a8 | ||
|
|
e827e74cc7 | ||
|
|
45ca1ebf02 | ||
|
|
3a81d7babd | ||
|
|
a1d5949177 | ||
|
|
d7ae52160b | ||
|
|
e3fa33b9b5 | ||
|
|
ac251114ff | ||
|
|
824d1c1501 | ||
|
|
ac88fd5cf6 | ||
|
|
5197d42807 | ||
|
|
7a0f4caa9b | ||
|
|
5bf1d29edc | ||
|
|
2687466ed4 | ||
|
|
14512d6470 | ||
|
|
32268f5a4a | ||
|
|
81401ca0b8 | ||
|
|
688cc271d5 | ||
|
|
a290353cfa | ||
|
|
6038e7acd6 | ||
|
|
4abec5a389 | ||
|
|
a2b51a8044 | ||
|
|
19cb239746 | ||
|
|
7aab610be5 | ||
|
|
4ec5a126ac | ||
|
|
32643caf51 | ||
|
|
114ebab6ae | ||
|
|
d1463e1fc6 | ||
|
|
aa49980231 | ||
|
|
2696da092d | ||
|
|
5415d95f36 | ||
|
|
efa71c8bb7 | ||
|
|
d59df4c561 | ||
|
|
140bcb037f | ||
|
|
2a4384e093 | ||
|
|
5aafed85ed | ||
|
|
6ad4b91c60 | ||
|
|
cd62686316 | ||
|
|
dcd606e573 | ||
|
|
f6f326119c | ||
|
|
f31e5e0d22 | ||
|
|
abc12d2a1d | ||
|
|
b7e2f084b1 | ||
|
|
adf1776b1e | ||
|
|
fd1edcdedf | ||
|
|
ebc25c401d | ||
|
|
67574bf759 | ||
|
|
e94923c3c6 | ||
|
|
5718d57b88 | ||
|
|
82cff36194 | ||
|
|
3e4e2d5eb6 | ||
|
|
015f09d27b | ||
|
|
3fedc5b1b3 | ||
|
|
4776ab9bd8 | ||
|
|
3bb01ef9a8 | ||
|
|
0204f5f68f | ||
|
|
217d88beaa | ||
|
|
77080b3934 | ||
|
|
83f6dc2f76 | ||
|
|
29b3ca4e69 | ||
|
|
9394ff49fd | ||
|
|
49949ecda5 | ||
|
|
1dab0f2b19 | ||
|
|
1cf03bf049 | ||
|
|
c00594738f | ||
|
|
d5f601b0eb | ||
|
|
304bff1f19 | ||
|
|
ce9e0cd88c | ||
|
|
40903d9ad5 | ||
|
|
0fc97ad2f1 | ||
|
|
2bb66ea583 | ||
|
|
03aa9780eb | ||
|
|
d3a9005964 | ||
|
|
48bcf4a848 | ||
|
|
72f0426531 | ||
|
|
44ec5b3de3 | ||
|
|
292fdb1288 | ||
|
|
76e65286fd | ||
|
|
9397a0ebae | ||
|
|
c37b5e52ac | ||
|
|
ecfced7195 | ||
|
|
1c7a79f7d7 | ||
|
|
1149906786 | ||
|
|
9db111c08a | ||
|
|
0844447b46 | ||
|
|
c7116ad165 | ||
|
|
a805e0639e | ||
|
|
e8e69a2e86 | ||
|
|
3e4761a60f | ||
|
|
3413157c67 | ||
|
|
b5f2174ed0 | ||
|
|
bdc8285255 | ||
|
|
cd79f0e434 | ||
|
|
171f40551e | ||
|
|
ba4efebbce | ||
|
|
2486287a0e | ||
|
|
2599639aeb | ||
|
|
c1192b37c6 | ||
|
|
1f647163f2 | ||
|
|
cc04efe76b | ||
|
|
18426d0481 | ||
|
|
500b469bce | ||
|
|
49c242e7bc | ||
|
|
2d72d6dbc9 | ||
|
|
1f3e55ebea | ||
|
|
0ecb37419b | ||
|
|
c758bf6530 | ||
|
|
46d985a720 | ||
|
|
9404882fc7 | ||
|
|
ec1c3d6070 | ||
|
|
8eb7816e30 | ||
|
|
c196e44bc6 | ||
|
|
989d88f7d3 | ||
|
|
cb4ebb6306 | ||
|
|
92e7ec9682 | ||
|
|
32b7ff1b36 | ||
|
|
5a68ef558f | ||
|
|
18d48ae963 | ||
|
|
d61c723933 | ||
|
|
bb64ff7278 | ||
|
|
d7760cd34d | ||
|
|
f9ecad1cf0 | ||
|
|
a6de89ab74 | ||
|
|
e663dcf83b | ||
|
|
88e8e5cd54 | ||
|
|
9b43d36793 | ||
|
|
794314a8e1 | ||
|
|
0a1c40cee5 | ||
|
|
958cdd25a5 | ||
|
|
2fb77c1bf8 | ||
|
|
3aa46664f7 | ||
|
|
8389ce5793 | ||
|
|
5199430766 | ||
|
|
0afe5ada2c | ||
|
|
1774eb63b7 | ||
|
|
609cd21603 | ||
|
|
97fc65e66d | ||
|
|
ccac691701 | ||
|
|
a283c8bbad | ||
|
|
9bc5580229 | ||
|
|
eca5d73b94 | ||
|
|
fdacd5f3f8 | ||
|
|
c449a070b4 | ||
|
|
9e2efe3717 | ||
|
|
90ad292b84 | ||
|
|
f2422ed16c | ||
|
|
52ac982481 | ||
|
|
661c3a6d61 | ||
|
|
c14db5fd0d | ||
|
|
6116e49a05 | ||
|
|
8b6cd759ef | ||
|
|
e3f1ad79a8 | ||
|
|
b4c190efb7 | ||
|
|
bd11f2e7b8 | ||
|
|
1f26f001e9 | ||
|
|
ecd2bb4590 | ||
|
|
330eabcfc5 | ||
|
|
bd8ecab31b | ||
|
|
e9af0c7042 | ||
|
|
72a49d0ed8 | ||
|
|
66304c91ec | ||
|
|
c2192dd657 | ||
|
|
1de9e0b79d | ||
|
|
608f401a80 | ||
|
|
ef1acdc3d1 | ||
|
|
82631fb336 | ||
|
|
a348d9131d | ||
|
|
fc575f5bc0 | ||
|
|
e277649878 | ||
|
|
f07cbcbb81 | ||
|
|
9df32816a1 | ||
|
|
f7fd589b13 | ||
|
|
852d031254 | ||
|
|
38c0ca0ce1 | ||
|
|
4eca73303b | ||
|
|
d5292f3fc3 | ||
|
|
6549fbb552 | ||
|
|
a71921cdd1 | ||
|
|
46c219505f | ||
|
|
0a129f9250 | ||
|
|
4ece14e921 | ||
|
|
a4c8fb6e1b | ||
|
|
c8d3f6efed | ||
|
|
fe47de01d3 | ||
|
|
84045b13c6 | ||
|
|
af37bb6e54 | ||
|
|
e1801a5fba | ||
|
|
50bfde6e8e | ||
|
|
f0ac319a73 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.cs text eol=lf
|
||||
26
.gitignore
vendored
26
.gitignore
vendored
@@ -10,8 +10,26 @@
|
||||
/[Ll]ogs/
|
||||
/[Mm]emoryCaptures/
|
||||
|
||||
|
||||
|
||||
/Bundles/
|
||||
/ProjectSettings/
|
||||
/App/
|
||||
/yoo/
|
||||
/Assets/Docs
|
||||
/Assets/Docs.meta
|
||||
/Assets/StreamingAssets
|
||||
/Assets/StreamingAssets.meta
|
||||
/Assets/Samples
|
||||
/Assets/Samples.meta
|
||||
/Assets/csc.rsp
|
||||
/Assets/csc.rsp.meta
|
||||
/UserSettings
|
||||
|
||||
|
||||
|
||||
# Asset meta data should only be ignored when the corresponding asset is also ignored
|
||||
!/[Aa]ssets/**/*.meta
|
||||
|
||||
|
||||
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||
# /[Aa]ssets/AssetStoreTools*
|
||||
@@ -54,11 +72,9 @@ sysinfo.txt
|
||||
# Builds
|
||||
*.apk
|
||||
*.unitypackage
|
||||
*.zip
|
||||
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
*.vsconfig
|
||||
|
||||
Sandbox/
|
||||
Bundles/
|
||||
*.vsconfig
|
||||
@@ -2,447 +2,6 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [1.2.4] - 2022-09-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了加密文件下载验证失败的问题。
|
||||
- 修复了可编程构建管线下模拟构建模式报错的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 可编程构建管线强制使用增量构建模式。
|
||||
- 移除了对Gizmos资源的打包限制。
|
||||
- AssetBundleCollector窗口增加配置表修复功能。
|
||||
|
||||
## [1.2.3] - 2022-09-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了资源收集器无法识别.bank音频文件格式。
|
||||
|
||||
### Changed
|
||||
|
||||
- **HostPlayMode正式支持WebGL平台。**
|
||||
- AssetBundleCollector里的着色器收集选项已经移除,现在必定收集。
|
||||
- AssetBundleCollector修改了默认的打包规则类。
|
||||
- AssetBundleBuilder现在构建结果增加补丁包目录。
|
||||
- 更新了UniTask的Sample。
|
||||
- 优化了缓存系统的代码结构。
|
||||
- 使用了新的断点续传下载器。
|
||||
|
||||
### Added
|
||||
|
||||
- 增加清理缓存资源的异步操作类。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 清空未被使用的缓存文件
|
||||
/// </summary>
|
||||
public static ClearUnusedCacheFilesOperation ClearUnusedCacheFiles();
|
||||
````
|
||||
|
||||
## [1.2.2] - 2022-07-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了加载多个相同的子场景而无法全部卸载的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- ShaderVariantCollecor支持在CI上调用运行。
|
||||
|
||||
- 资源补丁清单增加文件版本校验功能。
|
||||
|
||||
- AssetBundleBuilder现在构建结果可以查询构建失败信息。
|
||||
|
||||
- AssetBundleBuilder现在资源包文件名称样式提供选择功能。
|
||||
|
||||
````c#
|
||||
class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 补丁文件名称的样式
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle;
|
||||
}
|
||||
````
|
||||
|
||||
### Added
|
||||
|
||||
- 增加获取资源信息新方法。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetInfo GetAssetInfo(string location);
|
||||
````
|
||||
|
||||
## [1.2.1] - 2022-07-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#25)修复了资源文件不存在返回的handle无法完成的问题。
|
||||
- (#26)修复多个场景打进一个AB包时,卸载子场景时抛出异常。
|
||||
|
||||
### Changed
|
||||
|
||||
- 构建报告里增加主资源总数的统计。
|
||||
- 资源构建系统里修改了内置构建管线的构建结果验证逻辑,移除了对中文路径的检测。
|
||||
- 资源构建系统里移除了对增量更新初次无法构建的限制。
|
||||
- 优化了缓存验证逻辑,不期望删除断点续传的资源文件。
|
||||
- 资源构建系统里SBP构建参数增加了缓存服务器的地址和端口。
|
||||
|
||||
## [1.2.0] - 2022-07-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了ShaderVariantCollection刷新不及时问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 资源收集忽略了Gizmos资源文件。
|
||||
- 解密服务接口增加解密文件信息参数。
|
||||
- 资源收集窗体增加配置保存按钮。
|
||||
- 资源构建窗体增加配置保存按钮。
|
||||
|
||||
### Added
|
||||
|
||||
- 资源构建模块增加了可编程构建管线(SBP)的支持,开发者可以在内置构建管线和可编程构建管线之间自由选择,零修改成本。
|
||||
|
||||
## [1.1.1] - 2022-07-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了AssetBundleDebugger窗口,View下拉页签切换无效的问题。
|
||||
- 修复了在Unity2020.3版本下UniTask在真机上的一个IL2CPP相关的错误。
|
||||
|
||||
### Changed
|
||||
|
||||
- 优化了AssetBundleDebugger窗口,增加了帧数显示以及回放功能。
|
||||
- 优化了AssetBundleBuilder的代码结构。
|
||||
- 增强了YooAssets.GetRawFileAsync()方法的容错。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了OperationHandleBase.GetAssetInfo()方法。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
public AssetInfo GetAssetInfo();
|
||||
````
|
||||
|
||||
- 新增了AssetOperationHandle.GetAssetObjet<TAsset>()方法。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 获取资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TAsset">资源类型</typeparam>
|
||||
public TAsset GetAssetObjet<TAsset>();
|
||||
````
|
||||
|
||||
- 新增了弱联网情况下加载补丁清单方法。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 弱联网情况下加载补丁清单
|
||||
/// 注意:当指定版本内容验证失败后会返回失败。
|
||||
/// </summary>
|
||||
/// <param name="resourceVersion">指定的资源版本</param>
|
||||
public static UpdateManifestOperation WeaklyUpdateManifestAsync(int resourceVersion);
|
||||
````
|
||||
|
||||
### Removed
|
||||
|
||||
- 离线运行模式(OfflinePlayMode)下移除了资内置资源解压相关逻辑。
|
||||
- 移除了初始化参数:AutoReleaseGameObjectHandle及相关代码逻辑。
|
||||
|
||||
## [1.1.0] - 2022-06-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了AssetBundleCollector窗口,在切换EnableAddressable时未及时刷新界面的问题。
|
||||
- 修复了AssetBundleCollector窗口,资源过滤器CollectSprite无效的问题。
|
||||
- 修复了AssetBundleCollector窗口,无法正常预览StaticAssetCollector的资源列表的问题。
|
||||
- 修复了在离线模式下原生文件每次都从包内加载的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 变更了共享资源打包机制。
|
||||
- AssetBundleCollector窗口增加了分组禁用功能。
|
||||
- AssetBundleDebugger窗口增加了真机远程调试功能。
|
||||
- AssetBundleBuilder窗口在构建成功后自动显示构建文件夹。
|
||||
- DownloaderOperation.OnDownloadFileFailedCallback委托变更为OnDownloadErrorCallback委托。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增UpdateManifestOperation.FoundNewManifest字段。
|
||||
- 新增DownloaderOperation.OnStartDownloadFileCallback委托。
|
||||
- 新增AssetInfo.Address字段。
|
||||
- 新增YooAssets.IsInitialized字段。
|
||||
- 新增YooAssets初始化参数。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 下载文件校验等级
|
||||
/// </summary>
|
||||
public EVerifyLevel VerifyLevel = EVerifyLevel.High;
|
||||
````
|
||||
|
||||
- 新增YooAssets获取资源完成路径的方法。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 获取资源路径
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
||||
public static string GetAssetPath(string location);
|
||||
````
|
||||
|
||||
- 新增YooAssets初始化参数。
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 自动释放游戏对象所属资源句柄
|
||||
/// 说明:通过资源句柄实例化的游戏对象在销毁之后,会自动释放所属资源句柄。
|
||||
/// </summary>
|
||||
public bool AutoReleaseGameObjectHandle = false;
|
||||
```
|
||||
|
||||
## [1.0.10] - 2022-05-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了资源收集配置存在多个的时候,导致后续无法打开窗口的问题。
|
||||
- 修复了在编辑器模拟模式下加载精灵图片失败的问题。
|
||||
- 修复了在Unity2019版本无法识别配置文件的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 资源构建增加内置资源文件(首包资源文件)拷贝的选项。
|
||||
- 补丁下载器增加暂停方法和恢复方法。
|
||||
- 在资源收集界面,对Collector的增加和删除支持撤销和恢复操作。
|
||||
|
||||
## [1.0.9] - 2022-05-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了YooAssets.GetAssetInfos(string Tag)方法返回了无关的资源信息的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 编辑器下的模拟运行模式,不再依赖配置里的构建版本。
|
||||
- 更新资源清单结构,资源对象类增加分类标签。
|
||||
- 优化了资源工具相关配置文件的加载方式和途径,这些配置文件可以放置在任何目录下。
|
||||
- 优化了Location无效后的错误报告方式。
|
||||
- 优化了资源包的构建参数,现在始终开启DisableLoadAssetByFileName,帮助减小运行时的内存。
|
||||
- YooAssets.ProcessOperation()重命名为YooAssets.StartOperation()
|
||||
|
||||
### Added
|
||||
|
||||
- 新增YooAssets.IsNeedDownloadFromRemote()方法。
|
||||
|
||||
````c#
|
||||
public static bool IsNeedDownloadFromRemote(string location);
|
||||
````
|
||||
|
||||
- 新增获取所有子资源对象的方法。
|
||||
|
||||
````c#
|
||||
class SubAssetsOperationHandle
|
||||
{
|
||||
public TObject[] GetSubAssetObjects<TObject>();
|
||||
}
|
||||
````
|
||||
|
||||
### Removed
|
||||
|
||||
- YooAssets.GetBundleInfo()方法已经移除。
|
||||
|
||||
## [1.0.8] - 2022-05-08
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了资源收集器导出配置文件时没有导出公共设置。
|
||||
- 修复了不兼容Unity2018版本的错误。
|
||||
|
||||
### Changed
|
||||
|
||||
- AssetBundleGrouper窗口变更为AssetBundleCollector窗口。
|
||||
- **优化了编辑器下模拟运行的初始化速度**。
|
||||
- **优化了资源收集窗口打开时卡顿的问题**。
|
||||
- 资源收集XML配表支持版本兼容。
|
||||
- 资源报告查看窗口支持预览AssetBundle文件内容的功能。
|
||||
- 完善了对UniTask的支持。
|
||||
- YooAssets所有接口支持初始化容错检测。
|
||||
|
||||
### Added
|
||||
|
||||
- 异步操作类增加进度查询字段。
|
||||
|
||||
```c#
|
||||
class AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理进度
|
||||
/// </summary>
|
||||
public float Progress { get; protected set; }
|
||||
}
|
||||
```
|
||||
|
||||
- 增加开启异步操作的方法。
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 开启一个异步操作
|
||||
/// </summary>
|
||||
/// <param name="operation">异步操作对象</param>
|
||||
public static void ProcessOperaiton(GameAsyncOperation operation)
|
||||
```
|
||||
|
||||
- 新增编辑器下模拟模式的初始化参数。
|
||||
|
||||
````c#
|
||||
/// <summary>
|
||||
/// 用于模拟运行的资源清单路径
|
||||
/// 注意:如果路径为空,会自动重新构建补丁清单。
|
||||
/// </summary>
|
||||
public string SimulatePatchManifestPath;
|
||||
````
|
||||
|
||||
- 新增通用的初始化参数。
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower = false;
|
||||
```
|
||||
|
||||
## [1.0.7] - 2022-05-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了异步操作系统的Task再次等待无效的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- YooAssets.LoadRawFileAsync()方法重新命名为YooAssets.GetRawFileAsync()
|
||||
- YooAssetSetting文件夹支持了全路径搜索定位。
|
||||
- 优化了打包的核心逻辑,对依赖资源进行自动划分,以及支持设置依赖资源收集器。
|
||||
- 初始化的时候,删除验证失败的资源文件。
|
||||
- 构建报告浏览窗口支持排序功能。
|
||||
- 着色器变种收集工具支持了配置缓存。
|
||||
|
||||
### Added
|
||||
|
||||
- 支持可寻址资源定位系统,包括编辑器和运行时环境。
|
||||
- 增加快速构建模式,用于EditorPlayMode完美模拟线上环境。
|
||||
- 增加了Window Dock功能,已打开的界面会自动停靠在一个窗体下。
|
||||
- 增加一个新的打包规则:PackTopDirectory。
|
||||
- 增加获取资源信息的方法。
|
||||
```c#
|
||||
public static AssetInfo[] GetAssetInfos(string tag)
|
||||
```
|
||||
- 增加补丁下载器下载全部资源的方法。
|
||||
```c#
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
```
|
||||
- 增加指定资源版本的资源更新下载方法。
|
||||
```c#
|
||||
public static UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout = 60)
|
||||
```
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了自动释放资源的初始化参数。
|
||||
|
||||
## [1.0.6] - 2022-04-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复工具界面显示异常在Unity2021版本下。
|
||||
|
||||
### Changed
|
||||
|
||||
- 操作句柄支持错误信息查询。
|
||||
- 支持UniTask异步操作库。
|
||||
- 优化类型搜索方式,改为全域搜索类型。
|
||||
- AssetBundleGrouper窗口添加和移除Grouper支持操作回退。
|
||||
|
||||
## [1.0.5] - 2022-04-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了非主动收集的着色器没有打进统一的着色器资源包的问题。
|
||||
- 修复了单个收集的资源对象没有设置依赖资源列表的问题。
|
||||
- 修复Task异步加载一直等待的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 资源打包的过滤文件列表增加cginc格式。
|
||||
- 增加编辑器扩展的支持,第三方实现YooAsset插件。
|
||||
- 优化原生文件加载逻辑,支持离线运行模式和编辑器运行模式。
|
||||
- 优化场景卸载逻辑,在加载新的主场景的时候自动卸载已经加载的所有场景。
|
||||
- 支持演练构建模式,在不生成资源包的情况下快速构建查看结果。
|
||||
- 新增调试信息,出生场景和出生时间。
|
||||
|
||||
## [1.0.4] - 2022-04-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复资源清单附加版本之后引发的一个流程错误。
|
||||
- 修复原生文件拷贝目录不存导致的加载失败。
|
||||
|
||||
### Changed
|
||||
|
||||
- 在编辑器下检测资源路径是否合法并警告。
|
||||
- 完善原生文件异步加载接口。
|
||||
|
||||
## [1.0.3] - 2022-04-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了AssetBundleDebugger窗口的BundleView视口下,Using列表显示不完整的问题。
|
||||
- 修复了AssetBundleDebugger窗口的BundleView视口下,Bundle列表内元素重复的问题。
|
||||
- 修复了特殊情况下依赖的资源包列表里包含主资源包的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- 实例化GameObject的时候,如果没有传递坐标和角度则使用默认值。
|
||||
- 优化了资源分组配置保存策略,修改为窗口关闭时保存。
|
||||
- 简化了资源版本概念,降低学习成本,统一了CDN上的目录结构。
|
||||
- 资源定位接口扩展,方便开发可寻址资产定位功能。
|
||||
|
||||
### Added
|
||||
|
||||
- 离线运行模式支持WEBGL平台。
|
||||
- 保留构建窗口界面的配置数据。
|
||||
|
||||
## [1.0.2] - 2022-04-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复在资源加载完成回调内释放自身资源句柄时的异常报错。
|
||||
- 修复了资源分组在特殊情况下打包报错的问题。
|
||||
|
||||
### Changed
|
||||
|
||||
- StreamingAssets目录下增加了用于存放打包资源的总文件夹。
|
||||
|
||||
## [1.0.1] - 2022-04-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复Assets目录下存在多个YooAsset同名文件夹时,工具窗口无法显示的问题。
|
||||
- 修复通过Packages导入YooAsset,工具窗口无法显示的问题。
|
||||
|
||||
## [1.0.0] - 2022-04-05
|
||||
*Compatible with Unity 2019.4*
|
||||
## [3.0.0-beta] - 2026-05-09
|
||||
|
||||
beta released.
|
||||
|
||||
8
Assets/YooAsset/Editor/Assembly.meta
Normal file
8
Assets/YooAsset/Editor/Assembly.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fab3cd742c11be2479b07f5d447a78c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
5
Assets/YooAsset/Editor/Assembly/AssemblyInfo.cs
Normal file
5
Assets/YooAsset/Editor/Assembly/AssemblyInfo.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// 外部友元
|
||||
[assembly: InternalsVisibleTo("YooAsset.Extension.Editor")]
|
||||
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
|
||||
11
Assets/YooAsset/Editor/Assembly/AssemblyInfo.cs.meta
Normal file
11
Assets/YooAsset/Editor/Assembly/AssemblyInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef774f01e50ab0a4d88122041938a6b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilder
|
||||
{
|
||||
private readonly BuildContext _buildContext = new BuildContext();
|
||||
|
||||
/// <summary>
|
||||
/// 开始构建
|
||||
/// </summary>
|
||||
public BuildResult Run(BuildParameters buildParameters)
|
||||
{
|
||||
// 清空旧数据
|
||||
_buildContext.ClearAllContext();
|
||||
|
||||
// 检测构建参数是否为空
|
||||
if (buildParameters == null)
|
||||
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||
|
||||
// 检测可编程构建管线参数
|
||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
if (buildParameters.SBPParameters == null)
|
||||
throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !");
|
||||
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||
}
|
||||
|
||||
// 构建参数
|
||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||
_buildContext.SetContextObject(buildParametersContext);
|
||||
|
||||
// 是否显示LOG
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
BuildRunner.EnableLog = false;
|
||||
else
|
||||
BuildRunner.EnableLog = true;
|
||||
|
||||
// 创建构建节点
|
||||
List<IBuildTask> pipeline;
|
||||
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare(), //前期准备工作
|
||||
new TaskGetBuildMap(), //获取构建列表
|
||||
new TaskBuilding(), //开始执行构建
|
||||
new TaskVerifyBuildResult(), //验证构建结果
|
||||
new TaskEncryption(), //加密资源文件
|
||||
new TaskCreatePatchManifest(), //创建清单文件
|
||||
new TaskCreateReport(), //创建报告文件
|
||||
new TaskCreatePatchPackage(), //制作补丁包
|
||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||
};
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare(), //前期准备工作
|
||||
new TaskGetBuildMap(), //获取构建列表
|
||||
new TaskBuilding_SBP(), //开始执行构建
|
||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||
new TaskEncryption(), //加密资源文件
|
||||
new TaskCreatePatchManifest(), //创建清单文件
|
||||
new TaskCreateReport(), //创建报告文件
|
||||
new TaskCreatePatchPackage(), //制作补丁包
|
||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// 执行构建流程
|
||||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageDirectory();
|
||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||
Debug.LogError($"Build task failed : {buildResult.FailedTask}");
|
||||
Debug.LogError($"Build task error : {buildResult.FailedInfo}");
|
||||
}
|
||||
return buildResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取默认的输出根路录
|
||||
/// </summary>
|
||||
public static string GetDefaultOutputRoot()
|
||||
{
|
||||
string projectPath = EditorTools.GetProjectPath();
|
||||
return $"{projectPath}/Bundles";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取流文件夹路径
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsFolderPath()
|
||||
{
|
||||
return $"{Application.dataPath}/StreamingAssets/YooAssets/";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
public static string MakePipelineOutputDirectory(string outputRoot, BuildTarget buildTarget)
|
||||
{
|
||||
return $"{outputRoot}/{buildTarget}/{YooAssetSettings.OutputFolderName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空流文件夹
|
||||
/// </summary>
|
||||
public static void ClearStreamingAssetsFolder()
|
||||
{
|
||||
string streamingFolderPath = GetStreamingAssetsFolderPath();
|
||||
EditorTools.ClearFolder(streamingFolderPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除流文件夹内无关的文件
|
||||
/// 删除.manifest文件和.meta文件
|
||||
/// </summary>
|
||||
public static void DeleteStreamingAssetsIgnoreFiles()
|
||||
{
|
||||
string streamingFolderPath = GetStreamingAssetsFolderPath();
|
||||
if (Directory.Exists(streamingFolderPath))
|
||||
{
|
||||
string[] files = Directory.GetFiles(streamingFolderPath, "*.manifest", SearchOption.AllDirectories);
|
||||
foreach (var file in files)
|
||||
{
|
||||
FileInfo info = new FileInfo(file);
|
||||
info.Delete();
|
||||
}
|
||||
|
||||
files = Directory.GetFiles(streamingFolderPath, "*.meta", SearchOption.AllDirectories);
|
||||
foreach (var item in files)
|
||||
{
|
||||
FileInfo info = new FileInfo(item);
|
||||
info.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有补丁包版本列表
|
||||
/// 注意:列表会按照版本号从小到大排序
|
||||
/// </summary>
|
||||
private static List<int> GetPackageVersionList(BuildTarget buildTarget, string outputRoot)
|
||||
{
|
||||
List<int> versionList = new List<int>();
|
||||
|
||||
string parentPath = $"{outputRoot}/{buildTarget}";
|
||||
if (Directory.Exists(parentPath) == false)
|
||||
return versionList;
|
||||
|
||||
// 获取所有补丁包文件夹
|
||||
string[] allFolders = Directory.GetDirectories(parentPath);
|
||||
for (int i = 0; i < allFolders.Length; i++)
|
||||
{
|
||||
string folderName = Path.GetFileNameWithoutExtension(allFolders[i]);
|
||||
if (int.TryParse(folderName, out int version))
|
||||
versionList.Add(version);
|
||||
}
|
||||
|
||||
// 从小到大排序
|
||||
versionList.Sort();
|
||||
return versionList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前最大的补丁包版本号
|
||||
/// </summary>
|
||||
/// <returns>如果没有任何补丁版本,那么返回-1</returns>
|
||||
public static int GetMaxPackageVersion(BuildTarget buildTarget, string outputRoot)
|
||||
{
|
||||
List<int> versionList = GetPackageVersionList(buildTarget, outputRoot);
|
||||
if (versionList.Count == 0)
|
||||
return -1;
|
||||
return versionList[versionList.Count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在任何补丁包版本
|
||||
/// </summary>
|
||||
public static bool HasAnyPackageVersion(BuildTarget buildTarget, string outputRoot)
|
||||
{
|
||||
List<int> versionList = GetPackageVersionList(buildTarget, outputRoot);
|
||||
return versionList.Count > 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载补丁清单文件
|
||||
/// </summary>
|
||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, int resourceVersion)
|
||||
{
|
||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
throw new System.Exception($"Not found patch manifest file : {filePath}");
|
||||
}
|
||||
|
||||
string jsonData = FileUtility.ReadFile(filePath);
|
||||
return PatchManifest.Deserialize(jsonData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取旧的补丁清单
|
||||
/// </summary>
|
||||
internal static PatchManifest GetOldPatchManifest(string pipelineOutputDirectory)
|
||||
{
|
||||
string staticVersionFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string staticVersionContent = FileUtility.ReadFile(staticVersionFilePath);
|
||||
int staticVersion = int.Parse(staticVersionContent);
|
||||
return LoadPatchManifestFile(pipelineOutputDirectory, staticVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilderSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建版本号
|
||||
/// </summary>
|
||||
public int BuildVersion = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public EBuildPipeline BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode = EBuildMode.ForceRebuild;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源标签(首包资源标签)
|
||||
/// </summary>
|
||||
public string BuildTags = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 压缩方式
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.LZ4;
|
||||
|
||||
/// <summary>
|
||||
/// 输出文件名称样式
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 加密类名称
|
||||
/// </summary>
|
||||
public string EncyptionClassName = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilderSettingData
|
||||
{
|
||||
private static AssetBundleBuilderSetting _setting = null;
|
||||
public static AssetBundleBuilderSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置文件
|
||||
/// </summary>
|
||||
private static void LoadSettingData()
|
||||
{
|
||||
_setting = EditorHelper.LoadSettingData<AssetBundleBuilderSetting>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24698266f028e4a47bb88f091fd64547
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,215 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测所有损坏的预制体文件
|
||||
/// </summary>
|
||||
public static void CheckCorruptionPrefab(List<string> searchDirectorys)
|
||||
{
|
||||
if (searchDirectorys.Count == 0)
|
||||
throw new Exception("路径列表不能为空!");
|
||||
|
||||
// 获取所有资源列表
|
||||
int checkCount = 0;
|
||||
int invalidCount = 0;
|
||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.Prefab, searchDirectorys.ToArray());
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object));
|
||||
if (prefab == null)
|
||||
{
|
||||
invalidCount++;
|
||||
Debug.LogError($"发现损坏预制件:{assetPath}");
|
||||
}
|
||||
EditorTools.DisplayProgressBar("检测预制件文件是否损坏", ++checkCount, findAssets.Length);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
if (invalidCount == 0)
|
||||
Debug.Log($"没有发现损坏预制件");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测所有动画控制器的冗余状态
|
||||
/// </summary>
|
||||
public static void FindRedundantAnimationState(List<string> searchDirectorys)
|
||||
{
|
||||
if (searchDirectorys.Count == 0)
|
||||
throw new Exception("路径列表不能为空!");
|
||||
|
||||
// 获取所有资源列表
|
||||
int checkCount = 0;
|
||||
int findCount = 0;
|
||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.RuntimeAnimatorController, searchDirectorys.ToArray());
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
AnimatorController animator= AssetDatabase.LoadAssetAtPath<AnimatorController>(assetPath);
|
||||
if (FindRedundantAnimationState(animator))
|
||||
{
|
||||
findCount++;
|
||||
Debug.LogWarning($"发现冗余的动画控制器:{assetPath}");
|
||||
}
|
||||
EditorTools.DisplayProgressBar("检测冗余的动画控制器", ++checkCount, findAssets.Length);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
if (findCount == 0)
|
||||
Debug.Log($"没有发现冗余的动画控制器");
|
||||
else
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有材质球的冗余属性
|
||||
/// </summary>
|
||||
public static void ClearMaterialUnusedProperty(List<string> searchDirectorys)
|
||||
{
|
||||
if (searchDirectorys.Count == 0)
|
||||
throw new Exception("路径列表不能为空!");
|
||||
|
||||
// 获取所有资源列表
|
||||
int checkCount = 0;
|
||||
int removedCount = 0;
|
||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.Material, searchDirectorys.ToArray());
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
Material mat = AssetDatabase.LoadAssetAtPath<Material>(assetPath);
|
||||
if (ClearMaterialUnusedProperty(mat))
|
||||
{
|
||||
removedCount++;
|
||||
Debug.LogWarning($"材质球已被处理:{assetPath}");
|
||||
}
|
||||
EditorTools.DisplayProgressBar("清理冗余的材质球", ++checkCount, findAssets.Length);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
if (removedCount == 0)
|
||||
Debug.Log($"没有发现冗余的材质球");
|
||||
else
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清理无用的材质球属性
|
||||
/// </summary>
|
||||
private static bool ClearMaterialUnusedProperty(Material mat)
|
||||
{
|
||||
bool removeUnused = false;
|
||||
SerializedObject so = new SerializedObject(mat);
|
||||
SerializedProperty sp = so.FindProperty("m_SavedProperties");
|
||||
|
||||
sp.Next(true);
|
||||
do
|
||||
{
|
||||
if (sp.isArray == false)
|
||||
continue;
|
||||
|
||||
for (int i = sp.arraySize - 1; i >= 0; --i)
|
||||
{
|
||||
var p1 = sp.GetArrayElementAtIndex(i);
|
||||
if (p1.isArray)
|
||||
{
|
||||
for (int ii = p1.arraySize - 1; ii >= 0; --ii)
|
||||
{
|
||||
var p2 = p1.GetArrayElementAtIndex(ii);
|
||||
var val = p2.FindPropertyRelative("first");
|
||||
if (mat.HasProperty(val.stringValue) == false)
|
||||
{
|
||||
Debug.Log($"Material {mat.name} remove unused property : {val.stringValue}");
|
||||
p1.DeleteArrayElementAtIndex(ii);
|
||||
removeUnused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var val = p1.FindPropertyRelative("first");
|
||||
if (mat.HasProperty(val.stringValue) == false)
|
||||
{
|
||||
Debug.Log($"Material {mat.name} remove unused property : {val.stringValue}");
|
||||
sp.DeleteArrayElementAtIndex(i);
|
||||
removeUnused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (sp.Next(false));
|
||||
so.ApplyModifiedProperties();
|
||||
return removeUnused;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找动画控制器里冗余的动画状态机
|
||||
/// </summary>
|
||||
private static bool FindRedundantAnimationState(AnimatorController animatorController)
|
||||
{
|
||||
if (animatorController == null)
|
||||
return false;
|
||||
|
||||
string assetPath = AssetDatabase.GetAssetPath(animatorController);
|
||||
|
||||
// 查找使用的状态机名称
|
||||
List<string> usedStateNames = new List<string>();
|
||||
foreach (var layer in animatorController.layers)
|
||||
{
|
||||
foreach (var state in layer.stateMachine.states)
|
||||
{
|
||||
usedStateNames.Add(state.state.name);
|
||||
}
|
||||
}
|
||||
|
||||
List<string> allLines = new List<string>();
|
||||
List<int> stateIndexList = new List<int>();
|
||||
using (StreamReader reader = File.OpenText(assetPath))
|
||||
{
|
||||
string content;
|
||||
while (null != (content = reader.ReadLine()))
|
||||
{
|
||||
allLines.Add(content);
|
||||
if (content.StartsWith("AnimatorState:"))
|
||||
{
|
||||
stateIndexList.Add(allLines.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<string> allStateNames = new List<string>();
|
||||
foreach (var index in stateIndexList)
|
||||
{
|
||||
for (int i = index; i < allLines.Count; i++)
|
||||
{
|
||||
string content = allLines[i];
|
||||
content = content.Trim();
|
||||
if (content.StartsWith("m_Name"))
|
||||
{
|
||||
string[] splits = content.Split(':');
|
||||
string name = splits[1].TrimStart(' '); //移除前面的空格
|
||||
allStateNames.Add(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool foundRedundantState = false;
|
||||
foreach (var stateName in allStateNames)
|
||||
{
|
||||
if (usedStateNames.Contains(stateName) == false)
|
||||
{
|
||||
Debug.LogWarning($"发现冗余的动画文件:{assetPath}={stateName}");
|
||||
foundRedundantState = true;
|
||||
}
|
||||
}
|
||||
return foundRedundantState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe50795c51a46884088139b840c1557f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,272 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilderWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, EditorDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private BuildTarget _buildTarget;
|
||||
private List<Type> _encryptionServicesClassTypes;
|
||||
private List<string> _encryptionServicesClassNames;
|
||||
|
||||
private Button _saveButton;
|
||||
private TextField _buildOutputField;
|
||||
private IntegerField _buildVersionField;
|
||||
private EnumField _buildPipelineField;
|
||||
private EnumField _buildModeField;
|
||||
private TextField _buildinTagsField;
|
||||
private PopupField<string> _encryptionField;
|
||||
private EnumField _compressionField;
|
||||
private EnumField _outputNameStyleField;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 配置保存按钮
|
||||
_saveButton = root.Q<Button>("SaveButton");
|
||||
_saveButton.clicked += SaveBtn_clicked;
|
||||
|
||||
// 构建平台
|
||||
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
||||
// 加密服务类
|
||||
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
||||
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
|
||||
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(defaultOutputRoot, _buildTarget);
|
||||
_buildOutputField = root.Q<TextField>("BuildOutput");
|
||||
_buildOutputField.SetValueWithoutNotify(pipelineOutputDirectory);
|
||||
_buildOutputField.SetEnabled(false);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = root.Q<IntegerField>("BuildVersion");
|
||||
_buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion);
|
||||
_buildVersionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
|
||||
});
|
||||
|
||||
// 构建管线
|
||||
_buildPipelineField = root.Q<EnumField>("BuildPipeline");
|
||||
_buildPipelineField.Init(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||
_buildPipelineField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||
_buildPipelineField.style.width = 350;
|
||||
_buildPipelineField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.BuildPipeline = (EBuildPipeline)_buildPipelineField.value;
|
||||
RefreshWindow();
|
||||
});
|
||||
|
||||
// 构建模式
|
||||
_buildModeField = root.Q<EnumField>("BuildMode");
|
||||
_buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||
_buildModeField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||
_buildModeField.style.width = 350;
|
||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.BuildMode = (EBuildMode)_buildModeField.value;
|
||||
RefreshWindow();
|
||||
});
|
||||
|
||||
// 内置资源标签
|
||||
_buildinTagsField = root.Q<TextField>("BuildinTags");
|
||||
_buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
|
||||
_buildinTagsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
|
||||
});
|
||||
|
||||
// 加密方法
|
||||
var encryptionContainer = root.Q("EncryptionContainer");
|
||||
if (_encryptionServicesClassNames.Count > 0)
|
||||
{
|
||||
int defaultIndex = GetEncryptionDefaultIndex(AssetBundleBuilderSettingData.Setting.EncyptionClassName);
|
||||
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = 350;
|
||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
|
||||
});
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
else
|
||||
{
|
||||
_encryptionField = new PopupField<string>();
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = 350;
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
|
||||
// 压缩方式
|
||||
_compressionField = root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||
_compressionField.style.width = 350;
|
||||
_compressionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
||||
});
|
||||
|
||||
// 输出文件名称样式
|
||||
_outputNameStyleField = root.Q<EnumField>("OutputNameStyle");
|
||||
_outputNameStyleField.Init(AssetBundleBuilderSettingData.Setting.OutputNameStyle);
|
||||
_outputNameStyleField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.OutputNameStyle);
|
||||
_outputNameStyleField.style.width = 350;
|
||||
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.OutputNameStyle = (EOutputNameStyle)_outputNameStyleField.value;
|
||||
});
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked; ;
|
||||
|
||||
RefreshWindow();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
if(AssetBundleBuilderSettingData.IsDirty)
|
||||
AssetBundleBuilderSettingData.SaveFile();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if(_saveButton != null)
|
||||
{
|
||||
if(AssetBundleBuilderSettingData.IsDirty)
|
||||
{
|
||||
if (_saveButton.enabledSelf == false)
|
||||
_saveButton.SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_saveButton.enabledSelf)
|
||||
_saveButton.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
bool enableElement = buildMode == EBuildMode.ForceRebuild;
|
||||
_buildinTagsField.SetEnabled(enableElement);
|
||||
_encryptionField.SetEnabled(enableElement);
|
||||
_compressionField.SetEnabled(enableElement);
|
||||
_outputNameStyleField.SetEnabled(enableElement);
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
AssetBundleBuilderSettingData.SaveFile();
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] 打包已经取消");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
private void ExecuteBuild()
|
||||
{
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
BuildParameters buildParameters = new BuildParameters();
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = _buildTarget;
|
||||
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
buildParameters.CopyBuildinTagFiles = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||
|
||||
if (AssetBundleBuilderSettingData.Setting.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
buildParameters.SBPParameters = new BuildParameters.SBPBuildParameters();
|
||||
buildParameters.SBPParameters.WriteLinkXML = true;
|
||||
}
|
||||
|
||||
var builder = new AssetBundleBuilder();
|
||||
var buildResult = builder.Run(buildParameters);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
EditorUtility.RevealInFinder($"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.BuildVersion}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加密类相关
|
||||
private int GetEncryptionDefaultIndex(string className)
|
||||
{
|
||||
for (int index = 0; index < _encryptionServicesClassNames.Count; index++)
|
||||
{
|
||||
if (_encryptionServicesClassNames[index] == className)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private List<Type> GetEncryptionServicesClassTypes()
|
||||
{
|
||||
return EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
}
|
||||
private IEncryptionServices CreateEncryptionServicesInstance()
|
||||
{
|
||||
if (_encryptionField.index < 0)
|
||||
return null;
|
||||
var classType = _encryptionServicesClassTypes[_encryptionField.index];
|
||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="BuildContainer">
|
||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
||||
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
||||
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="Output Name Style" value="Center" name="OutputNameStyle" />
|
||||
<ui:TextField picking-mode="Ignore" label="Buildin Tags" name="BuildinTags" />
|
||||
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,43 +0,0 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleSimulateBuilder
|
||||
{
|
||||
private static string _manifestFilePath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static void SimulateBuild()
|
||||
{
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
BuildParameters buildParameters = new BuildParameters();
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.BuildVersion = 999;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
var buildResult = builder.Run(buildParameters);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
|
||||
_manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.SimulateBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_manifestFilePath = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的补丁清单路径
|
||||
/// </summary>
|
||||
public static string GetPatchManifestPath()
|
||||
{
|
||||
return _manifestFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildAssetInfo
|
||||
{
|
||||
private string _mainBundleName;
|
||||
private string _shareBundleName;
|
||||
private bool _isAddAssetTags = false;
|
||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为原生资源
|
||||
/// </summary>
|
||||
public bool IsRawAsset { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为着色器资源
|
||||
/// </summary>
|
||||
public bool IsShaderAsset { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> AssetTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> BundleTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的所有资源
|
||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||
/// </summary>
|
||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||
|
||||
|
||||
public BuildAssetInfo(ECollectorType collectorType, string mainBundleName, string address, string assetPath, bool isRawAsset)
|
||||
{
|
||||
_mainBundleName = mainBundleName;
|
||||
CollectorType = collectorType;
|
||||
Address = address;
|
||||
AssetPath = assetPath;
|
||||
IsRawAsset = isRawAsset;
|
||||
|
||||
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
IsShaderAsset = true;
|
||||
else
|
||||
IsShaderAsset = false;
|
||||
}
|
||||
public BuildAssetInfo(string assetPath)
|
||||
{
|
||||
CollectorType = ECollectorType.None;
|
||||
Address = string.Empty;
|
||||
AssetPath = assetPath;
|
||||
IsRawAsset = false;
|
||||
|
||||
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
IsShaderAsset = true;
|
||||
else
|
||||
IsShaderAsset = false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置所有依赖的资源
|
||||
/// </summary>
|
||||
public void SetAllDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
||||
{
|
||||
if (AllDependAssetInfos != null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
AllDependAssetInfos = dependAssetInfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源的分类标签
|
||||
/// 说明:原始定义的资源分类标签
|
||||
/// </summary>
|
||||
public void AddAssetTags(List<string> tags)
|
||||
{
|
||||
if (_isAddAssetTags)
|
||||
throw new Exception("Should never get here !");
|
||||
_isAddAssetTags = true;
|
||||
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (AssetTags.Contains(tag) == false)
|
||||
{
|
||||
AssetTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源包的分类标签
|
||||
/// 说明:传染算法统计到的分类标签
|
||||
/// </summary>
|
||||
public void AddBundleTags(List<string> tags)
|
||||
{
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (BundleTags.Contains(tag) == false)
|
||||
{
|
||||
BundleTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名是否存在
|
||||
/// </summary>
|
||||
public bool HasBundleName()
|
||||
{
|
||||
string bundleName = GetBundleName();
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包名称
|
||||
/// </summary>
|
||||
public string GetBundleName()
|
||||
{
|
||||
if (CollectorType == ECollectorType.None)
|
||||
return _shareBundleName;
|
||||
else
|
||||
return _mainBundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加关联的资源包名称
|
||||
/// </summary>
|
||||
public void AddReferenceBundleName(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||
_referenceBundleNames.Add(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算主资源或共享资源的完整包名
|
||||
/// </summary>
|
||||
public void CalculateFullBundleName()
|
||||
{
|
||||
if (CollectorType == ECollectorType.None)
|
||||
{
|
||||
if (IsRawAsset)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (IsShaderAsset)
|
||||
{
|
||||
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_referenceBundleNames.Count > 1)
|
||||
{
|
||||
IPackRule packRule = PackDirectory.StaticPackRule;
|
||||
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
||||
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsRawAsset)
|
||||
{
|
||||
string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.RawFileVariant}";
|
||||
_mainBundleName = EditorTools.GetRegularPath(mainBundleName).ToLower();
|
||||
}
|
||||
else
|
||||
{
|
||||
string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
_mainBundleName = EditorTools.GetRegularPath(mainBundleName).ToLower(); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> BuildinAssets = new List<BuildAssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 是否为原生文件
|
||||
/// </summary>
|
||||
public bool IsRawFile
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var asset in BuildinAssets)
|
||||
{
|
||||
if (asset.IsRawAsset)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建内容哈希值
|
||||
/// </summary>
|
||||
public string ContentHash { set; get; } = "00000000000000000000000000000000"; //32位
|
||||
|
||||
|
||||
public BuildBundleInfo(string bundleName)
|
||||
{
|
||||
BundleName = bundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
if (IsContainsAsset(assetInfo.AssetPath))
|
||||
throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}");
|
||||
|
||||
BuildinAssets.Add(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
{
|
||||
foreach (var assetInfo in BuildinAssets)
|
||||
{
|
||||
if (assetInfo.AssetPath == assetPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的分类标签列表
|
||||
/// </summary>
|
||||
public string[] GetBundleTags()
|
||||
{
|
||||
List<string> result = new List<string>(BuildinAssets.Count);
|
||||
foreach (var assetInfo in BuildinAssets)
|
||||
{
|
||||
foreach (var assetTag in assetInfo.BundleTags)
|
||||
{
|
||||
if (result.Contains(assetTag) == false)
|
||||
result.Add(assetTag);
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件的扩展名
|
||||
/// </summary>
|
||||
public string GetAppendExtension()
|
||||
{
|
||||
return System.IO.Path.GetExtension(BundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetBuildinAssetPaths()
|
||||
{
|
||||
return BuildinAssets.Select(t => t.AssetPath).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有写入补丁清单的资源
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllPatchAssetInfos()
|
||||
{
|
||||
return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建AssetBundleBuild类
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||
{
|
||||
// 注意:我们不在支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetBuildinAssetPaths();
|
||||
return build;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildMapContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
/// </summary>
|
||||
public int AssetFileCount;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(1000);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
string bundleName = assetInfo.GetBundleName();
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
bundleInfo.PackAsset(assetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
BundleInfos.Add(newBundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的打包资源
|
||||
/// </summary>
|
||||
public List<BuildAssetInfo> GetAllAssets()
|
||||
{
|
||||
List<BuildAssetInfo> result = new List<BuildAssetInfo>(BundleInfos.Count);
|
||||
foreach (var bundleInfo in BundleInfos)
|
||||
{
|
||||
result.AddRange(bundleInfo.BuildinAssets);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的分类标签列表
|
||||
/// </summary>
|
||||
public string[] GetBundleTags(string bundleName)
|
||||
{
|
||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
return bundleInfo.GetBundleTags();
|
||||
}
|
||||
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取AssetBundle内构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetBuildinAssetPaths(string bundleName)
|
||||
{
|
||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
return bundleInfo.GetBuildinAssetPaths();
|
||||
}
|
||||
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(BundleInfos.Count);
|
||||
foreach (var bundleInfo in BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile == false)
|
||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源包
|
||||
/// </summary>
|
||||
public bool IsContainsBundle(string bundleName)
|
||||
{
|
||||
return TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo);
|
||||
}
|
||||
|
||||
public bool TryGetBundleInfo(string bundleName, out BuildBundleInfo result)
|
||||
{
|
||||
foreach (var bundleInfo in BundleInfos)
|
||||
{
|
||||
if (bundleInfo.BundleName == bundleName)
|
||||
{
|
||||
result = bundleInfo;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class BuildMapCreater
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行资源构建上下文
|
||||
/// </summary>
|
||||
public static BuildMapContext CreateBuildMap(EBuildMode buildMode)
|
||||
{
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
|
||||
// 1. 检测配置合法性
|
||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||
|
||||
// 2. 获取所有收集器收集的资源
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode);
|
||||
|
||||
// 3. 剔除未被引用的依赖资源
|
||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
if (collectAssetInfo.CollectorType == ECollectorType.DependAssetCollector)
|
||||
{
|
||||
if (IsRemoveDependAsset(allCollectAssets, collectAssetInfo.AssetPath))
|
||||
removeDependList.Add(collectAssetInfo);
|
||||
}
|
||||
}
|
||||
foreach (var removeValue in removeDependList)
|
||||
{
|
||||
allCollectAssets.Remove(removeValue);
|
||||
}
|
||||
|
||||
// 4. 录入所有收集器收集的资源
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
|
||||
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||
buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Should never get here !");
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 录入相关依赖的资源
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (buildAssetDic.ContainsKey(dependAssetPath))
|
||||
{
|
||||
buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
|
||||
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||
buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName);
|
||||
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.AssetFileCount = buildAssetDic.Count;
|
||||
|
||||
// 6. 填充主动收集资源的依赖列表
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (buildAssetDic.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
||||
dependAssetInfos.Add(value);
|
||||
else
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||
}
|
||||
|
||||
// 7. 计算完整的资源包名
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
{
|
||||
pair.Value.CalculateFullBundleName();
|
||||
}
|
||||
|
||||
// 8. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
{
|
||||
var buildAssetInfo = pair.Value;
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
removeBuildList.Add(buildAssetInfo);
|
||||
}
|
||||
foreach (var removeValue in removeBuildList)
|
||||
{
|
||||
buildAssetDic.Remove(removeValue.AssetPath);
|
||||
}
|
||||
|
||||
// 9. 构建资源包
|
||||
var allBuildinAssets = buildAssetDic.Values.ToList();
|
||||
if (allBuildinAssets.Count == 0)
|
||||
throw new Exception("构建的资源列表不能为空");
|
||||
foreach (var assetInfo in allBuildinAssets)
|
||||
{
|
||||
context.PackAsset(assetInfo);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
private static bool IsRemoveDependAsset(List<CollectAssetInfo> allCollectAssets, string dependAssetPath)
|
||||
{
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
var collectorType = collectAssetInfo.CollectorType;
|
||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||
{
|
||||
if (collectAssetInfo.DependAssets.Contains(dependAssetPath))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
BuildRunner.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9274735f1f14af4b893c21a4240b816
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,121 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// SBP构建参数
|
||||
/// </summary>
|
||||
public class SBPBuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成代码防裁剪配置
|
||||
/// </summary>
|
||||
public bool WriteLinkXML = true;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存服务器地址
|
||||
/// </summary>
|
||||
public string CacheServerHost;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存服务器端口
|
||||
/// </summary>
|
||||
public int CacheServerPort;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可编程构建管线的参数
|
||||
/// </summary>
|
||||
public SBPBuildParameters SBPParameters;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 输出的根目录
|
||||
/// </summary>
|
||||
public string OutputRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public EBuildPipeline BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的版本(资源版本号)
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源标签集合(首包资源标签)
|
||||
/// 注意:分号为分隔符
|
||||
/// </summary>
|
||||
public string BuildinTags;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源文件到StreamingAssets目录(首包资源文件)
|
||||
/// </summary>
|
||||
public bool CopyBuildinTagFiles = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加密类
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices = null;
|
||||
|
||||
/// <summary>
|
||||
/// 补丁文件名称的样式
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源标签列表(首包资源标签)
|
||||
/// </summary>
|
||||
public List<string> GetBuildinTags()
|
||||
{
|
||||
return StringUtility.StringToStringList(BuildinTags, ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildParametersContext : IContextObject
|
||||
{
|
||||
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
|
||||
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线的输出目录
|
||||
/// </summary>
|
||||
public string PipelineOutputDirectory { private set; get; }
|
||||
|
||||
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
Parameters = parameters;
|
||||
|
||||
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
||||
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
||||
else if (parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁目录
|
||||
/// </summary>
|
||||
public string GetPackageDirectory()
|
||||
{
|
||||
return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置构建管线的构建选项
|
||||
/// </summary>
|
||||
public BuildAssetBundleOptions GetPipelineBuildOptions()
|
||||
{
|
||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||
|
||||
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||
|
||||
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||
return opt;
|
||||
}
|
||||
|
||||
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||
|
||||
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||
if (Parameters.DisableWriteTypeTree)
|
||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||
if (Parameters.IgnoreTypeTreeChanges)
|
||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||
|
||||
return opt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取可编程构建管线的构建参数
|
||||
/// </summary>
|
||||
public UnityEditor.Build.Pipeline.BundleBuildParameters GetSBPBuildParameters()
|
||||
{
|
||||
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
var targetGroup = BuildPipeline.GetBuildTargetGroup(Parameters.BuildTarget);
|
||||
var buildParams = new UnityEditor.Build.Pipeline.BundleBuildParameters(Parameters.BuildTarget, targetGroup, PipelineOutputDirectory);
|
||||
|
||||
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
||||
else if (Parameters.CompressOption == ECompressOption.LZMA)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
|
||||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
|
||||
else
|
||||
throw new System.NotImplementedException(Parameters.CompressOption.ToString());
|
||||
|
||||
if (Parameters.DisableWriteTypeTree)
|
||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||
|
||||
buildParams.UseCache = true;
|
||||
buildParams.CacheServerHost = Parameters.SBPParameters.CacheServerHost;
|
||||
buildParams.CacheServerPort = Parameters.SBPParameters.CacheServerPort;
|
||||
buildParams.WriteLinkXML = Parameters.SBPParameters.WriteLinkXML;
|
||||
|
||||
return buildParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的耗时(单位:秒)
|
||||
/// </summary>
|
||||
public float GetBuildingSeconds()
|
||||
{
|
||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||
return seconds;
|
||||
}
|
||||
public void BeginWatch()
|
||||
{
|
||||
_buildWatch.Start();
|
||||
}
|
||||
public void StopWatch()
|
||||
{
|
||||
_buildWatch.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6268d725eec21b4aae819adc1553f0e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建报告
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuildReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 汇总信息
|
||||
/// </summary>
|
||||
public ReportSummary Summary = new ReportSummary();
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象列表
|
||||
/// </summary>
|
||||
public List<ReportAssetInfo> AssetInfos = new List<ReportAssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包信息类
|
||||
/// </summary>
|
||||
public ReportBundleInfo GetBundleInfo(string bundleName)
|
||||
{
|
||||
foreach (var bundleInfo in BundleInfos)
|
||||
{
|
||||
if (bundleInfo.BundleName == bundleName)
|
||||
return bundleInfo;
|
||||
}
|
||||
throw new Exception($"Not found bundle : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息类
|
||||
/// </summary>
|
||||
public ReportAssetInfo GetAssetInfo(string assetPath)
|
||||
{
|
||||
foreach (var assetInfo in AssetInfos)
|
||||
{
|
||||
if (assetInfo.AssetPath == assetPath)
|
||||
return assetInfo;
|
||||
}
|
||||
throw new Exception($"Not found asset : {assetPath}");
|
||||
}
|
||||
|
||||
|
||||
public static void Serialize(string savePath, BuildReport buildReport)
|
||||
{
|
||||
string json = JsonUtility.ToJson(buildReport, true);
|
||||
FileUtility.CreateFile(savePath, json);
|
||||
}
|
||||
public static BuildReport Deserialize(string jsonData)
|
||||
{
|
||||
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportAssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address;
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// 说明:Meta文件记录的GUID
|
||||
/// </summary>
|
||||
public string AssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public string[] AssetTags;
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源包名称
|
||||
/// </summary>
|
||||
public string MainBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源包的大小
|
||||
/// </summary>
|
||||
public long MainBundleSize;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源包名称列表
|
||||
/// </summary>
|
||||
public List<string> DependBundles = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源路径列表
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportBundleInfo
|
||||
{
|
||||
public class FlagsData
|
||||
{
|
||||
public bool IsEncrypted { private set; get; }
|
||||
public bool IsBuildin { private set; get; }
|
||||
public bool IsRawFile { private set; get; }
|
||||
public FlagsData(bool isEncrypted, bool isBuildin, bool isRawFile)
|
||||
{
|
||||
IsEncrypted = isEncrypted;
|
||||
IsBuildin = isBuildin;
|
||||
IsRawFile = isRawFile;
|
||||
}
|
||||
}
|
||||
|
||||
private FlagsData _flagData;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string FileHash;
|
||||
|
||||
/// <summary>
|
||||
/// 文件校验码
|
||||
/// </summary>
|
||||
public string FileCRC;
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小(字节数)
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
|
||||
/// <summary>
|
||||
/// Tags
|
||||
/// </summary>
|
||||
public string[] Tags;
|
||||
|
||||
/// <summary>
|
||||
/// Flags
|
||||
/// </summary>
|
||||
public int Flags;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取标志位的解析数据
|
||||
/// </summary>
|
||||
public FlagsData GetFlagData()
|
||||
{
|
||||
if (_flagData == null)
|
||||
{
|
||||
BitMask32 value = Flags;
|
||||
bool isEncrypted = value.Test(0);
|
||||
bool isBuildin = value.Test(1);
|
||||
bool isRawFile = value.Test(2);
|
||||
_flagData = new FlagsData(isEncrypted, isBuildin, isRawFile);
|
||||
}
|
||||
return _flagData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源分类标签的字符串
|
||||
/// </summary>
|
||||
public string GetTagsString()
|
||||
{
|
||||
if (Tags != null)
|
||||
return String.Join(";", Tags);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为原生文件
|
||||
/// </summary>
|
||||
public bool IsRawFile()
|
||||
{
|
||||
if (System.IO.Path.GetExtension(BundleName) == $".{YooAssetSettingsData.Setting.RawFileVariant}")
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// YooAsset版本
|
||||
/// </summary>
|
||||
public string YooVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 引擎版本
|
||||
/// </summary>
|
||||
public string UnityVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建时间
|
||||
/// </summary>
|
||||
public string BuildDate;
|
||||
|
||||
/// <summary>
|
||||
/// 构建耗时(单位:秒)
|
||||
/// </summary>
|
||||
public int BuildSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// 构建平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public EBuildPipeline BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建版本
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源标签
|
||||
/// </summary>
|
||||
public string BuildinTags;
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源文件
|
||||
/// </summary>
|
||||
public bool CopyBuildinTagFiles;
|
||||
|
||||
/// <summary>
|
||||
/// 加密服务类名称
|
||||
/// </summary>
|
||||
public string EncryptionServicesClassName;
|
||||
|
||||
// 构建参数
|
||||
public EOutputNameStyle OutputNameStyle;
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
|
||||
// 构建结果
|
||||
public int AssetFileTotalCount;
|
||||
public int MainAssetTotalCount;
|
||||
public int AllBundleTotalCount;
|
||||
public long AllBundleTotalSize;
|
||||
public int BuildinBundleTotalCount;
|
||||
public long BuildinBundleTotalSize;
|
||||
public int EncryptedBundleTotalCount;
|
||||
public long EncryptedBundleTotalSize;
|
||||
public int RawBundleTotalCount;
|
||||
public long RawBundleTotalSize;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildContext
|
||||
{
|
||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有情景对象
|
||||
/// </summary>
|
||||
public void ClearAllContext()
|
||||
{
|
||||
_contextObjects.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置情景对象
|
||||
/// </summary>
|
||||
public void SetContextObject(IContextObject contextObject)
|
||||
{
|
||||
if (contextObject == null)
|
||||
throw new ArgumentNullException("contextObject");
|
||||
|
||||
var type = contextObject.GetType();
|
||||
if (_contextObjects.ContainsKey(type))
|
||||
throw new Exception($"Context object {type} is already existed.");
|
||||
|
||||
_contextObjects.Add(type, contextObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取情景对象
|
||||
/// </summary>
|
||||
public T GetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||
{
|
||||
return (T)contextObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found context object : {type}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildRunner
|
||||
{
|
||||
public static bool EnableLog = true;
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建流程
|
||||
/// </summary>
|
||||
/// <returns>如果成功返回TRUE,否则返回FALSE</returns>
|
||||
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
|
||||
{
|
||||
if (pipeline == null)
|
||||
throw new ArgumentNullException("pipeline");
|
||||
if (context == null)
|
||||
throw new ArgumentNullException("context");
|
||||
|
||||
BuildResult buildResult = new BuildResult();
|
||||
buildResult.Success = true;
|
||||
for (int i = 0; i < pipeline.Count; i++)
|
||||
{
|
||||
IBuildTask task = pipeline[i];
|
||||
try
|
||||
{
|
||||
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
||||
Log($"---------------------------------------->{taskAttribute.Desc}<---------------------------------------");
|
||||
task.Run(context);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
buildResult.FailedTask = task.GetType().Name;
|
||||
buildResult.FailedInfo = e.ToString();
|
||||
buildResult.Success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 返回运行结果
|
||||
return buildResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志输出
|
||||
/// </summary>
|
||||
public static void Log(string info)
|
||||
{
|
||||
if (EnableLog)
|
||||
{
|
||||
UnityEngine.Debug.Log(info);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志输出
|
||||
/// </summary>
|
||||
public static void Info(string info)
|
||||
{
|
||||
UnityEngine.Debug.Log(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IBuildTask
|
||||
{
|
||||
void Run(BuildContext context);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IContextObject
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class TaskAttribute : Attribute
|
||||
{
|
||||
public string Desc;
|
||||
public TaskAttribute(string desc)
|
||||
{
|
||||
Desc = desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35749e57d9a3da84aa60c348bc6bbe9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Build.Pipeline;
|
||||
using UnityEditor.Build.Pipeline.Interfaces;
|
||||
|
||||
namespace UnityEditor.Build.Pipeline.Tasks
|
||||
{
|
||||
public static class SBPBuildTasks
|
||||
{
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
||||
{
|
||||
var buildTasks = new List<IBuildTask>();
|
||||
|
||||
// Setup
|
||||
buildTasks.Add(new SwitchToBuildPlatform());
|
||||
buildTasks.Add(new RebuildSpriteAtlasCache());
|
||||
|
||||
// Player Scripts
|
||||
buildTasks.Add(new BuildPlayerScripts());
|
||||
buildTasks.Add(new PostScriptsCallback());
|
||||
|
||||
// Dependency
|
||||
buildTasks.Add(new CalculateSceneDependencyData());
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
buildTasks.Add(new CalculateCustomDependencyData());
|
||||
#endif
|
||||
buildTasks.Add(new CalculateAssetDependencyData());
|
||||
buildTasks.Add(new StripUnusedSpriteSources());
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
buildTasks.Add(new PostDependencyCallback());
|
||||
|
||||
// Packing
|
||||
buildTasks.Add(new GenerateBundlePacking());
|
||||
buildTasks.Add(new UpdateBundleObjectLayout());
|
||||
buildTasks.Add(new GenerateBundleCommands());
|
||||
buildTasks.Add(new GenerateSubAssetPathMaps());
|
||||
buildTasks.Add(new GenerateBundleMaps());
|
||||
buildTasks.Add(new PostPackingCallback());
|
||||
|
||||
// Writing
|
||||
buildTasks.Add(new WriteSerializedFiles());
|
||||
buildTasks.Add(new ArchiveAndCompressBundles());
|
||||
buildTasks.Add(new AppendBundleHash());
|
||||
buildTasks.Add(new GenerateLinkXml());
|
||||
buildTasks.Add(new PostWritingCallback());
|
||||
|
||||
return buildTasks;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建内容打包")]
|
||||
public class TaskBuilding : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public AssetBundleManifest UnityManifest;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
||||
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);
|
||||
if (buildResults == null)
|
||||
throw new Exception("构建过程中发生错误!");
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string unityOutputManifestFilePath = $"{buildParametersContext.PipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
if(System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
||||
}
|
||||
|
||||
BuildRunner.Log("Unity引擎打包成功!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.UnityManifest = buildResults;
|
||||
context.SetContextObject(buildResultContext);
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||
UpdateBuildBundleInfo(buildMapContext, buildParametersContext, buildResultContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝原生文件
|
||||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (buildAsset.IsRawAsset)
|
||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新构建结果
|
||||
/// </summary>
|
||||
private void UpdateBuildBundleInfo(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext, BuildResultContext buildResult)
|
||||
{
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
bundleInfo.ContentHash = HashUtility.FileMD5(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||
if (hash.isValid)
|
||||
bundleInfo.ContentHash = hash.ToString();
|
||||
else
|
||||
throw new Exception($"Not found bundle in build result : {bundleInfo.BundleName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9466e826c135e994c84961e4b921ca5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,98 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor.Build.Pipeline;
|
||||
using UnityEditor.Build.Pipeline.Interfaces;
|
||||
using UnityEditor.Build.Pipeline.Tasks;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建内容打包")]
|
||||
public class TaskBuilding_SBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public IBundleBuildResults Results;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 构建内容
|
||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
||||
var shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
||||
var taskList = SBPBuildTasks.Create(shadersBunldeName);
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
||||
}
|
||||
|
||||
BuildRunner.Log("Unity引擎打包成功!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
context.SetContextObject(buildResultContext);
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||
UpdateBuildBundleInfo(buildMapContext, buildParametersContext, buildResultContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝原生文件
|
||||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (buildAsset.IsRawAsset)
|
||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新构建结果
|
||||
/// </summary>
|
||||
private void UpdateBuildBundleInfo(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext, BuildResultContext buildResult)
|
||||
{
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
bundleInfo.ContentHash = HashUtility.FileMD5(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
bundleInfo.ContentHash = value.Hash.ToString();
|
||||
else
|
||||
throw new Exception($"Not found bundle in build result : {bundleInfo.BundleName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("拷贝内置文件到流目录")]
|
||||
public class TaskCopyBuildinFiles : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
// 注意:我们只有在强制重建的时候才会拷贝
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParameters.Parameters.CopyBuildinTagFiles)
|
||||
{
|
||||
// 清空流目录
|
||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||
|
||||
// 拷贝内置文件
|
||||
CopyBuildinFilesToStreaming(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyBuildinFilesToStreaming(string pipelineOutputDirectory, int buildVersion)
|
||||
{
|
||||
// 加载补丁清单
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildVersion);
|
||||
|
||||
// 拷贝文件列表
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsBuildin == false)
|
||||
continue;
|
||||
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝清单文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝清单哈希文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝静态版本文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettings.VersionFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildRunner.Log($"内置文件拷贝完成:{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor.Build.Pipeline;
|
||||
using UnityEditor.Build.Pipeline.Interfaces;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建补丁清单文件")]
|
||||
public class TaskCreatePatchManifest : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreatePatchManifestFile(context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁清单文件到输出目录
|
||||
/// </summary>
|
||||
private void CreatePatchManifestFile(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||
|
||||
// 创建新补丁清单
|
||||
PatchManifest patchManifest = new PatchManifest();
|
||||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
||||
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
|
||||
patchManifest.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||
patchManifest.OutputNameStyle = (int)buildParameters.Parameters.OutputNameStyle;
|
||||
patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||
|
||||
// 更新Unity内置资源包的引用关系
|
||||
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
if(buildParameters.Parameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建补丁清单文件
|
||||
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
|
||||
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||
string manifestHash = HashUtility.FileMD5(manifestFilePath);
|
||||
BuildRunner.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
|
||||
FileUtility.CreateFile(manifestHashFilePath, manifestHash);
|
||||
|
||||
// 创建静态版本文件
|
||||
string staticVersionFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string staticVersion = resourceVersion.ToString();
|
||||
BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}");
|
||||
FileUtility.CreateFile(staticVersionFilePath, staticVersion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包列表
|
||||
/// </summary>
|
||||
private List<PatchBundle> GetAllPatchBundle(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
|
||||
|
||||
List<PatchBundle> result = new List<PatchBundle>(1000);
|
||||
|
||||
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
var bundleName = bundleInfo.BundleName;
|
||||
string fileHash = GetBundleFileHash(bundleInfo, buildParameters);
|
||||
string fileCRC = GetBundleFileCRC(bundleInfo, buildParameters);
|
||||
long fileSize = GetBundleFileSize(bundleInfo, buildParameters);
|
||||
string[] tags = buildMapContext.GetBundleTags(bundleName);
|
||||
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
||||
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
||||
bool isRawFile = bundleInfo.IsRawFile;
|
||||
|
||||
PatchBundle patchBundle = new PatchBundle(bundleName, fileHash, fileCRC, fileSize, tags);
|
||||
patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile);
|
||||
result.Add(patchBundle);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private bool IsBuildinBundle(string[] bundleTags, List<string> buildinTags)
|
||||
{
|
||||
// 注意:没有任何分类标签的Bundle文件默认为内置文件
|
||||
if (bundleTags.Length == 0)
|
||||
return true;
|
||||
|
||||
foreach (var tag in bundleTags)
|
||||
{
|
||||
if (buildinTags.Contains(tag))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
private string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
private long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return 0;
|
||||
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源列表
|
||||
/// </summary>
|
||||
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
var assetInfos = bundleInfo.GetAllPatchAssetInfos();
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
PatchAsset patchAsset = new PatchAsset();
|
||||
if (buildParameters.Parameters.EnableAddressable)
|
||||
patchAsset.Address = assetInfo.Address;
|
||||
else
|
||||
patchAsset.Address = string.Empty;
|
||||
patchAsset.AssetPath = assetInfo.AssetPath;
|
||||
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest);
|
||||
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
|
||||
result.Add(patchAsset);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PatchManifest patchManifest)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||
{
|
||||
if (dependAssetInfo.HasBundleName())
|
||||
{
|
||||
int bundleID = GetAssetBundleID(dependAssetInfo.GetBundleName(), patchManifest);
|
||||
if (mainBundleID != bundleID)
|
||||
{
|
||||
if (result.Contains(bundleID) == false)
|
||||
result.Add(bundleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
private int GetAssetBundleID(string bundleName, PatchManifest patchManifest)
|
||||
{
|
||||
for (int index = 0; index < patchManifest.BundleList.Count; index++)
|
||||
{
|
||||
if (patchManifest.BundleList[index].BundleName == bundleName)
|
||||
return index;
|
||||
}
|
||||
throw new Exception($"Not found bundle name : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新Unity内置资源包的引用关系
|
||||
/// </summary>
|
||||
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults)
|
||||
{
|
||||
// 获取所有依赖着色器资源包的资源包列表
|
||||
string shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
||||
List<string> shaderBundleReferenceList = new List<string>();
|
||||
foreach (var valuePair in buildResults.BundleInfos)
|
||||
{
|
||||
if (valuePair.Value.Dependencies.Any(t => t == shadersBunldeName))
|
||||
shaderBundleReferenceList.Add(valuePair.Key);
|
||||
}
|
||||
|
||||
// 获取着色器资源包索引
|
||||
Predicate<PatchBundle> predicate = new Predicate<PatchBundle>(s => s.BundleName == shadersBunldeName);
|
||||
int shaderBundleId = patchManifest.BundleList.FindIndex(predicate);
|
||||
if (shaderBundleId == -1)
|
||||
throw new Exception("没有发现着色器资源包!");
|
||||
|
||||
// 检测依赖交集并更新依赖ID
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
List<string> dependBundles = GetPatchAssetAllDependBundles(patchManifest, patchAsset);
|
||||
List<string> conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList();
|
||||
if (conflictAssetPathList.Count > 0)
|
||||
{
|
||||
List<int> newDependIDs = new List<int>(patchAsset.DependIDs);
|
||||
if (newDependIDs.Contains(shaderBundleId) == false)
|
||||
newDependIDs.Add(shaderBundleId);
|
||||
patchAsset.DependIDs = newDependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<string> GetPatchAssetAllDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
string mainBundle = patchManifest.BundleList[patchAsset.BundleID].BundleName;
|
||||
result.Add(mainBundle);
|
||||
foreach (var dependID in patchAsset.DependIDs)
|
||||
{
|
||||
string dependBundle = patchManifest.BundleList[dependID].BundleName;
|
||||
result.Add(dependBundle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("制作补丁包")]
|
||||
public class TaskCreatePatchPackage : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
CopyPatchFiles(buildParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CopyPatchFiles(BuildParametersContext buildParameters)
|
||||
{
|
||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
||||
|
||||
// 拷贝Report文件
|
||||
{
|
||||
string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion);
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{reportFileName}";
|
||||
string destPath = $"{packageDirectory}/{reportFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单哈希文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝静态版本文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
// 拷贝构建日志
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/buildlogtep.json";
|
||||
string destPath = $"{packageDirectory}/buildlogtep.json";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝代码防裁剪配置
|
||||
if (buildParameters.Parameters.SBPParameters.WriteLinkXML)
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/link.xml";
|
||||
string destPath = $"{packageDirectory}/link.xml";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 拷贝UnityManifest序列化文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝UnityManifest文本文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
int patchFileTotalCount = patchManifest.BundleList.Count;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||
string destPath = $"{packageDirectory}/{patchBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d110092f543e3fe40a4d3882e1a718e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,238 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建构建报告文件")]
|
||||
public class TaskCreateReport : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
buildParameters.StopWatch();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext);
|
||||
}
|
||||
|
||||
float buildSeconds = buildParameters.GetBuildingSeconds();
|
||||
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
|
||||
}
|
||||
|
||||
private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||
{
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
#endif
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
|
||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.Parameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||
buildReport.Summary.CopyBuildinTagFiles = buildParameters.Parameters.CopyBuildinTagFiles;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
// 构建参数
|
||||
buildReport.Summary.OutputNameStyle = buildParameters.Parameters.OutputNameStyle;
|
||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
|
||||
|
||||
// 构建结果
|
||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(patchManifest);
|
||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(patchManifest);
|
||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(patchManifest);
|
||||
buildReport.Summary.BuildinBundleTotalCount = GetBuildinBundleCount(patchManifest);
|
||||
buildReport.Summary.BuildinBundleTotalSize = GetBuildinBundleSize(patchManifest);
|
||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(patchManifest);
|
||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(patchManifest);
|
||||
buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(patchManifest);
|
||||
buildReport.Summary.RawBundleTotalSize = GetRawBundleSize(patchManifest);
|
||||
}
|
||||
|
||||
// 资源对象列表
|
||||
buildReport.AssetInfos = new List<ReportAssetInfo>(patchManifest.AssetList.Count);
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
var mainBundle = patchManifest.BundleList[patchAsset.BundleID];
|
||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||
reportAssetInfo.Address = patchAsset.Address;
|
||||
reportAssetInfo.AssetPath = patchAsset.AssetPath;
|
||||
reportAssetInfo.AssetTags = patchAsset.AssetTags;
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||
reportAssetInfo.DependBundles = GetDependBundles(patchManifest, patchAsset);
|
||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, patchAsset.AssetPath);
|
||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||
}
|
||||
|
||||
// 资源包列表
|
||||
buildReport.BundleInfos = new List<ReportBundleInfo>(patchManifest.BundleList.Count);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||
reportBundleInfo.BundleName = patchBundle.BundleName;
|
||||
reportBundleInfo.FileName = patchBundle.FileName;
|
||||
reportBundleInfo.FileHash = patchBundle.FileHash;
|
||||
reportBundleInfo.FileCRC = patchBundle.FileCRC;
|
||||
reportBundleInfo.FileSize = patchBundle.FileSize;
|
||||
reportBundleInfo.Tags = patchBundle.Tags;
|
||||
reportBundleInfo.Flags = patchBundle.Flags;
|
||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
|
||||
// 删除旧文件
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion)}";
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
// 序列化文件
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(patchAsset.DependIDs.Length);
|
||||
foreach (int index in patchAsset.DependIDs)
|
||||
{
|
||||
string dependBundleName = patchManifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
if (buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (buildinAsset.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = buildinAsset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found bundle : {bundleName}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int GetMainAssetCount(PatchManifest patchManifest)
|
||||
{
|
||||
return patchManifest.AssetList.Count;
|
||||
}
|
||||
private int GetAllBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
return patchManifest.BundleList.Count;
|
||||
}
|
||||
private long GetAllBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
fileBytes += patchBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetBuildinBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsBuildin)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetBuildinBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsBuildin)
|
||||
fileBytes += patchBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetEncryptedBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsEncrypted)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetEncryptedBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsEncrypted)
|
||||
fileBytes += patchBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetRawBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsRawFile)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetRawBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsRawFile)
|
||||
fileBytes += patchBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源包加密")]
|
||||
public class TaskEncryption : IBuildTask
|
||||
{
|
||||
public class EncryptionContext : IContextObject
|
||||
{
|
||||
public List<string> EncryptList;
|
||||
|
||||
/// <summary>
|
||||
/// 检测是否为加密文件
|
||||
/// </summary>
|
||||
public bool IsEncryptFile(string bundleName)
|
||||
{
|
||||
return EncryptList.Contains(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
EncryptionContext encryptionContext = new EncryptionContext();
|
||||
encryptionContext.EncryptList = EncryptFiles(buildParameters, buildMapContext);
|
||||
context.SetContextObject(encryptionContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
EncryptionContext encryptionContext = new EncryptionContext();
|
||||
encryptionContext.EncryptList = new List<string>();
|
||||
context.SetContextObject(encryptionContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
private List<string> EncryptFiles(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||
{
|
||||
var encryptionServices = buildParameters.Parameters.EncryptionServices;
|
||||
|
||||
// 加密资源列表
|
||||
List<string> encryptList = new List<string>();
|
||||
|
||||
// 如果没有设置加密类
|
||||
if (encryptionServices == null)
|
||||
return encryptList;
|
||||
|
||||
int progressValue = 0;
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (encryptionServices.Check(bundleInfo.BundleName))
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
encryptList.Add(bundleInfo.BundleName);
|
||||
|
||||
// 注意:通过判断文件合法性,规避重复加密一个文件
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
byte[] fileData = File.ReadAllBytes(filePath);
|
||||
if (EditorTools.CheckBundleFileValid(fileData))
|
||||
{
|
||||
byte[] bytes = encryptionServices.Encrypt(fileData);
|
||||
File.WriteAllBytes(filePath, bytes);
|
||||
BuildRunner.Log($"文件加密完成:{filePath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 进度条
|
||||
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
if(encryptList.Count == 0)
|
||||
UnityEngine.Debug.LogWarning($"没有发现需要加密的文件!");
|
||||
return encryptList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("获取资源构建内容")]
|
||||
public class TaskGetBuildMap : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
|
||||
context.SetContextObject(buildMapContext);
|
||||
BuildRunner.Log("构建内容准备完毕!");
|
||||
|
||||
// 检测构建结果
|
||||
CheckBuildMapContent(buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建结果
|
||||
/// </summary>
|
||||
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
||||
{
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
// 注意:原生文件资源包只能包含一个原生文件
|
||||
bool isRawFile = bundleInfo.IsRawFile;
|
||||
if (isRawFile)
|
||||
{
|
||||
if (bundleInfo.BuildinAssets.Count != 1)
|
||||
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 注意:原生文件不能被其它资源文件依赖
|
||||
foreach (var assetInfo in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (assetInfo.AllDependAssetInfos != null)
|
||||
{
|
||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||
{
|
||||
if (dependAssetInfo.IsRawAsset)
|
||||
throw new Exception($"{assetInfo.AssetPath} can not depend raw asset : {dependAssetInfo.AssetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建准备工作")]
|
||||
public class TaskPrepare : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
buildParameters.BeginWatch();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
|
||||
// 检测构建平台是否合法
|
||||
if (buildParameters.Parameters.BuildTarget == BuildTarget.NoTarget)
|
||||
throw new Exception("请选择目标平台");
|
||||
|
||||
// 检测构建版本是否合法
|
||||
if (buildParameters.Parameters.BuildVersion <= 0)
|
||||
throw new Exception("请先设置版本号");
|
||||
|
||||
// 检测输出目录是否为空
|
||||
if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory))
|
||||
throw new Exception("输出目录不能为空");
|
||||
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (BuildPipeline.isBuildingPlayer)
|
||||
throw new Exception("当前正在构建资源包,请结束后再试");
|
||||
|
||||
// 检测是否有未保存场景
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
throw new Exception("检测到未保存的场景文件");
|
||||
|
||||
// 保存改动的资源
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
// 增量更新时候的必要检测
|
||||
if (buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
// 检测历史版本是否存在
|
||||
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot))
|
||||
{
|
||||
// 检测构建版本是否合法
|
||||
int maxPackageVersion = AssetBundleBuilderHelper.GetMaxPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot);
|
||||
if (buildParameters.Parameters.BuildVersion <= maxPackageVersion)
|
||||
throw new Exception("构建版本不能小于历史版本");
|
||||
|
||||
// 检测补丁包是否已经存在
|
||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||
if (Directory.Exists(packageDirectory))
|
||||
throw new Exception($"补丁包已经存在:{packageDirectory}");
|
||||
|
||||
// 检测内置资源分类标签是否一致
|
||||
var oldPatchManifest = AssetBundleBuilderHelper.GetOldPatchManifest(buildParameters.PipelineOutputDirectory);
|
||||
if (buildParameters.Parameters.BuildinTags != oldPatchManifest.BuildinTags)
|
||||
throw new Exception($"增量更新时内置资源标签必须一致:{buildParameters.Parameters.BuildinTags} != {oldPatchManifest.BuildinTags}");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是强制重建
|
||||
if (buildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
// 删除平台总目录
|
||||
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";
|
||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
||||
{
|
||||
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果输出目录不存在
|
||||
if (EditorTools.CreateDirectory(buildParameters.PipelineOutputDirectory))
|
||||
{
|
||||
BuildRunner.Log($"创建输出目录:{buildParameters.PipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("验证构建结果")]
|
||||
public class TaskVerifyBuildResult : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.UnityManifest);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
||||
|
||||
// 1. 过滤掉原生Bundle
|
||||
string[] mapBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
|
||||
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = buildedBundles.Except(mapBundles).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = mapBundles.Except(buildedBundles).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
}
|
||||
|
||||
// 4. 验证Asset
|
||||
bool isPass = true;
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
int progressValue = 0;
|
||||
foreach (var buildedBundle in buildedBundles)
|
||||
{
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{buildedBundle}";
|
||||
string[] buildedAssetPaths = GetAssetBundleAllAssets(filePath);
|
||||
string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
||||
if (mapAssetPaths.Length != buildedAssetPaths.Length)
|
||||
{
|
||||
Debug.LogWarning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
||||
var exceptAssetList1 = mapAssetPaths.Except(buildedAssetPaths).ToList();
|
||||
foreach (var excpetAsset in exceptAssetList1)
|
||||
{
|
||||
Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
|
||||
}
|
||||
var exceptAssetList2 = buildedAssetPaths.Except(mapAssetPaths).ToList();
|
||||
foreach (var excpetAsset in exceptAssetList2)
|
||||
{
|
||||
Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
|
||||
}
|
||||
isPass = false;
|
||||
continue;
|
||||
}
|
||||
EditorTools.DisplayProgressBar("验证构建结果", ++progressValue, buildedBundles.Length);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
if (isPass == false)
|
||||
{
|
||||
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
||||
}
|
||||
}
|
||||
|
||||
BuildRunner.Log("构建结果验证成功!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析.manifest文件并获取资源列表
|
||||
/// </summary>
|
||||
private string[] GetAssetBundleAllAssets(string filePath)
|
||||
{
|
||||
string manifestFilePath = $"{filePath}.manifest";
|
||||
List<string> assetLines = new List<string>();
|
||||
using (StreamReader reader = File.OpenText(manifestFilePath))
|
||||
{
|
||||
string content;
|
||||
bool findTarget = false;
|
||||
while (null != (content = reader.ReadLine()))
|
||||
{
|
||||
if (content.StartsWith("Dependencies:"))
|
||||
break;
|
||||
if (findTarget == false && content.StartsWith("Assets:"))
|
||||
findTarget = true;
|
||||
if (findTarget)
|
||||
{
|
||||
if (content.StartsWith("- "))
|
||||
{
|
||||
string assetPath = content.TrimStart("- ".ToCharArray());
|
||||
assetLines.Add(assetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return assetLines.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Build.Pipeline.Interfaces;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("验证构建结果")]
|
||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.Results);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
List<string> buildedBundles = buildResults.BundleInfos.Keys.ToList();
|
||||
|
||||
// 1. 过滤掉原生Bundle
|
||||
List<string> expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
|
||||
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = buildedBundles.Except(expectBundles).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = expectBundles.Except(buildedBundles).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
}
|
||||
|
||||
BuildRunner.Log("构建结果验证成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包流水线的构建模式
|
||||
/// </summary>
|
||||
public enum EBuildMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 强制重建模式
|
||||
/// </summary>
|
||||
ForceRebuild,
|
||||
|
||||
/// <summary>
|
||||
/// 增量构建模式
|
||||
/// </summary>
|
||||
IncrementalBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 演练构建模式
|
||||
/// </summary>
|
||||
DryRunBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
SimulateBuild,
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b6f2523a865e454d8fa3f48a2852d5a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建管线类型
|
||||
/// </summary>
|
||||
public enum EBuildPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// 传统内置构建管线
|
||||
/// </summary>
|
||||
BuiltinBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 可编程构建管线
|
||||
/// </summary>
|
||||
ScriptableBuildPipeline,
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// AssetBundle压缩选项
|
||||
/// </summary>
|
||||
public enum ECompressOption
|
||||
{
|
||||
Uncompressed = 0,
|
||||
LZMA,
|
||||
LZ4,
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 输出文件名称的样式
|
||||
/// </summary>
|
||||
public enum EOutputNameStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 000000000000000f000000000000000
|
||||
/// </summary>
|
||||
HashName = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 000000000000000f000000000000000.bundle
|
||||
/// </summary>
|
||||
HashName_Extension = 2,
|
||||
|
||||
/// <summary>
|
||||
/// bundle_name_000000000000000f000000000000000
|
||||
/// </summary>
|
||||
BundleName_HashName = 3,
|
||||
|
||||
/// <summary>
|
||||
/// bundle_name_000000000000000f000000000000000.bundle
|
||||
/// </summary>
|
||||
BundleName_HashName_Extension = 4,
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84c5eff5dedf53343897e83f6b10eea6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IEncryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测是否需要加密
|
||||
/// </summary>
|
||||
bool Check(string bundleName);
|
||||
|
||||
/// <summary>
|
||||
/// 加密方法
|
||||
/// </summary>
|
||||
/// <param name="fileData">要加密的文件数据</param>
|
||||
/// <returns>返回加密后的字节数据</returns>
|
||||
byte[] Encrypt(byte[] fileData);
|
||||
}
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleCollector
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集路径
|
||||
/// 注意:支持文件夹或单个资源文件
|
||||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器的GUID
|
||||
/// </summary>
|
||||
public string CollectorGUID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType = ECollectorType.MainAssetCollector;
|
||||
|
||||
/// <summary>
|
||||
/// 寻址规则类名
|
||||
/// </summary>
|
||||
public string AddressRuleName = nameof(AddressByFileName);
|
||||
|
||||
/// <summary>
|
||||
/// 打包规则类名
|
||||
/// </summary>
|
||||
public string PackRuleName = nameof(PackDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// 过滤规则类名
|
||||
/// </summary>
|
||||
public string FilterRuleName = nameof(CollectAll);
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 收集器是否有效
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
||||
return false;
|
||||
|
||||
if (CollectorType == ECollectorType.None)
|
||||
return false;
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
throw new Exception($"Invalid collect path : {CollectPath}");
|
||||
|
||||
if (CollectorType == ECollectorType.None)
|
||||
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
|
||||
if (string.IsNullOrEmpty(CollectorGUID) == false)
|
||||
{
|
||||
string convertAssetPath = AssetDatabase.GUIDToAssetPath(CollectorGUID);
|
||||
if (string.IsNullOrEmpty(convertAssetPath))
|
||||
{
|
||||
Debug.LogWarning($"Collector GUID {CollectorGUID} is invalid and has been auto removed !");
|
||||
CollectorGUID = string.Empty;
|
||||
isFixed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CollectPath != convertAssetPath)
|
||||
{
|
||||
CollectPath = convertAssetPath;
|
||||
isFixed = true;
|
||||
Debug.LogWarning($"Fix collect path : {CollectPath} -> {convertAssetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
string convertGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if(string.IsNullOrEmpty(convertGUID) == false)
|
||||
{
|
||||
CollectorGUID = convertGUID;
|
||||
}
|
||||
*/
|
||||
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, AssetBundleCollectorGroup group)
|
||||
{
|
||||
// 注意:模拟构建模式下只收集主资源
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
||||
|
||||
// 检测原生资源包的收集器类型
|
||||
if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector)
|
||||
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
||||
|
||||
if (string.IsNullOrEmpty(CollectPath))
|
||||
throw new Exception($"The collect path is null or empty in group : {group.GroupName}");
|
||||
|
||||
// 收集打包资源
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||
{
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string assetPath = CollectPath;
|
||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
if (adressTemper.Contains(address) == false)
|
||||
adressTemper.Add(address);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||
{
|
||||
string address = GetAddress(group, assetPath);
|
||||
string bundleName = GetBundleName(group, assetPath);
|
||||
List<string> assetTags = GetAssetTags(group);
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
collectAssetInfo.DependAssets = new List<string>();
|
||||
else
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||
|
||||
return collectAssetInfo;
|
||||
}
|
||||
private bool IsValidateAsset(string assetPath)
|
||||
{
|
||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 忽略文件夹
|
||||
if (AssetDatabase.IsValidFolder(assetPath))
|
||||
return false;
|
||||
|
||||
// 忽略编辑器下的类型资源
|
||||
Type type = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (type == typeof(LightingDataAsset))
|
||||
return false;
|
||||
|
||||
// 忽略Unity无法识别的无效文件
|
||||
/*
|
||||
if (type == typeof(UnityEditor.DefaultAsset))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
||||
if (IsIgnoreFile(fileExtension))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
private bool IsIgnoreFile(string fileExtension)
|
||||
{
|
||||
foreach (var extension in YooAssetSettings.IgnoreFileExtensions)
|
||||
{
|
||||
if (extension == fileExtension)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private bool IsCollectAsset(string assetPath)
|
||||
{
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
return true;
|
||||
|
||||
// 根据规则设置过滤资源文件
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
||||
}
|
||||
private string GetAddress(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return string.Empty;
|
||||
|
||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName));
|
||||
return adressValue;
|
||||
}
|
||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
{
|
||||
return EditorTools.GetRegularPath(YooAssetSettings.UnityShadersBundleName).ToLower();
|
||||
}
|
||||
|
||||
// 根据规则设置获取资源包名称
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||
{
|
||||
List<string> tags = StringUtility.StringToStringList(group.AssetTags, ';');
|
||||
List<string> temper = StringUtility.StringToStringList(AssetTags, ';');
|
||||
tags.AddRange(temper);
|
||||
return tags;
|
||||
}
|
||||
private List<string> GetAllDependencies(string mainAssetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||
foreach (string assetPath in depends)
|
||||
{
|
||||
if (IsValidateAsset(assetPath))
|
||||
{
|
||||
// 注意:排除主资源对象
|
||||
if (assetPath != mainAssetPath)
|
||||
result.Add(assetPath);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "1.0";
|
||||
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlGroup = "Group";
|
||||
public const string XmlGroupName = "GroupName";
|
||||
public const string XmlGroupDesc = "GroupDesc";
|
||||
public const string XmlCollector = "Collector";
|
||||
public const string XmlCollectPath = "CollectPath";
|
||||
public const string XmlCollectorGUID = "CollectGUID";
|
||||
public const string XmlCollectorType = "CollectType";
|
||||
public const string XmlAddressRule = "AddressRule";
|
||||
public const string XmlPackRule = "PackRule";
|
||||
public const string XmlFilterRule = "FilterRule";
|
||||
public const string XmlAssetTags = "AssetTags";
|
||||
|
||||
/// <summary>
|
||||
/// 导入XML配置表
|
||||
/// </summary>
|
||||
public static void ImportXmlConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
if (Path.GetExtension(filePath) != ".xml")
|
||||
throw new Exception($"Only support xml : {filePath}");
|
||||
|
||||
// 加载配置文件
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.Load(filePath);
|
||||
XmlElement root = xml.DocumentElement;
|
||||
|
||||
// 读取配置版本
|
||||
string configVersion = root.GetAttribute(XmlVersion);
|
||||
if (configVersion != ConfigVersion)
|
||||
{
|
||||
throw new Exception($"The config version is invalid : {configVersion}");
|
||||
}
|
||||
|
||||
// 读取公共配置
|
||||
bool enableAddressable = false;
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
}
|
||||
|
||||
// 读取分组配置
|
||||
List<AssetBundleCollectorGroup> groupTemper = new List<AssetBundleCollectorGroup>();
|
||||
var groupNodeList = root.GetElementsByTagName(XmlGroup);
|
||||
foreach (var groupNode in groupNodeList)
|
||||
{
|
||||
XmlElement groupElement = groupNode as XmlElement;
|
||||
if (groupElement.HasAttribute(XmlGroupName) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
||||
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||
groupTemper.Add(group);
|
||||
|
||||
// 读取收集器配置
|
||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||
foreach (var collectorNode in collectorNodeList)
|
||||
{
|
||||
XmlElement collectorElement = collectorNode as XmlElement;
|
||||
if (collectorElement.HasAttribute(XmlCollectPath) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlCollectorType) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAddressRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlPackRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||
|
||||
string collectorGUID = string.Empty;
|
||||
if (collectorElement.HasAttribute(XmlCollectorGUID))
|
||||
collectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
|
||||
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
|
||||
collector.CollectorGUID = collectorGUID;
|
||||
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
|
||||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置数据
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"导入配置完毕!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出XML配置表
|
||||
/// </summary>
|
||||
public static void ExportXmlConfig(string savePath)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
sb.AppendLine("<root>");
|
||||
sb.AppendLine("</root>");
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(sb.ToString());
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
|
||||
// 设置配置版本
|
||||
root.SetAttribute(XmlVersion, ConfigVersion);
|
||||
|
||||
// 设置公共配置
|
||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||
root.AppendChild(commonElement);
|
||||
|
||||
// 设置分组配置
|
||||
foreach (var group in AssetBundleCollectorSettingData.Setting.Groups)
|
||||
{
|
||||
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||
root.AppendChild(groupElement);
|
||||
|
||||
// 设置收集器配置
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||
collectorElement.SetAttribute(XmlCollectorGUID, collector.CollectorGUID);
|
||||
collectorElement.SetAttribute(XmlCollectorType, collector.CollectorType.ToString());
|
||||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||
groupElement.AppendChild(collectorElement);
|
||||
}
|
||||
}
|
||||
|
||||
// 生成配置文件
|
||||
xmlDoc.Save(savePath);
|
||||
Debug.Log($"导出配置完毕!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleCollectorGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组名称
|
||||
/// </summary>
|
||||
public string GroupName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组描述
|
||||
/// </summary>
|
||||
public string GroupDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组激活规则
|
||||
/// </summary>
|
||||
public string ActiveRuleName = nameof(EnableGroup);
|
||||
|
||||
/// <summary>
|
||||
/// 分组的收集器列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollector> Collectors = new List<AssetBundleCollector>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
collector.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
{
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
// 收集打包资源
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
var temper = collector.GetAllCollectAssets(buildMode, this);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
if (adressTemper.Contains(address) == false)
|
||||
adressTemper.Add(address);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} in group : {GroupName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
return result.Values.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
group.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool result = false;
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
bool isFixed = collector.FixConfigError();
|
||||
if (isFixed)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public List<string> GetAllTags()
|
||||
{
|
||||
HashSet<string> result = new HashSet<string>();
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
List<string> groupTags = StringUtility.StringToStringList(group.AssetTags, ';');
|
||||
foreach (var tag in groupTags)
|
||||
{
|
||||
if (result.Contains(tag) == false)
|
||||
result.Add(tag);
|
||||
}
|
||||
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
List<string> collectorTags = StringUtility.StringToStringList(collector.AssetTags, ';');
|
||||
foreach (var tag in collectorTags)
|
||||
{
|
||||
if (result.Contains(tag) == false)
|
||||
result.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
// 收集打包资源
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
var temper = group.GetAllCollectAssets(buildMode);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
if (adressTemper.Contains(address) == false)
|
||||
adressTemper.Add(address);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
return result.Values.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,409 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorSettingData
|
||||
{
|
||||
private static readonly Dictionary<string, System.Type> _cacheActiveRuleTypes = new Dictionary<string, Type>();
|
||||
private static readonly Dictionary<string, IActiveRule> _cacheActiveRuleInstance = new Dictionary<string, IActiveRule>();
|
||||
|
||||
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
||||
|
||||
private static readonly Dictionary<string, System.Type> _cachePackRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IPackRule> _cachePackRuleInstance = new Dictionary<string, IPackRule>();
|
||||
|
||||
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
||||
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { private set; get; } = false;
|
||||
|
||||
|
||||
private static AssetBundleCollectorSetting _setting = null;
|
||||
public static AssetBundleCollectorSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<string> GetActiveRuleNames()
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
|
||||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cacheActiveRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<string> GetAddressRuleNames()
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
|
||||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cacheAddressRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<string> GetPackRuleNames()
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
|
||||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cachePackRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<string> GetFilterRuleNames()
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
|
||||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cacheFilterRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static bool HasActiveRuleName(string ruleName)
|
||||
{
|
||||
foreach (var pair in _cacheActiveRuleTypes)
|
||||
{
|
||||
if (pair.Key == ruleName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool HasAddressRuleName(string ruleName)
|
||||
{
|
||||
foreach (var pair in _cacheAddressRuleTypes)
|
||||
{
|
||||
if (pair.Key == ruleName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool HasPackRuleName(string ruleName)
|
||||
{
|
||||
foreach (var pair in _cachePackRuleTypes)
|
||||
{
|
||||
if (pair.Key == ruleName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool HasFilterRuleName(string ruleName)
|
||||
{
|
||||
foreach (var pair in _cacheFilterRuleTypes)
|
||||
{
|
||||
if (pair.Key == ruleName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置文件
|
||||
/// </summary>
|
||||
private static void LoadSettingData()
|
||||
{
|
||||
_setting = EditorHelper.LoadSettingData<AssetBundleCollectorSetting>();
|
||||
|
||||
// IPackRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cachePackRuleTypes.Clear();
|
||||
_cachePackRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(PackSeparately),
|
||||
typeof(PackDirectory),
|
||||
typeof(PackTopDirectory),
|
||||
typeof(PackCollector),
|
||||
typeof(PackGroup),
|
||||
typeof(PackRawFile),
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cachePackRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cachePackRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
|
||||
// IFilterRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheFilterRuleTypes.Clear();
|
||||
_cacheFilterRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(CollectAll),
|
||||
typeof(CollectScene),
|
||||
typeof(CollectPrefab),
|
||||
typeof(CollectSprite)
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheFilterRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheFilterRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
|
||||
// IAddressRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheAddressRuleTypes.Clear();
|
||||
_cacheAddressRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByCollectorAndFileName),
|
||||
typeof(AddressByGroupAndFileName)
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheAddressRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheAddressRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
|
||||
// IActiveRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheActiveRuleTypes.Clear();
|
||||
_cacheActiveRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(EnableGroup),
|
||||
typeof(DisableGroup),
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置文件
|
||||
/// </summary>
|
||||
public static void FixFile()
|
||||
{
|
||||
bool isFixed = Setting.FixConfigError();
|
||||
if (isFixed)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.EnableAddressable = false;
|
||||
Setting.Groups.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
// 实例类相关
|
||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IActiveRule)Activator.CreateInstance(type);
|
||||
_cacheActiveRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IActiveRule)}类型无效:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheAddressRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IAddressRule)Activator.CreateInstance(type);
|
||||
_cacheAddressRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IAddressRule)}类型无效:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IPackRule GetPackRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cachePackRuleInstance.TryGetValue(ruleName, out IPackRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cachePackRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IPackRule)Activator.CreateInstance(type);
|
||||
_cachePackRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IPackRule)}类型无效:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IFilterRule GetFilterRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheFilterRuleInstance.TryGetValue(ruleName, out IFilterRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheFilterRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IFilterRule)Activator.CreateInstance(type);
|
||||
_cacheFilterRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IFilterRule)}类型无效:{ruleName}");
|
||||
}
|
||||
}
|
||||
|
||||
// 可寻址编辑相关
|
||||
public static void ModifyAddressable(bool enableAddressable)
|
||||
{
|
||||
Setting.EnableAddressable = enableAddressable;
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
// 资源分组编辑相关
|
||||
public static void CreateGroup(string groupName)
|
||||
{
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupName;
|
||||
Setting.Groups.Add(group);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveGroup(AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (Setting.Groups.Remove(group))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyGroup(AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集器编辑相关
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
group.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (group.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (group != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public static string GetAllTags()
|
||||
{
|
||||
var allTags = Setting.GetAllTags();
|
||||
return string.Join(";", allTags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,668 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, EditorDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private Button _saveButton;
|
||||
private List<string> _collectorTypeList;
|
||||
private List<string> _activeRuleList;
|
||||
private List<string> _addressRuleList;
|
||||
private List<string> _packRuleList;
|
||||
private List<string> _filterRuleList;
|
||||
private ListView _groupListView;
|
||||
private ScrollView _collectorScrollView;
|
||||
private PopupField<string> _activeRulePopupField;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private TextField _groupNameTxt;
|
||||
private TextField _groupDescTxt;
|
||||
private TextField _groupAssetTagsTxt;
|
||||
private VisualElement _groupContainer;
|
||||
private string _lastModifyGroup = string.Empty;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
Undo.undoRedoPerformed -= RefreshWindow;
|
||||
Undo.undoRedoPerformed += RefreshWindow;
|
||||
|
||||
try
|
||||
{
|
||||
_collectorTypeList = new List<string>()
|
||||
{
|
||||
$"{nameof(ECollectorType.MainAssetCollector)}",
|
||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||
};
|
||||
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
|
||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleCollectorWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 配置修复按钮
|
||||
var fixBtn = root.Q<Button>("FixButton");
|
||||
fixBtn.clicked += FixBtn_clicked;
|
||||
|
||||
// 导入导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_clicked;
|
||||
|
||||
// 配置保存按钮
|
||||
_saveButton = root.Q<Button>("SaveButton");
|
||||
_saveButton.clicked += SaveBtn_clicked;
|
||||
|
||||
// 公共设置相关
|
||||
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
||||
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||
RefreshWindow();
|
||||
});
|
||||
|
||||
// 分组列表相关
|
||||
_groupListView = root.Q<ListView>("GroupListView");
|
||||
_groupListView.makeItem = MakeGroupListViewItem;
|
||||
_groupListView.bindItem = BindGroupListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
||||
#else
|
||||
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 分组添加删除按钮
|
||||
var groupAddContainer = root.Q("GroupAddContainer");
|
||||
{
|
||||
var addBtn = groupAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddGroupBtn_clicked;
|
||||
var removeBtn = groupAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveGroupBtn_clicked;
|
||||
}
|
||||
|
||||
// 分组容器
|
||||
_groupContainer = root.Q("GroupContainer");
|
||||
|
||||
// 分组名称
|
||||
_groupNameTxt = root.Q<TextField>("GroupName");
|
||||
_groupNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGroup.GroupName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 分组备注
|
||||
_groupDescTxt = root.Q<TextField>("GroupDesc");
|
||||
_groupDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGroup.GroupDesc = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 分组的资源标签
|
||||
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags");
|
||||
_groupAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGroup.AssetTags = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 收集列表相关
|
||||
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
|
||||
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
|
||||
_collectorScrollView.viewDataKey = "scrollView";
|
||||
|
||||
// 收集器创建按钮
|
||||
var collectorAddContainer = root.Q("CollectorAddContainer");
|
||||
{
|
||||
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddCollectorBtn_clicked;
|
||||
}
|
||||
|
||||
// 分组激活规则
|
||||
var activeRuleContainer = root.Q("ActiveRuleContainer");
|
||||
{
|
||||
_activeRulePopupField = new PopupField<string>("Active Rule", _activeRuleList, 0);
|
||||
_activeRulePopupField.name = "ActiveRuleMaskField";
|
||||
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
activeRuleContainer.Add(_activeRulePopupField);
|
||||
_activeRulePopupField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGroup.ActiveRuleName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
FillGroupViewData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新窗体
|
||||
RefreshWindow();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 注意:清空所有撤销操作
|
||||
Undo.ClearAll();
|
||||
|
||||
if (AssetBundleCollectorSettingData.IsDirty)
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if (_saveButton != null)
|
||||
{
|
||||
if (AssetBundleCollectorSettingData.IsDirty)
|
||||
{
|
||||
if (_saveButton.enabledSelf == false)
|
||||
_saveButton.SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_saveButton.enabledSelf)
|
||||
_saveButton.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||
_groupContainer.visible = false;
|
||||
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void FixBtn_clicked()
|
||||
{
|
||||
AssetBundleCollectorSettingData.FixFile();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export XML", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetBundleCollectorConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleCollectorConfig)}.xml");
|
||||
}
|
||||
}
|
||||
private void ImportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFilePath("Import XML", "Assets/", "xml");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetBundleCollectorConfig.ImportXmlConfig(resultPath);
|
||||
RefreshWindow();
|
||||
}
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
}
|
||||
|
||||
// 分组列表相关
|
||||
private void FillGroupViewData()
|
||||
{
|
||||
_groupListView.Clear();
|
||||
_groupListView.ClearSelection();
|
||||
_groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups;
|
||||
_groupListView.Rebuild();
|
||||
|
||||
for (int index = 0; index < AssetBundleCollectorSettingData.Setting.Groups.Count; index++)
|
||||
{
|
||||
var group = AssetBundleCollectorSettingData.Setting.Groups[index];
|
||||
if (group.GroupName == _lastModifyGroup)
|
||||
{
|
||||
_groupListView.selectedIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private VisualElement MakeGroupListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.height = 20f;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindGroupListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var group = AssetBundleCollectorSettingData.Setting.Groups[index];
|
||||
|
||||
// Group Name
|
||||
var textField1 = element.Q<Label>("Label1");
|
||||
if (string.IsNullOrEmpty(group.GroupDesc))
|
||||
textField1.text = group.GroupName;
|
||||
else
|
||||
textField1.text = $"{group.GroupName} ({group.GroupDesc})";
|
||||
|
||||
// 激活状态
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
|
||||
bool isActive = activeRule.IsActiveGroup();
|
||||
textField1.SetEnabled(isActive);
|
||||
}
|
||||
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void AddGroupBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddGroup");
|
||||
AssetBundleCollectorSettingData.CreateGroup("Default Group");
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void RemoveGroupBtn_clicked()
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemoveGroup");
|
||||
AssetBundleCollectorSettingData.RemoveGroup(selectGroup);
|
||||
FillGroupViewData();
|
||||
}
|
||||
|
||||
// 收集列表相关
|
||||
private void FillCollectorViewData()
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
{
|
||||
_groupContainer.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_lastModifyGroup = selectGroup.GroupName;
|
||||
_groupContainer.visible = true;
|
||||
_activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName);
|
||||
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
||||
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
||||
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectGroup.Collectors.Count; i++)
|
||||
{
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
BindCollectorListViewItem(element, i);
|
||||
_collectorScrollView.Add(element);
|
||||
}
|
||||
}
|
||||
private VisualElement MakeCollectorListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
VisualElement elementTop = new VisualElement();
|
||||
elementTop.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementTop);
|
||||
|
||||
VisualElement elementBottom = new VisualElement();
|
||||
elementBottom.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementBottom);
|
||||
|
||||
VisualElement elementFoldout = new VisualElement();
|
||||
elementFoldout.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementFoldout);
|
||||
|
||||
VisualElement elementSpace = new VisualElement();
|
||||
elementSpace.style.flexDirection = FlexDirection.Column;
|
||||
element.Add(elementSpace);
|
||||
|
||||
// Top VisualElement
|
||||
{
|
||||
var button = new Button();
|
||||
button.name = "Button1";
|
||||
button.text = "-";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.style.flexGrow = 0f;
|
||||
elementTop.Add(button);
|
||||
}
|
||||
{
|
||||
var objectField = new ObjectField();
|
||||
objectField.name = "ObjectField1";
|
||||
objectField.label = "Collector";
|
||||
objectField.objectType = typeof(UnityEngine.Object);
|
||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
objectField.style.flexGrow = 1f;
|
||||
elementTop.Add(objectField);
|
||||
var label = objectField.Q<Label>();
|
||||
label.style.minWidth = 63;
|
||||
}
|
||||
|
||||
// Bottom VisualElement
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.width = 90;
|
||||
elementBottom.Add(label);
|
||||
}
|
||||
{
|
||||
var popupField = new PopupField<string>(_collectorTypeList, 0);
|
||||
popupField.name = "PopupField0";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 150;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
if (_enableAddressableToogle.value)
|
||||
{
|
||||
var popupField = new PopupField<string>(_addressRuleList, 0);
|
||||
popupField.name = "PopupField1";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 200;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
var popupField = new PopupField<string>(_packRuleList, 0);
|
||||
popupField.name = "PopupField2";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 150;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
var popupField = new PopupField<string>(_filterRuleList, 0);
|
||||
popupField.name = "PopupField3";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 150;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField1";
|
||||
textField.label = "Tags";
|
||||
textField.style.width = 100;
|
||||
textField.style.marginLeft = 20;
|
||||
textField.style.flexGrow = 1;
|
||||
elementBottom.Add(textField);
|
||||
var label = textField.Q<Label>();
|
||||
label.style.minWidth = 40;
|
||||
}
|
||||
|
||||
// Foldout VisualElement
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.width = 90;
|
||||
elementFoldout.Add(label);
|
||||
}
|
||||
{
|
||||
var foldout = new Foldout();
|
||||
foldout.name = "Foldout1";
|
||||
foldout.value = false;
|
||||
foldout.text = "Main Assets";
|
||||
elementFoldout.Add(foldout);
|
||||
}
|
||||
|
||||
// Space VisualElement
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.height = 10;
|
||||
elementSpace.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
var collector = selectGroup.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
||||
// Foldout
|
||||
var foldout = element.Q<Foldout>("Foldout1");
|
||||
foldout.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
if (evt.newValue)
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
else
|
||||
foldout.Clear();
|
||||
});
|
||||
|
||||
// Remove Button
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
removeBtn.clicked += () =>
|
||||
{
|
||||
RemoveCollectorBtn_clicked(collector);
|
||||
};
|
||||
|
||||
// Collector Path
|
||||
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
||||
objectField1.SetValueWithoutNotify(collectObject);
|
||||
objectField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Collector Type
|
||||
var popupField0 = element.Q<PopupField<string>>("PopupField0");
|
||||
popupField0.index = GetCollectorTypeIndex(collector.CollectorType.ToString());
|
||||
popupField0.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(evt.newValue);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Address Rule
|
||||
var popupField1 = element.Q<PopupField<string>>("PopupField1");
|
||||
if (popupField1 != null)
|
||||
{
|
||||
popupField1.index = GetAddressRuleIndex(collector.AddressRuleName);
|
||||
popupField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.AddressRuleName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Pack Rule
|
||||
var popupField2 = element.Q<PopupField<string>>("PopupField2");
|
||||
popupField2.index = GetPackRuleIndex(collector.PackRuleName);
|
||||
popupField2.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.PackRuleName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Filter Rule
|
||||
var popupField3 = element.Q<PopupField<string>>("PopupField3");
|
||||
popupField3.index = GetFilterRuleIndex(collector.FilterRuleName);
|
||||
popupField3.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.FilterRuleName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Tags
|
||||
var textFiled1 = element.Q<TextField>("TextField1");
|
||||
textFiled1.SetValueWithoutNotify(collector.AssetTags);
|
||||
textFiled1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.AssetTags = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
});
|
||||
}
|
||||
private void RefreshFoldout(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
// 清空旧元素
|
||||
foldout.Clear();
|
||||
|
||||
if (collector.IsValid() == false)
|
||||
{
|
||||
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in group : {group.GroupName}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (collector.CollectorType == ECollectorType.MainAssetCollector || collector.CollectorType == ECollectorType.StaticAssetCollector)
|
||||
{
|
||||
List<CollectAssetInfo> collectAssetInfos = null;
|
||||
|
||||
try
|
||||
{
|
||||
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, group);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
|
||||
if (collectAssetInfos != null)
|
||||
{
|
||||
foreach (var collectAssetInfo in collectAssetInfos)
|
||||
{
|
||||
VisualElement elementRow = new VisualElement();
|
||||
elementRow.style.flexDirection = FlexDirection.Row;
|
||||
foldout.Add(elementRow);
|
||||
|
||||
string showInfo = collectAssetInfo.AssetPath;
|
||||
if (_enableAddressableToogle.value)
|
||||
{
|
||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
|
||||
string addressValue = instance.GetAssetAddress(ruleData);
|
||||
showInfo = $"[{addressValue}] {showInfo}";
|
||||
}
|
||||
|
||||
var label = new Label();
|
||||
label.text = showInfo;
|
||||
label.style.width = 300;
|
||||
label.style.marginLeft = 0;
|
||||
label.style.flexGrow = 1;
|
||||
elementRow.Add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddCollector");
|
||||
AssetBundleCollectorSettingData.CreateCollector(selectGroup);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||
{
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemoveCollector");
|
||||
AssetBundleCollectorSettingData.RemoveCollector(selectGroup, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
private int GetCollectorTypeIndex(string typeName)
|
||||
{
|
||||
for (int i = 0; i < _collectorTypeList.Count; i++)
|
||||
{
|
||||
if (_collectorTypeList[i] == typeName)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private int GetAddressRuleIndex(string ruleName)
|
||||
{
|
||||
for (int i = 0; i < _addressRuleList.Count; i++)
|
||||
{
|
||||
if (_addressRuleList[i] == ruleName)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private int GetPackRuleIndex(string ruleName)
|
||||
{
|
||||
for (int i = 0; i < _packRuleList.Count; i++)
|
||||
{
|
||||
if (_packRuleList[i] == ruleName)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private int GetFilterRuleIndex(string ruleName)
|
||||
{
|
||||
for (int i = 0; i < _filterRuleList.Count; i++)
|
||||
{
|
||||
if (_filterRuleList[i] == ruleName)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="LeftContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="RightContainer" style="flex-direction: column; flex-grow: 1;">
|
||||
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="GroupContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,54 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class CollectAssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public List<string> AssetTags { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为原生资源
|
||||
/// </summary>
|
||||
public bool IsRawAsset { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源列表
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
|
||||
|
||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags, bool isRawAsset)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetPath = assetPath;
|
||||
AssetTags = assetTags;
|
||||
IsRawAsset = isRawAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 启用分组
|
||||
/// </summary>
|
||||
public class EnableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用分组
|
||||
/// </summary>
|
||||
public class DisableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 以文件名为定位地址
|
||||
/// </summary>
|
||||
public class AddressByFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以组名+文件名为定位地址
|
||||
/// </summary>
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
return $"{data.GroupName}_{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器名+文件名为定位地址
|
||||
/// </summary>
|
||||
public class AddressByCollectorAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
string collectorName = Path.GetFileNameWithoutExtension(data.CollectPath);
|
||||
return $"{collectorName}_{fileName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集所有资源
|
||||
/// </summary>
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只收集场景
|
||||
/// </summary>
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只收集预制体
|
||||
/// </summary>
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只收集精灵类型的资源
|
||||
/// </summary>
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||
if(mainAssetType == typeof(Texture2D))
|
||||
{
|
||||
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
||||
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只收集着色器变种收集文件
|
||||
/// </summary>
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 以文件路径作为资源包名
|
||||
/// 注意:每个文件独自打资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets/uipanel/shop/image/backgroud.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets/uipanel/shop/view/main.bundle"
|
||||
/// </summary>
|
||||
public class PackSeparately : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
string bundleName = StringUtility.RemoveExtension(data.AssetPath);
|
||||
return EditorTools.GetRegularPath(bundleName).Replace('/', '_');
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以父类文件夹路径作为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets/uipanel/shop/image.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets/uipanel/shop/view.bundle"
|
||||
/// </summary>
|
||||
public class PackDirectory : IPackRule
|
||||
{
|
||||
public static PackDirectory StaticPackRule = new PackDirectory();
|
||||
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||
return EditorTools.GetRegularPath(bundleName).Replace('/', '_');
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器路径下顶级文件夹为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets/uipanel/shop.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets/uipanel/shop.bundle"
|
||||
/// </summary>
|
||||
public class PackTopDirectory : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
||||
assetPath = assetPath.TrimStart('/');
|
||||
string[] splits = assetPath.Split('/');
|
||||
if (splits.Length > 0)
|
||||
{
|
||||
if (Path.HasExtension(splits[0]))
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
||||
return EditorTools.GetRegularPath(bundleName).Replace('/', '_');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器路径作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
public class PackCollector : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
string bundleName = StringUtility.RemoveExtension(data.CollectPath);
|
||||
return EditorTools.GetRegularPath(bundleName).Replace('/', '_');
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
return data.GroupName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件打包模式
|
||||
/// 注意:原生文件打包支持:图片,音频,视频,文本
|
||||
/// </summary>
|
||||
public class PackRawFile : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
string extension = StringUtility.RemoveFirstChar(Path.GetExtension(data.AssetPath));
|
||||
if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() ||
|
||||
extension == EAssetFileExtension.mat.ToString() || extension == EAssetFileExtension.controller.ToString() ||
|
||||
extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.anim.ToString() ||
|
||||
extension == EAssetFileExtension.shader.ToString())
|
||||
{
|
||||
throw new Exception($"{nameof(PackRawFile)} is not support file estension : {extension}");
|
||||
}
|
||||
|
||||
// 注意:原生文件只支持无依赖关系的资源
|
||||
string[] depends = AssetDatabase.GetDependencies(data.AssetPath, true);
|
||||
if (depends.Length != 1)
|
||||
throw new Exception($"{nameof(PackRawFile)} is not support estension : {extension}");
|
||||
|
||||
string bundleName = StringUtility.RemoveExtension(data.AssetPath);
|
||||
return EditorTools.GetRegularPath(bundleName).Replace('/', '_');
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 着色器变种收集文件
|
||||
/// </summary>
|
||||
public class PackShaderVariants : IPackRule
|
||||
{
|
||||
public string GetBundleName(PackRuleData data)
|
||||
{
|
||||
return YooAssetSettings.UnityShadersBundleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public enum ECollectorType
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
||||
/// </summary>
|
||||
MainAssetCollector,
|
||||
|
||||
/// <summary>
|
||||
/// 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||
/// </summary>
|
||||
StaticAssetCollector,
|
||||
|
||||
/// <summary>
|
||||
/// 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||
/// 注意:如果依赖资源对象没有被主资源对象引用,则不参与打包构建。
|
||||
/// </summary>
|
||||
DependAssetCollector,
|
||||
|
||||
/// <summary>
|
||||
/// 该收集器类型不能被设置
|
||||
/// </summary>
|
||||
None,
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源分组激活规则接口
|
||||
/// </summary>
|
||||
public interface IActiveRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否激活分组
|
||||
/// </summary>
|
||||
bool IsActiveGroup();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct AddressRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
|
||||
public AddressRuleData(string assetPath, string collectPath, string groupName)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 寻址规则接口
|
||||
/// </summary>
|
||||
public interface IAddressRule
|
||||
{
|
||||
string GetAssetAddress(AddressRuleData data);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct FilterRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
|
||||
public FilterRuleData(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源过滤规则接口
|
||||
/// </summary>
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为收集资源
|
||||
/// </summary>
|
||||
/// <returns>如果收集该资源返回TRUE</returns>
|
||||
bool IsCollectAsset(FilterRuleData data);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct PackRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
|
||||
public PackRuleData(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = string.Empty;
|
||||
GroupName = string.Empty;
|
||||
}
|
||||
public PackRuleData(string assetPath, string collectPath, string groupName)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源打包规则接口
|
||||
/// </summary>
|
||||
public interface IPackRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取资源打包所属的资源包名称
|
||||
/// </summary>
|
||||
string GetBundleName(PackRuleData data);
|
||||
}
|
||||
}
|
||||
@@ -1,298 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEditor.Networking.PlayerConnection;
|
||||
using UnityEngine.Networking.PlayerConnection;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleDebuggerWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, EditorDefine.DockedWindowTypes);
|
||||
wnd.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视图模式
|
||||
/// </summary>
|
||||
private enum EViewMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存视图
|
||||
/// </summary>
|
||||
MemoryView,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象视图
|
||||
/// </summary>
|
||||
AssetView,
|
||||
|
||||
/// <summary>
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
BundleView,
|
||||
}
|
||||
|
||||
|
||||
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
||||
|
||||
private Label _playerName;
|
||||
private ToolbarMenu _viewModeMenu;
|
||||
private SliderInt _frameSlider;
|
||||
private DebuggerAssetListViewer _assetListViewer;
|
||||
private DebuggerBundleListViewer _bundleListViewer;
|
||||
|
||||
private EViewMode _viewMode;
|
||||
private string _searchKeyWord;
|
||||
private DebugReport _currentReport;
|
||||
private RemotePlayerSession _currentPlayerSession;
|
||||
private int _rangeIndex = 0;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 采样按钮
|
||||
var sampleBtn = root.Q<Button>("SampleButton");
|
||||
sampleBtn.clicked += SampleBtn_onClick;
|
||||
|
||||
// 用户列表菜单
|
||||
_playerName = root.Q<Label>("PlayerName");
|
||||
_playerName.text = "Editor player";
|
||||
|
||||
// 视口模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
|
||||
// 搜索栏
|
||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 帧数相关
|
||||
{
|
||||
_frameSlider = root.Q<SliderInt>("FrameSlider");
|
||||
_frameSlider.label = "Frame:";
|
||||
_frameSlider.highValue = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
OnFrameSliderChange(evt.newValue);
|
||||
});
|
||||
|
||||
var frameLast = root.Q<ToolbarButton>("FrameLast");
|
||||
frameLast.clicked += OnFrameLast_clicked;
|
||||
|
||||
var frameNext = root.Q<ToolbarButton>("FrameNext");
|
||||
frameNext.clicked += OnFrameNext_clicked;
|
||||
|
||||
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||
frameClear.clicked += OnFrameClear_clicked;
|
||||
}
|
||||
|
||||
// 加载视图
|
||||
_assetListViewer = new DebuggerAssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
|
||||
// 加载视图
|
||||
_bundleListViewer = new DebuggerBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.AssetView;
|
||||
_assetListViewer.AttachParent(root);
|
||||
|
||||
// 远程调试
|
||||
EditorConnection.instance.Initialize();
|
||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 远程调试
|
||||
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
_playerSessions.Clear();
|
||||
}
|
||||
|
||||
private void OnHandleConnectionEvent(int playerId)
|
||||
{
|
||||
Debug.Log($"Game player connection : {playerId}");
|
||||
_playerName.text = $"Connected player : {playerId}";
|
||||
}
|
||||
private void OnHandleDisconnectionEvent(int playerId)
|
||||
{
|
||||
Debug.Log($"Game player disconnection : {playerId}");
|
||||
_playerName.text = $"Disconneced player : {playerId}";
|
||||
}
|
||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||
{
|
||||
var debugReport = DebugReport.Deserialize(args.data);
|
||||
OnHandleDebugReport(args.playerId, debugReport);
|
||||
}
|
||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||
{
|
||||
Debug.Log($"Handle player {playerId} debug report !");
|
||||
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||
_currentPlayerSession.AddDebugReport(debugReport);
|
||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
||||
UpdateFrameView(_currentPlayerSession);
|
||||
}
|
||||
private void OnFrameSliderChange(int sliderValue)
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameLast_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameNext_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameClear_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_frameSlider.label = $"Frame:";
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.highValue = 0;
|
||||
_currentPlayerSession.ClearDebugReport();
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
}
|
||||
}
|
||||
|
||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||
{
|
||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||
{
|
||||
return session;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||
_playerSessions.Add(playerId, newSession);
|
||||
return newSession;
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession)
|
||||
{
|
||||
if (playerSession != null)
|
||||
{
|
||||
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
||||
{
|
||||
if (playerSession == null)
|
||||
return;
|
||||
|
||||
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
||||
if (debugReport != null)
|
||||
{
|
||||
_currentReport = debugReport;
|
||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
|
||||
private void SampleBtn_onClick()
|
||||
{
|
||||
// 发送采集数据的命令
|
||||
RemoteCommand command = new RemoteCommand();
|
||||
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||
command.CommandParam = string.Empty;
|
||||
byte[] data = RemoteCommand.Serialize(command);
|
||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_currentReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||
{
|
||||
var viewMode = (EViewMode)action.userData;
|
||||
if (_viewMode != viewMode)
|
||||
{
|
||||
_viewMode = viewMode;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = viewMode.ToString();
|
||||
|
||||
if (viewMode == EViewMode.AssetView)
|
||||
{
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
}
|
||||
else if (viewMode == EViewMode.BundleView)
|
||||
{
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(viewMode.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||
{
|
||||
var viewMode = (EViewMode)action.userData;
|
||||
if (_viewMode == viewMode)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="TopToolbar" style="display: flex;">
|
||||
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" />
|
||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
</uie:Toolbar>
|
||||
<uie:Toolbar name="FrameToolbar">
|
||||
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />
|
||||
<uie:ToolbarButton text=" << " display-tooltip-when-elided="true" name="FrameLast" />
|
||||
<uie:ToolbarButton text=" >> " display-tooltip-when-elided="true" name="FrameNext" />
|
||||
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
|
||||
</uie:Toolbar>
|
||||
</ui:UXML>
|
||||
@@ -1,93 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class RemotePlayerSession
|
||||
{
|
||||
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
||||
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public int PlayerId { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 保存的报告最大数量
|
||||
/// </summary>
|
||||
public int MaxReportCount { private set; get; }
|
||||
|
||||
public int MinRangeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int MaxRangeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = _reportList.Count - 1;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||
{
|
||||
PlayerId = playerId;
|
||||
MaxReportCount = maxReportCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存数据
|
||||
/// </summary>
|
||||
public void ClearDebugReport()
|
||||
{
|
||||
_reportList.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个调试报告
|
||||
/// </summary>
|
||||
public void AddDebugReport(DebugReport report)
|
||||
{
|
||||
if (report == null)
|
||||
Debug.LogWarning("Invalid debug report data !");
|
||||
|
||||
if (_reportList.Count >= MaxReportCount)
|
||||
_reportList.RemoveAt(0);
|
||||
_reportList.Add(report);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取调试报告
|
||||
/// </summary>
|
||||
public DebugReport GetDebugReport(int rangeIndex)
|
||||
{
|
||||
if (_reportList.Count == 0)
|
||||
return null;
|
||||
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
||||
return null;
|
||||
return _reportList[rangeIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 规范索引值
|
||||
/// </summary>
|
||||
public int ClampRangeIndex(int rangeIndex)
|
||||
{
|
||||
if (rangeIndex < 0)
|
||||
return 0;
|
||||
|
||||
if (rangeIndex > MaxRangeValue)
|
||||
return MaxRangeValue;
|
||||
|
||||
return rangeIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerAssetListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private DebugReport _debugReport;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource.Clear();
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
var result = new List<DebugProviderInfo>(debugReport.ProviderInfos.Count);
|
||||
foreach (var providerInfo in debugReport.ProviderInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(providerInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 资源列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||
var providerInfo = sourceData[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Ref Count
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == (int)ProviderBase.EStatus.Fail)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
label5.style.color = textColor;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
||||
FillDependListView(providerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 依赖列表相关
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
||||
DebugBundleInfo bundleInfo = bundles[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
}
|
||||
private void FillDependListView(DebugProviderInfo providerInfo)
|
||||
{
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = providerInfo.BundleInfos;
|
||||
_dependListView.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="TopBar3" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar4" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,284 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerBundleListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _bundleListView;
|
||||
private ListView _usingListView;
|
||||
private DebugReport _debugReport;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeAssetListViewItem;
|
||||
_bundleListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 使用列表
|
||||
_usingListView = _root.Q<ListView>("BottomListView");
|
||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||
_usingListView.bindItem = BindIncludeListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource.Clear();
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
Dictionary<string, DebugBundleInfo> result = new Dictionary<string, DebugBundleInfo>(debugReport.ProviderInfos.Count);
|
||||
foreach (var providerInfo in debugReport.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.BundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
if (result.ContainsKey(bundleInfo.BundleName) == false)
|
||||
result.Add(bundleInfo.BundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (bundleInfo.Status == (int)AssetBundleLoaderBase.EStatus.Failed)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
label4.style.color = textColor;
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||
FillUsingListView(bundleInfo.BundleName);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
||||
DebugProviderInfo providerInfo = providers[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Ref Count
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
}
|
||||
private void FillUsingListView(string bundleName)
|
||||
{
|
||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||
foreach (var providerInfo in _debugReport.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.BundleName == bundleName)
|
||||
{
|
||||
source.Add(providerInfo);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
_usingListView.itemsSource = source;
|
||||
_usingListView.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Using Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="BottomBar2" style="width: 150px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="BottomBar3" style="width: 150px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar4" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,46 +0,0 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleInspector
|
||||
{
|
||||
[CustomEditor(typeof(AssetBundle))]
|
||||
internal class AssetBundleEditor : UnityEditor.Editor
|
||||
{
|
||||
internal bool pathFoldout = false;
|
||||
internal bool advancedFoldout = false;
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetBundle bundle = target as AssetBundle;
|
||||
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
|
||||
leftStyle.alignment = TextAnchor.UpperLeft;
|
||||
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
|
||||
|
||||
var assetNames = bundle.GetAllAssetNames();
|
||||
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
|
||||
if (pathFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
foreach (var asset in assetNames)
|
||||
EditorGUILayout.LabelField(asset);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
|
||||
}
|
||||
|
||||
if (advancedFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
base.OnInspectorGUI();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleRecorder
|
||||
{
|
||||
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
|
||||
|
||||
/// <summary>
|
||||
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
|
||||
/// </summary>
|
||||
public static AssetBundle GetAssetBundle(string filePath)
|
||||
{
|
||||
// 如果文件不存在
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
Debug.LogWarning($"Not found asset bundle file : {filePath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 验证文件有效性(可能文件被加密)
|
||||
byte[] fileData = File.ReadAllBytes(filePath);
|
||||
if (EditorTools.CheckBundleFileValid(fileData) == false)
|
||||
{
|
||||
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
|
||||
{
|
||||
return bundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
||||
if(newBundle != null)
|
||||
{
|
||||
string[] assetNames = newBundle.GetAllAssetNames();
|
||||
foreach (string name in assetNames)
|
||||
{
|
||||
newBundle.LoadAsset(name);
|
||||
}
|
||||
_loadedAssetBundles.Add(filePath, newBundle);
|
||||
}
|
||||
return newBundle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载所有已经加载的AssetBundle文件
|
||||
/// </summary>
|
||||
public static void UnloadAll()
|
||||
{
|
||||
foreach(var valuePair in _loadedAssetBundles)
|
||||
{
|
||||
if (valuePair.Value != null)
|
||||
valuePair.Value.Unload(true);
|
||||
}
|
||||
_loadedAssetBundles.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleReporterWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, EditorDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视图模式
|
||||
/// </summary>
|
||||
private enum EViewMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 概览视图
|
||||
/// </summary>
|
||||
Summary,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象视图
|
||||
/// </summary>
|
||||
AssetView,
|
||||
|
||||
/// <summary>
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
BundleView,
|
||||
}
|
||||
|
||||
private ToolbarMenu _viewModeMenu;
|
||||
private ReporterSummaryViewer _summaryViewer;
|
||||
private ReporterAssetListViewer _assetListViewer;
|
||||
private ReporterBundleListViewer _bundleListViewer;
|
||||
|
||||
private EViewMode _viewMode;
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleReporterWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入按钮
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_onClick;
|
||||
|
||||
// 视图模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
||||
|
||||
// 搜索栏
|
||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 加载视图
|
||||
_summaryViewer = new ReporterSummaryViewer();
|
||||
_summaryViewer.InitViewer();
|
||||
|
||||
// 加载视图
|
||||
_assetListViewer = new ReporterAssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
|
||||
// 加载视图
|
||||
_bundleListViewer = new ReporterBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.Summary;
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
AssetBundleRecorder.UnloadAll();
|
||||
}
|
||||
|
||||
private void ImportBtn_onClick()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "json");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
_reportFilePath = selectFilePath;
|
||||
string jsonData = FileUtility.ReadFile(_reportFilePath);
|
||||
_buildReport = BuildReport.Deserialize(jsonData);
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
_summaryViewer.FillViewData(_buildReport);
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_buildReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.Summary)
|
||||
{
|
||||
_viewMode = EViewMode.Summary;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.AssetView)
|
||||
{
|
||||
_viewMode = EViewMode.AssetView;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.BundleView)
|
||||
{
|
||||
_viewMode = EViewMode.BundleView;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.Summary)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.AssetView)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.BundleView)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex;">
|
||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="width: 300px; flex-grow: 1;" />
|
||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
</ui:UXML>
|
||||
@@ -1,321 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ReporterAssetListViewer
|
||||
{
|
||||
private enum ESortMode
|
||||
{
|
||||
AssetPath,
|
||||
BundleName
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ToolbarButton _topBar1;
|
||||
private ToolbarButton _topBar2;
|
||||
private ToolbarButton _bottomBar1;
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _searchKeyWord;
|
||||
private ESortMode _sortMode = ESortMode.AssetPath;
|
||||
private bool _descendingSort = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string searchKeyWord)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_searchKeyWord = searchKeyWord;
|
||||
RefreshView();
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterAndSortViewItems();
|
||||
_assetListView.Rebuild();
|
||||
RefreshSortingSymbol();
|
||||
}
|
||||
private List<ReportAssetInfo> FilterAndSortViewItems()
|
||||
{
|
||||
List<ReportAssetInfo> result = new List<ReportAssetInfo>(_buildReport.AssetInfos.Count);
|
||||
|
||||
// 过滤列表
|
||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
||||
{
|
||||
if (assetInfo.AssetPath.Contains(_searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(assetInfo);
|
||||
}
|
||||
|
||||
// 排序列表
|
||||
if (_sortMode == ESortMode.AssetPath)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.AssetPath).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.AssetPath).ToList();
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.MainBundleName).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.MainBundleName).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
private void RefreshSortingSymbol()
|
||||
{
|
||||
// 刷新符号
|
||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
||||
_topBar2.text = "Main Bundle";
|
||||
|
||||
if (_sortMode == ESortMode.AssetPath)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↓";
|
||||
else
|
||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↑";
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar2.text = "Main Bundle ↓";
|
||||
else
|
||||
_topBar2.text = "Main Bundle ↑";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 资源列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<ReportAssetInfo>;
|
||||
var assetInfo = sourceData[index];
|
||||
var bundleInfo = _buildReport.GetBundleInfo(assetInfo.MainBundleName);
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = assetInfo.AssetPath;
|
||||
|
||||
// Main Bundle
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = bundleInfo.BundleName;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
ReportAssetInfo assetInfo = item as ReportAssetInfo;
|
||||
FillDependListView(assetInfo);
|
||||
}
|
||||
}
|
||||
private void TopBar1_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.AssetPath)
|
||||
{
|
||||
_sortMode = ESortMode.AssetPath;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
private void TopBar2_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleName)
|
||||
{
|
||||
_sortMode = ESortMode.BundleName;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
// 依赖列表相关
|
||||
private void FillDependListView(ReportAssetInfo assetInfo)
|
||||
{
|
||||
List<ReportBundleInfo> bundles = new List<ReportBundleInfo>();
|
||||
var mainBundle = _buildReport.GetBundleInfo(assetInfo.MainBundleName);
|
||||
bundles.Add(mainBundle);
|
||||
foreach (string dependBundleName in assetInfo.DependBundles)
|
||||
{
|
||||
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
|
||||
bundles.Add(dependBundle);
|
||||
}
|
||||
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = bundles;
|
||||
_dependListView.Rebuild();
|
||||
_bottomBar1.text = $"Depend Bundles ({bundles.Count})";
|
||||
}
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<ReportBundleInfo> bundles = _dependListView.itemsSource as List<ReportBundleInfo>;
|
||||
ReportBundleInfo bundleInfo = bundles[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = EditorUtility.FormatBytes(bundleInfo.FileSize);
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.FileHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar2" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,388 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ReporterBundleListViewer
|
||||
{
|
||||
private enum ESortMode
|
||||
{
|
||||
BundleName,
|
||||
BundleSize,
|
||||
BundleTags
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ToolbarButton _topBar1;
|
||||
private ToolbarButton _topBar2;
|
||||
private ToolbarButton _topBar3;
|
||||
private ToolbarButton _topBar4;
|
||||
private ToolbarButton _bottomBar1;
|
||||
private ListView _bundleListView;
|
||||
private ListView _includeListView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
private ESortMode _sortMode = ESortMode.BundleName;
|
||||
private bool _descendingSort = false;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
||||
_topBar4 = _root.Q<ToolbarButton>("TopBar4");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
_topBar3.clicked += TopBar3_clicked;
|
||||
_topBar4.clicked += TopBar4_clicked;
|
||||
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 包含列表
|
||||
_includeListView = _root.Q<ListView>("BottomListView");
|
||||
_includeListView.makeItem = MakeIncludeListViewItem;
|
||||
_includeListView.bindItem = BindIncludeListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_reportFilePath = reprotFilePath;
|
||||
_searchKeyWord = searchKeyWord;
|
||||
RefreshView();
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterAndSortViewItems();
|
||||
_bundleListView.Rebuild();
|
||||
RefreshSortingSymbol();
|
||||
}
|
||||
private List<ReportBundleInfo> FilterAndSortViewItems()
|
||||
{
|
||||
List<ReportBundleInfo> result = new List<ReportBundleInfo>(_buildReport.BundleInfos.Count);
|
||||
|
||||
// 过滤列表
|
||||
foreach (var bundleInfo in _buildReport.BundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(_searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
|
||||
// 排序列表
|
||||
if (_sortMode == ESortMode.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.BundleName).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.BundleName).ToList();
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleSize)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.FileSize).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.FileSize).ToList();
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleTags)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.GetTagsString()).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.GetTagsString()).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
private void RefreshSortingSymbol()
|
||||
{
|
||||
// 刷新符号
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
||||
_topBar2.text = "Size";
|
||||
_topBar3.text = "Hash";
|
||||
_topBar4.text = "Tags";
|
||||
|
||||
if (_sortMode == ESortMode.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count}) ↓";
|
||||
else
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count}) ↑";
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleSize)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar2.text = "Size ↓";
|
||||
else
|
||||
_topBar2.text = "Size ↑";
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleTags)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar4.text = "Tags ↓";
|
||||
else
|
||||
_topBar4.text = "Tags ↑";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 80;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<ReportBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = EditorUtility.FormatBytes(bundleInfo.FileSize);
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.FileHash;
|
||||
|
||||
// Tags
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = bundleInfo.GetTagsString();
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
ReportBundleInfo bundleInfo = item as ReportBundleInfo;
|
||||
FillIncludeListView(bundleInfo);
|
||||
ShowAssetBundleInspector(bundleInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void ShowAssetBundleInspector(ReportBundleInfo bundleInfo)
|
||||
{
|
||||
if (bundleInfo.IsRawFile())
|
||||
return;
|
||||
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{bundleInfo.FileName}";
|
||||
if (File.Exists(filePath))
|
||||
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||
else
|
||||
Selection.activeObject = null;
|
||||
}
|
||||
private void TopBar1_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleName)
|
||||
{
|
||||
_sortMode = ESortMode.BundleName;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
private void TopBar2_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleSize)
|
||||
{
|
||||
_sortMode = ESortMode.BundleSize;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
private void TopBar3_clicked()
|
||||
{
|
||||
}
|
||||
private void TopBar4_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleTags)
|
||||
{
|
||||
_sortMode = ESortMode.BundleTags;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private void FillIncludeListView(ReportBundleInfo bundleInfo)
|
||||
{
|
||||
List<ReportAssetInfo> containsList = new List<ReportAssetInfo>();
|
||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||
{
|
||||
if (assetInfo.MainBundleName == bundleInfo.BundleName)
|
||||
containsList.Add(assetInfo);
|
||||
}
|
||||
|
||||
_includeListView.Clear();
|
||||
_includeListView.ClearSelection();
|
||||
_includeListView.itemsSource = containsList;
|
||||
_includeListView.Rebuild();
|
||||
_bottomBar1.text = $"Include Assets ({containsList.Count})";
|
||||
}
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<ReportAssetInfo> containsList = _includeListView.itemsSource as List<ReportAssetInfo>;
|
||||
ReportAssetInfo assetInfo = containsList[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = assetInfo.AssetPath;
|
||||
|
||||
// GUID
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = assetInfo.AssetGUID;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="Viewer" style="flex-grow: 1; display: flex;">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar4" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Include Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="GUID" display-tooltip-when-elided="true" name="BottomBar2" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,172 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ReporterSummaryViewer
|
||||
{
|
||||
private class ItemWrapper
|
||||
{
|
||||
public string Title { private set; get; }
|
||||
public string Value { private set; get; }
|
||||
|
||||
public ItemWrapper(string title, string value)
|
||||
{
|
||||
Title = title;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _listView;
|
||||
private BuildReport _buildReport;
|
||||
private readonly List<ItemWrapper> _items = new List<ItemWrapper>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 概述列表
|
||||
_listView = _root.Q<ListView>("ListView");
|
||||
_listView.makeItem = MakeListViewItem;
|
||||
_listView.bindItem = BindListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
|
||||
_items.Clear();
|
||||
|
||||
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
||||
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
||||
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildDate));
|
||||
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
||||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
|
||||
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
||||
|
||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("拷贝内置资源文件", $"{buildReport.Summary.CopyBuildinTagFiles}"));
|
||||
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
||||
_items.Add(new ItemWrapper("OutputNameStyle", $"{buildReport.Summary.OutputNameStyle}"));
|
||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
||||
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("构建结果", string.Empty));
|
||||
_items.Add(new ItemWrapper("构建文件总数", $"{buildReport.Summary.AssetFileTotalCount}"));
|
||||
_items.Add(new ItemWrapper("主资源总数", $"{buildReport.Summary.MainAssetTotalCount}"));
|
||||
_items.Add(new ItemWrapper("资源包总数", $"{buildReport.Summary.AllBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("资源包总大小", ConvertSize(buildReport.Summary.AllBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("内置资源包总数", $"{buildReport.Summary.BuildinBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("内置资源包总大小", ConvertSize(buildReport.Summary.BuildinBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("加密资源包总数", $"{buildReport.Summary.EncryptedBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("加密资源包总大小", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("原生资源包总数", $"{buildReport.Summary.RawBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("原生资源包总大小", ConvertSize(buildReport.Summary.RawBundleTotalSize)));
|
||||
|
||||
_listView.Clear();
|
||||
_listView.ClearSelection();
|
||||
_listView.itemsSource = _items;
|
||||
_listView.Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
// 列表相关
|
||||
private VisualElement MakeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 200;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var itemWrapper = _items[index];
|
||||
|
||||
// Title
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = itemWrapper.Title;
|
||||
|
||||
// Value
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = itemWrapper.Value;
|
||||
}
|
||||
|
||||
private string ConvertSize(long size)
|
||||
{
|
||||
if (size == 0)
|
||||
return "0";
|
||||
if (size < 1024)
|
||||
return $"{size} Bytes";
|
||||
else if (size < 1024 * 1024)
|
||||
return $"{(int)(size / 1024)} KB";
|
||||
else
|
||||
return $"{(int)(size / (1024 * 1024))} MB";
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="概览" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="参数" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
157
Assets/YooAsset/Editor/BundleBuilder/BuildAssetInfo.cs
Normal file
157
Assets/YooAsset/Editor/BundleBuilder/BuildAssetInfo.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建资源信息,记录单个资源在构建过程中的元数据
|
||||
/// </summary>
|
||||
public class BuildAssetInfo
|
||||
{
|
||||
private bool _isAddAssetTags = false;
|
||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||
private readonly List<string> _assetTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包完整名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源信息
|
||||
/// </summary>
|
||||
public EditorAssetInfo AssetInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public IReadOnlyList<string> AssetTags
|
||||
{
|
||||
get { return _assetTags; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的所有资源
|
||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||
/// </summary>
|
||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建实例
|
||||
/// </summary>
|
||||
/// <param name="collectorType">收集器类型</param>
|
||||
/// <param name="bundleName">所属的资源包名称</param>
|
||||
/// <param name="address">可寻址地址</param>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, EditorAssetInfo assetInfo)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetInfo = assetInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建零依赖或冗余的实例
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public BuildAssetInfo(EditorAssetInfo assetInfo)
|
||||
{
|
||||
CollectorType = ECollectorType.None;
|
||||
BundleName = string.Empty;
|
||||
Address = string.Empty;
|
||||
AssetInfo = assetInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置所有依赖的资源
|
||||
/// </summary>
|
||||
/// <param name="dependAssetInfos">依赖资源信息列表</param>
|
||||
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
||||
{
|
||||
if (AllDependAssetInfos != null)
|
||||
throw new YooInternalException("Should never get here.");
|
||||
|
||||
AllDependAssetInfos = dependAssetInfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置资源包名称
|
||||
/// </summary>
|
||||
/// <param name="bundleName">资源包完整名称</param>
|
||||
public void SetBundleName(string bundleName)
|
||||
{
|
||||
if (HasBundleName())
|
||||
throw new YooInternalException("Should never get here.");
|
||||
|
||||
BundleName = bundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源的分类标签
|
||||
/// </summary>
|
||||
/// <remarks>仅在首次调用时生效,不可重复设置。</remarks>
|
||||
/// <param name="tags">资源分类标签列表</param>
|
||||
public void AddAssetTags(List<string> tags)
|
||||
{
|
||||
if (_isAddAssetTags)
|
||||
throw new YooInternalException("Should never get here.");
|
||||
_isAddAssetTags = true;
|
||||
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (_assetTags.Contains(tag) == false)
|
||||
{
|
||||
_assetTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加关联的资源包名称
|
||||
/// </summary>
|
||||
/// <param name="bundleName">引用该资源的资源包名称</param>
|
||||
public void AddReferenceBundleName(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new YooInternalException("Should never get here.");
|
||||
|
||||
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||
_referenceBundleNames.Add(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否已分配资源包名称
|
||||
/// </summary>
|
||||
/// <returns>已分配返回 true,否则返回 false</returns>
|
||||
public bool HasBundleName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(BundleName))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取关联资源包的数量
|
||||
/// </summary>
|
||||
/// <returns>引用该资源的资源包数量</returns>
|
||||
public int GetReferenceBundleCount()
|
||||
{
|
||||
return _referenceBundleNames.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
234
Assets/YooAsset/Editor/BundleBuilder/BuildBundleInfo.cs
Normal file
234
Assets/YooAsset/Editor/BundleBuilder/BuildBundleInfo.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建资源包信息,记录单个资源包在构建过程中的完整元数据
|
||||
/// </summary>
|
||||
public class BuildBundleInfo
|
||||
{
|
||||
#region 补丁文件的关键信息
|
||||
/// <summary>
|
||||
/// Unity引擎生成的哈希值(构建内容的哈希值)
|
||||
/// </summary>
|
||||
public string PackageUnityHash { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Unity引擎生成的CRC
|
||||
/// </summary>
|
||||
public uint PackageUnityCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileHash { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件 CRC 校验值
|
||||
/// </summary>
|
||||
public uint PackageFileCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小(字节)
|
||||
/// </summary>
|
||||
public long PackageFileSize { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建输出的文件路径
|
||||
/// </summary>
|
||||
public string BuildOutputFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 补丁包的源文件路径
|
||||
/// </summary>
|
||||
public string PackageSourceFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 补丁包的目标文件路径
|
||||
/// </summary>
|
||||
public string PackageDestFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加密生成文件的路径
|
||||
/// 注意:如果未加密该路径为空
|
||||
/// </summary>
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
private readonly Dictionary<string, BuildAssetInfo> _packAssetDictionary = new Dictionary<string, BuildAssetInfo>(100);
|
||||
private readonly List<BuildAssetInfo> _allPackAssets = new List<BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public IReadOnlyList<BuildAssetInfo> AllPackAssets
|
||||
{
|
||||
get { return _allPackAssets; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已加密
|
||||
/// </summary>
|
||||
public bool Encrypted { set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建实例
|
||||
/// </summary>
|
||||
/// <param name="bundleName">资源包名称</param>
|
||||
public BuildBundleInfo(string bundleName)
|
||||
{
|
||||
BundleName = bundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
/// <param name="buildAsset">待打包的资源信息</param>
|
||||
public void PackAsset(BuildAssetInfo buildAsset)
|
||||
{
|
||||
string assetPath = buildAsset.AssetInfo.AssetPath;
|
||||
if (_packAssetDictionary.ContainsKey(assetPath))
|
||||
throw new YooInternalException($"Should never get here. Asset already exists: '{assetPath}'.");
|
||||
|
||||
_packAssetDictionary.Add(assetPath, buildAsset);
|
||||
_allPackAssets.Add(buildAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含指定资源
|
||||
/// </summary>
|
||||
/// <param name="assetPath">资源路径</param>
|
||||
/// <returns>包含返回 true,否则返回 false</returns>
|
||||
public bool IsContainsPackAsset(string assetPath)
|
||||
{
|
||||
return _packAssetDictionary.ContainsKey(assetPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
/// <returns>所有打包资源的路径数组</returns>
|
||||
public string[] GetAllPackAssetPaths()
|
||||
{
|
||||
List<string> results = new List<string>(AllPackAssets.Count);
|
||||
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||
{
|
||||
var packAsset = AllPackAssets[i];
|
||||
results.Add(packAsset.AssetInfo.AssetPath);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源可寻址列表
|
||||
/// </summary>
|
||||
/// <returns>所有打包资源的可寻址地址数组</returns>
|
||||
public string[] GetAllPackAssetAddress()
|
||||
{
|
||||
List<string> results = new List<string>(AllPackAssets.Count);
|
||||
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||
{
|
||||
var packAsset = AllPackAssets[i];
|
||||
results.Add(packAsset.Address);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的主资源信息
|
||||
/// </summary>
|
||||
/// <param name="assetPath">资源路径</param>
|
||||
/// <returns>对应的构建资源信息</returns>
|
||||
public BuildAssetInfo GetPackAssetInfo(string assetPath)
|
||||
{
|
||||
if (_packAssetDictionary.TryGetValue(assetPath, out BuildAssetInfo value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"Could not find pack asset info '{assetPath}' in bundle: '{BundleName}'.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包内部所有资产
|
||||
/// </summary>
|
||||
/// <returns>资源包包含的所有资源信息列表</returns>
|
||||
public List<EditorAssetInfo> GetBundleContents()
|
||||
{
|
||||
Dictionary<string, EditorAssetInfo> result = new Dictionary<string, EditorAssetInfo>(AllPackAssets.Count);
|
||||
foreach (var packAsset in AllPackAssets)
|
||||
{
|
||||
result.Add(packAsset.AssetInfo.AssetPath, packAsset.AssetInfo);
|
||||
if (packAsset.AllDependAssetInfos != null)
|
||||
{
|
||||
foreach (var dependAssetInfo in packAsset.AllDependAssetInfos)
|
||||
{
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
string dependAssetPath = dependAssetInfo.AssetInfo.AssetPath;
|
||||
if (result.ContainsKey(dependAssetPath) == false)
|
||||
result.Add(dependAssetPath, dependAssetInfo.AssetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建 Unity 构建管线所需的数据
|
||||
/// </summary>
|
||||
/// <param name="replaceAssetPathWithAddress">是否使用可寻址地址替代资源路径</param>
|
||||
/// <returns>构建管线所需的 AssetBundleBuild 数据</returns>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild(bool replaceAssetPathWithAddress)
|
||||
{
|
||||
// 注意:我们不再支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllPackAssetPaths();
|
||||
if (replaceAssetPathWithAddress)
|
||||
build.addressableNames = GetAllPackAssetAddress();
|
||||
return build;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有写入补丁清单的资源
|
||||
/// </summary>
|
||||
/// <returns>需要写入清单的主资源信息数组</returns>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建PackageBundle类
|
||||
/// </summary>
|
||||
internal PackageBundle CreatePackageBundle()
|
||||
{
|
||||
PackageBundle packageBundle = new PackageBundle();
|
||||
packageBundle.BundleName = BundleName;
|
||||
packageBundle.UnityCrc = PackageUnityCRC;
|
||||
packageBundle.FileHash = PackageFileHash;
|
||||
packageBundle.FileCrc = PackageFileCRC;
|
||||
packageBundle.FileSize = PackageFileSize;
|
||||
packageBundle.IsEncrypted = Encrypted;
|
||||
packageBundle.DependentBundleIDs = Array.Empty<int>();
|
||||
return packageBundle;
|
||||
}
|
||||
}
|
||||
}
|
||||
148
Assets/YooAsset/Editor/BundleBuilder/BuildMapContext.cs
Normal file
148
Assets/YooAsset/Editor/BundleBuilder/BuildMapContext.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建资源映射上下文,管理构建过程中所有资源包和资源的映射关系
|
||||
/// </summary>
|
||||
[ContextObject]
|
||||
public class BuildMapContext
|
||||
{
|
||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDictionary = new Dictionary<string, BuildBundleInfo>(10000);
|
||||
private readonly List<BuildAssetInfo> _spriteAtlasAssetList = new List<BuildAssetInfo>(10000);
|
||||
private readonly List<ReportIndependentAsset> _independentAssets = new List<ReportIndependentAsset>(1000);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// </summary>
|
||||
/// <remarks>包括主动收集的资源以及其依赖的所有资源。</remarks>
|
||||
public int AssetFileCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源收集命令
|
||||
/// </summary>
|
||||
public CollectCommand Command { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包信息列表
|
||||
/// </summary>
|
||||
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bundleInfoDictionary.Values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图集资源集合
|
||||
/// </summary>
|
||||
public IReadOnlyList<BuildAssetInfo> SpriteAtlasAssetList
|
||||
{
|
||||
get { return _spriteAtlasAssetList; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 未被依赖的资源列表
|
||||
/// </summary>
|
||||
public IReadOnlyList<ReportIndependentAsset> IndependentAssets
|
||||
{
|
||||
get { return _independentAssets; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个未被依赖的资源
|
||||
/// </summary>
|
||||
internal void AddIndependentAsset(ReportIndependentAsset asset)
|
||||
{
|
||||
_independentAssets.Add(asset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">待打包的资源信息</param>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
string bundleName = assetInfo.BundleName;
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new YooInternalException("Should never get here.");
|
||||
|
||||
if (_bundleInfoDictionary.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
bundleInfo.PackAsset(assetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
_bundleInfoDictionary.Add(bundleName, newBundleInfo);
|
||||
}
|
||||
|
||||
// 统计所有的精灵图集
|
||||
if (assetInfo.AssetInfo.IsSpriteAtlas())
|
||||
{
|
||||
_spriteAtlasAssetList.Add(assetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含指定名称的资源包
|
||||
/// </summary>
|
||||
/// <param name="bundleName">资源包名称</param>
|
||||
/// <returns>包含返回 true,否则返回 false</returns>
|
||||
public bool IsContainsBundle(string bundleName)
|
||||
{
|
||||
return _bundleInfoDictionary.ContainsKey(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包信息
|
||||
/// </summary>
|
||||
/// <param name="bundleName">资源包名称</param>
|
||||
/// <returns>对应的资源包构建信息</returns>
|
||||
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||
{
|
||||
if (_bundleInfoDictionary.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new YooInternalException($"Should never get here. Bundle not found: '{bundleName}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
/// <param name="replaceAssetPathWithAddress">是否使用可寻址地址替代资源路径</param>
|
||||
/// <returns>所有资源包的 AssetBundleBuild 数据数组</returns>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds(bool replaceAssetPathWithAddress)
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDictionary.Count);
|
||||
foreach (var bundleInfo in _bundleInfoDictionary.Values)
|
||||
{
|
||||
builds.Add(bundleInfo.CreatePipelineBuild(replaceAssetPathWithAddress));
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建空的资源包
|
||||
/// </summary>
|
||||
/// <param name="bundleName">资源包名称</param>
|
||||
public void CreateEmptyBundleInfo(string bundleName)
|
||||
{
|
||||
if (IsContainsBundle(bundleName) == false)
|
||||
{
|
||||
var bundleInfo = new BuildBundleInfo(bundleName);
|
||||
_bundleInfoDictionary.Add(bundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
249
Assets/YooAsset/Editor/BundleBuilder/BuildParameters.cs
Normal file
249
Assets/YooAsset/Editor/BundleBuilder/BuildParameters.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public abstract class BuildParameters
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 构建输出的根目录
|
||||
/// </summary>
|
||||
public string BuildOutputRoot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 首包资源的根目录
|
||||
/// </summary>
|
||||
public string BundledFileRoot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线名称
|
||||
/// </summary>
|
||||
public string BuildPipeline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建资源包类型
|
||||
/// </summary>
|
||||
public int BuildBundleType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹备注
|
||||
/// </summary>
|
||||
public string PackageNote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 清空构建缓存文件
|
||||
/// </summary>
|
||||
public bool ClearBuildCacheFiles { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用资源依赖缓存数据库
|
||||
/// </summary>
|
||||
/// <remarks>开启此项可以极大提高资源收集速度</remarks>
|
||||
public bool UseAssetDependencyDB { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用共享资源打包
|
||||
/// </summary>
|
||||
public bool EnableSharePackRule { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否对单独引用的共享资源进行独立打包
|
||||
/// </summary>
|
||||
/// <remarks>关闭该选项,单独引用的共享资源将会构建到引用它的资源包内。</remarks>
|
||||
public bool SingleReferencedPackAlone { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称样式
|
||||
/// </summary>
|
||||
public EFileNameStyle FileNameStyle { get; set; } = EFileNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 首包资源的拷贝选项
|
||||
/// </summary>
|
||||
public EBundledCopyOption BundledCopyOption { get; set; } = EBundledCopyOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 首包资源的拷贝参数
|
||||
/// </summary>
|
||||
public string BundledCopyParams { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包加密器
|
||||
/// </summary>
|
||||
public IBundleEncryptor BundleEncryptor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单加密器
|
||||
/// </summary>
|
||||
public IManifestEncryptor ManifestEncryptor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单解密器
|
||||
/// </summary>
|
||||
public IManifestDecryptor ManifestDecryptor { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public void CheckBuildParameters()
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "Pipeline build is in progress.");
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
// 检测构建参数合法性
|
||||
if (BuildTarget == BuildTarget.NoTarget)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Build target platform is not selected.");
|
||||
throw new ArgumentException(message, nameof(BuildTarget));
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty.");
|
||||
throw new ArgumentException(message, nameof(BuildOutputRoot));
|
||||
}
|
||||
if (string.IsNullOrEmpty(BundledFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BundledRootIsNullOrEmpty, "Bundled file root is null or empty.");
|
||||
throw new ArgumentException(message, nameof(BundledFileRoot));
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildPipeline))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineIsNullOrEmpty, "Build pipeline is null or empty.");
|
||||
throw new ArgumentException(message, nameof(BuildPipeline));
|
||||
}
|
||||
if (BuildBundleType == (int)EBundleType.None)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildBundleTypeIsUnknown, $"Build bundle type is unknown: {BuildBundleType}.");
|
||||
throw new ArgumentException(message, nameof(BuildBundleType));
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageName))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty.");
|
||||
throw new ArgumentException(message, nameof(PackageName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty.");
|
||||
throw new ArgumentException(message, nameof(PackageVersion));
|
||||
}
|
||||
|
||||
// 设置默认备注信息
|
||||
if (string.IsNullOrEmpty(PackageNote))
|
||||
{
|
||||
PackageNote = DateTime.Now.ToString();
|
||||
}
|
||||
|
||||
CheckBuildParametersCore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns>构建管线的输出目录路径</returns>
|
||||
public string GetPipelineOutputDirectory()
|
||||
{
|
||||
return GetPipelineOutputDirectoryCore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
/// <returns>本次构建的补丁输出目录路径</returns>
|
||||
public string GetPackageOutputDirectory()
|
||||
{
|
||||
return GetPackageOutputDirectoryCore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
/// <returns>本次构建的补丁根目录路径</returns>
|
||||
public string GetPackageRootDirectory()
|
||||
{
|
||||
return GetPackageRootDirectoryCore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取首包资源的根目录
|
||||
/// </summary>
|
||||
/// <returns>首包资源的根目录路径</returns>
|
||||
public string GetBundledRootDirectory()
|
||||
{
|
||||
return GetBundledRootDirectoryCore();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 执行子类特定的构建参数验证
|
||||
/// </summary>
|
||||
protected virtual void CheckBuildParametersCore() { }
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线输出目录的核心实现
|
||||
/// </summary>
|
||||
/// <returns>构建管线的输出目录路径</returns>
|
||||
protected virtual string GetPipelineOutputDirectoryCore()
|
||||
{
|
||||
return $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{YooAssetSettings.OutputFolderName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁输出目录的核心实现
|
||||
/// </summary>
|
||||
/// <returns>本次构建的补丁输出目录路径</returns>
|
||||
protected virtual string GetPackageOutputDirectoryCore()
|
||||
{
|
||||
return $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{PackageVersion}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁根目录的核心实现
|
||||
/// </summary>
|
||||
/// <returns>本次构建的补丁根目录路径</returns>
|
||||
protected virtual string GetPackageRootDirectoryCore()
|
||||
{
|
||||
return $"{BuildOutputRoot}/{BuildTarget}/{PackageName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取首包资源根目录的核心实现
|
||||
/// </summary>
|
||||
/// <returns>首包资源的根目录路径</returns>
|
||||
protected virtual string GetBundledRootDirectoryCore()
|
||||
{
|
||||
return $"{BundledFileRoot}/{PackageName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数上下文
|
||||
/// </summary>
|
||||
[ContextObject]
|
||||
public class BuildParametersContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建实例
|
||||
/// </summary>
|
||||
/// <param name="parameters">构建参数</param>
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public void CheckBuildParameters()
|
||||
{
|
||||
Parameters.CheckBuildParameters();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns>构建管线的输出目录路径</returns>
|
||||
public string GetPipelineOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPipelineOutputDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
/// <returns>本次构建的补丁输出目录路径</returns>
|
||||
public string GetPackageOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPackageOutputDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
/// <returns>本次构建的补丁根目录路径</returns>
|
||||
public string GetPackageRootDirectory()
|
||||
{
|
||||
return Parameters.GetPackageRootDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取首包资源的根目录
|
||||
/// </summary>
|
||||
/// <returns>首包资源的根目录路径</returns>
|
||||
public string GetBundledRootDirectory()
|
||||
{
|
||||
return Parameters.GetBundledRootDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user