Compare commits

..

69 Commits

Author SHA1 Message Date
semantic-release-bot 4b98abd746 chore(release): 4.11.2 [skip ci]
## [4.11.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.11.1...v4.11.2) (2025-03-15)

### Bug Fixes

* IL2CPP build fails on older versions of Unity ([0da6525](0da652520c))
* NRE on enable ([0cff50e](0cff50ef69)), closes [#359](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/359)
2025-03-15 07:59:37 +00:00
mob-sakai 63ec8f61e3 fix: NRE on enable
close #359
2025-03-14 19:44:02 +09:00
mob-sakai 29eebf79fa fix: IL2CPP build fails on older versions of Unity 2025-03-14 19:29:41 +09:00
mob-sakai 4b6da7c218 chore: fix settings icon 2025-03-14 19:24:22 +09:00
semantic-release-bot 7ea0a436d1 chore(release): 4.11.1 [skip ci]
## [4.11.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.11.0...v4.11.1) (2025-02-21)

### Bug Fixes

* component icons will no longer be displayed in the scene view ([6dfbdae](6dfbdae38d))
2025-02-21 09:35:05 +00:00
mob-sakai 803af8113d fix: component icons will no longer be displayed in the scene view 2025-02-21 18:22:24 +09:00
mob-sakai 8b5f7ff57e doc: update readme 2025-02-21 17:57:12 +09:00
semantic-release-bot 3d0284c630 chore(release): 4.11.0 [skip ci]
# [4.11.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.7...v4.11.0) (2025-02-21)

### Features

* add 'TimeScaleMultiplier' option ([925af0b](925af0b604))
2025-02-21 07:17:09 +00:00
mob-sakai 9832485c04 feat: add 'TimeScaleMultiplier' option 2025-02-21 16:10:06 +09:00
semantic-release-bot 201bd9180e chore(release): 4.10.7 [skip ci]
## [4.10.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.6...v4.10.7) (2025-01-14)

### Bug Fixes

* editor crashed on exit play mode (editor, windows) ([47ee45c](47ee45cbbe)), closes [#351](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/351)
2025-01-14 11:49:21 +00:00
mob-sakai 12d604fedd fix: editor crashed on exit play mode (editor, windows)
close #351
2025-01-07 10:25:23 +09:00
semantic-release-bot 4f42996514 chore(release): 4.10.6 [skip ci]
## [4.10.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.5...v4.10.6) (2025-01-03)

### Bug Fixes

* sub-emitter particles may not render correctly in certain scenarios ([8276684](8276684c3b)), closes [#348](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/348)
* sub-emitter's `inherit velocity` module doubles at runtime ([67de3d1](67de3d1bd3)), closes [#349](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/349)
2025-01-03 14:24:40 +00:00
mob-sakai a0a2f4aece chore: update coffee.internal 2025-01-03 23:13:17 +09:00
mob-sakai 23cd448766 fix: sub-emitter particles may not render correctly in certain scenarios
close #348
2025-01-03 23:13:17 +09:00
mob-sakai 1c33dac125 fix: sub-emitter's `inherit velocity` module doubles at runtime
close #349
2025-01-03 23:13:17 +09:00
semantic-release-bot f4b28b68b1 chore(release): 4.10.5 [skip ci]
## [4.10.5](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.4...v4.10.5) (2024-12-23)

### Bug Fixes

* '3D' scale toggle in the inspector does not keep on reload ([934f4b8](934f4b8f1c)), closes [#346](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/346)
2024-12-23 03:54:11 +00:00
mob-sakai ff179f0271 refactor: update coffee.internal 2024-12-23 12:53:15 +09:00
mob-sakai abdf260352 fix: '3D' scale toggle in the inspector does not keep on reload
close #346
2024-12-22 13:10:21 +09:00
semantic-release-bot 847af6397e chore(release): 4.10.4 [skip ci]
## [4.10.4](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.3...v4.10.4) (2024-12-19)

### Bug Fixes

* rendering issues when playing with opening a prefab stage ([95235a9](95235a929b)), closes [#345](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/345)
2024-12-19 08:50:19 +00:00
mob-sakai ac3e147bd9 fix: rendering issues when playing with opening a prefab stage
close #345
2024-12-18 19:46:32 +09:00
semantic-release-bot 598c85e0f4 chore(release): 4.10.3 [skip ci]
## [4.10.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.2...v4.10.3) (2024-11-20)

### Bug Fixes

* if not configured as a preloaded asset, the project settings asset will be regenerated ([abe0948](abe09485f6)), closes [#342](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/342)
2024-11-20 16:56:36 +00:00
mob-sakai 5f479902aa fix: if not configured as a preloaded asset, the project settings asset will be regenerated
close #342
2024-11-21 01:39:16 +09:00
mob-sakai 2a66393cb0 refactor: update coffee.internal 2024-11-21 01:36:51 +09:00
semantic-release-bot 2b3cec69ac chore(release): 4.10.2 [skip ci]
## [4.10.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.1...v4.10.2) (2024-11-01)

### Bug Fixes

* trail incorrect offset ([afe00a1](afe00a1dde)), closes [#335](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/335)
2024-11-01 02:15:40 +00:00
Jie a4dd8c5776 fix: trail incorrect offset
close #335
2024-11-01 11:14:03 +09:00
mob-sakai dd94bba43c refactor 2024-09-30 03:01:48 +09:00
semantic-release-bot 2e813c5313 chore(release): 4.10.1 [skip ci]
## [4.10.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.0...v4.10.1) (2024-09-29)

### Bug Fixes

* mainTex will be ignored ([2ee69d0](2ee69d0424))
2024-09-29 17:46:35 +00:00
mob-sakai 1b61904018 fix: mainTex will be ignored 2024-09-30 02:36:45 +09:00
semantic-release-bot 672cb0abbb chore(release): 4.10.0 [skip ci]
# [4.10.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.1...v4.10.0) (2024-09-29)

### Bug Fixes

* component icon is not set ([5ff6ec8](5ff6ec815a))

### Features

* add project settings ([1ce4e31](1ce4e31a96))
2024-09-29 17:14:48 +00:00
mob-sakai 54da6b3bbf fix: component icon is not set 2024-09-30 01:56:54 +09:00
mob-sakai c00f5c8806 docs: update readme 2024-09-30 01:56:54 +09:00
mob-sakai dddbeff155 style: format 2024-09-30 01:56:54 +09:00
mob-sakai 20b9085ca1 feat: add project settings 2024-09-30 01:56:54 +09:00
mob-sakai 8c1bef4373 refactor: using Coffee.Internal 2024-09-30 01:48:06 +09:00
mob-sakai a96b6915ef import Coffee.Internal 2024-09-30 01:48:06 +09:00
semantic-release-bot 025efcbc5d chore(release): 4.9.1 [skip ci]
## [4.9.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.0...v4.9.1) (2024-08-07)

### Bug Fixes

* ParticleSystem trails gain offset on parent canvas change ([2a1cd50](2a1cd502b4)), closes [#323](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/323)
2024-08-07 17:13:07 +00:00
mob-sakai 162ee53180 fix: ParticleSystem trails gain offset on parent canvas change
close #323
2024-08-08 02:00:40 +09:00
semantic-release-bot 4dfcb9075e chore(release): 4.9.0 [skip ci]
# [4.9.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.8.1...v4.9.0) (2024-07-18)

### Features

* ParticleAttractor supports multiple ParticleSystems ([3834780](3834780fdb))
2024-07-18 05:09:44 +00:00
mob-sakai 7916056868 demos: update demo 2024-07-18 13:40:58 +09:00
mob-sakai b87a0a02af docs: update readme 2024-07-18 09:33:42 +09:00
mob-sakai 3052cab41b refactor: refactor multiple attractor
- Convert 'm_ParticleSystem' to 'm_ParticleSystems'
- Collect parent UIParticles on attract
- Improve performance
2024-07-18 00:56:13 +09:00
dogramacigokhan a439248e1a feat: ParticleAttractor supports multiple ParticleSystems 2024-07-18 00:56:13 +09:00
semantic-release-bot 686fff8690 chore(release): 4.8.1 [skip ci]
## [4.8.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.8.0...v4.8.1) (2024-06-27)

### Bug Fixes

* remove debug code ([669deb4](669deb41d4))
2024-06-27 09:27:20 +00:00
mob-sakai 3638df524f fix: remove debug code 2024-06-27 18:26:47 +09:00
semantic-release-bot 592d871da2 chore(release): 4.8.0 [skip ci]
# [4.8.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.7.2...v4.8.0) (2024-06-27)

### Bug Fixes

* generated baking-camera object remains in the prefab or scene (again) ([de35cba](de35cba34c))
* SetParticleSystemInstance/Prefab APIs destroy generated objects ([ae3f3a8](ae3f3a8e62))

### Features

* add 'custom view' option. ([a703c29](a703c2921c))
* remove overlay window (editor) ([8358170](835817049f))
* restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` (again) ([88a970d](88a970d93a))
* the rendering order list in inspector is now more compact ([be90172](be901724e0))
2024-06-27 06:40:30 +00:00
mob-sakai 4d0cfd3510 refactor 2024-06-27 14:12:53 +09:00
mob-sakai 4c5251a5ba feat: the rendering order list in inspector is now more compact 2024-06-27 10:48:34 +09:00
mob-sakai cbb37b0b3a feat: restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` (again) 2024-06-27 10:48:27 +09:00
mob-sakai 3c54f6dc8d feat: add 'custom view' option.
Use this if the particles are not displayed correctly due to min/max particle size.
2024-06-27 10:48:05 +09:00
mob-sakai d3532b9708 fix: generated baking-camera object remains in the prefab or scene (again) 2024-06-27 10:46:25 +09:00
mob-sakai 2ac8a1175b fix: SetParticleSystemInstance/Prefab APIs destroy generated objects
# Conflicts:
#	Packages/src/Runtime/UIParticle.cs
2024-06-27 10:46:10 +09:00
mob-sakai 9a37e64b20 feat: remove overlay window (editor) 2024-06-27 10:44:13 +09:00
semantic-release-bot bc0c2e4e63 chore(release): 4.7.2 [skip ci]
## [4.7.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.7.1...v4.7.2) (2024-06-21)

### Bug Fixes

* generated baking-camera object remains in the prefab or scene ([0bb8438](0bb8438301))
2024-06-21 05:22:49 +00:00
mob-sakai 929c0d686b fix: generated baking-camera object remains in the prefab or scene 2024-06-21 14:21:53 +09:00
semantic-release-bot 1674e850e0 chore(release): 4.7.1 [skip ci]
## [4.7.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.7.0...v4.7.1) (2024-06-20)

### Bug Fixes

* despite not using the size module, particles become smaller based on their z position ([a8ed6e6](a8ed6e6858)), closes [#316](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/316)
2024-06-20 03:55:01 +00:00
mob-sakai c43ba67a9b fix: despite not using the size module, particles become smaller based on their z position
close #316
2024-06-20 12:51:02 +09:00
mob-sakai 4c285fde14 docs: update license 2024-06-19 13:47:05 +09:00
semantic-release-bot 22795fca9a chore(release): 4.7.0 [skip ci]
# [4.7.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.8...v4.7.0) (2024-06-19)

### Bug Fixes

* `UIParticle.transform.localScale` does not scale particles ([1d40e24](1d40e24c74)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* UIParticle is scaled by canvas size even when `AutoScalingMode.None` and `ScalingMode.Local` ([54a4b1c](54a4b1cdfd)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* UIParticle is scaled incorrectly with nested canvases ([f26920f](f26920f982)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)

### Features

* reset previous position on start play for world space simulation ([3880484](3880484ce5)), closes [#303](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/303)
* restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` ([5505247](5505247a94))
2024-06-19 04:30:47 +00:00
mob-sakai 1aca69bbb7 fix demo 2024-06-19 13:23:40 +09:00
mob-sakai 3619b4ff94 feat: reset previous position on start play for world space simulation
close #303
2024-06-19 11:07:29 +09:00
mob-sakai cc3e95d8c7 fix: `UIParticle.transform.localScale` does not scale particles
close #313
2024-06-19 11:07:29 +09:00
mob-sakai 5c28e9a2f3 fix: UIParticle is scaled by canvas size even when `AutoScalingMode.None` and `ScalingMode.Local`
close #313
2024-06-19 11:07:29 +09:00
mob-sakai b82f79c2de feat: restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` 2024-06-19 11:07:29 +09:00
mob-sakai f029b7508e fix: UIParticle is scaled incorrectly with nested canvases
close #313
2024-06-18 19:44:00 +09:00
mob-sakai 5c41c39847 refactor: refactor 2024-06-18 17:11:14 +09:00
semantic-release-bot 49f46d5c9e chore(release): 4.6.8 [skip ci]
## [4.6.8](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.7...v4.6.8) (2024-06-14)

### Bug Fixes

* 'Resource ID out of range in GetResource' error in overlay rendering mode ([05286ce](05286cedfd)), closes [#308](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/308)
2024-06-14 01:48:23 +00:00
SAMYTHEBIGJUICY 628b9582b2 fix: 'Resource ID out of range in GetResource' error in overlay rendering mode
close #308
2024-06-14 10:47:32 +09:00
semantic-release-bot e8c9873201 chore(release): 4.6.7 [skip ci]
## [4.6.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.6...v4.6.7) (2024-05-24)

### Bug Fixes

* the ParticleSystem's localPosition drifts at certain scales due to floating-point precision issues ([e924eb4](e924eb4596)), closes [#299](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/299) [#312](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/312)
2024-05-24 08:38:56 +00:00
mob-sakai fa6881a028 fix: the ParticleSystem's localPosition drifts at certain scales due to floating-point precision issues
close #299, close #312
2024-05-24 17:37:32 +09:00
34 changed files with 691 additions and 296 deletions

View File

@ -1,64 +1,166 @@
# [5.0.0-preview.5](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v5.0.0-preview.4...v5.0.0-preview.5) (2024-07-18)
### Features
* ParticleAttractor supports multiple ParticleSystems ([e0a6381](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e0a63817e1e31b0f7c400dcdc67e255f0714273d))
# [5.0.0-preview.4](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v5.0.0-preview.3...v5.0.0-preview.4) (2024-06-27)
## [4.11.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.11.1...v4.11.2) (2025-03-15)
### Bug Fixes
* generated baking-camera object remains in the prefab or scene (again) ([5babd6d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5babd6d07b2ac17341a29964baf552785cefd90e))
* SetParticleSystemInstance/Prefab APIs destroy generated objects ([4b30c16](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4b30c16b9a48531873f9be91eec2a573370d17a1))
* IL2CPP build fails on older versions of Unity ([0da6525](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0da652520cd165b43de7404c0b0ab1fbcf9349d1))
* NRE on enable ([0cff50e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0cff50ef696aa53fb7c46a9a737b7cf3a05b7b9b)), closes [#359](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/359)
### Features
* add 'custom view' option. ([4252f11](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4252f1199b8a7038a6fb447989534c512ec40283))
* restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` (again) ([04232b6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/04232b67491e4506dbf84ce77c1dee7127936a3a))
* the rendering order list in inspector is now more compact ([9212eaa](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/9212eaa84c85524c00f9228ff8ba887e028838dc))
# [5.0.0-preview.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v5.0.0-preview.2...v5.0.0-preview.3) (2024-06-21)
## [4.11.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.11.0...v4.11.1) (2025-02-21)
### Bug Fixes
* generated baking-camera object remains in the prefab or scene ([fd66928](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fd66928efe584aeb4f6347b9a9dca97d9512eb88))
* component icons will no longer be displayed in the scene view ([6dfbdae](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/6dfbdae38d3822ab9c2c6f0e4ca1ca32ee98a239))
# [5.0.0-preview.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v5.0.0-preview.1...v5.0.0-preview.2) (2024-06-20)
# [4.11.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.7...v4.11.0) (2025-02-21)
### Features
* add 'TimeScaleMultiplier' option ([925af0b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/925af0b6046f65f23a778f67cefa8ff9cbedb513))
## [4.10.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.6...v4.10.7) (2025-01-14)
### Bug Fixes
* 'Resource ID out of range in GetResource' error in overlay rendering mode ([ff78b6f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ff78b6fe32ceed8ddad50e63dcb7a202eab95266)), closes [#308](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/308)
* `UIParticle.transform.localScale` does not scale particles ([491ee7b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/491ee7b0c3e528e1e577ae5ff2588d7c3bd8ecdb)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* despite not using the size module, particles become smaller based on their z position ([c96ddf2](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c96ddf293e855f7ebccaaaf3b112092955545e61)), closes [#316](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/316)
* the ParticleSystem's localPosition drifts at certain scales due to floating-point precision issues ([a9c2b19](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a9c2b19edf00e1c86c928ef23405906952ede852)), closes [#299](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/299) [#312](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/312)
* UIParticle is scaled by canvas size even when `AutoScalingMode.None` and `ScalingMode.Local` ([63b24d8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/63b24d8a8b478b3165733ece3eec524e88b28855)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* UIParticle is scaled incorrectly with nested canvases ([c95d8c6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c95d8c6b1774396ff252d13121ad32a3cab0fe5c)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* editor crashed on exit play mode (editor, windows) ([47ee45c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/47ee45cbbe651a8f87ca2b8a3948f8b88db8211e)), closes [#351](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/351)
## [4.10.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.5...v4.10.6) (2025-01-03)
### Bug Fixes
* sub-emitter particles may not render correctly in certain scenarios ([8276684](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8276684c3b1646f0490ed64557547ba15281664a)), closes [#348](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/348)
* sub-emitter's `inherit velocity` module doubles at runtime ([67de3d1](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/67de3d1bd3e16dc9b564625cb990c53d75769506)), closes [#349](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/349)
## [4.10.5](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.4...v4.10.5) (2024-12-23)
### Bug Fixes
* '3D' scale toggle in the inspector does not keep on reload ([934f4b8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/934f4b8f1c61f8ff20228d0ebcea9f636a3758ed)), closes [#346](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/346)
## [4.10.4](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.3...v4.10.4) (2024-12-19)
### Bug Fixes
* rendering issues when playing with opening a prefab stage ([95235a9](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/95235a929b82cf681365ed6eba837d857f83e3d2)), closes [#345](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/345)
## [4.10.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.2...v4.10.3) (2024-11-20)
### Bug Fixes
* if not configured as a preloaded asset, the project settings asset will be regenerated ([abe0948](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/abe09485f65dd4efd18e74675e752e0213bdf3be)), closes [#342](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/342)
## [4.10.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.1...v4.10.2) (2024-11-01)
### Bug Fixes
* trail incorrect offset ([afe00a1](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/afe00a1dde80eb1c0a7bb668b75f4c3733d3fa43)), closes [#335](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/335)
## [4.10.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.0...v4.10.1) (2024-09-29)
### Bug Fixes
* mainTex will be ignored ([2ee69d0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2ee69d04245fabce185f67dc9bd68c870e556564))
# [4.10.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.1...v4.10.0) (2024-09-29)
### Bug Fixes
* component icon is not set ([5ff6ec8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5ff6ec815a174de5d3f16d424f1204c60912a8d8))
### Features
* remove overlay window (editor) ([fc3fbdd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fc3fbdd230595ad3471875ec6fec384a3dad0d17))
* reset previous position on start play for world space simulation ([e741584](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e7415845074143abae23e3ae7eedc767a01d020d)), closes [#303](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/303)
* restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` ([dfb94f4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/dfb94f4badfb3035a4374579c53293460b4fd946))
* add project settings ([1ce4e31](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1ce4e31a9681bf1a201d2723c8d97e07ecc16592))
# [5.0.0-preview.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.6...v5.0.0-preview.1) (2024-05-23)
## [4.9.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.0...v4.9.1) (2024-08-07)
### Bug Fixes
* ParticleSystem trails gain offset on parent canvas change ([2a1cd50](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2a1cd502b452b5b56edf8bcfe91adf99d1bb5147)), closes [#323](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/323)
# [4.9.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.8.1...v4.9.0) (2024-07-18)
### Features
* add project settings for UIParticle ([b6e6185](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b6e6185c521fef0f118f61cfdfdac07b87555c01))
* change the default value of `UIParticle.scale` from `10` to `1` ([1b3c0f9](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1b3c0f92dcc6a1974d1ea074821e5264200e9711)), closes [#310](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/310)
* UIParticle no longer inherits from MaskableGraphic ([b6d921b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b6d921b3e47f749b5028d22b0e89b6eb3a1af7de))
* ParticleAttractor supports multiple ParticleSystems ([3834780](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3834780fdb43443fe6e1ef89df54d26a24d62a91))
## [4.8.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.8.0...v4.8.1) (2024-06-27)
### BREAKING CHANGES
### Bug Fixes
* Some members inherited from MaskableGraphic will no longer be available.
* remove debug code ([669deb4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/669deb41d4ac589d9db93b29bc8e95383e7f28a5))
# [4.8.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.7.2...v4.8.0) (2024-06-27)
### Bug Fixes
* generated baking-camera object remains in the prefab or scene (again) ([de35cba](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/de35cba34c6312c1405ed522e9927c620c78e72d))
* SetParticleSystemInstance/Prefab APIs destroy generated objects ([ae3f3a8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ae3f3a8e62cc733420354d237ab765ac777127c8))
### Features
* add 'custom view' option. ([a703c29](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a703c2921ca08c2280d0c8fde01e4c0b33b5c69e))
* remove overlay window (editor) ([8358170](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/835817049f4fcf00dd2bf98dbada14f041ad3544))
* restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` (again) ([88a970d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/88a970d93a2b69cf011d86bd1807569e90538e0e))
* the rendering order list in inspector is now more compact ([be90172](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/be901724e064befacf617f4940b0331e1d31e1ca))
## [4.7.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.7.1...v4.7.2) (2024-06-21)
### Bug Fixes
* generated baking-camera object remains in the prefab or scene ([0bb8438](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0bb843830197d8c1252232928becc211c0ada08d))
## [4.7.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.7.0...v4.7.1) (2024-06-20)
### Bug Fixes
* despite not using the size module, particles become smaller based on their z position ([a8ed6e6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a8ed6e68584e1d9e45ed852eefcc03979ea7e0e1)), closes [#316](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/316)
# [4.7.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.8...v4.7.0) (2024-06-19)
### Bug Fixes
* `UIParticle.transform.localScale` does not scale particles ([1d40e24](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1d40e24c742741e97f03c55468ccb1e505341133)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* UIParticle is scaled by canvas size even when `AutoScalingMode.None` and `ScalingMode.Local` ([54a4b1c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/54a4b1cdfd06400c7be89c1ee704bb42a659c7c2)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
* UIParticle is scaled incorrectly with nested canvases ([f26920f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f26920f9825547222a4afbb31cc5dc5a002c3e9b)), closes [#313](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/313)
### Features
* reset previous position on start play for world space simulation ([3880484](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3880484ce5190c42fc79c81d0b69e3fbeda09dd0)), closes [#303](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/303)
* restore `Transform.localScale` when setting `autoScalingMode` to something other than `Transform` ([5505247](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5505247a94a929ff89635fde512a9b95691e0043))
## [4.6.8](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.7...v4.6.8) (2024-06-14)
### Bug Fixes
* 'Resource ID out of range in GetResource' error in overlay rendering mode ([05286ce](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/05286cedfd17b1a0cb90a5e918513644f47cd831)), closes [#308](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/308)
## [4.6.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.6...v4.6.7) (2024-05-24)
### Bug Fixes
* the ParticleSystem's localPosition drifts at certain scales due to floating-point precision issues ([e924eb4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e924eb45968a112347471cabaeabc274e4c37ce4)), closes [#299](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/299) [#312](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/312)
## [4.6.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.6.5...v4.6.6) (2024-05-23)

View File

@ -2,20 +2,19 @@ using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.UI;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.UI;
using Coffee.UIParticleInternal;
#if UNITY_2021_2_OR_NEWER
using UnityEditor.Overlays;
#else
using System;
using System.Reflection;
using Coffee.UIParticleInternal;
using Object = UnityEngine.Object;
#endif
#if UNITY_2021_2_OR_NEWER
using UnityEditor.SceneManagement;
@ -27,8 +26,13 @@ namespace Coffee.UIExtensions
{
[CustomEditor(typeof(UIParticle))]
[CanEditMultipleObjects]
internal class UIParticleEditor : Editor
internal class UIParticleEditor : GraphicEditor
{
internal class State : ScriptableSingleton<State>
{
public bool is3DScaleMode;
}
//################################
// Constant or Static Members.
//################################
@ -47,7 +51,6 @@ namespace Coffee.UIExtensions
private static readonly GUIContent s_ContentPrimary = new GUIContent("Primary");
private static readonly Regex s_RegexBuiltInGuid = new Regex(@"^0{16}.0{15}$", RegexOptions.Compiled);
private static readonly List<Material> s_TempMaterials = new List<Material>();
private static bool s_XYZMode;
private SerializedProperty _maskable;
private SerializedProperty _scale3D;
@ -59,8 +62,10 @@ namespace Coffee.UIExtensions
private SerializedProperty _autoScalingMode;
private SerializedProperty _useCustomView;
private SerializedProperty _customViewSize;
private SerializedProperty _timeScaleMultiplier;
private ReorderableList _ro;
private bool _showMax;
private bool _is3DScaleMode;
private static readonly HashSet<Shader> s_Shaders = new HashSet<Shader>();
#if UNITY_2018 || UNITY_2019
@ -82,8 +87,10 @@ namespace Coffee.UIExtensions
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
private void OnEnable()
protected override void OnEnable()
{
base.OnEnable();
_maskable = serializedObject.FindProperty("m_Maskable");
_scale3D = serializedObject.FindProperty("m_Scale3D");
_animatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
@ -94,6 +101,7 @@ namespace Coffee.UIExtensions
_autoScalingMode = serializedObject.FindProperty("m_AutoScalingMode");
_useCustomView = serializedObject.FindProperty("m_UseCustomView");
_customViewSize = serializedObject.FindProperty("m_CustomViewSize");
_timeScaleMultiplier = serializedObject.FindProperty("m_TimeScaleMultiplier");
var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true)
@ -162,6 +170,19 @@ namespace Coffee.UIExtensions
uip.RefreshParticles(uip.particles);
}
}
// Initialize 3D scale mode.
_is3DScaleMode = State.instance.is3DScaleMode;
if (!_is3DScaleMode)
{
var x = _scale3D.FindPropertyRelative("x");
var y = _scale3D.FindPropertyRelative("y");
var z = _scale3D.FindPropertyRelative("z");
_is3DScaleMode = !Mathf.Approximately(x.floatValue, y.floatValue) ||
!Mathf.Approximately(y.floatValue, z.floatValue) ||
y.hasMultipleDifferentValues ||
z.hasMultipleDifferentValues;
}
}
/// <summary>
@ -180,7 +201,11 @@ namespace Coffee.UIExtensions
// Scale
EditorGUI.BeginDisabledGroup(!_meshSharing.hasMultipleDifferentValues && _meshSharing.intValue == 4);
s_XYZMode = DrawFloatOrVector3Field(_scale3D, s_XYZMode);
if (DrawFloatOrVector3Field(_scale3D, _is3DScaleMode) != _is3DScaleMode)
{
State.instance.is3DScaleMode = _is3DScaleMode = !_is3DScaleMode;
}
EditorGUI.EndDisabledGroup();
// AnimatableProperties
@ -221,6 +246,9 @@ namespace Coffee.UIExtensions
_customViewSize.floatValue = Mathf.Max(0.1f, _customViewSize.floatValue);
}
// Time Scale Multiplier
EditorGUILayout.PropertyField(_timeScaleMultiplier);
// Target ParticleSystems.
EditorGUI.BeginChangeCheck();
_ro.DoLayoutList();
@ -436,7 +464,9 @@ namespace Coffee.UIExtensions
{
if (!p || (ignoreCurrent && target == p)) return;
var cr = p.canvasRenderer;
DestroyImmediate(p);
DestroyImmediate(cr);
#if UNITY_2018_3_OR_NEWER
var stage = PrefabStageUtility.GetCurrentPrefabStage();

View File

Before

Width:  |  Height:  |  Size: 418 B

After

Width:  |  Height:  |  Size: 418 B

View File

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

View File

@ -11,7 +11,7 @@
[![](https://img.shields.io/github/watchers/mob-sakai/ParticleEffectForUGUI.svg?style=social&label=Watch)](https://github.com/mob-sakai/ParticleEffectForUGUI/subscription)
[![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai)
<< [📝 Description](#-description-) | [📌 Key Features](#-key-features) | [🎮 Demo](#-demo) | [⚙ Installation](#-installation) | [🔄 Upgrading to 5.x](#-upgrading-from-3x4x-to-5x) | [🚀 Usage](#-usage) | [🛠 Development Note](#-development-note) | [🤝 Contributing](#-contributing) >>
<< [📝 Description](#-description-) | [📌 Key Features](#-key-features) | [🎮 Demo](#-demo) | [⚙ Installation](#-installation) | [🚀 Usage](#-usage) | [🛠 Development Note](#-development-note) | [🤝 Contributing](#-contributing) >>
## 📝 Description <!-- omit in toc -->
@ -27,8 +27,6 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
- [Install via UPM (with Package Manager UI)](#install-via-upm-with-package-manager-ui)
- [Install via UPM (Manually)](#install-via-upm-manually)
- [Install as Embedded Package](#install-as-embedded-package)
- [🔄 Upgrading from 3.x/4.x to 5.x](#-upgrading-from-3x4x-to-5x)
- [Breaking Changes](#breaking-changes)
- [🚀 Usage](#-usage)
- [Component: UIParticle](#component-uiparticle)
- [Basic Usage](#basic-usage)
@ -36,6 +34,7 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
- [Usage with `Mask` or `RectMask2D` Component](#usage-with-mask-or-rectmask2d-component)
- [Usage with Script](#usage-with-script)
- [Component: UIParticleAttractor](#component-uiparticleattractor)
- [Project Settings](#project-settings)
- [🛠 Development Note](#-development-note)
- [Compares the Baking mesh approach with the conventional approach](#compares-the-baking-mesh-approach-with-the-conventional-approach)
- [Performance test results](#performance-test-results)
@ -153,24 +152,13 @@ _This package requires **Unity 2018.3 or later**._
<br><br>
## 🔄 Upgrading from 3.x/4.x to 5.x
### Breaking Changes
- The default value of `UIParticle.scale` has been changed from `10` to `1`.
- `UIParticle` no longer inherits from `MaskableGraphic`.
- Add project settings for UIParticle
- enableLinearToGamma: Enables LinearToGamma during mesh baking
<br><br>
## 🚀 Usage
### Component: UIParticle
`UIParticle` controls the ParticleSystems that are attached to its own game objects and child game objects.
![](https://github.com/mob-sakai/ParticleEffectForUGUI/assets/12690315/1cf5753b-33fc-4cef-91c3-413c515a954f)
![](https://github.com/user-attachments/assets/bc9eb783-afce-4102-ac61-aee9ea8d6f2f)
- **Maskable**: Does this graphic allow maskable.
- **Scale**: Scale the rendering particles. When the `3D` toggle is enabled, 3D scale (x, y, z) is supported.
@ -192,6 +180,7 @@ _This package requires **Unity 2018.3 or later**._
- **UIParticle:** UIParticle.scale will be adjusted.
- **Use Custom View:** Use this if the particles are not displayed correctly due to min/max particle size.
- **Custom view size:** Change the bake view size.
- **Time Scale Multiplier:** Time scale multiplier.
- **Rendering Order**: The ParticleSystem list to be rendered. You can change the order and the materials.
**NOTE:** Press the `Refresh` button to reconstruct the rendering order based on children ParticleSystem's sorting order
@ -222,7 +211,7 @@ and z-position.
If you want to mask particles, set a stencil-supported shader (such as `UI/UIAdditive`) to the material for
ParticleSystem.
If you use some custom shaders, see
the [How to Make a Custom Shader to Support Mask/RectMask2D Component](#how-to-make-a-custom-shader-to-support-maskrectmask2d-component)
the [How to Make a Custom Shader to Support Mask/RectMask2D Component](#how-to-make-a-custom-shader-to-support-mask-and-rectmask2d-component)
section.
![](https://user-images.githubusercontent.com/12690315/95017591-3b512700-0695-11eb-864e-04166ea1809a.png)
@ -269,6 +258,14 @@ uiParticle.Stop();
<br><br>
### Project Settings
![](https://github.com/user-attachments/assets/befc7f34-fb47-4006-831a-eba79fda11ca)
- Click `Edit > Project Settings` to open the Project Settings window and then select `UI > UI Particle` category.
<br><br>
## 🛠 Development Note
### Compares the Baking mesh approach with the conventional approach

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 4d73b3825bf044d418ae21bb331d3902
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -18,10 +18,10 @@ namespace Coffee.UIParticleInternal
public static T[] GetComponentsInChildren<T>(this Component self, int depth)
where T : Component
{
var results = ListPool<T>.Rent();
var results = InternalListPool<T>.Rent();
self.GetComponentsInChildren_Internal(results, depth);
var array = results.ToArray();
ListPool<T>.Return(ref results);
InternalListPool<T>.Return(ref results);
return array;
}
@ -134,6 +134,35 @@ namespace Coffee.UIParticleInternal
Profiler.EndSample();
}
/// <summary>
/// Add a component of a specific type to the children of a GameObject.
/// </summary>
public static void AddComponentOnChildren<T>(this Component self, bool includeSelf)
where T : Component
{
if (self == null) return;
Profiler.BeginSample("(COF)[ComponentExt] AddComponentOnChildren > Self");
if (includeSelf && !self.TryGetComponent<T>(out _))
{
self.gameObject.AddComponent<T>();
}
Profiler.EndSample();
Profiler.BeginSample("(COF)[ComponentExt] AddComponentOnChildren > Child");
var childCount = self.transform.childCount;
for (var i = 0; i < childCount; i++)
{
var child = self.transform.GetChild(i);
if (child.TryGetComponent<T>(out _)) continue;
child.gameObject.AddComponent<T>();
}
Profiler.EndSample();
}
#if !UNITY_2021_2_OR_NEWER && !UNITY_2020_3_45 && !UNITY_2020_3_46 && !UNITY_2020_3_47 && !UNITY_2020_3_48
public static T GetComponentInParent<T>(this Component self, bool includeInactive) where T : Component
{
@ -175,7 +204,7 @@ namespace Coffee.UIParticleInternal
target.enabled = false;
// Find MonoScript of the specified component.
foreach (var script in Resources.FindObjectsOfTypeAll<MonoScript>())
foreach (var script in MonoImporter.GetAllRuntimeMonoScripts())
{
if (script.GetClass() != typeof(T))
{

View File

@ -1,19 +0,0 @@
using System.Collections.Generic;
namespace Coffee.UIParticleInternal
{
/// <summary>
/// Extension methods for Component class.
/// </summary>
internal static class ListExtensions
{
public static void RemoveAtFast<T>(this List<T> self, int index)
{
if (self == null) return;
var lastIndex = self.Count - 1;
self[index] = self[lastIndex];
self.RemoveAt(lastIndex);
}
}
}

View File

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

View File

@ -1,48 +0,0 @@
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIParticleInternal
{
internal static class Misc
{
public static void Destroy(Object obj)
{
if (!obj) return;
#if UNITY_EDITOR
if (!Application.isPlaying)
{
Object.DestroyImmediate(obj);
}
else
#endif
{
Object.Destroy(obj);
}
}
public static void DestroyImmediate(Object obj)
{
if (!obj) return;
#if UNITY_EDITOR
if (Application.isEditor)
{
Object.DestroyImmediate(obj);
}
else
#endif
{
Object.Destroy(obj);
}
}
[Conditional("UNITY_EDITOR")]
public static void SetDirty(Object obj)
{
#if UNITY_EDITOR
if (!obj) return;
EditorUtility.SetDirty(obj);
#endif
}
}
}

View File

@ -17,11 +17,15 @@ namespace Coffee.UIParticleInternal
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
private static readonly MethodInfo s_GetActiveAtlasTextureMethod = s_SpriteEditorExtensionType
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
private static readonly Func<Sprite, Texture2D> s_GetActiveAtlasTextureMethod =
(Func<Sprite, Texture2D>)Delegate.CreateDelegate(typeof(Func<Sprite, Texture2D>),
s_SpriteEditorExtensionType
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic));
private static readonly MethodInfo s_GetActiveAtlasMethod = s_SpriteEditorExtensionType
.GetMethod("GetActiveAtlas", BindingFlags.Static | BindingFlags.NonPublic);
private static readonly Func<Sprite, SpriteAtlas> s_GetActiveAtlasMethod =
(Func<Sprite, SpriteAtlas>)Delegate.CreateDelegate(typeof(Func<Sprite, SpriteAtlas>),
s_SpriteEditorExtensionType
.GetMethod("GetActiveAtlas", BindingFlags.Static | BindingFlags.NonPublic));
/// <summary>
/// Get the actual texture of a sprite in play mode or edit mode.
@ -30,9 +34,7 @@ namespace Coffee.UIParticleInternal
{
if (!self) return null;
if (Application.isPlaying) return self.texture;
var ret = s_GetActiveAtlasTextureMethod.Invoke(null, new object[] { self }) as Texture2D;
var ret = s_GetActiveAtlasTextureMethod(self);
return ret ? ret : self.texture;
}
@ -43,7 +45,7 @@ namespace Coffee.UIParticleInternal
{
if (!self) return null;
return s_GetActiveAtlasMethod.Invoke(null, new object[] { self }) as SpriteAtlas;
return s_GetActiveAtlasMethod(self);
}
#else
/// <summary>

View File

@ -1,9 +1,9 @@
using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using Object = UnityEngine.Object;
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
@ -14,6 +14,14 @@ namespace Coffee.UIParticleInternal
public abstract class PreloadedProjectSettings : ScriptableObject
#if UNITY_EDITOR
{
private class Postprocessor : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____)
{
Initialize();
}
}
private class PreprocessBuildWithReport : IPreprocessBuildWithReport
{
int IOrderedCallback.callbackOrder => 0;
@ -24,32 +32,32 @@ namespace Coffee.UIParticleInternal
}
}
[InitializeOnLoadMethod]
[InitializeOnEnterPlayMode]
private static void Initialize()
{
const BindingFlags flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
foreach (var t in TypeCache.GetTypesDerivedFrom(typeof(PreloadedProjectSettings<>)))
{
var defaultSettings = GetDefaultSettings(t);
if (!defaultSettings)
{
defaultSettings = t.GetProperty("instance", flags)
?.GetValue(null, null) as PreloadedProjectSettings;
// When create a new instance, automatically set it as default settings.
defaultSettings = CreateInstance(t) as PreloadedProjectSettings;
SetDefaultSettings(defaultSettings);
}
else if (GetPreloadedSettings(t).Length != 1)
{
SetDefaultSettings(defaultSettings);
}
}
EditorApplication.QueuePlayerLoopUpdate();
if (defaultSettings)
{
defaultSettings.OnInitialize();
}
}
}
protected static string GetDefaultName(Type type, bool nicify)
{
var typeName = type.Name.Replace("ProjectSettings", "");
var typeName = type.Name;
return nicify
? ObjectNames.NicifyVariableName(typeName)
: typeName;
@ -73,6 +81,8 @@ namespace Coffee.UIParticleInternal
protected static void SetDefaultSettings(PreloadedProjectSettings asset)
{
if (!asset) return;
var type = asset.GetType();
if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(asset)))
{
@ -83,7 +93,11 @@ namespace Coffee.UIParticleInternal
var assetPath = $"Assets/ProjectSettings/{GetDefaultName(type, false)}.asset";
assetPath = AssetDatabase.GenerateUniqueAssetPath(assetPath);
AssetDatabase.CreateAsset(asset, assetPath);
if (!File.Exists(assetPath))
{
AssetDatabase.CreateAsset(asset, assetPath);
asset.OnCreateAsset();
}
}
var preloadedAssets = PlayerSettings.GetPreloadedAssets();
@ -97,13 +111,20 @@ namespace Coffee.UIParticleInternal
AssetDatabase.Refresh();
}
protected virtual void OnCreateAsset()
{
}
protected virtual void OnInitialize()
{
}
}
#else
{
}
#endif
public abstract class PreloadedProjectSettings<T> : PreloadedProjectSettings
where T : PreloadedProjectSettings<T>
{
@ -112,6 +133,8 @@ namespace Coffee.UIParticleInternal
#if UNITY_EDITOR
private string _jsonText;
public static bool hasInstance => s_Instance;
public static T instance
{
get

View File

@ -10,8 +10,9 @@ namespace Coffee.UIParticleInternal
/// </summary>
internal class FastActionBase<T>
{
private static readonly ObjectPool<LinkedListNode<T>> s_NodePool =
new ObjectPool<LinkedListNode<T>>(() => new LinkedListNode<T>(default), _ => true, x => x.Value = default);
private static readonly InternalObjectPool<LinkedListNode<T>> s_NodePool =
new InternalObjectPool<LinkedListNode<T>>(() => new LinkedListNode<T>(default), _ => true,
x => x.Value = default);
private readonly LinkedList<T> _delegates = new LinkedList<T>();

View File

@ -46,7 +46,6 @@ namespace Coffee.UIParticleInternal
GetFrameCache<T>().Set((key1.GetHashCode(), key2.GetHashCode()), result);
}
/// <summary>
/// Sets a value in the frame cache with a specified key.
/// </summary>

View File

@ -5,7 +5,6 @@ using Object = UnityEngine.Object;
#if ENABLE_COFFEE_LOGGER
using System.Reflection;
using System.Collections.Generic;
#else
using Conditional = System.Diagnostics.ConditionalAttribute;
#endif
@ -43,7 +42,6 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@ -53,7 +51,6 @@ namespace Coffee.UIParticleInternal
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@ -62,7 +59,6 @@ namespace Coffee.UIParticleInternal
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@ -80,7 +76,6 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@ -124,7 +119,6 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@ -170,7 +164,6 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@ -209,7 +202,6 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif

View File

@ -15,7 +15,7 @@ namespace Coffee.UIParticleInternal
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void Clear()
public static void Clear()
{
s_Repository.Clear();
}
@ -55,7 +55,6 @@ namespace Coffee.UIParticleInternal
Profiler.EndSample();
}
/// <summary>
/// Adds or retrieves a cached material based on the hash.
/// </summary>

View File

@ -0,0 +1,132 @@
using System;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
#if UNITY_EDITOR
using System.IO;
using System.Linq;
using System.Reflection;
#if UNITY_2021_2_OR_NEWER
using UnityEditor.SceneManagement;
#else
using UnityEditor.Experimental.SceneManagement;
#endif
#endif
namespace Coffee.UIParticleInternal
{
internal static class Misc
{
public static T[] FindObjectsOfType<T>() where T : Object
{
#if UNITY_2023_1_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None);
#else
return Object.FindObjectsOfType<T>();
#endif
}
public static void Destroy(Object obj)
{
if (!obj) return;
#if UNITY_EDITOR
if (!Application.isPlaying)
{
Object.DestroyImmediate(obj);
}
else
#endif
{
Object.Destroy(obj);
}
}
public static void DestroyImmediate(Object obj)
{
if (!obj) return;
#if UNITY_EDITOR
if (Application.isEditor)
{
Object.DestroyImmediate(obj);
}
else
#endif
{
Object.Destroy(obj);
}
}
[Conditional("UNITY_EDITOR")]
public static void SetDirty(Object obj)
{
#if UNITY_EDITOR
if (!obj) return;
EditorUtility.SetDirty(obj);
#endif
}
#if UNITY_EDITOR
public static T[] GetAllComponentsInPrefabStage<T>() where T : Component
{
var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
if (prefabStage == null) return Array.Empty<T>();
return prefabStage.prefabContentsRoot.GetComponentsInChildren<T>(true);
}
public static bool isBatchOrBuilding => Application.isBatchMode || BuildPipeline.isBuildingPlayer;
#endif
[Conditional("UNITY_EDITOR")]
public static void QueuePlayerLoopUpdate()
{
#if UNITY_EDITOR
if (!EditorApplication.isPlaying)
{
EditorApplication.QueuePlayerLoopUpdate();
}
#endif
}
}
#if !UNITY_2021_2_OR_NEWER
[AttributeUsage(AttributeTargets.Class)]
[Conditional("UNITY_EDITOR")]
internal class IconAttribute : Attribute
{
private readonly string _path;
public IconAttribute(string path)
{
_path = path;
}
#if UNITY_EDITOR
private static Action<Object, Texture2D> s_SetIconForObject = typeof(EditorGUIUtility)
.GetMethod("SetIconForObject", BindingFlags.Static | BindingFlags.NonPublic)
.CreateDelegate(typeof(Action<Object, Texture2D>), null) as Action<Object, Texture2D>;
[InitializeOnLoadMethod]
private static void InitializeOnLoadMethod()
{
if (Misc.isBatchOrBuilding) return;
var types = TypeCache.GetTypesWithAttribute<IconAttribute>();
var scripts = MonoImporter.GetAllRuntimeMonoScripts();
foreach (var type in types)
{
var script = scripts.FirstOrDefault(x => x.GetClass() == type);
if (!script) continue;
var path = type.GetCustomAttribute<IconAttribute>()?._path;
var icon = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
if (!icon) continue;
s_SetIconForObject(script, icon);
}
}
#endif
}
#endif
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 39ed6a6b0a72e482488bd298b2ae762e
guid: 182319ecc315e4858b119764af0fbcb0
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -6,15 +6,58 @@ namespace Coffee.UIParticleInternal
/// <summary>
/// Object pool.
/// </summary>
internal class ObjectPool<T>
internal class InternalObjectPool<T> where T : class
{
#if UNITY_2021_1_OR_NEWER
private readonly Predicate<T> _onValid; // Delegate for checking if instances are valid
private readonly UnityEngine.Pool.ObjectPool<T> _pool;
public InternalObjectPool(Func<T> onCreate, Predicate<T> onValid, Action<T> onReturn)
{
_pool = new UnityEngine.Pool.ObjectPool<T>(onCreate, null, onReturn);
_onValid = onValid;
}
/// <summary>
/// Rent an instance from the pool.
/// When you no longer need it, return it with <see cref="Return" />.
/// </summary>
public T Rent()
{
while (0 < _pool.CountInactive)
{
var instance = _pool.Get();
if (_onValid(instance))
{
return instance;
}
}
// If there are no instances in the pool, create a new one.
Logging.Log(this, $"A new instance is created (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
return _pool.Get();
}
/// <summary>
/// Return an instance to the pool and assign null.
/// Be sure to return the instance obtained with <see cref="Rent" /> with this method.
/// </summary>
public void Return(ref T instance)
{
if (instance == null) return; // Ignore if already pooled or null.
_pool.Release(instance);
Logging.Log(this, $"An instance is released (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
instance = default; // Set the reference to null.
}
#else
private readonly Func<T> _onCreate; // Delegate for creating instances
private readonly Action<T> _onReturn; // Delegate for returning instances to the pool
private readonly Predicate<T> _onValid; // Delegate for checking if instances are valid
private readonly Stack<T> _pool = new Stack<T>(32); // Object pool
private int _count; // Total count of created instances
public ObjectPool(Func<T> onCreate, Predicate<T> onValid, Action<T> onReturn)
public InternalObjectPool(Func<T> onCreate, Predicate<T> onValid, Action<T> onReturn)
{
_onCreate = onCreate;
_onValid = onValid;
@ -54,15 +97,40 @@ namespace Coffee.UIParticleInternal
Logging.Log(this, $"An instance is released (pooled: {_pool.Count}, created: {_count}).");
instance = default; // Set the reference to null.
}
#endif
}
/// <summary>
/// Object pool for <see cref="List{T}" />.
/// </summary>
internal static class ListPool<T>
internal static class InternalListPool<T>
{
private static readonly ObjectPool<List<T>> s_ListPool =
new ObjectPool<List<T>>(() => new List<T>(), _ => true, x => x.Clear());
#if UNITY_2021_1_OR_NEWER
/// <summary>
/// Rent an instance from the pool.
/// When you no longer need it, return it with <see cref="Return" />.
/// </summary>
public static List<T> Rent()
{
return UnityEngine.Pool.ListPool<T>.Get();
}
/// <summary>
/// Return an instance to the pool and assign null.
/// Be sure to return the instance obtained with <see cref="Rent" /> with this method.
/// </summary>
public static void Return(ref List<T> toRelease)
{
if (toRelease != null)
{
UnityEngine.Pool.ListPool<T>.Release(toRelease);
}
toRelease = null;
}
#else
private static readonly InternalObjectPool<List<T>> s_ListPool =
new InternalObjectPool<List<T>>(() => new List<T>(), _ => true, x => x.Clear());
/// <summary>
/// Rent an instance from the pool.
@ -81,5 +149,6 @@ namespace Coffee.UIParticleInternal
{
s_ListPool.Return(ref toRelease);
}
#endif
}
}

View File

@ -14,6 +14,8 @@ namespace Coffee.UIParticleInternal
private static readonly FastAction s_AfterCanvasRebuildAction = new FastAction();
private static readonly FastAction s_LateAfterCanvasRebuildAction = new FastAction();
private static readonly FastAction s_BeforeCanvasRebuildAction = new FastAction();
private static readonly FastAction s_OnScreenSizeChangedAction = new FastAction();
private static Vector2Int s_LastScreenSize;
static UIExtraCallbacks()
{
@ -48,6 +50,15 @@ namespace Coffee.UIParticleInternal
remove => s_AfterCanvasRebuildAction.Remove(value);
}
/// <summary>
/// Event that occurs when the screen size changes.
/// </summary>
public static event Action onScreenSizeChanged
{
add => s_OnScreenSizeChangedAction.Add(value);
remove => s_OnScreenSizeChangedAction.Remove(value);
}
/// <summary>
/// Initializes the UIExtraCallbacks to ensure proper event handling.
/// </summary>
@ -77,6 +88,17 @@ namespace Coffee.UIParticleInternal
/// </summary>
private static void OnBeforeCanvasRebuild()
{
var screenSize = new Vector2Int(Screen.width, Screen.height);
if (s_LastScreenSize != screenSize)
{
if (s_LastScreenSize != default)
{
s_OnScreenSizeChangedAction.Invoke();
}
s_LastScreenSize = screenSize;
}
s_BeforeCanvasRebuildAction.Invoke();
InitializeAfterCanvasRebuild();
}

View File

@ -3,22 +3,25 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Coffee.UIParticleInternal;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.UI;
using Random = UnityEngine.Random;
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
[assembly: InternalsVisibleTo("Coffee.UIParticle.PerformanceDemo")]
[assembly: InternalsVisibleTo("Coffee.UIParticle.Demo")]
namespace Coffee.UIExtensions
{
/// <summary>
/// Render maskable and sortable particle effect ,without Camera, RenderTexture or Canvas.
/// </summary>
[Icon("Packages/com.coffee.ui-particle/Icons/UIParticleIcon.png")]
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))]
public class UIParticle : UIBehaviour, ISerializationCallbackReceiver
public class UIParticle : MaskableGraphic, ISerializationCallbackReceiver
{
public enum AutoScalingMode
{
@ -60,7 +63,7 @@ namespace Coffee.UIExtensions
[Tooltip("Scale the rendering particles. When the `3D` toggle is enabled, 3D scale (x, y, z) is supported.")]
[SerializeField]
private Vector3 m_Scale3D = new Vector3(1, 1, 1);
private Vector3 m_Scale3D = new Vector3(10, 10, 10);
[Tooltip("If you want to update material properties (e.g. _MainTex_ST, _Color) in AnimationClip, " +
"use this to mark as animatable.")]
@ -118,47 +121,23 @@ namespace Coffee.UIExtensions
private float m_CustomViewSize = 10;
[SerializeField]
private bool m_Maskable = true;
[Tooltip("Time scale multiplier.")]
private float m_TimeScaleMultiplier = 1;
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
private Camera _bakeCamera;
private Canvas _canvas;
private int _groupId;
private bool _isScaleStored;
private Vector3 _storedScale;
private DrivenRectTransformTracker _tracker;
public RectTransform rectTransform => transform as RectTransform;
public Canvas canvas
{
get
{
if (_canvas) return _canvas;
var tr = transform;
while (tr && !_canvas)
{
if (tr.TryGetComponent(out _canvas)) return _canvas;
tr = tr.parent;
}
return null;
}
}
/// <summary>
/// Does this graphic allow masking.
/// Should this graphic be considered a target for ray-casting?
/// </summary>
public bool maskable
public override bool raycastTarget
{
get => m_Maskable;
set
{
if (value == m_Maskable) return;
m_Maskable = value;
UpdateRendererMaterial();
}
get => false;
set { }
}
/// <summary>
@ -283,6 +262,15 @@ namespace Coffee.UIExtensions
set => m_CustomViewSize = Mathf.Max(0.1f, value);
}
/// <summary>
/// Time scale multiplier.
/// </summary>
public float timeScaleMultiplier
{
get => m_TimeScaleMultiplier;
set => m_TimeScaleMultiplier = value;
}
internal bool useMeshSharing => m_MeshSharing != MeshSharing.None;
internal bool isPrimary =>
@ -335,15 +323,15 @@ namespace Coffee.UIExtensions
public Vector3 parentScale { get; private set; }
private Vector3 canvasScale { get; set; }
public Vector3 canvasScale { get; private set; }
protected override void OnEnable()
{
_isScaleStored = false;
ResetGroupId();
UIParticleUpdater.Register(this);
RegisterDirtyMaterialCallback(UpdateRendererMaterial);
//
if (0 < particles.Count)
{
RefreshParticles(particles);
@ -353,7 +341,7 @@ namespace Coffee.UIExtensions
RefreshParticles();
}
UpdateRendererMaterial();
base.OnEnable();
}
/// <summary>
@ -370,15 +358,9 @@ namespace Coffee.UIExtensions
_isScaleStored = false;
UIParticleUpdater.Unregister(this);
_renderers.ForEach(r => r.Reset());
_canvas = null;
}
UnregisterDirtyMaterialCallback(UpdateRendererMaterial);
/// <summary>
/// Called when the state of the parent Canvas is changed.
/// </summary>
protected override void OnCanvasHierarchyChanged()
{
_canvas = null;
base.OnDisable();
}
/// <summary>
@ -388,14 +370,6 @@ namespace Coffee.UIExtensions
{
}
/// <summary>
/// This function is called when a direct or indirect parent of the transform of the GameObject has changed.
/// </summary>
protected override void OnTransformParentChanged()
{
_canvas = null;
}
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
}
@ -617,12 +591,14 @@ namespace Coffee.UIExtensions
{
var ps = particleSystems[i];
if (!ps) continue;
GetRenderer(j++).Set(this, ps, false);
var mainEmitter = ps.GetMainEmitter(particleSystems);
GetRenderer(j++).Set(this, ps, false, mainEmitter);
// If the trail is enabled, set it additionally.
if (ps.trails.enabled)
{
GetRenderer(j++).Set(this, ps, true);
GetRenderer(j++).Set(this, ps, true, mainEmitter);
}
}
}
@ -688,6 +664,17 @@ namespace Coffee.UIExtensions
: Random.Range(m_GroupId, m_GroupMaxId + 1);
}
protected override void UpdateMaterial()
{
}
/// <summary>
/// Call to update the geometry of the Graphic onto the CanvasRenderer.
/// </summary>
protected override void UpdateGeometry()
{
}
private void UpdateRendererMaterial()
{
for (var i = 0; i < _renderers.Count; i++)
@ -763,7 +750,7 @@ namespace Coffee.UIExtensions
_bakeCamera.useOcclusionCulling = false;
_bakeCamera.gameObject.SetActive(false);
_bakeCamera.gameObject.hideFlags = HideFlags.HideAndDontSave;
_bakeCamera.gameObject.hideFlags = UIParticleProjectSettings.globalHideFlags;
return _bakeCamera;
}

View File

@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 5f0675613942149309588d556e33d990, type: 3}
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -148,7 +148,7 @@ namespace Coffee.UIExtensions
// Collect UIParticle if needed (same size as m_ParticleSystems)
CollectUIParticlesIfNeeded();
for (var particleIndex = 0; particleIndex < this.m_ParticleSystems.Count; particleIndex++)
for (var particleIndex = 0; particleIndex < m_ParticleSystems.Count; particleIndex++)
{
var particleSystem = m_ParticleSystems[particleIndex];
@ -163,21 +163,21 @@ namespace Coffee.UIExtensions
particleSystem.GetParticles(particles, count);
var uiParticle = _uiParticles[particleIndex];
var dstPos = this.GetDestinationPosition(uiParticle, particleSystem);
var dstPos = GetDestinationPosition(uiParticle, particleSystem);
for (var i = 0; i < count; i++)
{
// Attracted
var p = particles[i];
if (0f < p.remainingLifetime && Vector3.Distance(p.position, dstPos) < this.m_DestinationRadius)
if (0f < p.remainingLifetime && Vector3.Distance(p.position, dstPos) < m_DestinationRadius)
{
p.remainingLifetime = 0f;
particles[i] = p;
if (this.m_OnAttracted != null)
if (m_OnAttracted != null)
{
try
{
this.m_OnAttracted.Invoke();
m_OnAttracted.Invoke();
}
catch (Exception e)
{
@ -189,7 +189,7 @@ namespace Coffee.UIExtensions
}
// Calc attracting time
var delayTime = p.startLifetime * this.m_DelayRate;
var delayTime = p.startLifetime * m_DelayRate;
var duration = p.startLifetime - delayTime;
var time = Mathf.Max(0, p.startLifetime - p.remainingLifetime - delayTime);
@ -197,7 +197,7 @@ namespace Coffee.UIExtensions
if (time <= 0) continue;
// Attract
p.position = this.GetAttractedPosition(p.position, dstPos, duration, time);
p.position = GetAttractedPosition(p.position, dstPos, duration, time);
p.velocity *= 0.5f;
particles[i] = p;
}

View File

@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 5f0675613942149309588d556e33d990, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -17,6 +17,18 @@ namespace Coffee.UIExtensions
set => instance.m_EnableLinearToGamma = value;
}
[Header("Editor")]
[Tooltip("Hide the automatically generated objects.\n" +
" - UIParticleRenderer\n" +
" - UIParticle BakingCamera")]
[SerializeField]
private bool m_HideGeneratedObjects = true;
public static HideFlags globalHideFlags => instance.m_HideGeneratedObjects
? HideFlags.DontSave | HideFlags.NotEditable | HideFlags.HideInHierarchy | HideFlags.HideInInspector
: HideFlags.DontSave | HideFlags.NotEditable;
#if UNITY_EDITOR
[SettingsProvider]
private static SettingsProvider CreateSettingsProvider()

View File

@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 5f0675613942149309588d556e33d990, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,7 +4,6 @@
#elif UNITY_2022_3_OR_NEWER
#define PS_BAKE_API_V2
#endif
using System;
using System.Collections.Generic;
using Coffee.UIParticleInternal;
@ -16,6 +15,7 @@ using UnityEngine.UI;
namespace Coffee.UIExtensions
{
[Icon("Packages/com.coffee.ui-particle/Icons/UIParticleIcon.png")]
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))]
@ -41,6 +41,7 @@ namespace Coffee.UIExtensions
private Vector2Int _prevScreenSize;
private bool _preWarm;
private ParticleSystemRenderer _renderer;
private ParticleSystem _mainEmitter;
public override Texture mainTexture => _isTrail ? null : _particleSystem.GetTextureForSprite();
@ -113,6 +114,7 @@ namespace Coffee.UIExtensions
_parent = null;
_particleSystem = null;
_renderer = null;
_mainEmitter = null;
if (0 <= index)
{
_index = index;
@ -137,6 +139,7 @@ namespace Coffee.UIExtensions
{
base.OnEnable();
hideFlags = UIParticleProjectSettings.globalHideFlags;
if (!s_CombineInstances[0].mesh)
{
s_CombineInstances[0].mesh = new Mesh
@ -161,7 +164,7 @@ namespace Coffee.UIExtensions
// Create renderer object.
var go = new GameObject("[generated] UIParticleRenderer", typeof(UIParticleRenderer))
{
hideFlags = HideFlags.HideAndDontSave,
hideFlags = UIParticleProjectSettings.globalHideFlags,
layer = parent.gameObject.layer
};
@ -201,7 +204,6 @@ namespace Coffee.UIExtensions
return modifiedMaterial;
}
//
var hash = new Hash128(
modifiedMaterial ? (uint)modifiedMaterial.GetInstanceID() : 0,
texture ? (uint)texture.GetInstanceID() : 0,
@ -224,7 +226,7 @@ namespace Coffee.UIExtensions
return _modifiedMaterial;
}
public void Set(UIParticle parent, ParticleSystem ps, bool isTrail)
public void Set(UIParticle parent, ParticleSystem ps, bool isTrail, ParticleSystem mainEmitter)
{
_parent = parent;
maskable = parent.maskable;
@ -247,10 +249,7 @@ namespace Coffee.UIExtensions
ps.TryGetComponent(out _renderer);
_renderer.enabled = false;
//_emitter = emitter;
_isTrail = isTrail;
_renderer.GetSharedMaterials(s_Materials);
material = s_Materials[isTrail ? 1 : 0];
s_Materials.Clear();
@ -267,6 +266,7 @@ namespace Coffee.UIExtensions
_prevScreenSize = new Vector2Int(Screen.width, Screen.height);
_prevCanvasScale = canvas ? canvas.scaleFactor : 1f;
_delay = true;
_mainEmitter = mainEmitter;
canvasRenderer.SetTexture(null);
@ -304,7 +304,7 @@ namespace Coffee.UIExtensions
// Simulate particles.
Profiler.BeginSample("[UIParticle] Bake Mesh > Simulate Particles");
if (!_isTrail && _parent.canSimulate)
if (!_isTrail && _parent.canSimulate && !_mainEmitter)
{
#if UNITY_EDITOR
if (!Application.isPlaying)
@ -422,17 +422,16 @@ namespace Coffee.UIExtensions
workerMesh.LinearToGamma();
}
var components = ListPool<Component>.Rent();
var components = InternalListPool<Component>.Rent();
GetComponents(typeof(IMeshModifier), components);
#pragma warning disable CS0618 // Type or member is obsolete
for (var i = 0; i < components.Count; i++)
{
#pragma warning disable CS0618 // Type or member is obsolete
((IMeshModifier)components[i]).ModifyMesh(workerMesh);
}
#pragma warning restore CS0618 // Type or member is obsolete
}
ListPool<Component>.Return(ref components);
InternalListPool<Component>.Return(ref components);
}
Profiler.EndSample();
@ -444,7 +443,7 @@ namespace Coffee.UIExtensions
// Get grouped renderers.
Profiler.BeginSample("[UIParticleRenderer] Set Mesh");
var renderers = ListPool<UIParticleRenderer>.Rent();
var renderers = InternalListPool<UIParticleRenderer>.Rent();
if (_parent.useMeshSharing)
{
UIParticleUpdater.GetGroupedRenderers(_parent.groupId, _index, renderers);
@ -461,7 +460,7 @@ namespace Coffee.UIExtensions
r.canvasRenderer.SetMaterial(materialForRendering, 0);
}
ListPool<UIParticleRenderer>.Return(ref renderers);
InternalListPool<UIParticleRenderer>.Return(ref renderers);
if (_parent.canRender)
{
@ -544,6 +543,30 @@ namespace Coffee.UIExtensions
return Matrix4x4.Translate(psPos)
* Matrix4x4.Scale(scale);
case ParticleSystemSimulationSpace.World:
if (_isTrail)
{
return Matrix4x4.Translate(psPos)
* Matrix4x4.Scale(scale)
* Matrix4x4.Translate(-psPos);
}
if (_mainEmitter)
{
if (_mainEmitter.IsLocalSpace())
{
return Matrix4x4.Translate(psPos)
* Matrix4x4.Scale(scale)
* Matrix4x4.Translate(-psPos);
}
else
{
psPos = _particleSystem.transform.position - _mainEmitter.transform.position;
return Matrix4x4.Translate(psPos)
* Matrix4x4.Scale(scale)
* Matrix4x4.Translate(-psPos);
}
}
return Matrix4x4.Scale(scale);
case ParticleSystemSimulationSpace.Custom:
return Matrix4x4.Translate(_particleSystem.main.customSimulationSpace.position.GetScaled(scale))
@ -606,6 +629,7 @@ namespace Coffee.UIExtensions
: main.useUnscaledTime
? Time.unscaledDeltaTime
: Time.deltaTime;
deltaTime *= _parent.timeScaleMultiplier;
// Pre-warm:
if (0 < deltaTime && _preWarm)

View File

@ -40,13 +40,26 @@ namespace Coffee.UIExtensions
#if UNITY_EDITOR
[InitializeOnLoadMethod]
private static void InitializeOnLoad()
{
UIExtraCallbacks.onAfterCanvasRebuild += Refresh;
EditorApplication.playModeStateChanged += state =>
{
UIExtraCallbacks.onAfterCanvasRebuild -= Refresh;
if (state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.EnteredPlayMode)
{
UIExtraCallbacks.onAfterCanvasRebuild += Refresh;
}
};
}
#else
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
#endif
private static void InitializeOnLoad()
{
UIExtraCallbacks.onAfterCanvasRebuild += Refresh;
}
#endif
private static void Refresh()
{

View File

@ -171,5 +171,32 @@ namespace Coffee.UIParticleInternal
action.Invoke(p);
}
}
public static ParticleSystem GetMainEmitter(this ParticleSystem self, List<ParticleSystem> list)
{
if (!self || list == null || list.Count == 0) return null;
for (var i = 0; i < list.Count; i++)
{
var parent = list[i];
if (parent != self && IsSubEmitterOf(self, parent)) return parent;
}
return null;
}
public static bool IsSubEmitterOf(this ParticleSystem self, ParticleSystem parent)
{
if (!self || !parent) return false;
var subEmitters = parent.subEmitters;
var count = subEmitters.subEmittersCount;
for (var i = 0; i < count; i++)
{
if (subEmitters.GetSubEmitterSystem(i) == self) return true;
}
return false;
}
}
}

View File

@ -1,3 +1,4 @@
using Coffee.UIParticleInternal;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
@ -51,11 +52,7 @@ namespace Coffee.UIExtensions.Demo
public void EnableAnimations(bool flag)
{
#if UNITY_2023_1_OR_NEWER
foreach (var animator in FindObjectsByType<Animator>(FindObjectsInactive.Include, FindObjectsSortMode.None))
#else
foreach (var animator in FindObjectsOfType<Animator>())
#endif
foreach (var animator in Misc.FindObjectsOfType<Animator>())
{
animator.enabled = flag;
}
@ -83,11 +80,7 @@ namespace Coffee.UIExtensions.Demo
public void UIParticle_Scale(float scale)
{
#if UNITY_2023_1_OR_NEWER
foreach (var uip in FindObjectsByType<UIParticle>(FindObjectsInactive.Include, FindObjectsSortMode.None))
#else
foreach (var uip in FindObjectsOfType<UIParticle>())
#endif
foreach (var uip in Misc.FindObjectsOfType<UIParticle>())
{
uip.scale = scale;
}
@ -95,11 +88,7 @@ namespace Coffee.UIExtensions.Demo
public void ParticleSystem_WorldSpaseSimulation(bool flag)
{
#if UNITY_2023_1_OR_NEWER
foreach (var p in FindObjectsByType<ParticleSystem>(FindObjectsInactive.Include, FindObjectsSortMode.None))
#else
foreach (var p in FindObjectsOfType<ParticleSystem>())
#endif
foreach (var p in Misc.FindObjectsOfType<ParticleSystem>())
{
var main = p.main;
main.simulationSpace = flag
@ -135,11 +124,7 @@ namespace Coffee.UIExtensions.Demo
public void ParticleSystem_SetScale(float scale)
{
#if UNITY_2023_1_OR_NEWER
foreach (var ps in FindObjectsByType<ParticleSystem>(FindObjectsInactive.Include, FindObjectsSortMode.None))
#else
foreach (var ps in FindObjectsOfType<ParticleSystem>())
#endif
foreach (var ps in Misc.FindObjectsOfType<ParticleSystem>())
{
ps.transform.localScale = new Vector3(scale, scale, scale);
}

View File

@ -40,7 +40,10 @@
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog { Mode Off }
Fog
{
Mode Off
}
Blend One One
ColorMask [_ColorMask]
@ -61,21 +64,21 @@
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
@ -114,4 +117,4 @@
ENDCG
}
}
}
}

View File

@ -2,7 +2,7 @@
"name": "com.coffee.ui-particle",
"displayName": "UI Particle",
"description": "This package provides a component to render particle effects for uGUI.\nThe particle rendering is maskable and sortable, without the need for an extra Camera, RenderTexture, or Canvas.",
"version": "5.0.0-preview.5",
"version": "4.11.2",
"unity": "2018.2",
"license": "MIT",
"repository": {