mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
620 Commits
2.2.1-prev
...
2.3.18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,6 +20,8 @@
|
|||||||
/Assets/StreamingAssets.meta
|
/Assets/StreamingAssets.meta
|
||||||
/Assets/Samples
|
/Assets/Samples
|
||||||
/Assets/Samples.meta
|
/Assets/Samples.meta
|
||||||
|
/Assets/csc.rsp
|
||||||
|
/Assets/csc.rsp.meta
|
||||||
/UserSettings
|
/UserSettings
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 58462a7dcef164e43878a037395d4417
|
guid: fab3cd742c11be2479b07f5d447a78c9
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("YooAsset.Editor")]
|
// 外部友元
|
||||||
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
||||||
[assembly: InternalsVisibleTo("YooAsset.RuntimeExtension")]
|
|
||||||
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
|
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0c3f4136cf7142346ae33e8a82cbdb27
|
guid: ef774f01e50ab0a4d88122041938a6b9
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: db23997b705e34a419ba834ac85344f5
|
guid: bdbb4647038dcc842802f546c2fedc83
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,670 @@
|
|||||||
|
#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
|
||||||
|
{
|
||||||
|
public class AssetArtReporterWindow : EditorWindow
|
||||||
|
{
|
||||||
|
[MenuItem("YooAsset/AssetArt Reporter", false, 302)]
|
||||||
|
public static AssetArtReporterWindow OpenWindow()
|
||||||
|
{
|
||||||
|
AssetArtReporterWindow window = GetWindow<AssetArtReporterWindow>("AssetArt Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||||
|
window.minSize = new Vector2(800, 600);
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ElementTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public ReportElement Element;
|
||||||
|
}
|
||||||
|
private class PassesBtnCell : ITableCell, IComparable
|
||||||
|
{
|
||||||
|
public object CellValue { set; get; }
|
||||||
|
public string SearchTag { private set; get; }
|
||||||
|
public ReportElement Element
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ReportElement)CellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PassesBtnCell(string searchTag, ReportElement element)
|
||||||
|
{
|
||||||
|
SearchTag = searchTag;
|
||||||
|
CellValue = element;
|
||||||
|
}
|
||||||
|
public object GetDisplayObject()
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
public int CompareTo(object other)
|
||||||
|
{
|
||||||
|
if (other is PassesBtnCell cell)
|
||||||
|
{
|
||||||
|
return this.Element.Passes.CompareTo(cell.Element.Passes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private class WhiteListBtnCell : ITableCell, IComparable
|
||||||
|
{
|
||||||
|
public object CellValue { set; get; }
|
||||||
|
public string SearchTag { private set; get; }
|
||||||
|
public ReportElement Element
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ReportElement)CellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteListBtnCell(string searchTag, ReportElement element)
|
||||||
|
{
|
||||||
|
SearchTag = searchTag;
|
||||||
|
CellValue = element;
|
||||||
|
}
|
||||||
|
public object GetDisplayObject()
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
public int CompareTo(object other)
|
||||||
|
{
|
||||||
|
if (other is WhiteListBtnCell cell)
|
||||||
|
{
|
||||||
|
return this.Element.IsWhiteList.CompareTo(cell.Element.IsWhiteList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolbarSearchField _searchField;
|
||||||
|
private Button _showHiddenBtn;
|
||||||
|
private Button _whiteListVisibleBtn;
|
||||||
|
private Button _passesVisibleBtn;
|
||||||
|
private Label _titleLabel;
|
||||||
|
private Label _descLabel;
|
||||||
|
private TableViewer _elementTableView;
|
||||||
|
|
||||||
|
private ScanReportCombiner _reportCombiner;
|
||||||
|
private string _lastestOpenFolder;
|
||||||
|
private List<ITableData> _sourceDatas;
|
||||||
|
private bool _elementVisibleState = true;
|
||||||
|
private bool _whiteListVisibleState = true;
|
||||||
|
private bool _passesVisibleState = true;
|
||||||
|
|
||||||
|
public void CreateGUI()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
|
// 加载布局文件
|
||||||
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtReporterWindow>();
|
||||||
|
if (visualAsset == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
|
// 导入按钮
|
||||||
|
var importSingleBtn = root.Q<Button>("SingleImportButton");
|
||||||
|
importSingleBtn.clicked += ImportSingleBtn_clicked;
|
||||||
|
var importMultiBtn = root.Q<Button>("MultiImportButton");
|
||||||
|
importMultiBtn.clicked += ImportMultiBtn_clicked;
|
||||||
|
|
||||||
|
// 修复按钮
|
||||||
|
var fixAllBtn = root.Q<Button>("FixAllButton");
|
||||||
|
fixAllBtn.clicked += FixAllBtn_clicked;
|
||||||
|
var fixSelectBtn = root.Q<Button>("FixSelectButton");
|
||||||
|
fixSelectBtn.clicked += FixSelectBtn_clicked;
|
||||||
|
|
||||||
|
// 可见性按钮
|
||||||
|
_showHiddenBtn = root.Q<Button>("ShowHiddenButton");
|
||||||
|
_showHiddenBtn.clicked += ShowHiddenBtn_clicked;
|
||||||
|
_whiteListVisibleBtn = root.Q<Button>("WhiteListVisibleButton");
|
||||||
|
_whiteListVisibleBtn.clicked += WhiteListVisibleBtn_clicked;
|
||||||
|
_passesVisibleBtn = root.Q<Button>("PassesVisibleButton");
|
||||||
|
_passesVisibleBtn.clicked += PassesVsibleBtn_clicked;
|
||||||
|
|
||||||
|
// 文件导出按钮
|
||||||
|
var exportFilesBtn = root.Q<Button>("ExportFilesButton");
|
||||||
|
exportFilesBtn.clicked += ExportFilesBtn_clicked;
|
||||||
|
|
||||||
|
// 搜索过滤
|
||||||
|
_searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
|
_searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||||
|
|
||||||
|
// 标题和备注
|
||||||
|
_titleLabel = root.Q<Label>("ReportTitle");
|
||||||
|
_descLabel = root.Q<Label>("ReportDesc");
|
||||||
|
|
||||||
|
// 列表相关
|
||||||
|
_elementTableView = root.Q<TableViewer>("TopTableView");
|
||||||
|
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
|
||||||
|
|
||||||
|
_lastestOpenFolder = EditorTools.GetProjectPath();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
if (_reportCombiner != null)
|
||||||
|
_reportCombiner.SaveChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导入单个报告文件
|
||||||
|
/// </summary>
|
||||||
|
public void ImportSingleReprotFile(string filePath)
|
||||||
|
{
|
||||||
|
// 记录本次打开目录
|
||||||
|
_lastestOpenFolder = Path.GetDirectoryName(filePath);
|
||||||
|
_reportCombiner = new ScanReportCombiner();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var scanReport = ScanReportConfig.ImportJsonConfig(filePath);
|
||||||
|
_reportCombiner.Combine(scanReport);
|
||||||
|
|
||||||
|
// 刷新页面
|
||||||
|
RefreshToolbar();
|
||||||
|
FillTableView();
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
_reportCombiner = null;
|
||||||
|
_titleLabel.text = "导入报告失败!";
|
||||||
|
_descLabel.text = e.Message;
|
||||||
|
UnityEngine.Debug.LogError(e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导入单个报告对象
|
||||||
|
/// </summary>
|
||||||
|
public void ImportSingleReprotFile(ScanReport report)
|
||||||
|
{
|
||||||
|
_reportCombiner = new ScanReportCombiner();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportCombiner.Combine(report);
|
||||||
|
|
||||||
|
// 刷新页面
|
||||||
|
RefreshToolbar();
|
||||||
|
FillTableView();
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
_reportCombiner = null;
|
||||||
|
_titleLabel.text = "导入报告失败!";
|
||||||
|
_descLabel.text = e.Message;
|
||||||
|
UnityEngine.Debug.LogError(e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ImportSingleBtn_clicked()
|
||||||
|
{
|
||||||
|
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", _lastestOpenFolder, "json");
|
||||||
|
if (string.IsNullOrEmpty(selectFilePath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImportSingleReprotFile(selectFilePath);
|
||||||
|
}
|
||||||
|
private void ImportMultiBtn_clicked()
|
||||||
|
{
|
||||||
|
string selectFolderPath = EditorUtility.OpenFolderPanel("导入报告", _lastestOpenFolder, null);
|
||||||
|
if (string.IsNullOrEmpty(selectFolderPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 记录本次打开目录
|
||||||
|
_lastestOpenFolder = selectFolderPath;
|
||||||
|
_reportCombiner = new ScanReportCombiner();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string[] files = Directory.GetFiles(selectFolderPath);
|
||||||
|
foreach (string filePath in files)
|
||||||
|
{
|
||||||
|
string extension = System.IO.Path.GetExtension(filePath);
|
||||||
|
if (extension == ".json")
|
||||||
|
{
|
||||||
|
var scanReport = ScanReportConfig.ImportJsonConfig(filePath);
|
||||||
|
_reportCombiner.Combine(scanReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新页面
|
||||||
|
RefreshToolbar();
|
||||||
|
FillTableView();
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
_reportCombiner = null;
|
||||||
|
_titleLabel.text = "Failed to import report!";
|
||||||
|
_descLabel.text = e.Message;
|
||||||
|
UnityEngine.Debug.LogError(e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void FixAllBtn_clicked()
|
||||||
|
{
|
||||||
|
if (EditorUtility.DisplayDialog("Info", "Fix all resources (excluding whitelist and hidden elements)", "Yes", "No"))
|
||||||
|
{
|
||||||
|
if (_reportCombiner != null)
|
||||||
|
_reportCombiner.FixAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void FixSelectBtn_clicked()
|
||||||
|
{
|
||||||
|
if (EditorUtility.DisplayDialog("Info", "Fix selected resources (including whitelist and hidden elements)", "Yes", "No"))
|
||||||
|
{
|
||||||
|
if (_reportCombiner != null)
|
||||||
|
_reportCombiner.FixSelect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ShowHiddenBtn_clicked()
|
||||||
|
{
|
||||||
|
_elementVisibleState = !_elementVisibleState;
|
||||||
|
RefreshToolbar();
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
private void WhiteListVisibleBtn_clicked()
|
||||||
|
{
|
||||||
|
_whiteListVisibleState = !_whiteListVisibleState;
|
||||||
|
RefreshToolbar();
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
private void PassesVsibleBtn_clicked()
|
||||||
|
{
|
||||||
|
_passesVisibleState = !_passesVisibleState;
|
||||||
|
RefreshToolbar();
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
private void ExportFilesBtn_clicked()
|
||||||
|
{
|
||||||
|
string selectFolderPath = EditorUtility.OpenFolderPanel("Export all selected resources", EditorTools.GetProjectPath(), string.Empty);
|
||||||
|
if (string.IsNullOrEmpty(selectFolderPath) == false)
|
||||||
|
{
|
||||||
|
if (_reportCombiner != null)
|
||||||
|
_reportCombiner.ExportFiles(selectFolderPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshToolbar()
|
||||||
|
{
|
||||||
|
if (_reportCombiner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_titleLabel.text = _reportCombiner.ReportTitle;
|
||||||
|
_descLabel.text = _reportCombiner.ReportDesc;
|
||||||
|
|
||||||
|
var enableColor = new Color32(18, 100, 18, 255);
|
||||||
|
var disableColor = new Color32(100, 100, 100, 255);
|
||||||
|
|
||||||
|
if (_elementVisibleState)
|
||||||
|
_showHiddenBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||||
|
else
|
||||||
|
_showHiddenBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||||
|
|
||||||
|
if (_whiteListVisibleState)
|
||||||
|
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||||
|
else
|
||||||
|
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||||
|
|
||||||
|
if (_passesVisibleState)
|
||||||
|
_passesVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||||
|
else
|
||||||
|
_passesVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||||
|
}
|
||||||
|
private void FillTableView()
|
||||||
|
{
|
||||||
|
if (_reportCombiner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_elementTableView.ClearAll(true, true);
|
||||||
|
|
||||||
|
// 眼睛标题
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(20);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = false;
|
||||||
|
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var toggle = new ToggleDisplay();
|
||||||
|
toggle.text = string.Empty;
|
||||||
|
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
|
||||||
|
return toggle;
|
||||||
|
};
|
||||||
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
|
{
|
||||||
|
var toggle = element as ToggleDisplay;
|
||||||
|
toggle.userData = data;
|
||||||
|
var tableData = data as ElementTableData;
|
||||||
|
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
|
||||||
|
};
|
||||||
|
_elementTableView.AddColumn(column);
|
||||||
|
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
|
||||||
|
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通过标题
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(70);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
var column = new TableColumn("通过", "通过", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var button = new Button();
|
||||||
|
button.text = "通过";
|
||||||
|
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
button.SetEnabled(false);
|
||||||
|
return button;
|
||||||
|
};
|
||||||
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
|
{
|
||||||
|
Button button = element as Button;
|
||||||
|
var elementTableData = data as ElementTableData;
|
||||||
|
if (elementTableData.Element.Passes)
|
||||||
|
{
|
||||||
|
button.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
|
||||||
|
button.text = "通过";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.style.backgroundColor = new StyleColor(new Color32(137, 0, 0, 255));
|
||||||
|
button.text = "失败";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_elementTableView.AddColumn(column);
|
||||||
|
var headerElement = _elementTableView.GetHeaderElement("通过");
|
||||||
|
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 白名单标题
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(70);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
var column = new TableColumn("白名单", "白名单", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
Button button = new Button();
|
||||||
|
button.text = "白名单";
|
||||||
|
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
button.clickable.clickedWithEventInfo += OnClickWhitListButton;
|
||||||
|
return button;
|
||||||
|
};
|
||||||
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
|
{
|
||||||
|
Button button = element as Button;
|
||||||
|
button.userData = data;
|
||||||
|
var elementTableData = data as ElementTableData;
|
||||||
|
if (elementTableData.Element.IsWhiteList)
|
||||||
|
button.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
|
||||||
|
else
|
||||||
|
button.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255));
|
||||||
|
};
|
||||||
|
_elementTableView.AddColumn(column);
|
||||||
|
var headerElement = _elementTableView.GetHeaderElement("白名单");
|
||||||
|
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选中标题
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(20);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = false;
|
||||||
|
var column = new TableColumn("选中框", string.Empty, columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var toggle = new Toggle();
|
||||||
|
toggle.text = string.Empty;
|
||||||
|
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
toggle.RegisterValueChangedCallback((evt) => { OnSelectToggleValueChange(toggle, evt); });
|
||||||
|
return toggle;
|
||||||
|
};
|
||||||
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
|
{
|
||||||
|
var toggle = element as Toggle;
|
||||||
|
toggle.userData = data;
|
||||||
|
var tableData = data as ElementTableData;
|
||||||
|
toggle.SetValueWithoutNotify(tableData.Element.IsSelected);
|
||||||
|
};
|
||||||
|
_elementTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义标题栏
|
||||||
|
foreach (var header in _reportCombiner.Headers)
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(header.Width, header.MinWidth, header.MaxWidth);
|
||||||
|
columnStyle.Stretchable = header.Stretchable;
|
||||||
|
columnStyle.Searchable = header.Searchable;
|
||||||
|
columnStyle.Sortable = header.Sortable;
|
||||||
|
columnStyle.Counter = header.Counter;
|
||||||
|
columnStyle.Units = header.Units;
|
||||||
|
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
if (header.HeaderType == EHeaderType.AssetObject)
|
||||||
|
{
|
||||||
|
var objectFiled = new ObjectField();
|
||||||
|
return objectFiled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
|
{
|
||||||
|
if (header.HeaderType == EHeaderType.AssetObject)
|
||||||
|
{
|
||||||
|
var objectFiled = element as ObjectField;
|
||||||
|
objectFiled.value = (UnityEngine.Object)cell.GetDisplayObject();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var infoLabel = element as Label;
|
||||||
|
infoLabel.text = (string)cell.GetDisplayObject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_elementTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充数据源
|
||||||
|
_sourceDatas = new List<ITableData>(_reportCombiner.Elements.Count);
|
||||||
|
foreach (var element in _reportCombiner.Elements)
|
||||||
|
{
|
||||||
|
var tableData = new ElementTableData();
|
||||||
|
tableData.Element = element;
|
||||||
|
|
||||||
|
// 固定标题
|
||||||
|
tableData.AddButtonCell("眼睛框");
|
||||||
|
tableData.AddCell(new PassesBtnCell("通过", element));
|
||||||
|
tableData.AddCell(new WhiteListBtnCell("白名单", element));
|
||||||
|
tableData.AddButtonCell("选中框");
|
||||||
|
|
||||||
|
// 自定义标题
|
||||||
|
foreach (var scanInfo in element.ScanInfos)
|
||||||
|
{
|
||||||
|
var header = _reportCombiner.GetHeader(scanInfo.HeaderTitle);
|
||||||
|
if (header.HeaderType == EHeaderType.AssetPath)
|
||||||
|
{
|
||||||
|
tableData.AddAssetPathCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||||
|
}
|
||||||
|
else if (header.HeaderType == EHeaderType.AssetObject)
|
||||||
|
{
|
||||||
|
tableData.AddAssetObjectCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||||
|
}
|
||||||
|
else if (header.HeaderType == EHeaderType.StringValue)
|
||||||
|
{
|
||||||
|
tableData.AddStringValueCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||||
|
}
|
||||||
|
else if (header.HeaderType == EHeaderType.LongValue)
|
||||||
|
{
|
||||||
|
long value = Convert.ToInt64(scanInfo.ScanInfo);
|
||||||
|
tableData.AddLongValueCell(scanInfo.HeaderTitle, value);
|
||||||
|
}
|
||||||
|
else if (header.HeaderType == EHeaderType.DoubleValue)
|
||||||
|
{
|
||||||
|
double value = Convert.ToDouble(scanInfo.ScanInfo);
|
||||||
|
tableData.AddDoubleValueCell(scanInfo.HeaderTitle, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException(header.HeaderType.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_sourceDatas.Add(tableData);
|
||||||
|
}
|
||||||
|
_elementTableView.itemsSource = _sourceDatas;
|
||||||
|
}
|
||||||
|
private void RebuildView()
|
||||||
|
{
|
||||||
|
if (_reportCombiner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string searchKeyword = _searchField.value;
|
||||||
|
|
||||||
|
// 搜索匹配
|
||||||
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyword);
|
||||||
|
|
||||||
|
// 开关匹配
|
||||||
|
foreach (var tableData in _sourceDatas)
|
||||||
|
{
|
||||||
|
var elementTableData = tableData as ElementTableData;
|
||||||
|
if (_elementVisibleState == false && elementTableData.Element.Hidden)
|
||||||
|
{
|
||||||
|
tableData.Visible = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (_passesVisibleState == false && elementTableData.Element.Passes)
|
||||||
|
{
|
||||||
|
tableData.Visible = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (_whiteListVisibleState == false && elementTableData.Element.IsWhiteList)
|
||||||
|
{
|
||||||
|
tableData.Visible = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重建视图
|
||||||
|
_elementTableView.RebuildView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClickTableViewItem(PointerDownEvent evt, ITableData tableData)
|
||||||
|
{
|
||||||
|
// 双击后检视对应的资源
|
||||||
|
if (evt.clickCount == 2)
|
||||||
|
{
|
||||||
|
foreach (var cell in tableData.Cells)
|
||||||
|
{
|
||||||
|
if (cell is AssetPathCell assetPathCell)
|
||||||
|
{
|
||||||
|
if (assetPathCell.PingAssetObject())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
|
{
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
private void OnSelectToggleValueChange(Toggle toggle, ChangeEvent<bool> e)
|
||||||
|
{
|
||||||
|
// 处理自身
|
||||||
|
toggle.SetValueWithoutNotify(e.newValue);
|
||||||
|
|
||||||
|
// 记录数据
|
||||||
|
var elementTableData = toggle.userData as ElementTableData;
|
||||||
|
elementTableData.Element.IsSelected = e.newValue;
|
||||||
|
|
||||||
|
// 处理多选目标
|
||||||
|
var selectedItems = _elementTableView.selectedItems;
|
||||||
|
foreach (var selectedItem in selectedItems)
|
||||||
|
{
|
||||||
|
var selectElement = selectedItem as ElementTableData;
|
||||||
|
selectElement.Element.IsSelected = e.newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重绘视图
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
private void OnDisplayToggleValueChange(ToggleDisplay toggle, ChangeEvent<bool> e)
|
||||||
|
{
|
||||||
|
// 处理自身
|
||||||
|
toggle.SetValueWithoutNotify(e.newValue);
|
||||||
|
|
||||||
|
// 记录数据
|
||||||
|
var elementTableData = toggle.userData as ElementTableData;
|
||||||
|
elementTableData.Element.Hidden = e.newValue;
|
||||||
|
|
||||||
|
// 处理多选目标
|
||||||
|
var selectedItems = _elementTableView.selectedItems;
|
||||||
|
foreach (var selectedItem in selectedItems)
|
||||||
|
{
|
||||||
|
var selectElement = selectedItem as ElementTableData;
|
||||||
|
if (selectElement != null)
|
||||||
|
selectElement.Element.Hidden = e.newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重绘视图
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
private void OnClickWhitListButton(EventBase evt)
|
||||||
|
{
|
||||||
|
// 刷新点击的按钮
|
||||||
|
Button button = evt.target as Button;
|
||||||
|
var elementTableData = button.userData as ElementTableData;
|
||||||
|
elementTableData.Element.IsWhiteList = !elementTableData.Element.IsWhiteList;
|
||||||
|
|
||||||
|
// 刷新框选的按钮
|
||||||
|
var selectedItems = _elementTableView.selectedItems;
|
||||||
|
if (selectedItems.Count() > 1)
|
||||||
|
{
|
||||||
|
foreach (var selectedItem in selectedItems)
|
||||||
|
{
|
||||||
|
var selectElement = selectedItem as ElementTableData;
|
||||||
|
selectElement.Element.IsWhiteList = selectElement.Element.IsWhiteList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RebuildView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0b6f2523a865e454d8fa3f48a2852d5a
|
guid: 4048f85b9ff1f424a89a9d6109e6faaf
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||||
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
|
||||||
|
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||||
|
<ui:Button text="Fix Select" display-tooltip-when-elided="true" name="FixSelectButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||||
|
<ui:Button text="Fix All" display-tooltip-when-elided="true" name="FixAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||||
|
<ui:Button text="Export Select" display-tooltip-when-elided="true" name="ExportFilesButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||||
|
<ui:Button text=" Multi-Import" display-tooltip-when-elided="true" name="MultiImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||||
|
<ui:Button text="Import" display-tooltip-when-elided="true" name="SingleImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||||
|
</uie:Toolbar>
|
||||||
|
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
|
<ui:Label text="标题" display-tooltip-when-elided="true" name="ReportTitle" style="height: 16px; -unity-font-style: bold; -unity-text-align: middle-center;" />
|
||||||
|
<ui:Label text="说明" display-tooltip-when-elided="true" name="ReportDesc" style="-unity-text-align: upper-left; -unity-font-style: bold; background-color: rgb(42, 42, 42); min-height: 50px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; white-space: normal;" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
|
||||||
|
<ui:Button text="显示隐藏元素" display-tooltip-when-elided="true" name="ShowHiddenButton" style="width: 100px;" />
|
||||||
|
<ui:Button text="显示通过元素" display-tooltip-when-elided="true" name="PassesVisibleButton" style="width: 100px;" />
|
||||||
|
<ui:Button text="显示白名单元素" display-tooltip-when-elided="true" name="WhiteListVisibleButton" style="width: 100px;" />
|
||||||
|
</uie:Toolbar>
|
||||||
|
<ui:VisualElement name="AssetGroup" 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;">
|
||||||
|
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:UXML>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b87fc70b750616849942173af3bdfd90
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
31
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs
Normal file
31
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public enum EHeaderType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源路径
|
||||||
|
/// </summary>
|
||||||
|
AssetPath,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源对象
|
||||||
|
/// </summary>
|
||||||
|
AssetObject,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串
|
||||||
|
/// </summary>
|
||||||
|
StringValue,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 整数数值
|
||||||
|
/// </summary>
|
||||||
|
LongValue,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 浮点数数值
|
||||||
|
/// </summary>
|
||||||
|
DoubleValue,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 56ea224b45d314e4a86b558404e9b6c8
|
guid: 97cd7d0d616708e42bc53ed7d88718c9
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
88
Assets/YooAsset/Editor/AssetArtReporter/ReportElement.cs
Normal file
88
Assets/YooAsset/Editor/AssetArtReporter/ReportElement.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class ReportElement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// GUID(白名单存储对象)
|
||||||
|
/// </summary>
|
||||||
|
public string GUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描是否通过
|
||||||
|
/// </summary>
|
||||||
|
public bool Passes = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反馈的信息列表
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportScanInfo> ScanInfos = new List<ReportScanInfo>();
|
||||||
|
|
||||||
|
|
||||||
|
public ReportElement(string guid)
|
||||||
|
{
|
||||||
|
GUID = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加扫描信息
|
||||||
|
/// </summary>
|
||||||
|
public void AddScanInfo(string headerTitle, string value)
|
||||||
|
{
|
||||||
|
var reportScanInfo = new ReportScanInfo(headerTitle, value);
|
||||||
|
ScanInfos.Add(reportScanInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加扫描信息
|
||||||
|
/// </summary>
|
||||||
|
public void AddScanInfo(string headerTitle, long value)
|
||||||
|
{
|
||||||
|
AddScanInfo(headerTitle, value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加扫描信息
|
||||||
|
/// </summary>
|
||||||
|
public void AddScanInfo(string headerTitle, double value)
|
||||||
|
{
|
||||||
|
AddScanInfo(headerTitle, value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取扫描信息
|
||||||
|
/// </summary>
|
||||||
|
public ReportScanInfo GetScanInfo(string headerTitle)
|
||||||
|
{
|
||||||
|
foreach (var scanInfo in ScanInfos)
|
||||||
|
{
|
||||||
|
if (scanInfo.HeaderTitle == headerTitle)
|
||||||
|
return scanInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityEngine.Debug.LogWarning($"Not found {nameof(ReportScanInfo)} : {headerTitle}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 临时字段
|
||||||
|
/// <summary>
|
||||||
|
/// 是否在列表里选中
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSelected { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否在白名单里
|
||||||
|
/// </summary>
|
||||||
|
public bool IsWhiteList { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否隐藏元素
|
||||||
|
/// </summary>
|
||||||
|
public bool Hidden { set; get; }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 1c8ce2c52a3e9964fa50a9c031e4e593
|
guid: d61f7ee1a8215bf438071055f0a9cb09
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
154
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs
Normal file
154
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class ReportHeader
|
||||||
|
{
|
||||||
|
public const int MaxValue = 8388608;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
public string HeaderTitle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题宽度
|
||||||
|
/// </summary>
|
||||||
|
public int Width;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单元列最小宽度
|
||||||
|
/// </summary>
|
||||||
|
public int MinWidth = 50;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单元列最大宽度
|
||||||
|
/// </summary>
|
||||||
|
public int MaxWidth = MaxValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可伸缩选项
|
||||||
|
/// </summary>
|
||||||
|
public bool Stretchable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可搜索选项
|
||||||
|
/// </summary>
|
||||||
|
public bool Searchable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可排序选项
|
||||||
|
/// </summary>
|
||||||
|
public bool Sortable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 统计数量
|
||||||
|
/// </summary>
|
||||||
|
public bool Counter = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 展示单位
|
||||||
|
/// </summary>
|
||||||
|
public string Units = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数值类型
|
||||||
|
/// </summary>
|
||||||
|
public EHeaderType HeaderType = EHeaderType.StringValue;
|
||||||
|
|
||||||
|
|
||||||
|
public ReportHeader(string headerTitle, int width)
|
||||||
|
{
|
||||||
|
HeaderTitle = headerTitle;
|
||||||
|
Width = width;
|
||||||
|
MinWidth = width;
|
||||||
|
MaxWidth = width;
|
||||||
|
}
|
||||||
|
public ReportHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||||
|
{
|
||||||
|
HeaderTitle = headerTitle;
|
||||||
|
Width = width;
|
||||||
|
MinWidth = minWidth;
|
||||||
|
MaxWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReportHeader SetMinWidth(int value)
|
||||||
|
{
|
||||||
|
MinWidth = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetMaxWidth(int value)
|
||||||
|
{
|
||||||
|
MaxWidth = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetStretchable()
|
||||||
|
{
|
||||||
|
Stretchable = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetSearchable()
|
||||||
|
{
|
||||||
|
Searchable = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetSortable()
|
||||||
|
{
|
||||||
|
Sortable = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetCounter()
|
||||||
|
{
|
||||||
|
Counter = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetUnits(string units)
|
||||||
|
{
|
||||||
|
Units = units;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetHeaderType(EHeaderType value)
|
||||||
|
{
|
||||||
|
HeaderType = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测数值有效性
|
||||||
|
/// </summary>
|
||||||
|
public void CheckValueValid(string value)
|
||||||
|
{
|
||||||
|
if (HeaderType == EHeaderType.AssetPath)
|
||||||
|
{
|
||||||
|
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||||
|
if (string.IsNullOrEmpty(guid))
|
||||||
|
throw new Exception($"{HeaderTitle} value is invalid asset path : {value}");
|
||||||
|
}
|
||||||
|
else if (HeaderType == EHeaderType.AssetObject)
|
||||||
|
{
|
||||||
|
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||||
|
if (string.IsNullOrEmpty(guid))
|
||||||
|
throw new Exception($"{HeaderTitle} value is invalid asset object : {value}");
|
||||||
|
}
|
||||||
|
else if (HeaderType == EHeaderType.DoubleValue)
|
||||||
|
{
|
||||||
|
if (double.TryParse(value, out double doubleValue) == false)
|
||||||
|
throw new Exception($"{HeaderTitle} value is invalid double value : {value}");
|
||||||
|
}
|
||||||
|
else if (HeaderType == EHeaderType.LongValue)
|
||||||
|
{
|
||||||
|
if (long.TryParse(value, out long longValue) == false)
|
||||||
|
throw new Exception($"{HeaderTitle} value is invalid long value : {value}");
|
||||||
|
}
|
||||||
|
else if (HeaderType == EHeaderType.StringValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(HeaderType.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3be8b45a77bb720478379c26da3aa68a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
26
Assets/YooAsset/Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
26
Assets/YooAsset/Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class ReportScanInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
public string HeaderTitle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描反馈的信息
|
||||||
|
/// </summary>
|
||||||
|
public string ScanInfo;
|
||||||
|
|
||||||
|
public ReportScanInfo(string headerTitle, string scanInfo)
|
||||||
|
{
|
||||||
|
HeaderTitle = headerTitle;
|
||||||
|
ScanInfo = scanInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 02caa7ae84ee8294a8904a5aaed420ee
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
118
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs
Normal file
118
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class ScanReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件签名(自动填写)
|
||||||
|
/// </summary>
|
||||||
|
public string FileSign;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件版本(自动填写)
|
||||||
|
/// </summary>
|
||||||
|
public string FileVersion;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模式类型(自动填写)
|
||||||
|
/// </summary>
|
||||||
|
public string SchemaType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描器GUID(自动填写)
|
||||||
|
/// </summary>
|
||||||
|
public string ScannerGUID;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报告名称
|
||||||
|
/// </summary>
|
||||||
|
public string ReportName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报告介绍
|
||||||
|
/// </summary>
|
||||||
|
public string ReportDesc;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报告的标题列表
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportHeader> ReportHeaders = new List<ReportHeader>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描的元素列表
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportElement> ReportElements = new List<ReportElement>();
|
||||||
|
|
||||||
|
|
||||||
|
public ScanReport(string reportName, string reportDesc)
|
||||||
|
{
|
||||||
|
ReportName = reportName;
|
||||||
|
ReportDesc = reportDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加标题
|
||||||
|
/// </summary>
|
||||||
|
public ReportHeader AddHeader(string headerTitle, int width)
|
||||||
|
{
|
||||||
|
var reportHeader = new ReportHeader(headerTitle, width);
|
||||||
|
ReportHeaders.Add(reportHeader);
|
||||||
|
return reportHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加标题
|
||||||
|
/// </summary>
|
||||||
|
public ReportHeader AddHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||||
|
{
|
||||||
|
var reportHeader = new ReportHeader(headerTitle, width, minWidth, maxWidth);
|
||||||
|
ReportHeaders.Add(reportHeader);
|
||||||
|
return reportHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测错误
|
||||||
|
/// </summary>
|
||||||
|
public void CheckError()
|
||||||
|
{
|
||||||
|
// 检测标题
|
||||||
|
Dictionary<string, ReportHeader> headerMap = new Dictionary<string, ReportHeader>();
|
||||||
|
foreach (var header in ReportHeaders)
|
||||||
|
{
|
||||||
|
string headerTitle = header.HeaderTitle;
|
||||||
|
if (headerMap.ContainsKey(headerTitle))
|
||||||
|
throw new Exception($"The header title {headerTitle} already exists !");
|
||||||
|
else
|
||||||
|
headerMap.Add(headerTitle, header);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测扫描元素
|
||||||
|
HashSet<string> elementMap = new HashSet<string>();
|
||||||
|
foreach (var element in ReportElements)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(element.GUID))
|
||||||
|
throw new Exception($"The report element GUID is null or empty !");
|
||||||
|
|
||||||
|
if (elementMap.Contains(element.GUID))
|
||||||
|
throw new Exception($"The report element GUID already exists ! {element.GUID}");
|
||||||
|
else
|
||||||
|
elementMap.Add(element.GUID);
|
||||||
|
|
||||||
|
foreach (var scanInfo in element.ScanInfos)
|
||||||
|
{
|
||||||
|
if (headerMap.ContainsKey(scanInfo.HeaderTitle) == false)
|
||||||
|
throw new Exception($"The report element header {scanInfo.HeaderTitle} is missing !");
|
||||||
|
|
||||||
|
// 检测数值有效性
|
||||||
|
var header = headerMap[scanInfo.HeaderTitle];
|
||||||
|
header.CheckValueValid(scanInfo.ScanInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 650e3e4af4ede2a4eb2471c30e7820bb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
221
Assets/YooAsset/Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
221
Assets/YooAsset/Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源扫描报告合并器
|
||||||
|
/// 说明:相同类型的报告可以合并查看
|
||||||
|
/// </summary>
|
||||||
|
public class ScanReportCombiner
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模式类型
|
||||||
|
/// </summary>
|
||||||
|
public string SchemaType { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报告标题
|
||||||
|
/// </summary>
|
||||||
|
public string ReportTitle { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报告介绍
|
||||||
|
/// </summary>
|
||||||
|
public string ReportDesc { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题列表
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportHeader> Headers = new List<ReportHeader>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描结果
|
||||||
|
/// </summary>
|
||||||
|
public readonly List<ReportElement> Elements = new List<ReportElement>(10000);
|
||||||
|
private readonly Dictionary<string, ScanReport> _combines = new Dictionary<string, ScanReport>(100);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 合并报告文件
|
||||||
|
/// 注意:模式不同的报告文件会合并失败!
|
||||||
|
/// </summary>
|
||||||
|
public bool Combine(ScanReport scanReport)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(scanReport.SchemaType))
|
||||||
|
{
|
||||||
|
Debug.LogError("Scan report schema type is null or empty !");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(SchemaType))
|
||||||
|
{
|
||||||
|
SchemaType = scanReport.SchemaType;
|
||||||
|
ReportTitle = scanReport.ReportName;
|
||||||
|
ReportDesc = scanReport.ReportDesc;
|
||||||
|
Headers = scanReport.ReportHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SchemaType != scanReport.SchemaType)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Scan report has different schema type!{scanReport.SchemaType} != {SchemaType}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_combines.ContainsKey(scanReport.ScannerGUID))
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Scan report has already existed : {scanReport.ScannerGUID}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_combines.Add(scanReport.ScannerGUID, scanReport);
|
||||||
|
CombineInternal(scanReport);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CombineInternal(ScanReport scanReport)
|
||||||
|
{
|
||||||
|
string scannerGUID = scanReport.ScannerGUID;
|
||||||
|
List<ReportElement> elements = scanReport.ReportElements;
|
||||||
|
|
||||||
|
// 设置白名单
|
||||||
|
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||||
|
if (scanner != null)
|
||||||
|
{
|
||||||
|
foreach (var element in elements)
|
||||||
|
{
|
||||||
|
if (scanner.CheckWhiteList(element.GUID))
|
||||||
|
element.IsWhiteList = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加到集合
|
||||||
|
Elements.AddRange(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定的标题类
|
||||||
|
/// </summary>
|
||||||
|
public ReportHeader GetHeader(string headerTitle)
|
||||||
|
{
|
||||||
|
foreach (var header in Headers)
|
||||||
|
{
|
||||||
|
if (header.HeaderTitle == headerTitle)
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityEngine.Debug.LogWarning($"Not found {nameof(ReportHeader)} : {headerTitle}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导出选中文件
|
||||||
|
/// </summary>
|
||||||
|
public void ExportFiles(string exportFolderPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(exportFolderPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var element in Elements)
|
||||||
|
{
|
||||||
|
if (element.IsSelected)
|
||||||
|
{
|
||||||
|
string assetPath = AssetDatabase.GUIDToAssetPath(element.GUID);
|
||||||
|
if (string.IsNullOrEmpty(assetPath) == false)
|
||||||
|
{
|
||||||
|
string destPath = Path.Combine(exportFolderPath, assetPath);
|
||||||
|
EditorTools.CopyFile(assetPath, destPath, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存改变数据
|
||||||
|
/// </summary>
|
||||||
|
public void SaveChange()
|
||||||
|
{
|
||||||
|
// 存储白名单
|
||||||
|
foreach (var scanReport in _combines.Values)
|
||||||
|
{
|
||||||
|
string scannerGUID = scanReport.ScannerGUID;
|
||||||
|
var elements = scanReport.ReportElements;
|
||||||
|
|
||||||
|
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||||
|
if (scanner != null)
|
||||||
|
{
|
||||||
|
List<string> whiteList = new List<string>(elements.Count);
|
||||||
|
foreach (var element in elements)
|
||||||
|
{
|
||||||
|
if (element.IsWhiteList)
|
||||||
|
whiteList.Add(element.GUID);
|
||||||
|
}
|
||||||
|
whiteList.Sort();
|
||||||
|
scanner.WhiteList = whiteList;
|
||||||
|
AssetArtScannerSettingData.SaveFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修复所有元素
|
||||||
|
/// 注意:排除白名单和隐藏元素
|
||||||
|
/// </summary>
|
||||||
|
public void FixAll()
|
||||||
|
{
|
||||||
|
foreach (var scanReport in _combines.Values)
|
||||||
|
{
|
||||||
|
string scannerGUID = scanReport.ScannerGUID;
|
||||||
|
var elements = scanReport.ReportElements;
|
||||||
|
|
||||||
|
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
|
||||||
|
foreach (var element in elements)
|
||||||
|
{
|
||||||
|
if (element.Passes || element.IsWhiteList || element.Hidden)
|
||||||
|
continue;
|
||||||
|
fixList.Add(element);
|
||||||
|
}
|
||||||
|
FixInternal(scannerGUID, fixList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修复选定元素
|
||||||
|
/// 注意:包含白名单和隐藏元素
|
||||||
|
/// </summary>
|
||||||
|
public void FixSelect()
|
||||||
|
{
|
||||||
|
foreach (var scanReport in _combines.Values)
|
||||||
|
{
|
||||||
|
string scannerGUID = scanReport.ScannerGUID;
|
||||||
|
var elements = scanReport.ReportElements;
|
||||||
|
|
||||||
|
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
|
||||||
|
foreach (var element in elements)
|
||||||
|
{
|
||||||
|
if (element.Passes)
|
||||||
|
continue;
|
||||||
|
if (element.IsSelected)
|
||||||
|
fixList.Add(element);
|
||||||
|
}
|
||||||
|
FixInternal(scannerGUID, fixList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixInternal(string scannerGUID, List<ReportElement> fixList)
|
||||||
|
{
|
||||||
|
AssetArtScanner scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||||
|
if (scanner != null)
|
||||||
|
{
|
||||||
|
var schema = scanner.LoadSchema();
|
||||||
|
if (schema != null)
|
||||||
|
{
|
||||||
|
schema.FixResult(fixList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8524c3deb9b27fe4e8e63f15b9ffaaa3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
54
Assets/YooAsset/Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
54
Assets/YooAsset/Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ScanReportConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 导入JSON报告文件
|
||||||
|
/// </summary>
|
||||||
|
public static ScanReport ImportJsonConfig(string filePath)
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
throw new FileNotFoundException(filePath);
|
||||||
|
|
||||||
|
string jsonData = FileUtility.ReadAllText(filePath);
|
||||||
|
ScanReport report = JsonUtility.FromJson<ScanReport>(jsonData);
|
||||||
|
|
||||||
|
// 检测配置文件的签名
|
||||||
|
if (report.FileSign != ScannerDefine.ReportFileSign)
|
||||||
|
throw new Exception($"导入的报告文件无法识别 : {filePath}");
|
||||||
|
|
||||||
|
// 检测报告文件的版本
|
||||||
|
if (report.FileVersion != ScannerDefine.ReportFileVersion)
|
||||||
|
throw new Exception($"报告文件的版本不匹配 : {report.FileVersion} != {ScannerDefine.ReportFileVersion}");
|
||||||
|
|
||||||
|
// 检测标题数和内容是否匹配
|
||||||
|
foreach (var element in report.ReportElements)
|
||||||
|
{
|
||||||
|
if (element.ScanInfos.Count != report.ReportHeaders.Count)
|
||||||
|
{
|
||||||
|
throw new Exception($"报告的标题数和内容不匹配!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导出JSON报告文件
|
||||||
|
/// </summary>
|
||||||
|
public static void ExportJsonConfig(string savePath, ScanReport scanReport)
|
||||||
|
{
|
||||||
|
if (File.Exists(savePath))
|
||||||
|
File.Delete(savePath);
|
||||||
|
|
||||||
|
string json = JsonUtility.ToJson(scanReport, true);
|
||||||
|
FileUtility.WriteAllText(savePath, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 694cf47ade54f2b4fa6e618c1310c476
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 9f9f9848e17e5eb46b596a07391a42cc
|
guid: 9bc1ecc3b72dfc34782fb6926d679f92
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
13
Assets/YooAsset/Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
13
Assets/YooAsset/Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AssetArtCollector
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描目录
|
||||||
|
/// </summary>
|
||||||
|
public string CollectPath = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e7252b59455e5c45af0041ccd24b234
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
132
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
132
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AssetArtScanner
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描器GUID
|
||||||
|
/// </summary>
|
||||||
|
public string ScannerGUID = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描器名称
|
||||||
|
/// </summary>
|
||||||
|
public string ScannerName = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描器描述
|
||||||
|
/// </summary>
|
||||||
|
public string ScannerDesc = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描模式
|
||||||
|
/// 注意:文件路径或文件GUID
|
||||||
|
/// </summary>
|
||||||
|
public string ScannerSchema = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存储目录
|
||||||
|
/// </summary>
|
||||||
|
public string SaveDirectory = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收集列表
|
||||||
|
/// </summary>
|
||||||
|
public List<AssetArtCollector> Collectors = new List<AssetArtCollector>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 白名单
|
||||||
|
/// </summary>
|
||||||
|
public List<string> WhiteList = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测关键字匹配
|
||||||
|
/// </summary>
|
||||||
|
public bool CheckKeyword(string keyword)
|
||||||
|
{
|
||||||
|
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否在白名单里
|
||||||
|
/// </summary>
|
||||||
|
public bool CheckWhiteList(string guid)
|
||||||
|
{
|
||||||
|
return WhiteList.Contains(guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测配置错误
|
||||||
|
/// </summary>
|
||||||
|
public void CheckConfigError()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ScannerName))
|
||||||
|
throw new Exception($"Scanner name is null or empty !");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(ScannerSchema))
|
||||||
|
throw new Exception($"Scanner {ScannerName} schema is null !");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(SaveDirectory) == false)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(SaveDirectory) == false)
|
||||||
|
throw new Exception($"Scanner {ScannerName} save directory is invalid : {SaveDirectory}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载扫描模式实例
|
||||||
|
/// </summary>
|
||||||
|
public ScannerSchema LoadSchema()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ScannerSchema))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
string filePath;
|
||||||
|
if (ScannerSchema.StartsWith("Assets/"))
|
||||||
|
{
|
||||||
|
filePath = ScannerSchema;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string guid = ScannerSchema;
|
||||||
|
filePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var schema = AssetDatabase.LoadMainAssetAtPath(filePath) as ScannerSchema;
|
||||||
|
if (schema == null)
|
||||||
|
Debug.LogWarning($"Failed load scanner schema : {filePath}");
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 运行扫描器生成报告类
|
||||||
|
/// </summary>
|
||||||
|
public ScanReport RunScanner()
|
||||||
|
{
|
||||||
|
if (Collectors.Count == 0)
|
||||||
|
Debug.LogWarning($"Scanner {ScannerName} collector is empty !");
|
||||||
|
|
||||||
|
ScannerSchema schema = LoadSchema();
|
||||||
|
if (schema == null)
|
||||||
|
throw new Exception($"Failed to load schema : {ScannerSchema}");
|
||||||
|
|
||||||
|
var report = schema.RunScanner(this);
|
||||||
|
report.FileSign = ScannerDefine.ReportFileSign;
|
||||||
|
report.FileVersion = ScannerDefine.ReportFileVersion;
|
||||||
|
report.SchemaType = schema.GetType().FullName;
|
||||||
|
report.ScannerGUID = ScannerGUID;
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c63683b07b7a2454b93539ae6b9f32ea
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class AssetArtScannerConfig
|
||||||
|
{
|
||||||
|
public class ConfigWrapper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件签名
|
||||||
|
/// </summary>
|
||||||
|
public string FileSign;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件版本
|
||||||
|
/// </summary>
|
||||||
|
public string FileVersion;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描器列表
|
||||||
|
/// </summary>
|
||||||
|
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导入JSON配置文件
|
||||||
|
/// </summary>
|
||||||
|
public static void ImportJsonConfig(string filePath)
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
throw new FileNotFoundException(filePath);
|
||||||
|
|
||||||
|
string json = FileUtility.ReadAllText(filePath);
|
||||||
|
ConfigWrapper setting = JsonUtility.FromJson<ConfigWrapper>(json);
|
||||||
|
|
||||||
|
// 检测配置文件的签名
|
||||||
|
if (setting.FileSign != ScannerDefine.SettingFileSign)
|
||||||
|
throw new Exception($"导入的配置文件无法识别 : {filePath}");
|
||||||
|
|
||||||
|
// 检测配置文件的版本
|
||||||
|
if (setting.FileVersion != ScannerDefine.SettingFileVersion)
|
||||||
|
throw new Exception($"配置文件的版本不匹配 : {setting.FileVersion} != {ScannerDefine.SettingFileVersion}");
|
||||||
|
|
||||||
|
// 检测配置合法性
|
||||||
|
HashSet<string> scanGUIDs = new HashSet<string>();
|
||||||
|
foreach (var sacnner in setting.Scanners)
|
||||||
|
{
|
||||||
|
if (scanGUIDs.Contains(sacnner.ScannerGUID))
|
||||||
|
{
|
||||||
|
throw new Exception($"Scanner {sacnner.ScannerName} GUID is existed : {sacnner.ScannerGUID} ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scanGUIDs.Add(sacnner.ScannerGUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetArtScannerSettingData.Setting.Scanners = setting.Scanners;
|
||||||
|
AssetArtScannerSettingData.SaveFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导出JSON配置文件
|
||||||
|
/// </summary>
|
||||||
|
public static void ExportJsonConfig(string savePath)
|
||||||
|
{
|
||||||
|
if (File.Exists(savePath))
|
||||||
|
File.Delete(savePath);
|
||||||
|
|
||||||
|
ConfigWrapper wrapper = new ConfigWrapper();
|
||||||
|
wrapper.FileSign = ScannerDefine.SettingFileSign;
|
||||||
|
wrapper.FileVersion = ScannerDefine.SettingFileVersion;
|
||||||
|
wrapper.Scanners = AssetArtScannerSettingData.Setting.Scanners;
|
||||||
|
|
||||||
|
string json = JsonUtility.ToJson(wrapper, true);
|
||||||
|
FileUtility.WriteAllText(savePath, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bed1ef72d1c03e848a41d5ea115e9870
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using NUnit.Framework.Constraints;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class AssetArtScannerSetting : ScriptableObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描器列表
|
||||||
|
/// </summary>
|
||||||
|
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始扫描
|
||||||
|
/// </summary>
|
||||||
|
public ScannerResult BeginScan(string scannerGUID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 获取扫描器配置
|
||||||
|
var scanner = GetScanner(scannerGUID);
|
||||||
|
if (scanner == null)
|
||||||
|
throw new Exception($"Invalid scanner GUID : {scannerGUID}");
|
||||||
|
|
||||||
|
// 检测配置合法性
|
||||||
|
scanner.CheckConfigError();
|
||||||
|
|
||||||
|
// 开始扫描工作
|
||||||
|
ScanReport report = scanner.RunScanner();
|
||||||
|
report.CheckError();
|
||||||
|
|
||||||
|
// 返回扫描结果
|
||||||
|
return new ScannerResult(report);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new ScannerResult(e.Message, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定的扫描器
|
||||||
|
/// </summary>
|
||||||
|
public AssetArtScanner GetScanner(string scannerGUID)
|
||||||
|
{
|
||||||
|
foreach (var scanner in Scanners)
|
||||||
|
{
|
||||||
|
if (scanner.ScannerGUID == scannerGUID)
|
||||||
|
return scanner;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogWarning($"Not found scanner : {scannerGUID}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 84df5e62e3f1b6746a1263e076b003e1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class AssetArtScannerSettingData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置数据是否被修改
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsDirty { private set; get; } = false;
|
||||||
|
|
||||||
|
|
||||||
|
static AssetArtScannerSettingData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AssetArtScannerSetting _setting = null;
|
||||||
|
public static AssetArtScannerSetting Setting
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
_setting = SettingLoader.LoadSettingData<AssetArtScannerSetting>();
|
||||||
|
return _setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存储配置文件
|
||||||
|
/// </summary>
|
||||||
|
public static void SaveFile()
|
||||||
|
{
|
||||||
|
if (Setting != null)
|
||||||
|
{
|
||||||
|
IsDirty = false;
|
||||||
|
EditorUtility.SetDirty(Setting);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
Debug.Log($"{nameof(AssetArtScannerSetting)}.asset is saved!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空所有数据
|
||||||
|
/// </summary>
|
||||||
|
public static void ClearAll()
|
||||||
|
{
|
||||||
|
Setting.Scanners.Clear();
|
||||||
|
SaveFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描所有项
|
||||||
|
/// </summary>
|
||||||
|
public static void ScanAll()
|
||||||
|
{
|
||||||
|
foreach (var scanner in Setting.Scanners)
|
||||||
|
{
|
||||||
|
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||||
|
if (scanResult.Succeed == false)
|
||||||
|
{
|
||||||
|
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描所有项
|
||||||
|
/// </summary>
|
||||||
|
public static void ScanAll(string keyword)
|
||||||
|
{
|
||||||
|
foreach (var scanner in Setting.Scanners)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(keyword) == false)
|
||||||
|
{
|
||||||
|
if (scanner.CheckKeyword(keyword) == false)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||||
|
if (scanResult.Succeed == false)
|
||||||
|
{
|
||||||
|
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描单项
|
||||||
|
/// </summary>
|
||||||
|
public static ScannerResult Scan(string scannerGUID)
|
||||||
|
{
|
||||||
|
var scanResult = Setting.BeginScan(scannerGUID);
|
||||||
|
if (scanResult.Succeed == false)
|
||||||
|
{
|
||||||
|
Debug.LogError(scanResult.ErrorInfo);
|
||||||
|
}
|
||||||
|
return scanResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扫描器编辑相关
|
||||||
|
public static AssetArtScanner CreateScanner(string name, string desc)
|
||||||
|
{
|
||||||
|
AssetArtScanner scanner = new AssetArtScanner();
|
||||||
|
scanner.ScannerGUID = System.Guid.NewGuid().ToString();
|
||||||
|
scanner.ScannerName = name;
|
||||||
|
scanner.ScannerDesc = desc;
|
||||||
|
Setting.Scanners.Add(scanner);
|
||||||
|
IsDirty = true;
|
||||||
|
return scanner;
|
||||||
|
}
|
||||||
|
public static void RemoveScanner(AssetArtScanner scanner)
|
||||||
|
{
|
||||||
|
if (Setting.Scanners.Remove(scanner))
|
||||||
|
{
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Failed remove scanner : {scanner.ScannerName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void ModifyScanner(AssetArtScanner scanner)
|
||||||
|
{
|
||||||
|
if (scanner != null)
|
||||||
|
{
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 资源收集编辑相关
|
||||||
|
public static void CreateCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||||
|
{
|
||||||
|
scanner.Collectors.Add(collector);
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
public static void RemoveCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||||
|
{
|
||||||
|
if (scanner.Collectors.Remove(collector))
|
||||||
|
{
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void ModifyCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||||
|
{
|
||||||
|
if (scanner != null && collector != null)
|
||||||
|
{
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fda10f23f6f36bf498b54323fe4f680b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
549
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
549
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
@@ -0,0 +1,549 @@
|
|||||||
|
#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 AssetArtScannerWindow : EditorWindow
|
||||||
|
{
|
||||||
|
[MenuItem("YooAsset/AssetArt Scanner", false, 301)]
|
||||||
|
public static void OpenWindow()
|
||||||
|
{
|
||||||
|
AssetArtScannerWindow window = GetWindow<AssetArtScannerWindow>("AssetArt Scanner", true, WindowsDefine.DockedWindowTypes);
|
||||||
|
window.minSize = new Vector2(800, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button _saveButton;
|
||||||
|
private ListView _scannerListView;
|
||||||
|
private ToolbarSearchField _scannerSearchField;
|
||||||
|
private VisualElement _scannerContentContainer;
|
||||||
|
private VisualElement _inspectorContainer;
|
||||||
|
private Label _schemaGuideTxt;
|
||||||
|
private TextField _scannerNameTxt;
|
||||||
|
private TextField _scannerDescTxt;
|
||||||
|
private ObjectField _scannerSchemaField;
|
||||||
|
private ObjectField _outputFolderField;
|
||||||
|
private ScrollView _collectorScrollView;
|
||||||
|
|
||||||
|
private int _lastModifyScannerIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public void CreateGUI()
|
||||||
|
{
|
||||||
|
Undo.undoRedoPerformed -= RefreshWindow;
|
||||||
|
Undo.undoRedoPerformed += RefreshWindow;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
|
// 加载布局文件
|
||||||
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtScannerWindow>();
|
||||||
|
if (visualAsset == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
|
// 导入导出按钮
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 扫描按钮
|
||||||
|
var scanAllBtn = root.Q<Button>("ScanAllButton");
|
||||||
|
scanAllBtn.clicked += ScanAllBtn_clicked;
|
||||||
|
var scanBtn = root.Q<Button>("ScanBtn");
|
||||||
|
scanBtn.clicked += ScanBtn_clicked;
|
||||||
|
|
||||||
|
// 扫描列表相关
|
||||||
|
_scannerListView = root.Q<ListView>("ScannerListView");
|
||||||
|
_scannerListView.makeItem = MakeScannerListViewItem;
|
||||||
|
_scannerListView.bindItem = BindScannerListViewItem;
|
||||||
|
#if UNITY_2022_3_OR_NEWER
|
||||||
|
_scannerListView.selectionChanged += ScannerListView_onSelectionChange;
|
||||||
|
#elif UNITY_2020_1_OR_NEWER
|
||||||
|
_scannerListView.onSelectionChange += ScannerListView_onSelectionChange;
|
||||||
|
#else
|
||||||
|
_scannerListView.onSelectionChanged += ScannerListView_onSelectionChange;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 扫描列表过滤
|
||||||
|
_scannerSearchField = root.Q<ToolbarSearchField>("ScannerSearchField");
|
||||||
|
_scannerSearchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||||
|
|
||||||
|
// 扫描器添加删除按钮
|
||||||
|
var scannerAddContainer = root.Q("ScannerAddContainer");
|
||||||
|
{
|
||||||
|
var addBtn = scannerAddContainer.Q<Button>("AddBtn");
|
||||||
|
addBtn.clicked += AddScannerBtn_clicked;
|
||||||
|
var removeBtn = scannerAddContainer.Q<Button>("RemoveBtn");
|
||||||
|
removeBtn.clicked += RemoveScannerBtn_clicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扫描器容器
|
||||||
|
_scannerContentContainer = root.Q("ScannerContentContainer");
|
||||||
|
|
||||||
|
// 检视界面容器
|
||||||
|
_inspectorContainer = root.Q("InspectorContainer");
|
||||||
|
|
||||||
|
// 扫描器指南
|
||||||
|
_schemaGuideTxt = root.Q<Label>("SchemaUserGuide");
|
||||||
|
|
||||||
|
// 扫描器名称
|
||||||
|
_scannerNameTxt = root.Q<TextField>("ScannerName");
|
||||||
|
_scannerNameTxt.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner != null)
|
||||||
|
{
|
||||||
|
selectScanner.ScannerName = evt.newValue;
|
||||||
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
|
FillScannerListViewData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 扫描器备注
|
||||||
|
_scannerDescTxt = root.Q<TextField>("ScannerDesc");
|
||||||
|
_scannerDescTxt.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner != null)
|
||||||
|
{
|
||||||
|
selectScanner.ScannerDesc = evt.newValue;
|
||||||
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
|
FillScannerListViewData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 扫描模式
|
||||||
|
_scannerSchemaField = root.Q<ObjectField>("ScanSchema");
|
||||||
|
_scannerSchemaField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner != null)
|
||||||
|
{
|
||||||
|
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
|
selectScanner.ScannerSchema = AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 存储目录
|
||||||
|
_outputFolderField = root.Q<ObjectField>("OutputFolder");
|
||||||
|
_outputFolderField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner != null)
|
||||||
|
{
|
||||||
|
if (evt.newValue == null)
|
||||||
|
{
|
||||||
|
selectScanner.SaveDirectory = string.Empty;
|
||||||
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
|
if (AssetDatabase.IsValidFolder(assetPath))
|
||||||
|
{
|
||||||
|
selectScanner.SaveDirectory = assetPath;
|
||||||
|
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Select asset object not folder ! {assetPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 收集列表相关
|
||||||
|
_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新窗体
|
||||||
|
RefreshWindow();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
// 注意:清空所有撤销操作
|
||||||
|
Undo.ClearAll();
|
||||||
|
|
||||||
|
if (AssetArtScannerSettingData.IsDirty)
|
||||||
|
AssetArtScannerSettingData.SaveFile();
|
||||||
|
}
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (_saveButton != null)
|
||||||
|
{
|
||||||
|
if (AssetArtScannerSettingData.IsDirty)
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf == false)
|
||||||
|
_saveButton.SetEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf)
|
||||||
|
_saveButton.SetEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshWindow()
|
||||||
|
{
|
||||||
|
_scannerContentContainer.visible = false;
|
||||||
|
|
||||||
|
FillScannerListViewData();
|
||||||
|
}
|
||||||
|
private void ExportBtn_clicked()
|
||||||
|
{
|
||||||
|
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||||
|
if (resultPath != null)
|
||||||
|
{
|
||||||
|
AssetArtScannerConfig.ExportJsonConfig($"{resultPath}/AssetArtScannerConfig.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ImportBtn_clicked()
|
||||||
|
{
|
||||||
|
string resultPath = EditorTools.OpenFilePath("Import JSON", "Assets/", "json");
|
||||||
|
if (resultPath != null)
|
||||||
|
{
|
||||||
|
AssetArtScannerConfig.ImportJsonConfig(resultPath);
|
||||||
|
RefreshWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void SaveBtn_clicked()
|
||||||
|
{
|
||||||
|
AssetArtScannerSettingData.SaveFile();
|
||||||
|
}
|
||||||
|
private void ScanAllBtn_clicked()
|
||||||
|
{
|
||||||
|
if (EditorUtility.DisplayDialog("Info", $"Start full scan!", "Yes", "No"))
|
||||||
|
{
|
||||||
|
string searchKeyWord = _scannerSearchField.value;
|
||||||
|
AssetArtScannerSettingData.ScanAll(searchKeyWord);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Full scan has been canceled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ScanBtn_clicked()
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ScannerResult scannerResult = AssetArtScannerSettingData.Scan(selectScanner.ScannerGUID);
|
||||||
|
if (scannerResult.Succeed)
|
||||||
|
{
|
||||||
|
// 自动打开报告界面
|
||||||
|
scannerResult.OpenReportWindow();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
|
{
|
||||||
|
_lastModifyScannerIndex = 0;
|
||||||
|
RefreshWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分组列表相关
|
||||||
|
private void FillScannerListViewData()
|
||||||
|
{
|
||||||
|
_scannerListView.Clear();
|
||||||
|
_scannerListView.ClearSelection();
|
||||||
|
|
||||||
|
var filterItems = FilterScanners();
|
||||||
|
if (AssetArtScannerSettingData.Setting.Scanners.Count == filterItems.Count)
|
||||||
|
{
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
_scannerListView.reorderable = true;
|
||||||
|
#endif
|
||||||
|
_scannerListView.itemsSource = AssetArtScannerSettingData.Setting.Scanners;
|
||||||
|
_scannerListView.Rebuild();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
_scannerListView.reorderable = false;
|
||||||
|
#endif
|
||||||
|
_scannerListView.itemsSource = filterItems;
|
||||||
|
_scannerListView.Rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_lastModifyScannerIndex >= 0 && _lastModifyScannerIndex < _scannerListView.itemsSource.Count)
|
||||||
|
{
|
||||||
|
_scannerListView.selectedIndex = _lastModifyScannerIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<AssetArtScanner> FilterScanners()
|
||||||
|
{
|
||||||
|
string searchKeyWord = _scannerSearchField.value;
|
||||||
|
List<AssetArtScanner> result = new List<AssetArtScanner>(AssetArtScannerSettingData.Setting.Scanners.Count);
|
||||||
|
|
||||||
|
// 过滤列表
|
||||||
|
foreach (var scanner in AssetArtScannerSettingData.Setting.Scanners)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||||
|
{
|
||||||
|
if (scanner.CheckKeyword(searchKeyWord) == false)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.Add(scanner);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
private VisualElement MakeScannerListViewItem()
|
||||||
|
{
|
||||||
|
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 BindScannerListViewItem(VisualElement element, int index)
|
||||||
|
{
|
||||||
|
List<AssetArtScanner> sourceList = _scannerListView.itemsSource as List<AssetArtScanner>;
|
||||||
|
var scanner = sourceList[index];
|
||||||
|
var textField1 = element.Q<Label>("Label1");
|
||||||
|
if (string.IsNullOrEmpty(scanner.ScannerDesc))
|
||||||
|
textField1.text = scanner.ScannerName;
|
||||||
|
else
|
||||||
|
textField1.text = $"{scanner.ScannerName} ({scanner.ScannerDesc})";
|
||||||
|
}
|
||||||
|
private void ScannerListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner == null)
|
||||||
|
{
|
||||||
|
_scannerContentContainer.visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_scannerContentContainer.visible = true;
|
||||||
|
_lastModifyScannerIndex = _scannerListView.selectedIndex;
|
||||||
|
_scannerNameTxt.SetValueWithoutNotify(selectScanner.ScannerName);
|
||||||
|
_scannerDescTxt.SetValueWithoutNotify(selectScanner.ScannerDesc);
|
||||||
|
|
||||||
|
// 显示检视面板
|
||||||
|
var scanSchema = selectScanner.LoadSchema();
|
||||||
|
RefreshInspector(scanSchema);
|
||||||
|
|
||||||
|
// 设置Schema对象
|
||||||
|
if (scanSchema == null)
|
||||||
|
{
|
||||||
|
_scannerSchemaField.SetValueWithoutNotify(null);
|
||||||
|
_schemaGuideTxt.text = string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_scannerSchemaField.SetValueWithoutNotify(scanSchema);
|
||||||
|
_schemaGuideTxt.text = scanSchema.GetUserGuide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示存储目录
|
||||||
|
DefaultAsset saveFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(selectScanner.SaveDirectory);
|
||||||
|
if (saveFolder == null)
|
||||||
|
{
|
||||||
|
_outputFolderField.SetValueWithoutNotify(null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_outputFolderField.SetValueWithoutNotify(saveFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
FillCollectorViewData();
|
||||||
|
}
|
||||||
|
private void AddScannerBtn_clicked()
|
||||||
|
{
|
||||||
|
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddScanner");
|
||||||
|
AssetArtScannerSettingData.CreateScanner("Default Scanner", string.Empty);
|
||||||
|
FillScannerListViewData();
|
||||||
|
}
|
||||||
|
private void RemoveScannerBtn_clicked()
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveScanner");
|
||||||
|
AssetArtScannerSettingData.RemoveScanner(selectScanner);
|
||||||
|
FillScannerListViewData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收集列表相关
|
||||||
|
private void FillCollectorViewData()
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 填充数据
|
||||||
|
_collectorScrollView.Clear();
|
||||||
|
for (int i = 0; i < selectScanner.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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Space VisualElement
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.style.height = 10;
|
||||||
|
elementSpace.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||||
|
{
|
||||||
|
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectScanner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var collector = selectScanner.Collectors[index];
|
||||||
|
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||||
|
if (collectObject != null)
|
||||||
|
collectObject.name = collector.CollectPath;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
objectField1.value.name = collector.CollectPath;
|
||||||
|
AssetArtScannerSettingData.ModifyCollector(selectScanner, collector);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private void AddCollectorBtn_clicked()
|
||||||
|
{
|
||||||
|
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectSacnner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddCollector");
|
||||||
|
AssetArtCollector collector = new AssetArtCollector();
|
||||||
|
AssetArtScannerSettingData.CreateCollector(selectSacnner, collector);
|
||||||
|
FillCollectorViewData();
|
||||||
|
}
|
||||||
|
private void RemoveCollectorBtn_clicked(AssetArtCollector selectCollector)
|
||||||
|
{
|
||||||
|
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||||
|
if (selectSacnner == null)
|
||||||
|
return;
|
||||||
|
if (selectCollector == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveCollector");
|
||||||
|
AssetArtScannerSettingData.RemoveCollector(selectSacnner, selectCollector);
|
||||||
|
FillCollectorViewData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 属性面板相关
|
||||||
|
private void RefreshInspector(ScannerSchema scanSchema)
|
||||||
|
{
|
||||||
|
if (scanSchema == null)
|
||||||
|
{
|
||||||
|
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var inspector = scanSchema.CreateInspector();
|
||||||
|
if (inspector == null)
|
||||||
|
{
|
||||||
|
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inspector.Containner is VisualElement container)
|
||||||
|
{
|
||||||
|
UIElementsTools.SetElementVisible(_inspectorContainer, true);
|
||||||
|
_inspectorContainer.Clear();
|
||||||
|
_inspectorContainer.Add(container);
|
||||||
|
_inspectorContainer.style.width = inspector.Width;
|
||||||
|
_inspectorContainer.style.minWidth = inspector.MinWidth;
|
||||||
|
_inspectorContainer.style.maxWidth = inspector.MaxWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"{nameof(ScannerSchema)} inspector container is invalid !");
|
||||||
|
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bff583b32bbeb7e498920bfdc84dba90
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" 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="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
|
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
|
<ui:Button text="Scan All" display-tooltip-when-elided="true" name="ScanAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||||
|
</uie:Toolbar>
|
||||||
|
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||||
|
<ui:VisualElement name="ScannerListContainer" style="width: 250px; 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:Label text="Scanner List" display-tooltip-when-elided="true" name="ScannerListTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 3px; border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; font-size: 12px;" />
|
||||||
|
<uie:ToolbarSearchField focusable="true" name="ScannerSearchField" style="width: 230px;" />
|
||||||
|
<ui:ListView focusable="true" name="ScannerListView" item-height="20" virtualization-method="DynamicHeight" reorder-mode="Animated" reorderable="true" style="flex-grow: 1;" />
|
||||||
|
<ui:VisualElement name="ScannerAddContainer" style="justify-content: center; flex-direction: row; flex-shrink: 0;">
|
||||||
|
<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="ScannerContentContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; min-width: 400px;">
|
||||||
|
<ui:Label text="Scanner" display-tooltip-when-elided="true" name="ScannerContentTitle" style="-unity-text-align: upper-center; -unity-font-style: bold; font-size: 12px; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; background-color: rgb(89, 89, 89);" />
|
||||||
|
<ui:Label display-tooltip-when-elided="true" name="SchemaUserGuide" style="-unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px; height: 40px;" />
|
||||||
|
<ui:TextField picking-mode="Ignore" label="Scanner Name" name="ScannerName" />
|
||||||
|
<ui:TextField picking-mode="Ignore" label="Scanner Desc" name="ScannerDesc" />
|
||||||
|
<uie:ObjectField label="Scanner Schema" name="ScanSchema" type="YooAsset.Editor.ScannerSchema, YooAsset.Editor" allow-scene-objects="false" />
|
||||||
|
<uie:ObjectField label="Output Folder" name="OutputFolder" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" />
|
||||||
|
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||||
|
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||||
|
<ui:Button text="Scan" display-tooltip-when-elided="true" name="ScanBtn" style="width: 60px;" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
<ui:VisualElement name="InspectorContainer" style="flex-grow: 1; border-top-width: 5px; border-right-width: 5px; border-bottom-width: 5px; border-left-width: 5px; background-color: rgb(67, 67, 67);" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:UXML>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5bbb873a7bee2924a86c876b67bb2cb4
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
26
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs
Normal file
26
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ScannerDefine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报告文件签名
|
||||||
|
/// </summary>
|
||||||
|
public const string ReportFileSign = "596f6f4172745265706f7274";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置文件签名
|
||||||
|
/// </summary>
|
||||||
|
public const string SettingFileSign = "596f6f41727453657474696e67";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报告文件的版本
|
||||||
|
/// </summary>
|
||||||
|
public const string ReportFileVersion = "1.0";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置文件的版本
|
||||||
|
/// </summary>
|
||||||
|
public const string SettingFileVersion = "1.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ed658bfc32cbfc44caf262a741a7c387
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
72
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs
Normal file
72
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ScannerResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报告对象
|
||||||
|
/// </summary>
|
||||||
|
public ScanReport Report { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误信息
|
||||||
|
/// </summary>
|
||||||
|
public string ErrorInfo { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误堆栈
|
||||||
|
/// </summary>
|
||||||
|
public string ErrorStack { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否成功
|
||||||
|
/// </summary>
|
||||||
|
public bool Succeed
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ErrorInfo))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ScannerResult(string error, string stack)
|
||||||
|
{
|
||||||
|
ErrorInfo = error;
|
||||||
|
ErrorStack = stack;
|
||||||
|
}
|
||||||
|
public ScannerResult(ScanReport report)
|
||||||
|
{
|
||||||
|
Report = report;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打开报告窗口
|
||||||
|
/// </summary>
|
||||||
|
public void OpenReportWindow()
|
||||||
|
{
|
||||||
|
if (Succeed)
|
||||||
|
{
|
||||||
|
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||||
|
reproterWindow.ImportSingleReprotFile(Report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存报告文件
|
||||||
|
/// </summary>
|
||||||
|
public void SaveReportFile(string saveDirectory)
|
||||||
|
{
|
||||||
|
if (Report == null)
|
||||||
|
throw new System.Exception("Scan report is invalid !");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(saveDirectory))
|
||||||
|
saveDirectory = "Assets/";
|
||||||
|
string filePath = $"{saveDirectory}/{Report.ReportName}_{Report.ReportDesc}.json";
|
||||||
|
ScanReportConfig.ExportJsonConfig(filePath, Report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e10cdab189d80b142ad5903d12956c59
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
32
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs
Normal file
32
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public abstract class ScannerSchema : ScriptableObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户指南信息
|
||||||
|
/// </summary>
|
||||||
|
public abstract string GetUserGuide();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 运行生成扫描报告
|
||||||
|
/// </summary>
|
||||||
|
public abstract ScanReport RunScanner(AssetArtScanner scanner);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修复扫描结果
|
||||||
|
/// </summary>
|
||||||
|
public abstract void FixResult(List<ReportElement> fixList);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建检视面板
|
||||||
|
/// </summary>
|
||||||
|
public virtual SchemaInspector CreateInspector()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eb6a587c72ccecc4ab6d386063cf0736
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
45
Assets/YooAsset/Editor/AssetArtScanner/SchemaInspector.cs
Normal file
45
Assets/YooAsset/Editor/AssetArtScanner/SchemaInspector.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class SchemaInspector
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 检视界面的UI元素容器(UIElements元素)
|
||||||
|
/// </summary>
|
||||||
|
public object Containner { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检视界面宽度
|
||||||
|
/// </summary>
|
||||||
|
public int Width = 250;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检视界面最小宽度
|
||||||
|
/// </summary>
|
||||||
|
public int MinWidth = 250;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检视界面最大宽度
|
||||||
|
/// </summary>
|
||||||
|
public int MaxWidth = 250;
|
||||||
|
|
||||||
|
public SchemaInspector(object containner)
|
||||||
|
{
|
||||||
|
Containner = containner;
|
||||||
|
}
|
||||||
|
public SchemaInspector(object containner, int width)
|
||||||
|
{
|
||||||
|
Containner = containner;
|
||||||
|
Width = width;
|
||||||
|
MinWidth = width;
|
||||||
|
MaxWidth = width;
|
||||||
|
}
|
||||||
|
public SchemaInspector(object containner, int width, int minWidth, int maxWidth)
|
||||||
|
{
|
||||||
|
Containner = containner;
|
||||||
|
Width = width;
|
||||||
|
MinWidth = minWidth;
|
||||||
|
MaxWidth = maxWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3440549fcb36bbf4c8c6da17fb858947
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -32,11 +32,12 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_buildContext.SetContextObject(buildParametersContext);
|
||||||
|
|
||||||
// 初始化日志
|
// 初始化日志系统
|
||||||
BuildLogger.InitLogger(enableLog);
|
string logFilePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/buildInfo.log";
|
||||||
|
BuildLogger.InitLogger(enableLog, logFilePath);
|
||||||
|
|
||||||
// 执行构建流程
|
// 执行构建流程
|
||||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
BuildLogger.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
@@ -50,6 +51,9 @@ namespace YooAsset.Editor
|
|||||||
BuildLogger.Error(buildResult.ErrorInfo);
|
BuildLogger.Error(buildResult.ErrorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关闭日志系统
|
||||||
|
BuildLogger.Shuntdown();
|
||||||
|
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetStreamingAssetsRoot()
|
public static string GetStreamingAssetsRoot()
|
||||||
{
|
{
|
||||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
return YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,88 +6,125 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public static class AssetBundleBuilderSetting
|
public static class AssetBundleBuilderSetting
|
||||||
{
|
{
|
||||||
// EBuildPipeline
|
// BuildPipelineName
|
||||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
public static string GetPackageBuildPipeline(string packageName)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
string defaultValue = EBuildPipeline.ScriptableBuildPipeline.ToString();
|
||||||
|
return EditorPrefs.GetString(key, defaultValue);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
public static void SetPackageBuildPipeline(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
EditorPrefs.SetString(key, buildPipeline);
|
||||||
}
|
|
||||||
|
|
||||||
// EBuildMode
|
|
||||||
public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline)
|
|
||||||
{
|
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
|
||||||
return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild);
|
|
||||||
}
|
|
||||||
public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode)
|
|
||||||
{
|
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
|
||||||
EditorPrefs.SetInt(key, (int)buildMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECompressOption
|
// ECompressOption
|
||||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
public static ECompressOption GetPackageCompressOption(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||||
}
|
}
|
||||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
public static void SetPackageCompressOption(string packageName, string buildPipeline, ECompressOption compressOption)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||||
EditorPrefs.SetInt(key, (int)compressOption);
|
EditorPrefs.SetInt(key, (int)compressOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EFileNameStyle
|
// EFileNameStyle
|
||||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
public static EFileNameStyle GetPackageFileNameStyle(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||||
}
|
}
|
||||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
public static void SetPackageFileNameStyle(string packageName, string buildPipeline, EFileNameStyle fileNameStyle)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EBuildinFileCopyOption
|
// EBuildinFileCopyOption
|
||||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
public static void SetPackageBuildinFileCopyOption(string packageName, string buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildFileCopyParams
|
// BuildFileCopyParams
|
||||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
public static string GetPackageBuildinFileCopyParams(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||||
return EditorPrefs.GetString(key, string.Empty);
|
return EditorPrefs.GetString(key, string.Empty);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
public static void SetPackageBuildinFileCopyParams(string packageName, string buildPipeline, string buildinFileCopyParams)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncyptionClassName
|
// EncyptionServicesClassName
|
||||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
public static string GetPackageEncyptionServicesClassName(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||||
return EditorPrefs.GetString(key, string.Empty);
|
return EditorPrefs.GetString(key, $"{typeof(EncryptionNone).FullName}");
|
||||||
}
|
}
|
||||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
public static void SetPackageEncyptionServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||||
EditorPrefs.SetString(key, encyptionClassName);
|
EditorPrefs.SetString(key, encyptionClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ManifestProcessServicesClassName
|
||||||
|
public static string GetPackageManifestProcessServicesClassName(string packageName, string buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestProcessServicesClassName";
|
||||||
|
return EditorPrefs.GetString(key, $"{typeof(ManifestProcessNone).FullName}");
|
||||||
|
}
|
||||||
|
public static void SetPackageManifestProcessServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestProcessServicesClassName";
|
||||||
|
EditorPrefs.SetString(key, encyptionClassName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ManifestRestoreServicesClassName
|
||||||
|
public static string GetPackageManifestRestoreServicesClassName(string packageName, string buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestRestoreServicesClassName";
|
||||||
|
return EditorPrefs.GetString(key, $"{typeof(ManifestRestoreNone).FullName}");
|
||||||
|
}
|
||||||
|
public static void SetPackageManifestRestoreServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestRestoreServicesClassName";
|
||||||
|
EditorPrefs.SetString(key, encyptionClassName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearBuildCache
|
||||||
|
public static bool GetPackageClearBuildCache(string packageName, string buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||||
|
return EditorPrefs.GetInt(key, 0) > 0;
|
||||||
|
}
|
||||||
|
public static void SetPackageClearBuildCache(string packageName, string buildPipeline, bool clearBuildCache)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||||
|
EditorPrefs.SetInt(key, clearBuildCache ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UseAssetDependencyDB
|
||||||
|
public static bool GetPackageUseAssetDependencyDB(string packageName, string buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||||
|
return EditorPrefs.GetInt(key, 0) > 0;
|
||||||
|
}
|
||||||
|
public static void SetPackageUseAssetDependencyDB(string packageName, string buildPipeline, bool useAssetDependencyDB)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||||
|
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,9 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string _buildPackage;
|
private string _buildPackage;
|
||||||
private EBuildPipeline _buildPipeline;
|
private string _buildPipeline;
|
||||||
|
|
||||||
|
private Dictionary<string, Type> _viewClassDic = new Dictionary<string, Type>(10);
|
||||||
|
|
||||||
private Toolbar _toolbar;
|
private Toolbar _toolbar;
|
||||||
private ToolbarMenu _packageMenu;
|
private ToolbarMenu _packageMenu;
|
||||||
@@ -69,10 +71,29 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_pipelineMenu = new ToolbarMenu();
|
_pipelineMenu = new ToolbarMenu();
|
||||||
_pipelineMenu.style.width = 200;
|
_pipelineMenu.style.width = 200;
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
|
||||||
_toolbar.Add(_pipelineMenu);
|
_toolbar.Add(_pipelineMenu);
|
||||||
|
|
||||||
|
var viewerClassTypes = EditorTools.GetAssignableTypes(typeof(BuildPipelineViewerBase));
|
||||||
|
foreach (var classType in viewerClassTypes)
|
||||||
|
{
|
||||||
|
var buildPipelineAttribute = EditorTools.GetAttribute<BuildPipelineAttribute>(classType);
|
||||||
|
if (buildPipelineAttribute == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"The class {classType.FullName} need attribute {nameof(BuildPipelineAttribute)}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
string pipelineName = buildPipelineAttribute.PipelineName;
|
||||||
|
if (_viewClassDic.ContainsKey(pipelineName))
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"The pipeline has already exist : {pipelineName}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_viewClassDic.Add(pipelineName, classType);
|
||||||
|
_pipelineMenu.menu.AppendAction(pipelineName, PipelineMenuAction, PipelineMenuFun);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshBuildPipelineView();
|
RefreshBuildPipelineView();
|
||||||
@@ -90,24 +111,18 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||||
_packageMenu.text = _buildPackage;
|
_packageMenu.text = _buildPackage;
|
||||||
_pipelineMenu.text = _buildPipeline.ToString();
|
_pipelineMenu.text = _buildPipeline;
|
||||||
|
|
||||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
if (_viewClassDic.TryGetValue(_buildPipeline, out Type value))
|
||||||
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
|
||||||
{
|
{
|
||||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
}
|
var viewer = Activator.CreateInstance(value) as BuildPipelineViewerBase;
|
||||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
viewer.InitView(_buildPackage, _buildPipeline, buildTarget);
|
||||||
{
|
viewer.CreateView(_container);
|
||||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
|
||||||
}
|
|
||||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
|
||||||
{
|
|
||||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
Debug.LogError($"Not found build pipeline : {_buildPipeline}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetBuildPackageNames()
|
private List<string> GetBuildPackageNames()
|
||||||
@@ -140,18 +155,16 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private void PipelineMenuAction(DropdownMenuAction action)
|
private void PipelineMenuAction(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var pipelineType = (EBuildPipeline)action.userData;
|
if (_buildPipeline != action.name)
|
||||||
if (_buildPipeline != pipelineType)
|
|
||||||
{
|
{
|
||||||
_buildPipeline = pipelineType;
|
_buildPipeline = action.name;
|
||||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, _buildPipeline);
|
||||||
RefreshBuildPipelineView();
|
RefreshBuildPipelineView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var pipelineType = (EBuildPipeline)action.userData;
|
if (_buildPipeline == action.name)
|
||||||
if (_buildPipeline == pipelineType)
|
|
||||||
return DropdownMenuAction.Status.Checked;
|
return DropdownMenuAction.Status.Checked;
|
||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
|
|||||||
@@ -8,78 +8,44 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模拟构建
|
/// 模拟构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SimulateBuildResult SimulateBuild(string buildPipelineName, string packageName)
|
public static PackageInvokeBuildResult SimulateBuild(PackageInvokeBuildParam buildParam)
|
||||||
{
|
{
|
||||||
string packageVersion = "Simulate";
|
string packageName = buildParam.PackageName;
|
||||||
BuildResult buildResult;
|
string buildPipelineName = buildParam.BuildPipelineName;
|
||||||
|
|
||||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
if (buildPipelineName == "EditorSimulateBuildPipeline")
|
||||||
{
|
{
|
||||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
var buildParameters = new EditorSimulateBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = packageVersion;
|
buildParameters.PackageVersion = "Simulate";
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||||
|
buildParameters.UseAssetDependencyDB = true;
|
||||||
|
|
||||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
var pipeline = new EditorSimulateBuildPipeline();
|
||||||
buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
}
|
if (buildResult.Success)
|
||||||
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
{
|
||||||
{
|
var reulst = new PackageInvokeBuildResult();
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
return reulst;
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
}
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
else
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
{
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
Debug.LogError(buildResult.ErrorInfo);
|
||||||
buildParameters.PackageName = packageName;
|
throw new System.Exception($"{nameof(EditorSimulateBuildPipeline)} build failed !");
|
||||||
buildParameters.PackageVersion = packageVersion;
|
}
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
|
||||||
buildResult = pipeline.Run(buildParameters, true);
|
|
||||||
}
|
|
||||||
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
|
||||||
{
|
|
||||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
|
||||||
buildParameters.PackageName = packageName;
|
|
||||||
buildParameters.PackageVersion = packageVersion;
|
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
|
||||||
|
|
||||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
|
||||||
buildResult = pipeline.Run(buildParameters, true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(buildPipelineName);
|
throw new System.NotImplementedException(buildPipelineName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回结果
|
|
||||||
if (buildResult.Success)
|
|
||||||
{
|
|
||||||
SimulateBuildResult reulst = new SimulateBuildResult();
|
|
||||||
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
|
||||||
return reulst;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageFileCRC { set; get; }
|
public uint PackageFileCRC { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
@@ -56,12 +56,13 @@ namespace YooAsset.Editor
|
|||||||
public string EncryptedFilePath { set; get; }
|
public string EncryptedFilePath { set; get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private readonly Dictionary<string, BuildAssetInfo> _packAssetDic = new Dictionary<string, BuildAssetInfo>(100);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源列表
|
/// 参与构建的资源列表
|
||||||
/// 注意:不包含零依赖资源和冗余资源
|
/// 注意:不包含零依赖资源和冗余资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
public readonly List<BuildAssetInfo> AllPackAssets = new List<BuildAssetInfo>(100);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
@@ -84,69 +85,103 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo buildAsset)
|
public void PackAsset(BuildAssetInfo buildAsset)
|
||||||
{
|
{
|
||||||
if (IsContainsAsset(buildAsset.AssetInfo.AssetPath))
|
string assetPath = buildAsset.AssetInfo.AssetPath;
|
||||||
throw new System.Exception($"Should never get here ! Asset is existed : {buildAsset.AssetInfo.AssetPath}");
|
if (_packAssetDic.ContainsKey(assetPath))
|
||||||
|
throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}");
|
||||||
|
|
||||||
MainAssets.Add(buildAsset);
|
_packAssetDic.Add(assetPath, buildAsset);
|
||||||
|
AllPackAssets.Add(buildAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否包含指定资源
|
/// 是否包含指定资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsAsset(string assetPath)
|
public bool IsContainsPackAsset(string assetPath)
|
||||||
{
|
{
|
||||||
foreach (var buildAsset in MainAssets)
|
return _packAssetDic.ContainsKey(assetPath);
|
||||||
{
|
|
||||||
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建的资源路径列表
|
/// 获取构建的资源路径列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetAllMainAssetPaths()
|
public string[] GetAllPackAssetPaths()
|
||||||
{
|
{
|
||||||
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
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>
|
||||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
/// 获取构建的资源可寻址列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> GetAllBuiltinAssetPaths()
|
public string[] GetAllPackAssetAddress()
|
||||||
{
|
{
|
||||||
var packAssets = GetAllMainAssetPaths();
|
List<string> results = new List<string>(AllPackAssets.Count);
|
||||||
List<string> result = new List<string>(packAssets);
|
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||||
foreach (var buildAsset in MainAssets)
|
|
||||||
{
|
{
|
||||||
if (buildAsset.AllDependAssetInfos == null)
|
var packAsset = AllPackAssets[i];
|
||||||
continue;
|
results.Add(packAsset.Address);
|
||||||
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
|
}
|
||||||
|
return results.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取构建的主资源信息
|
||||||
|
/// </summary>
|
||||||
|
public BuildAssetInfo GetPackAssetInfo(string assetPath)
|
||||||
|
{
|
||||||
|
if (_packAssetDic.TryGetValue(assetPath, out BuildAssetInfo value))
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Can not found pack asset info {assetPath} in bundle : {BundleName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包内部所有资产
|
||||||
|
/// </summary>
|
||||||
|
public List<AssetInfo> GetBundleContents()
|
||||||
|
{
|
||||||
|
Dictionary<string, AssetInfo> result = new Dictionary<string, AssetInfo>(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)
|
|
||||||
{
|
{
|
||||||
if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
|
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
if (dependAssetInfo.HasBundleName() == false)
|
||||||
|
{
|
||||||
|
string dependAssetPath = dependAssetInfo.AssetInfo.AssetPath;
|
||||||
|
if (result.ContainsKey(dependAssetPath) == false)
|
||||||
|
result.Add(dependAssetPath, dependAssetInfo.AssetInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建AssetBundleBuild类
|
/// 创建AssetBundleBuild类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
public UnityEditor.AssetBundleBuild CreatePipelineBuild(bool replaceAssetPathWithAddress)
|
||||||
{
|
{
|
||||||
// 注意:我们不再支持AssetBundle的变种机制
|
// 注意:我们不再支持AssetBundle的变种机制
|
||||||
AssetBundleBuild build = new AssetBundleBuild();
|
AssetBundleBuild build = new AssetBundleBuild();
|
||||||
build.assetBundleName = BundleName;
|
build.assetBundleName = BundleName;
|
||||||
build.assetBundleVariant = string.Empty;
|
build.assetBundleVariant = string.Empty;
|
||||||
build.assetNames = GetAllMainAssetPaths();
|
build.assetNames = GetAllPackAssetPaths();
|
||||||
|
if (replaceAssetPathWithAddress)
|
||||||
|
build.addressableNames = GetAllPackAssetAddress();
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +190,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||||
{
|
{
|
||||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -13,11 +13,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 图集资源集合
|
||||||
|
/// </summary>
|
||||||
|
public readonly List<BuildAssetInfo> SpriteAtlasAssetList = new List<BuildAssetInfo>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 未被依赖的资源列表
|
/// 未被依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||||
@@ -60,6 +65,12 @@ namespace YooAsset.Editor
|
|||||||
newBundleInfo.PackAsset(assetInfo);
|
newBundleInfo.PackAsset(assetInfo);
|
||||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统计所有的精灵图集
|
||||||
|
if (assetInfo.AssetInfo.IsSpriteAtlas())
|
||||||
|
{
|
||||||
|
SpriteAtlasAssetList.Add(assetInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -85,25 +96,25 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线里需要的数据
|
/// 获取构建管线里需要的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds(bool replaceAssetPathWithAddres)
|
||||||
{
|
{
|
||||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||||
{
|
{
|
||||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
builds.Add(bundleInfo.CreatePipelineBuild(replaceAssetPathWithAddres));
|
||||||
}
|
}
|
||||||
return builds.ToArray();
|
return builds.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建着色器信息类
|
/// 创建空的资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
public void CreateEmptyBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (IsContainsBundle(shadersBundleName) == false)
|
if (IsContainsBundle(bundleName) == false)
|
||||||
{
|
{
|
||||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
var bundleInfo = new BuildBundleInfo(bundleName);
|
||||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
_bundleInfoDic.Add(bundleName, bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,20 +22,20 @@ namespace YooAsset.Editor
|
|||||||
public string BuildinFileRoot;
|
public string BuildinFileRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建管线
|
/// 构建管线名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPipeline;
|
public string BuildPipeline;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建资源包类型
|
||||||
|
/// </summary>
|
||||||
|
public int BuildBundleType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的平台
|
/// 构建的平台
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建模式
|
|
||||||
/// </summary>
|
|
||||||
public EBuildMode BuildMode;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的包裹名称
|
/// 构建的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,12 +46,33 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建的包裹备注
|
||||||
|
/// </summary>
|
||||||
|
public string PackageNote;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用共享资源打包
|
/// 清空构建缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public bool ClearBuildCacheFiles = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用资源依赖缓存数据库
|
||||||
|
/// 说明:开启此项可以极大提高资源收集速度!
|
||||||
|
/// </summary>
|
||||||
|
public bool UseAssetDependencyDB = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用共享资源打包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableSharePackRule = false;
|
public bool EnableSharePackRule = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对单独引用的共享资源进行独立打包
|
||||||
|
/// 说明:关闭该选项单独引用的共享资源将会构建到引用它的资源包内!
|
||||||
|
/// </summary>
|
||||||
|
public bool SingleReferencedPackAlone = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -60,12 +81,12 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称样式
|
/// 资源包名称样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileNameStyle FileNameStyle;
|
public EFileNameStyle FileNameStyle = EFileNameStyle.HashName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的拷贝选项
|
/// 内置文件的拷贝选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
public EBuildinFileCopyOption BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的拷贝参数
|
/// 内置文件的拷贝参数
|
||||||
@@ -77,6 +98,15 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IEncryptionServices EncryptionServices;
|
public IEncryptionServices EncryptionServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单加密服务类
|
||||||
|
/// </summary>
|
||||||
|
public IManifestProcessServices ManifestProcessServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单解密服务类
|
||||||
|
/// </summary>
|
||||||
|
public IManifestRestoreServices ManifestRestoreServices;
|
||||||
|
|
||||||
private string _pipelineOutputDirectory = string.Empty;
|
private string _pipelineOutputDirectory = string.Empty;
|
||||||
private string _packageOutputDirectory = string.Empty;
|
private string _packageOutputDirectory = string.Empty;
|
||||||
@@ -95,32 +125,12 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测是否有未保存场景
|
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
if (EditorTools.HasDirtyScenes())
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测构建参数合法性
|
// 检测构建参数合法性
|
||||||
if (BuildTarget == BuildTarget.NoTarget)
|
if (BuildTarget == BuildTarget.NoTarget)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(PackageName))
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(PackageVersion))
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||||
@@ -131,33 +141,31 @@ namespace YooAsset.Editor
|
|||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(BuildPipeline))
|
||||||
// 强制构建删除包裹目录
|
|
||||||
if (BuildMode == EBuildMode.ForceRebuild)
|
|
||||||
{
|
{
|
||||||
string packageRootDirectory = GetPackageRootDirectory();
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineIsNullOrEmpty, "Build pipeline is null or empty !");
|
||||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
throw new Exception(message);
|
||||||
{
|
}
|
||||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
if (BuildBundleType == (int)EBuildBundleType.Unknown)
|
||||||
}
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildBundleTypeIsUnknown, $"Build bundle type is unknown {BuildBundleType} !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PackageName))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测包裹输出目录是否存在
|
// 设置默认备注信息
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
if (string.IsNullOrEmpty(PackageNote))
|
||||||
{
|
{
|
||||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
PackageNote = DateTime.Now.ToString();
|
||||||
if (Directory.Exists(packageOutputDirectory))
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果输出目录不存在
|
|
||||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
|
||||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
|
||||||
{
|
|
||||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生成内置资源记录文件
|
||||||
|
/// </summary>
|
||||||
|
internal void CreateCatalogFile(BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||||
|
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||||
|
var manifestServices = buildParametersContext.Parameters.ManifestRestoreServices;
|
||||||
|
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||||
|
|
||||||
|
// 刷新目录
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d2c835e5e40ca34d93480587c8125df
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -12,42 +13,61 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
public abstract class TaskCreateManifest
|
public abstract class TaskCreateManifest
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
private readonly Dictionary<string, int> _cachedBundleIndexIDs = new Dictionary<string, int>(10000);
|
||||||
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void CreateManifestFile(BuildContext context)
|
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, bool replaceAssetPathWithAddress, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
|
||||||
|
// 检测资源包哈希冲突
|
||||||
|
CheckBundleHashConflict(buildMapContext);
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = ManifestDefine.FileVersion;
|
||||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
|
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
|
manifest.ReplaceAssetPathWithAddress = replaceAssetPathWithAddress;
|
||||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||||
|
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
||||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
manifest.PackageName = buildParameters.PackageName;
|
manifest.PackageName = buildParameters.PackageName;
|
||||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
manifest.PackageNote = buildParameters.PackageNote;
|
||||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||||
|
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
// 1. 处理资源清单的资源对象
|
||||||
{
|
ProcessPacakgeAsset(manifest);
|
||||||
// 处理资源包的依赖列表
|
|
||||||
|
// 2. 处理资源包的依赖列表
|
||||||
|
if (processBundleDepends)
|
||||||
ProcessBundleDepends(context, manifest);
|
ProcessBundleDepends(context, manifest);
|
||||||
|
|
||||||
// 处理资源包的标签集合
|
// 3. 处理资源包的标签集合
|
||||||
|
if (processBundleTags)
|
||||||
ProcessBundleTags(manifest);
|
ProcessBundleTags(manifest);
|
||||||
|
|
||||||
|
// 4. 处理内置资源包
|
||||||
|
if (processBundleDepends)
|
||||||
|
{
|
||||||
|
// 注意:初始化资源清单建立引用关系
|
||||||
|
manifest.Initialize();
|
||||||
|
|
||||||
|
ProcessBuiltinBundleDependency(context, manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单文本文件
|
|
||||||
|
// 创建资源清单文本文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
@@ -55,22 +75,18 @@ namespace YooAsset.Editor
|
|||||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单二进制文件
|
// 创建资源清单二进制文件
|
||||||
string packageHash;
|
string packageHash;
|
||||||
|
string packagePath;
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestProcessServices);
|
||||||
packageHash = HashUtility.FileMD5(filePath);
|
packageHash = HashUtility.FileCRC32(packagePath);
|
||||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||||
|
|
||||||
ManifestContext manifestContext = new ManifestContext();
|
|
||||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
|
||||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
|
||||||
context.SetContextObject(manifestContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单哈希文件
|
// 创建资源清单哈希文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
@@ -78,13 +94,43 @@ namespace YooAsset.Editor
|
|||||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单版本文件
|
// 创建资源清单版本文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 填充上下文
|
||||||
|
{
|
||||||
|
ManifestContext manifestContext = new ManifestContext();
|
||||||
|
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||||
|
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestRestoreServices);
|
||||||
|
context.SetContextObject(manifestContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测资源包哈希冲突
|
||||||
|
/// </summary>
|
||||||
|
private void CheckBundleHashConflict(BuildMapContext buildMapContext)
|
||||||
|
{
|
||||||
|
// 说明:在特殊情况下,例如某些文件加密算法会导致加密后的文件哈希值冲突!
|
||||||
|
// 说明:二进制完全相同的原生文件也会冲突!
|
||||||
|
HashSet<string> guids = new HashSet<string>();
|
||||||
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
|
{
|
||||||
|
if (guids.Contains(bundleInfo.PackageFileHash))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleHashConflict, $"Bundle hash conflict : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
guids.Add(bundleInfo.PackageFileHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -93,9 +139,9 @@ namespace YooAsset.Editor
|
|||||||
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取主资源对象列表
|
/// 创建资源对象列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
private List<PackageAsset> CreatePackageAssetList(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
@@ -108,17 +154,20 @@ namespace YooAsset.Editor
|
|||||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
packageAsset.TempDataInEditor = assetInfo;
|
||||||
result.Add(packageAsset);
|
result.Add(packageAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按照AssetPath排序
|
||||||
|
result.Sort((a, b) => a.AssetPath.CompareTo(b.AssetPath));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包列表
|
/// 创建资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
private List<PackageBundle> CreatePackageBundleList(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
@@ -127,14 +176,37 @@ namespace YooAsset.Editor
|
|||||||
result.Add(packageBundle);
|
result.Add(packageBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:缓存资源包索引
|
// 按照BundleName排序
|
||||||
for (int index = 0; index < result.Count; index++)
|
result.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理资源清单的资源对象列表
|
||||||
|
/// </summary>
|
||||||
|
private void ProcessPacakgeAsset(PackageManifest manifest)
|
||||||
|
{
|
||||||
|
// 注意:优先缓存资源包索引
|
||||||
|
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||||
{
|
{
|
||||||
string bundleName = result[index].BundleName;
|
string bundleName = manifest.BundleList[index].BundleName;
|
||||||
_cachedBundleID.Add(bundleName, index);
|
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
// 记录资源对象所属的资源包ID
|
||||||
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
|
{
|
||||||
|
var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||||
|
packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录资源对象依赖的资源包ID集合
|
||||||
|
// 注意:依赖关系非引擎构建结果里查询!
|
||||||
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
|
{
|
||||||
|
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||||
|
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -145,16 +217,19 @@ namespace YooAsset.Editor
|
|||||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
string[] dependNames = GetBundleDepends(context, packageBundle.BundleName);
|
||||||
List<int> dependIDs = new List<int>(depends.Length);
|
List<int> dependIDs = new List<int>(dependNames.Length);
|
||||||
foreach (var dependBundleName in depends)
|
foreach (var dependName in dependNames)
|
||||||
{
|
{
|
||||||
int bundleID = GetCachedBundleID(dependBundleName);
|
int dependBundleID = GetCachedBundleIndexID(dependName);
|
||||||
if (bundleID != mainBundleID)
|
if (dependBundleID != mainBundleID)
|
||||||
dependIDs.Add(bundleID);
|
dependIDs.Add(dependBundleID);
|
||||||
}
|
}
|
||||||
packageBundle.DependIDs = dependIDs.ToArray();
|
|
||||||
|
// 排序并填充数据
|
||||||
|
dependIDs.Sort();
|
||||||
|
packageBundle.DependBundleIDs = dependIDs.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,20 +238,27 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ProcessBundleTags(PackageManifest manifest)
|
private void ProcessBundleTags(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
packageBundle.Tags = Array.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||||
foreach (var packageAsset in manifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
var assetTags = packageAsset.AssetTags;
|
var assetTags = packageAsset.AssetTags;
|
||||||
int bundleID = packageAsset.BundleID;
|
int bundleID = packageAsset.BundleID;
|
||||||
CacheBundleTags(bundleID, assetTags);
|
CacheBundleTags(bundleID, assetTags);
|
||||||
|
if (packageAsset.DependBundleIDs != null)
|
||||||
var packageBundle = manifest.BundleList[bundleID];
|
|
||||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
|
||||||
{
|
{
|
||||||
CacheBundleTags(dependBundleID, assetTags);
|
foreach (var dependBundleID in packageAsset.DependBundleIDs)
|
||||||
|
{
|
||||||
|
CacheBundleTags(dependBundleID, assetTags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将缓存的资源标签赋值给资源包
|
||||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||||
{
|
{
|
||||||
var packageBundle = manifest.BundleList[index];
|
var packageBundle = manifest.BundleList[index];
|
||||||
@@ -205,15 +287,123 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的索引ID
|
/// 获取缓存的资源包的索引ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int GetCachedBundleID(string bundleName)
|
private int GetCachedBundleIndexID(string bundleName)
|
||||||
{
|
{
|
||||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
if (_cachedBundleIndexIDs.TryGetValue(bundleName, out int value) == false)
|
||||||
{
|
{
|
||||||
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
throw new Exception($"Should never get here ! Not found bundle index ID : {bundleName}");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否包含该资源包的索引ID
|
||||||
|
/// </summary>
|
||||||
|
private bool ContainsCachedBundleIndexID(string bundleName)
|
||||||
|
{
|
||||||
|
return _cachedBundleIndexIDs.ContainsKey(bundleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region YOOASSET_LEGACY_DEPENDENCY
|
||||||
|
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||||
|
{
|
||||||
|
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||||
|
// 注意:该步骤依赖前面的操作!
|
||||||
|
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
|
|
||||||
|
if (buildResultContext != null)
|
||||||
|
{
|
||||||
|
ProcessBuiltinBundleReference(manifest, buildResultContext.BuiltinShadersBundleName);
|
||||||
|
ProcessBuiltinBundleReference(manifest, buildResultContext.MonoScriptsBundleName);
|
||||||
|
|
||||||
|
var buildParametersContext = context.TryGetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
if (buildParameters is ScriptableBuildParameters scriptableBuildParameters)
|
||||||
|
{
|
||||||
|
if (scriptableBuildParameters.TrackSpriteAtlasDependencies)
|
||||||
|
{
|
||||||
|
// 注意:检测是否开启图集模式
|
||||||
|
// 说明:需要记录主资源对象对图集的依赖关系!
|
||||||
|
if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled)
|
||||||
|
{
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList)
|
||||||
|
{
|
||||||
|
string spriteAtlasBundleName = spriteAtlasAsset.BundleName;
|
||||||
|
ProcessBuiltinBundleReference(manifest, spriteAtlasBundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ProcessBuiltinBundleReference(PackageManifest manifest, string builtinBundleName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(builtinBundleName))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 查询内置资源包是否存在
|
||||||
|
if (ContainsCachedBundleIndexID(builtinBundleName) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 获取内置资源包
|
||||||
|
int builtinBundleID = GetCachedBundleIndexID(builtinBundleName);
|
||||||
|
var builtinPackageBundle = manifest.BundleList[builtinBundleID];
|
||||||
|
|
||||||
|
// 更新依赖资源包ID集合
|
||||||
|
HashSet<int> cacheBundleIDs = new HashSet<int>(builtinPackageBundle.ReferenceBundleIDs);
|
||||||
|
HashSet<string> tempTags = new HashSet<string>();
|
||||||
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
|
{
|
||||||
|
if (cacheBundleIDs.Contains(packageAsset.BundleID))
|
||||||
|
{
|
||||||
|
if (packageAsset.DependBundleIDs.Contains(builtinBundleID) == false)
|
||||||
|
{
|
||||||
|
var tempBundleIDs = new List<int>(packageAsset.DependBundleIDs);
|
||||||
|
tempBundleIDs.Add(builtinBundleID);
|
||||||
|
packageAsset.DependBundleIDs = tempBundleIDs.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var tag in packageAsset.AssetTags)
|
||||||
|
{
|
||||||
|
if (tempTags.Contains(tag) == false)
|
||||||
|
tempTags.Add(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新内置资源包的标签集合
|
||||||
|
foreach (var tag in builtinPackageBundle.Tags)
|
||||||
|
{
|
||||||
|
if (tempTags.Contains(tag) == false)
|
||||||
|
tempTags.Add(tag);
|
||||||
|
}
|
||||||
|
builtinPackageBundle.Tags = tempTags.ToArray();
|
||||||
|
}
|
||||||
|
private int[] GetAssetDependBundleIDs(BuildAssetInfo mainAssetInfo)
|
||||||
|
{
|
||||||
|
HashSet<int> result = new HashSet<int>();
|
||||||
|
int mainBundleID = GetCachedBundleIndexID(mainAssetInfo.BundleName);
|
||||||
|
foreach (var dependAssetInfo in mainAssetInfo.AllDependAssetInfos)
|
||||||
|
{
|
||||||
|
if (dependAssetInfo.HasBundleName())
|
||||||
|
{
|
||||||
|
int bundleID = GetCachedBundleIndexID(dependAssetInfo.BundleName);
|
||||||
|
if (mainBundleID != bundleID)
|
||||||
|
{
|
||||||
|
if (result.Contains(bundleID) == false)
|
||||||
|
result.Add(bundleID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序并返回数据
|
||||||
|
List<int> listResult = new List<int>(result);
|
||||||
|
listResult.Sort();
|
||||||
|
return listResult.ToArray();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,53 +18,56 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
{
|
{
|
||||||
#if UNITY_2019_4_OR_NEWER
|
buildReport.Summary.YooVersion = EditorTools.GetPackageManagerYooVersion();
|
||||||
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.UnityVersion = UnityEngine.Application.unityVersion;
|
||||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildBundleType = buildParameters.BuildBundleType;
|
||||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||||
|
buildReport.Summary.BuildPackageNote = buildParameters.PackageNote;
|
||||||
|
|
||||||
// 收集器配置
|
// 收集器配置
|
||||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
|
buildReport.Summary.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
|
||||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
|
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
|
||||||
|
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||||
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
|
||||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||||
|
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||||
|
buildReport.Summary.ManifestProcessServicesClassName = buildParameters.ManifestProcessServices == null ? "null" : buildParameters.ManifestProcessServices.GetType().FullName;
|
||||||
|
buildReport.Summary.ManifestRestoreServicesClassName = buildParameters.ManifestRestoreServices == null ? "null" : buildParameters.ManifestRestoreServices.GetType().FullName;
|
||||||
|
|
||||||
|
if (buildParameters is BuiltinBuildParameters)
|
||||||
{
|
{
|
||||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
|
||||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||||
|
buildReport.Summary.ReplaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||||
}
|
}
|
||||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
else if (buildParameters is ScriptableBuildParameters)
|
||||||
{
|
{
|
||||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
|
||||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||||
}
|
buildReport.Summary.ReplaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
|
||||||
else
|
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
||||||
{
|
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
||||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
buildReport.Summary.BuiltinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName;
|
||||||
buildReport.Summary.DisableWriteTypeTree = false;
|
buildReport.Summary.MonoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建结果
|
// 构建结果
|
||||||
@@ -88,7 +91,8 @@ namespace YooAsset.Editor
|
|||||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
reportAssetInfo.DependAssets = GetAssetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||||
|
reportAssetInfo.DependBundles = GetAssetDependBundles(manifest, packageAsset);
|
||||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +108,9 @@ namespace YooAsset.Editor
|
|||||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||||
reportBundleInfo.Tags = packageBundle.Tags;
|
reportBundleInfo.Tags = packageBundle.Tags;
|
||||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
reportBundleInfo.DependBundles = GetBundleDependBundles(manifest, packageBundle);
|
||||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
reportBundleInfo.ReferenceBundles = GetBundleReferenceBundles(manifest, packageBundle);
|
||||||
|
reportBundleInfo.BundleContents = GetBundleContents(buildMapContext, packageBundle.BundleName);
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,62 +118,82 @@ namespace YooAsset.Editor
|
|||||||
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
|
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetBuildReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
BuildReport.Serialize(filePath, buildReport);
|
BuildReport.Serialize(filePath, buildReport);
|
||||||
BuildLogger.Log($"Create build report file: {filePath}");
|
BuildLogger.Log($"Create build report file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取资源对象依赖的所有资源包
|
|
||||||
/// </summary>
|
|
||||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
|
||||||
{
|
|
||||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
|
||||||
foreach (int index in packageBundle.DependIDs)
|
|
||||||
{
|
|
||||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
|
||||||
dependBundles.Add(dependBundleName);
|
|
||||||
}
|
|
||||||
return dependBundles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源对象依赖的其它所有资源
|
/// 获取资源对象依赖的其它所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
private List<AssetInfo> GetAssetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<AssetInfo> result = new List<AssetInfo>();
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
|
var assetInfo = bundleInfo.GetPackAssetInfo(assetPath);
|
||||||
|
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
result.Add(dependAssetInfo.AssetInfo);
|
||||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
|
||||||
{
|
|
||||||
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
|
||||||
{
|
|
||||||
findAssetInfo = buildAsset;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (findAssetInfo == null)
|
|
||||||
{
|
|
||||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
|
||||||
}
|
|
||||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
|
||||||
{
|
|
||||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
result.Sort();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取该资源包内的所有资源
|
/// 获取资源对象依赖的资源包集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
private List<string> GetAssetDependBundles(PackageManifest manifest, PackageAsset packageAsset)
|
||||||
|
{
|
||||||
|
List<string> dependBundles = new List<string>(packageAsset.DependBundleIDs.Length);
|
||||||
|
foreach (int index in packageAsset.DependBundleIDs)
|
||||||
|
{
|
||||||
|
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||||
|
dependBundles.Add(dependBundleName);
|
||||||
|
}
|
||||||
|
dependBundles.Sort();
|
||||||
|
return dependBundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包依赖的资源包集合
|
||||||
|
/// </summary>
|
||||||
|
private List<string> GetBundleDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
List<string> dependBundles = new List<string>(packageBundle.DependBundleIDs.Length);
|
||||||
|
foreach (int index in packageBundle.DependBundleIDs)
|
||||||
|
{
|
||||||
|
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||||
|
dependBundles.Add(dependBundleName);
|
||||||
|
}
|
||||||
|
dependBundles.Sort();
|
||||||
|
return dependBundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取引用该资源包的资源包集合
|
||||||
|
/// </summary>
|
||||||
|
private List<string> GetBundleReferenceBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
List<string> referenceBundles = new List<string>(packageBundle.ReferenceBundleIDs.Count);
|
||||||
|
foreach (int index in packageBundle.ReferenceBundleIDs)
|
||||||
|
{
|
||||||
|
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||||
|
referenceBundles.Add(dependBundleName);
|
||||||
|
}
|
||||||
|
referenceBundles.Sort();
|
||||||
|
return referenceBundles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包内部所有资产
|
||||||
|
/// </summary>
|
||||||
|
private List<AssetInfo> GetBundleContents(BuildMapContext buildMapContext, string bundleName)
|
||||||
{
|
{
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
return bundleInfo.GetAllBuiltinAssetPaths();
|
List<AssetInfo> result = bundleInfo.GetBundleContents();
|
||||||
|
result.Sort();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetMainAssetCount(PackageManifest manifest)
|
private int GetMainAssetCount(PackageManifest manifest)
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成资源构建上下文
|
/// 生成资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
public BuildMapContext CreateBuildMap(bool simulateBuild, BuildParameters buildParameters)
|
||||||
{
|
{
|
||||||
BuildMapContext context = new BuildMapContext();
|
BuildMapContext context = new BuildMapContext();
|
||||||
var buildMode = buildParameters.BuildMode;
|
|
||||||
var packageName = buildParameters.PackageName;
|
var packageName = buildParameters.PackageName;
|
||||||
|
|
||||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
// 1. 获取所有收集器收集的资源
|
// 1. 获取所有收集器收集的资源
|
||||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||||
|
var collectResult = AssetBundleCollectorSettingData.Setting.BeginCollect(packageName, simulateBuild, useAssetDependencyDB);
|
||||||
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||||
|
|
||||||
// 2. 剔除未被引用的依赖项资源
|
// 2. 剔除未被引用的依赖项资源
|
||||||
@@ -109,15 +109,10 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (buildAssetInfo.HasBundleName() == false)
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
ProcessingPackShareBundle(buildParameters, collectResult.Command, buildAssetInfo);
|
||||||
if (packRuleResult.IsValid())
|
|
||||||
{
|
|
||||||
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
|
||||||
buildAssetInfo.SetBundleName(shareBundleName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PostProcessPackShareBundle();
|
PostProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 记录关键信息
|
// 8. 记录关键信息
|
||||||
@@ -209,21 +204,38 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 共享资源打包后置处理
|
/// 共享资源打包机制
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void PostProcessPackShareBundle()
|
protected virtual void ProcessingPackShareBundle(BuildParameters buildParameters, CollectCommand command, BuildAssetInfo buildAssetInfo)
|
||||||
{
|
{
|
||||||
}
|
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||||
|
if (packRuleResult.IsValid() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
/// <summary>
|
// 处理单个引用的共享资源
|
||||||
/// 获取共享资源包名称
|
if (buildAssetInfo.GetReferenceBundleCount() <= 1)
|
||||||
/// </summary>
|
{
|
||||||
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
if (buildParameters.SingleReferencedPackAlone == false)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置共享资源包名
|
||||||
|
string shareBundleName = packRuleResult.GetShareBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
|
buildAssetInfo.SetBundleName(shareBundleName);
|
||||||
|
}
|
||||||
|
private PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||||
{
|
{
|
||||||
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源打包后置处理
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PostProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,9 +44,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, context);
|
||||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, context);
|
||||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
@@ -62,35 +62,8 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
|
|
||||||
protected string GetFilePathTempHash(string filePath)
|
|
||||||
{
|
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
|
||||||
return HashUtility.BytesMD5(bytes);
|
|
||||||
|
|
||||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
|
||||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
|
||||||
}
|
|
||||||
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
|
||||||
{
|
|
||||||
long tempSize = 0;
|
|
||||||
|
|
||||||
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
|
||||||
foreach (var assetPath in assetPaths)
|
|
||||||
{
|
|
||||||
long size = FileUtility.GetFileSize(assetPath);
|
|
||||||
tempSize += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tempSize == 0)
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
return tempSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,29 +20,23 @@ namespace YooAsset.Editor
|
|||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过引擎构建
|
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 开始构建
|
// 开始构建
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
var bundleBuilds = buildMapContext.GetPipelineBuilds(builtinBuildParameters.ReplaceAssetPathWithAddress);
|
||||||
|
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, bundleBuilds, buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||||
if (unityManifest == null)
|
if (unityManifest == null)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
// 检测输出目录
|
||||||
|
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||||
|
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||||
{
|
{
|
||||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
throw new Exception(message);
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("UnityEngine build success !");
|
BuildLogger.Log("UnityEngine build success !");
|
||||||
|
|||||||
@@ -12,14 +12,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
{
|
||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
{
|
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_BBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fe3d00b03dc9c64a96b7acfdf99b54c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -11,7 +11,10 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
bool replaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||||
|
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -9,17 +9,13 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
CreatePackagePatch(buildParameters, buildMapContext);
|
||||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
|
||||||
{
|
|
||||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
|||||||
@@ -13,12 +13,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||||
@@ -12,12 +7,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(false, buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,42 @@ namespace YooAsset.Editor
|
|||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
|
// 检测是否有未保存场景
|
||||||
|
if (EditorTools.HasDirtyScenes())
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除包裹目录
|
||||||
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
|
{
|
||||||
|
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||||
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测包裹输出目录是否存在
|
||||||
|
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||||
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果输出目录不存在
|
||||||
|
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||||
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
|
}
|
||||||
|
|
||||||
// 检测Unity版本
|
// 检测Unity版本
|
||||||
#if UNITY_2021_3_OR_NEWER
|
#if UNITY_2021_3_OR_NEWER
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||||
{
|
BuildLogger.Warning(warning);
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
|
||||||
BuildLogger.Warning(warning);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,77 +15,45 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||||
var parameters = buildParametersContext.Parameters;
|
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||||
var buildMode = parameters.BuildMode;
|
if (hash.isValid)
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
{
|
||||||
return "00000000000000000000000000000000"; //32位
|
return hash.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
throw new Exception(message);
|
||||||
if (hash.isValid)
|
|
||||||
{
|
|
||||||
return hash.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
string filePath = bundleInfo.BuildOutputFilePath;
|
||||||
var parameters = buildParametersContext.Parameters;
|
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||||
var buildMode = parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return crc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.BuildOutputFilePath;
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
throw new Exception(message);
|
||||||
{
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
return HashUtility.FileMD5(filePath);
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return GetFilePathTempHash(filePath);
|
|
||||||
else
|
|
||||||
return HashUtility.FileMD5(filePath);
|
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return "00000000"; //8位
|
|
||||||
else
|
|
||||||
return HashUtility.FileCRC32(filePath);
|
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
return FileUtility.GetFileSize(filePath);
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return GetBundleTempSize(bundleInfo);
|
|
||||||
else
|
|
||||||
return FileUtility.GetFileSize(filePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,10 +15,6 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过验证
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
if (buildParameters.VerifyBuildingResult)
|
if (buildParameters.VerifyBuildingResult)
|
||||||
{
|
{
|
||||||
@@ -32,15 +28,14 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
string[] unityBuildContent = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 计划内容
|
||||||
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
string[] planningContent = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证差异
|
||||||
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
List<string> exceptBundleList1 = unityBuildContent.Except(planningContent).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
@@ -53,8 +48,8 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception(exception);
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证差异
|
||||||
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
List<string> exceptBundleList2 = planningContent.Except(unityBuildContent).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从文件头里剥离Unity版本信息
|
||||||
|
/// </summary>
|
||||||
|
public bool StripUnityVersion = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -22,6 +27,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用可寻址地址代替资源路径
|
||||||
|
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||||
|
/// </summary>
|
||||||
|
public bool ReplaceAssetPathWithAddress = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置构建管线的构建选项
|
/// 获取内置构建管线的构建选项
|
||||||
@@ -34,19 +45,15 @@ namespace YooAsset.Editor
|
|||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
if (BuildMode == EBuildMode.DryRunBuild)
|
|
||||||
{
|
|
||||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
|
||||||
return opt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CompressOption == ECompressOption.Uncompressed)
|
if (CompressOption == ECompressOption.Uncompressed)
|
||||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||||
else if (CompressOption == ECompressOption.LZ4)
|
else if (CompressOption == ECompressOption.LZ4)
|
||||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||||
|
|
||||||
if (BuildMode == EBuildMode.ForceRebuild)
|
if (ClearBuildCacheFiles)
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
|
if (StripUnityVersion)
|
||||||
|
opt |= BuildAssetBundleOptions.AssetBundleStripUnityVersion; //Removes the Unity Version number in the Archive File & Serialized File headers
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||||
if (IgnoreTypeTreeChanges)
|
if (IgnoreTypeTreeChanges)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
{
|
{
|
||||||
if (buildParameters is BuiltinBuildParameters)
|
if (buildParameters is BuiltinBuildParameters)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskCreateReport_BBP(),
|
new TaskCreateReport_BBP(),
|
||||||
new TaskCreatePackage_BBP(),
|
new TaskCreatePackage_BBP(),
|
||||||
new TaskCopyBuildinFiles_BBP(),
|
new TaskCopyBuildinFiles_BBP(),
|
||||||
|
new TaskCreateCatalog_BBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12f78ad22f0513c44b6037469dbd6363
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1138888cdba447345abb498b0c89affa
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateManifest_ESBP : TaskCreateManifest, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
CreateManifestFile(false, true, false, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 120e126cc10604c4f811c3b6377f7452
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskGetBuildMap_ESBP : TaskGetBuildMap, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||||
|
context.SetContextObject(buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 789c337b5b82f1c438a588982dfca346
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskPrepare_ESBP : IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
|
// 检测基础构建参数
|
||||||
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: abbe56a7120e34349b10f20956ed51a7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
using System.Text;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskUpdateBundleInfo_ESBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
UpdateBundleInfo(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return "00000000000000000000000000000000"; //32位
|
||||||
|
}
|
||||||
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
|
return GetFilePathTempHash(filePath);
|
||||||
|
}
|
||||||
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return GetBundleTempSize(bundleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetFilePathTempHash(string filePath)
|
||||||
|
{
|
||||||
|
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
||||||
|
return HashUtility.BytesMD5(bytes);
|
||||||
|
|
||||||
|
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||||
|
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||||
|
}
|
||||||
|
private long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
||||||
|
{
|
||||||
|
long tempSize = 0;
|
||||||
|
|
||||||
|
var assetPaths = bundleInfo.GetAllPackAssetPaths();
|
||||||
|
foreach (var assetPath in assetPaths)
|
||||||
|
{
|
||||||
|
long size = FileUtility.GetFileSize(assetPath);
|
||||||
|
tempSize += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempSize == 0)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
return tempSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 990b41f647b80a34ab666a3b0c1ba3f6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class EditorSimulateBuildParameters : BuildParameters
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03ea37371e6dc644cb2e6eabf9e7e2ad
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class EditorSimulateBuildPipeline : IBuildPipeline
|
||||||
|
{
|
||||||
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
|
{
|
||||||
|
if (buildParameters is EditorSimulateBuildParameters)
|
||||||
|
{
|
||||||
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取默认的构建流程
|
||||||
|
/// </summary>
|
||||||
|
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||||
|
{
|
||||||
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
|
{
|
||||||
|
new TaskPrepare_ESBP(),
|
||||||
|
new TaskGetBuildMap_ESBP(),
|
||||||
|
new TaskUpdateBundleInfo_ESBP(),
|
||||||
|
new TaskCreateManifest_ESBP()
|
||||||
|
};
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9caf8e4846ad8b64eb04a4d5179942ff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -10,14 +10,8 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -29,7 +23,7 @@ namespace YooAsset.Editor
|
|||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
foreach (var buildAsset in bundleInfo.AllPackAssets)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
|
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,9 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
{
|
||||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
{
|
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_RFBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 563771ecaff17ee498b5fda7c1132e62
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(false, true, false, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -9,17 +9,13 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
CreatePackagePatch(buildParameters, buildMapContext);
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|||||||
@@ -13,12 +13,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskEncryption_RFBP : TaskEncryption, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3e156139dcc25f4c9440ec3d6cb96d2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
|
|
||||||
// 检测构建结果
|
// 检测构建结果
|
||||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
// 注意:原生文件资源包只能包含一个原生文件
|
// 注意:原生文件资源包只能包含一个原生文件
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
if (bundleInfo.MainAssets.Count != 1)
|
if (bundleInfo.AllPackAssets.Count != 1)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
|
|||||||
@@ -16,23 +16,29 @@ namespace YooAsset.Editor
|
|||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
// 检测不被支持的参数
|
// 删除包裹目录
|
||||||
if (buildParameters.EnableSharePackRule)
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportSharePackRule, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support share pack rule !");
|
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||||
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测包裹输出目录是否存在
|
||||||
|
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||||
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 如果输出目录不存在
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||||
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user