You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
Compare commits
117 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f43d4c38ea | ||
|
|
ccb8386672 | ||
|
|
e15319a46e | ||
|
|
e352d153ce | ||
|
|
4f9bbf57bc | ||
|
|
0b9d80da93 | ||
|
|
24d32d8441 | ||
|
|
476c4027ff | ||
|
|
12c748a8cd | ||
|
|
0259ad2464 | ||
|
|
5f3ead2086 | ||
|
|
e3f42d747a | ||
|
|
b93e0e4701 | ||
|
|
9f9e04724d | ||
|
|
5981af6c0a | ||
|
|
f38240f527 | ||
|
|
d775e805fb | ||
|
|
d9eb91c120 | ||
|
|
13223b2d74 | ||
|
|
d5ce78ae5a | ||
|
|
3bb5241275 | ||
|
|
41e895a2db | ||
|
|
17ce81eb0e | ||
|
|
ba3b80db7a | ||
|
|
2a1f3345ba | ||
|
|
c0aa89bd6f | ||
|
|
501aa7b7f1 | ||
|
|
9313489552 | ||
|
|
63b36a45b9 | ||
|
|
087dbe99b9 | ||
|
|
d11cd0a06d | ||
|
|
429ff2dd09 | ||
|
|
3f16943ccd | ||
|
|
4b4aebff8c | ||
|
|
46a7dddd11 | ||
|
|
2ec81da048 | ||
|
|
08c4aba8ab | ||
|
|
44889c8a33 | ||
|
|
6884c62687 | ||
|
|
fc4bd708fd | ||
|
|
08273cb0c3 | ||
|
|
06d8fae58f | ||
|
|
22bcecd0ab | ||
|
|
68669c7396 | ||
|
|
1b1ca56461 | ||
|
|
b322db3ca9 | ||
|
|
44beab0de8 | ||
|
|
82f81efd7e | ||
|
|
af5f7e90b0 | ||
|
|
3d8f11ba82 | ||
|
|
61f7706259 | ||
|
|
c4c35a6611 | ||
|
|
7acbf22b4d | ||
|
|
f7eac0a34f | ||
|
|
f2c78e3ae4 | ||
|
|
f317e4475a | ||
|
|
d586d19d2f | ||
|
|
d7a7d1b5b6 | ||
|
|
f1338813ca | ||
|
|
4be56669fb | ||
|
|
6b397f39b8 | ||
|
|
d9f9244e49 | ||
|
|
37ff06dd12 | ||
|
|
8b328154a4 | ||
|
|
7bf1bae64a | ||
|
|
4b4d70bdd1 | ||
|
|
94ae9d2016 | ||
|
|
bda77ab039 | ||
|
|
82aeb0e419 | ||
|
|
64787261df | ||
|
|
6f3f4803da | ||
|
|
b12b82c172 | ||
|
|
c8ecd56e76 | ||
|
|
7f36ca15dd | ||
|
|
2b9e8ecd73 | ||
|
|
eafc615ea6 | ||
|
|
94df58276a | ||
|
|
9071798353 | ||
|
|
0eb76a6432 | ||
|
|
58465259ad | ||
|
|
46ec957a52 | ||
|
|
ab27f0af6f | ||
|
|
0d4a5875d1 | ||
|
|
eccb3ecb5e | ||
|
|
785709fa02 | ||
|
|
f2034e27b7 | ||
|
|
7355c2ac78 | ||
|
|
2b3bf91655 | ||
|
|
e036d254a8 | ||
|
|
af9909f4dc | ||
|
|
901e7f1647 | ||
|
|
bb7443400c | ||
|
|
ce6478cf1f | ||
|
|
c5ff121b35 | ||
|
|
8cd1b9e46b | ||
|
|
5b40341984 | ||
|
|
628a8c6bf0 | ||
|
|
94b1c71a32 | ||
|
|
47edd82542 | ||
|
|
c1d747695d | ||
|
|
a4cbebeb29 | ||
|
|
9c525ad0f0 | ||
|
|
66a0ab7ad5 | ||
|
|
888eac4e54 | ||
|
|
f6e64c325b | ||
|
|
beb6fa8367 | ||
|
|
6c2ed22e3a | ||
|
|
4c260061c8 | ||
|
|
fb2904160e | ||
|
|
7696451ac9 | ||
|
|
54098eea56 | ||
|
|
79bbc4de95 | ||
|
|
b73a8adb4d | ||
|
|
9749e3e01c | ||
|
|
8c674cba2e | ||
|
|
87bdefce2b | ||
|
|
59fc95f1ea |
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: mob-sakai # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: mob_sakai # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: mob-sakai
|
||||
|
||||
---
|
||||
|
||||
NOTE: Your issue may already be reported! Please search on the [issue tracker](../) before creating one.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Environment (please complete the following information):**
|
||||
- Version [e.g. 1.0.0]
|
||||
- Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL]
|
||||
- Unity version: [e.g. 2018.2.8f1]
|
||||
- Build options: [e.g. IL2CPP, .Net 4.x, LWRP]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: mob-sakai
|
||||
|
||||
---
|
||||
|
||||
NOTE: Your issue may already be reported! Please search on the [issue tracker](../) before creating one.
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
16
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
16
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask a question about this project
|
||||
title: ''
|
||||
labels: question
|
||||
assignees: mob-sakai
|
||||
|
||||
---
|
||||
|
||||
NOTE: Your issue may already be reported! Please search on the [issue tracker](../) before creating one.
|
||||
|
||||
**Describe what help do you need**
|
||||
A description of the question.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the question here.
|
||||
24
.github/workflows/release.yml
vendored
Normal file
24
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- preview
|
||||
- main
|
||||
- v*.x
|
||||
tags-ignore:
|
||||
- "**"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: cycjimmy/semantic-release-action@v2
|
||||
with:
|
||||
extra_plugins: |
|
||||
@semantic-release/changelog
|
||||
@semantic-release/git
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
94
.github/workflows/test.yml
vendored
Normal file
94
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
# Secrets
|
||||
# UNITY_LICENSE:
|
||||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
tags:
|
||||
- "!*"
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
unity-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
unityVersion: [
|
||||
"2018.3.14f1",
|
||||
"2018.4.30f1",
|
||||
"2019.1.14f1",
|
||||
"2019.2.21f1",
|
||||
"2019.3.15f1",
|
||||
"2019.4.16f1",
|
||||
"2020.1.17f1",
|
||||
"2020.2.1f1",
|
||||
]
|
||||
|
||||
steps:
|
||||
# Checkout sandbox project
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: sandbox
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
|
||||
# Update package submodule
|
||||
- name: "Update package submodule"
|
||||
working-directory: Packages/dev
|
||||
run: git checkout ${{ github.sha }}
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.unityVersion }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
Library-${{ matrix.unityVersion }}-
|
||||
Library-
|
||||
|
||||
# Install codecoverage package
|
||||
- name: "Install codecoverage package"
|
||||
if: startsWith(matrix.unityVersion, '2019.4.')
|
||||
run: |
|
||||
npx openupm-cli add -f com.unity.testtools.codecoverage@0.4.0-preview
|
||||
|
||||
# Run tests
|
||||
- name: "Run tests"
|
||||
uses: game-ci/unity-test-runner@main
|
||||
with:
|
||||
unityVersion: ${{ matrix.unityVersion }}
|
||||
customParameters: -nographics -enableCodeCoverage -coverageOptions assemblyFilters:+Coffee.UIParticle.*Tests
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: TestResults-${{ matrix.unityVersion }}
|
||||
path: |
|
||||
artifacts/*.xml
|
||||
CodeCoverage/**/TestCoverageResults_*.xml
|
||||
|
||||
publish:
|
||||
needs: unity-test
|
||||
runs-on: ubuntu-latest
|
||||
if: always()
|
||||
steps:
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- uses: testspace-com/setup-testspace@v1
|
||||
with:
|
||||
domain: ${{github.repository_owner}}
|
||||
|
||||
- name: Push test results
|
||||
if: always()
|
||||
run: |
|
||||
testspace `find . -name '*.xml' | tr '\n' ' '`
|
||||
25
.releaserc.json
Normal file
25
.releaserc.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"branches": [
|
||||
"+([0-9])?(.{+([0-9]),x}).x",
|
||||
"master",
|
||||
"main",
|
||||
{
|
||||
"name": "preview",
|
||||
"prerelease": true
|
||||
}
|
||||
],
|
||||
"tagFormat": "${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
[
|
||||
"@semantic-release/npm",
|
||||
{
|
||||
"npmPublish": false
|
||||
}
|
||||
],
|
||||
"@semantic-release/git",
|
||||
"@semantic-release/github"
|
||||
]
|
||||
}
|
||||
680
CHANGELOG.md
680
CHANGELOG.md
@@ -1,20 +1,624 @@
|
||||
## [3.3.8](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.7...3.3.8) (2021-06-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* improve performance ([e352d15](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e352d153cef8c1efb2792e35010d7eed1e31a040))
|
||||
|
||||
## [3.3.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.6...3.3.7) (2021-06-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Refresh() will be called multiple times in the same frame, due to external assets ([0b9d80d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0b9d80da939580c72ca1471081d7a034edc985d4))
|
||||
|
||||
## [3.3.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.5...3.3.6) (2021-05-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* In rare cases, the generated camera (for baking) will not be deactivated ([12c748a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/12c748a8cd4adfd2dc5f085cec77050431f261a4))
|
||||
* remove from "Add Component" menu ([476c402](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/476c4027ff5f70fb9b4c026dd5fc59bf5a876227))
|
||||
|
||||
## [3.3.5](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.4...3.3.5) (2021-02-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix cached position for pre-warmed particles ([e3f42d7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e3f42d747a7fd973b5813cc72a9444943a6c3ad0))
|
||||
* ParticleSystem creates particles in wrong position during pre-warm ([b93e0e4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b93e0e4701c7011176eeec5c109dda7f4ea632e0)), closes [#147](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/147)
|
||||
|
||||
## [3.3.4](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.3...3.3.4) (2021-02-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Multiselecting sets all scales to the same value ([13223b2](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/13223b2d747609cf88b424ad590bda7f857b387d))
|
||||
* support sub emitter with 'PlayOnAwake' ([d5ce78a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/d5ce78ae5acf2740ba7fdc6cde9f197c4e165484))
|
||||
* The maximum material count is 8 ([3bb5241](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3bb52412751360409747192150188ae904f2c3d3))
|
||||
|
||||
## [3.3.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.2...3.3.3) (2021-02-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* particle trails draw in wrong transform ([17ce81e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/17ce81eb0eccb103c21fa553183df97429cf5c6f)), closes [#145](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/145)
|
||||
|
||||
## [3.3.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.1...3.3.2) (2021-02-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* _cachedPosition defaults to localPosition ([c0aa89b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c0aa89bd6f7847723a4702b6ca70fa202e8a8304)), closes [#121](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/121)
|
||||
* submeshes can't over 8 ([2a1f334](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2a1f3345bacdecf38e8890781a181a1392224e35)), closes [#122](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/122)
|
||||
|
||||
## [3.3.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.0...3.3.1) (2021-02-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ignore material check and transform check ([d11cd0a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/d11cd0a06d76a32b2a119387bddc34c703b9b497)), closes [#119](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/119)
|
||||
* the trail is incorrect in SimulationSpace.Local ([9313489](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/9313489552b30f2e2b0b42a641f5e0502995b03d))
|
||||
|
||||
# [3.3.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.2.0...3.3.0) (2020-11-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* the particles may disappear unintentionally ([2ec81da](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2ec81da04877d63593dd863133b6da149dcd79e6)), closes [#117](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/117)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* ignore rendering of particle systems that do not have a SharedMaterial and TrailMaterial ([08c4aba](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/08c4aba8ab9b5a041d4350a72dae62d25530afca)), closes [#118](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/118)
|
||||
* show/hide materials in inspector ([4b4aebf](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4b4aebff8cdaff9acc696a1094e170e65631135f))
|
||||
* shrink rendering by material ([46a7ddd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/46a7dddd11c3e030192cd998ae1a79441f5e5c14)), closes [#113](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/113)
|
||||
|
||||
# [3.2.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.1.1...3.2.0) (2020-11-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* compatibility with other IMaterialModifier ([08273cb](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/08273cb0c340ccb4f35120dc804c37d758da9ce1)), closes [#115](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/115)
|
||||
|
||||
## [3.1.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.1.0...3.1.1) (2020-11-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* error on build in Unity 2019.3.11-15 ([68669c7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/68669c739676f2354db4913a0e2296ab1715ee1f)), closes [#114](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/114)
|
||||
* null Reference when creating New Scene after Prefab was open in PrefabMode ([22bcecd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/22bcecd0abd6ad651fcf066e5c9efe9a43fd217a)), closes [#111](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/111)
|
||||
|
||||
# [3.1.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.0.1...3.1.0) (2020-10-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* compile error in 2018.2 ([82f81ef](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/82f81efd7e4ea06465e24f44f96d9726a1a60cc8))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* maskable option to ignore masking ([af5f7e9](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/af5f7e90b0570d5c7fcf045fd6b81036a060e493)), closes [#109](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/109)
|
||||
|
||||
## [3.0.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.0.0...3.0.1) (2020-10-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix the sorting algorithm ([7acbf22](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/7acbf22b4de7c3b5251fbb720bb5b575946622f6))
|
||||
* in rare cases, an IndexOutOfRangeException is thrown ([f7eac0a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f7eac0a34f07767dc04e035f97179cc30935284f))
|
||||
|
||||
# [3.0.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/2.3.0...3.0.0) (2020-10-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* IgnoreCanvasScaler may be enabled unintentionally ([d9f9244](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/d9f9244e49127bea405c3cb802b588c1eae00831))
|
||||
* an error happens during loading scene in editor ([ab9d9aa](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ab9d9aa7b3afcdbdda00004f7af3fd4827aaea54)), closes [#101](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/101)
|
||||
* not working as expected in world simulation space ([683fcb4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/683fcb4ecdf8bfa0994571f5d6c3dd2bc242ca2a)), closes [#98](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/98)
|
||||
* if the package was installed via openupm, an unintended directory 'Samples' was included ([1913de5](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1913de557743b9480f72c5378d13c284a4ac93f9))
|
||||
* animatable properties not working ([5b8b0bd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5b8b0bd28b251a7ea6e0cfa0c4b69bd7f9c4d953)), closes [#95](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/95)
|
||||
* combine Instances error ([878f812](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/878f81202ac29a8a20f174efa916da64eef99e8a)), closes [#91](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/91)
|
||||
* in rare cases, the particle size is incorrect with camera-space mode ([90593ac](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/90593ac021ce19d164927e44804354535db047bb)), closes [#93](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/93)
|
||||
* trails material uses sprite texture ([9e65ee7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/9e65ee7345e16b5124e94d26f5749999c648f677)), closes [#92](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/92)
|
||||
* ignore missing object on initialize ([8bd9b62](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8bd9b621b9efcd242c410405d066494a1d53f9a3))
|
||||
* not masked ([4ef5947](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4ef5947baa325002aecd1ccbdc75056a6567f14b))
|
||||
* in Unity 2018.2, PrefabStageUtility is not found ([0b6dcff](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0b6dcff5d6356db497532daa0a26804852e8de24))
|
||||
* removed UIParticle will be saved in prefab mode ([08e2d51](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/08e2d51c73a294d44974e7fba35e2477f04e6860))
|
||||
* hide camera for baking ([30b4703](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/30b4703e2a1746efc4b7db154354f80fd0593b98))
|
||||
* In ignore canvas scaler mode, Transform.localScale is zero ([cc71f2b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/cc71f2bdac1a61fd5e5fc85d0a69589e05a0f79d)), closes [#89](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/89)
|
||||
* In prefab mode, an error occurs ([a222f37](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a222f3710b530c7fc9fab10f25bd28d820ffebe2)), closes [#88](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/88)
|
||||
* the default value of IgnoreCanvasScaler is true ([966fae1](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/966fae1d22a98259ec5aff68b4603b7c21dfdfc9))
|
||||
* build fails ([ac080a4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ac080a44e4d872bc3f784fc222cc74aac7e795e9)), closes [#85](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/85)
|
||||
* if in the mask, rendering material will be destroyed ([0db40cf](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0db40cf160b2a5a27c83ef15d648b2771a47b51a))
|
||||
* baking camera settings for camera space ([436c5e4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/436c5e47f75c3e167dcd77c188847e9d7d6ea68d))
|
||||
* fix local simulation ([7add9de](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/7add9defb70be29ddbe536d854591c2e0d9e83fa))
|
||||
* fix camera for baking mesh ([6395a4f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/6395a4fa744a46551593185711d6545a94d8b456))
|
||||
* The type or namespace name 'U2D' does not exist in the namespace 'UnityEditor.Experimental' in Unity 2019.3 or later ([930199e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/930199e5e42920825b27d5bf3e2b2a4bda77fa14)), closes [#82](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/82)
|
||||
* texture sheet animation module Sprite mode not working ([30d1d5d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/30d1d5d3cc67234a8cd985e98f181aff2a8bd8ef)), closes [#79](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/79)
|
||||
* An exception in the OnSceneGUI caused the scale of the transformation to change unintentionally ([75413e0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/75413e0e2cff42a85b73b33e17e0bb6344ecc8f6))
|
||||
* read-only properties in the inspector ([f012b23](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f012b238d97aad3fdc3107b1f9a197de869c43e6))
|
||||
* Added CanvasRenderer as a required component ([a8950f6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a8950f65c817be04b0be222c9728c716fdd7c658))
|
||||
* If sprite is null, a null exception is thrown ([50c6e98](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/50c6e980ca37dda1bece5252162fa05ca3472ee8))
|
||||
* fix displayed version in readme ([c29bbdd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c29bbddf8ad9a251d5f472b77cf85b3d432bba71))
|
||||
* abnormal Mesh Bounds with Particle Trails ([518a749](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/518a7497105a114a0f6b1782df0c35ba0aecfab2)), closes [#61](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/61)
|
||||
* multiple UIParticleOverlayCamera in scene ([3f09395](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3f093958b3353463d6c5bd29ef3338203d4e41d7)), closes [#73](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/73)
|
||||
* add package keywords ([49d8f3f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/49d8f3fe4c76cf6bd2cd5b6134ee23134532da8e))
|
||||
* particles not visible if scale.z is 0 ([35718e0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/35718e099acbb04fdadf131c7e4d2e6c3f4a1756)), closes [#64](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/64)
|
||||
* remove unnecessary scripts ([0a43740](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0a4374099dc3151e7f1a3a24a6ce6c39a968e163))
|
||||
* workaround for [#70](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/70) ([4bbcc33](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4bbcc334abb7cd6db2897fad0bda219d5ea73530))
|
||||
* change the text in the inspector to make it more understandable. ([7ca0b6f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/7ca0b6fa34c1168ef103992e1c69b68631b3bc60)), closes [#66](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/66)
|
||||
* editor crashes when mesh is set to null when ParticleSystem.RenderMode=Mesh ([e5ebadd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e5ebadd84731716f82c63ac5ba3eb676720e3ad6)), closes [#69](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/69)
|
||||
* getting massive errors on editor ([ef82fa8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ef82fa82a69894e643f0d257f99eb9177785f697)), closes [#67](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/67)
|
||||
* heavy editor UI ([d3b470a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/d3b470a2be3a21add9e126b357e46bdfaa6f16c8))
|
||||
* remove a menu to add overlay camera ([f5d3b6e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f5d3b6edb5687c4d465992ef5c3c0d54f7b36d74))
|
||||
* rotating the particle rect may cause out of bounds ([3439842](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3439842119f334b50910c0a983e561944cc792a2)), closes [#55](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/55)
|
||||
* scale will be decrease on editor ([0c59846](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0c59846f11438b12caad04ae5d5b544a28883ea6))
|
||||
* UI darker than normal when change to linear color space ([db4d8a7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/db4d8a742ca36c8dd2de6936b9cf2912c72d4b9f)), closes [#57](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/57)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* cache modified material ([6b397f3](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/6b397f39b89f40c4aae9c9f56706b3bc68a376be)), closes [#94](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/94)
|
||||
* improve the material batching ([4be5666](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4be56669fb764bf61c0246a6e56d18640053b565))
|
||||
* un-limit on the number of mesh instances ([f133881](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f1338813ca85d305f334799b78154e03b0aff60c))
|
||||
* refresh children ParticleSystem with a gameObjects as root ([8bae1d0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8bae1d08cc6f00e2b8d6f336aad92233891da1e4))
|
||||
* add API to bind ParticleSystem object ([a77bbd3](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a77bbd3a9a65d5fd1198bd8e580982ca8e07fca8))
|
||||
* material batching ([8f703e6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8f703e6d2c0e8229ca14b25638dae5d91a5658c3))
|
||||
* support AnimatableProperty for multiple materials ([062d988](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/062d9887fb8b096250ec3b43d9aa82637940a8bb))
|
||||
* remove menu in inspector ([e7f8f51](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e7f8f512122a01423de415b55e3190d62bda146a))
|
||||
* add menu to create UIParticle ([2fa1843](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2fa18431f0c8c4aeadfdd1cb98eeeef5ac6970a0))
|
||||
* add play/pause/stop api ([f09a386](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f09a386bc59fbab8143f7f0b814c8684aea7f27c))
|
||||
* support for changing rendering orders ([745d4a5](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/745d4a598846b3e77d1071433079fdd5140921a8))
|
||||
* Support for child ParticleSystem rendering ([4ee90be](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4ee90be17c68bf405f81f432615a3eebaa022366))
|
||||
* UIParticle for trail is no longer needed ([466e43c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/466e43cf931d211907419f804a90776a0d9f4906))
|
||||
* add menu to create UIParticle ([14f1c78](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/14f1c782ff0f2b67d85d7c9ad0cf662da1dd1fc6))
|
||||
* Combine baked meshes to improve performance ([633d058](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/633d058756fde776a7e5192a0f023adf6eb0ca7b))
|
||||
* improve performance ([77c056a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/77c056ad5f2918efe457883f3b0361f952600568))
|
||||
* optimization for vertices transforms and adding node for trails ([e070e8d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e070e8d5ee205c25a1e3be5d3178821d4a8265d0)), closes [#75](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/75)
|
||||
* option to ignoring canvas scaling ([fe85fed](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fe85fed3c0ad2881578ff68722863d65dfa4db7a))
|
||||
* support 3d scaling ([42a84bc](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/42a84bc5e130aed3cf5e57dcd6a9d8dc94deb641))
|
||||
* support custom simulation space ([a83e647](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a83e64761c008e88ff328a2609118806e97f19cf)), closes [#78](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/78)
|
||||
* support for particle systems including trail only ([f389d39](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f389d39953c85b97482b12d1c8578ecaeddacd18)), closes [#61](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/61)
|
||||
* add support for SpriteAtlas ([b31e325](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b31e325bb1ef0856cb1ac4c4b0c4da0f1578b8ba))
|
||||
* add menu to import sample ([b8b1827](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b8b18273185769235101da01f5bbadbac188e387))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* The development branch name has been changed. Most cases are unaffected.
|
||||
* The child UIParticle is no longer needed.
|
||||
* The bake-task has changed significantly. It may look different from previous versions.
|
||||
* update develop environment to Unity 2018.3. Unity 2018.2 will continue to be supported.
|
||||
|
||||
# [3.0.0-preview.38](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.37...v3.0.0-preview.38) (2020-10-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* delete unused file in package ([2e69974](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2e699749a8f0f620505621a13a628aa87f192875))
|
||||
* material dirty on validate (on editor) ([fa34301](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fa3430130cdffa3f934e926645958ad9f19edc5d))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* display material properties in inspector ([313c1fc](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/313c1fc159429034f84b2e7c30424158c43b71e9)), closes [#104](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/104)
|
||||
* support 3D scaling ([a508c3b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a508c3bb86ad6694722868303385b20adc914134)), closes [#105](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/105)
|
||||
|
||||
# [3.0.0-preview.37](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.36...v3.0.0-preview.37) (2020-10-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix menus ([5fa12b5](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5fa12b5338a90764a3bf384dcd3911f2ab4eba61))
|
||||
|
||||
# [3.0.0-preview.36](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.35...v3.0.0-preview.36) (2020-09-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not bake particle system to mesh when the alpha is zero ([1775713](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1775713c2dbeef09ad3eb1f49b53cf44bf61d535)), closes [#102](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/102)
|
||||
* in Unity 2018.x, sample import failed on Windows ([f5861b0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f5861b0add1477987d6b9a3db26979fde50930ad))
|
||||
|
||||
# [3.0.0-preview.35](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.34...v3.0.0-preview.35) (2020-09-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* an error happens during loading scene in editor ([ab9d9aa](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ab9d9aa7b3afcdbdda00004f7af3fd4827aaea54)), closes [#101](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/101)
|
||||
|
||||
# [3.0.0-preview.34](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.33...v3.0.0-preview.34) (2020-09-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* not working as expected in world simulation space ([683fcb4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/683fcb4ecdf8bfa0994571f5d6c3dd2bc242ca2a)), closes [#98](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/98)
|
||||
|
||||
# [3.0.0-preview.33](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.32...v3.0.0-preview.33) (2020-09-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* if the package was installed via openupm, an unintended directory 'Samples' was included ([1913de5](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1913de557743b9480f72c5378d13c284a4ac93f9))
|
||||
|
||||
# [3.0.0-preview.32](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.31...v3.0.0-preview.32) (2020-09-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* animatable properties not working ([5b8b0bd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5b8b0bd28b251a7ea6e0cfa0c4b69bd7f9c4d953)), closes [#95](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/95)
|
||||
|
||||
# [3.0.0-preview.31](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.30...v3.0.0-preview.31) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* combine Instances error ([878f812](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/878f81202ac29a8a20f174efa916da64eef99e8a)), closes [#91](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/91)
|
||||
* in rare cases, the particle size is incorrect with camera-space mode ([90593ac](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/90593ac021ce19d164927e44804354535db047bb)), closes [#93](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/93)
|
||||
* trails material uses sprite texture ([9e65ee7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/9e65ee7345e16b5124e94d26f5749999c648f677)), closes [#92](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/92)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* refresh children ParticleSystem with a gameObjects as root ([8bae1d0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8bae1d08cc6f00e2b8d6f336aad92233891da1e4))
|
||||
|
||||
# [3.0.0-preview.30](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.29...v3.0.0-preview.30) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ignore missing object on initialize ([8bd9b62](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8bd9b621b9efcd242c410405d066494a1d53f9a3))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add API to bind ParticleSystem object ([a77bbd3](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a77bbd3a9a65d5fd1198bd8e580982ca8e07fca8))
|
||||
|
||||
# [3.0.0-preview.29](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.28...v3.0.0-preview.29) (2020-09-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* material batching ([8f703e6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8f703e6d2c0e8229ca14b25638dae5d91a5658c3))
|
||||
|
||||
# [3.0.0-preview.28](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.27...v3.0.0-preview.28) (2020-09-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support AnimatableProperty for multiple materials ([062d988](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/062d9887fb8b096250ec3b43d9aa82637940a8bb))
|
||||
|
||||
# [3.0.0-preview.27](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.26...v3.0.0-preview.27) (2020-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* not masked ([4ef5947](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4ef5947baa325002aecd1ccbdc75056a6567f14b))
|
||||
|
||||
# [3.0.0-preview.26](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.25...v3.0.0-preview.26) (2020-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* in Unity 2018.2, PrefabStageUtility is not found ([0b6dcff](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0b6dcff5d6356db497532daa0a26804852e8de24))
|
||||
|
||||
# [3.0.0-preview.25](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.24...v3.0.0-preview.25) (2020-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* removed UIParticle will be saved in prefab mode ([08e2d51](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/08e2d51c73a294d44974e7fba35e2477f04e6860))
|
||||
|
||||
# [3.0.0-preview.24](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.23...v3.0.0-preview.24) (2020-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* hide camera for baking ([30b4703](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/30b4703e2a1746efc4b7db154354f80fd0593b98))
|
||||
* In ignore canvas scaler mode, Transform.localScale is zero ([cc71f2b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/cc71f2bdac1a61fd5e5fc85d0a69589e05a0f79d)), closes [#89](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/89)
|
||||
* In prefab mode, an error occurs ([a222f37](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a222f3710b530c7fc9fab10f25bd28d820ffebe2)), closes [#88](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/88)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* remove menu in inspector ([e7f8f51](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e7f8f512122a01423de415b55e3190d62bda146a))
|
||||
|
||||
# [3.0.0-preview.23](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.22...v3.0.0-preview.23) (2020-08-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* the default value of IgnoreCanvasScaler is true ([966fae1](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/966fae1d22a98259ec5aff68b4603b7c21dfdfc9))
|
||||
|
||||
# [3.0.0-preview.22](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.21...v3.0.0-preview.22) (2020-08-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* build fails ([ac080a4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ac080a44e4d872bc3f784fc222cc74aac7e795e9)), closes [#85](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/85)
|
||||
|
||||
# [3.0.0-preview.21](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.20...v3.0.0-preview.21) (2020-08-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* if in the mask, rendering material will be destroyed ([0db40cf](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0db40cf160b2a5a27c83ef15d648b2771a47b51a))
|
||||
* support animatable material property (again) ([cf6ca80](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/cf6ca80d1273bcf49e18d805260afa8e36e94617))
|
||||
|
||||
# [3.0.0-preview.20](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.19...v3.0.0-preview.20) (2020-08-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* automatically update ([96a868b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/96a868b60a3f36d761d58b5082aa9d37666e63a3))
|
||||
|
||||
# [3.0.0-preview.19](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.18...v3.0.0-preview.19) (2020-08-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* baking camera settings for camera space ([436c5e4](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/436c5e47f75c3e167dcd77c188847e9d7d6ea68d))
|
||||
* fix local simulation ([7add9de](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/7add9defb70be29ddbe536d854591c2e0d9e83fa))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add menu to create UIParticle ([2fa1843](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2fa18431f0c8c4aeadfdd1cb98eeeef5ac6970a0))
|
||||
* add play/pause/stop api ([f09a386](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f09a386bc59fbab8143f7f0b814c8684aea7f27c))
|
||||
* support for changing rendering orders ([745d4a5](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/745d4a598846b3e77d1071433079fdd5140921a8))
|
||||
* Support for child ParticleSystem rendering ([4ee90be](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4ee90be17c68bf405f81f432615a3eebaa022366))
|
||||
* UIParticle for trail is no longer needed ([466e43c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/466e43cf931d211907419f804a90776a0d9f4906))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* The child UIParticle is no longer needed.
|
||||
|
||||
# [3.0.0-preview.18](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.17...v3.0.0-preview.18) (2020-08-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* AsmdefEx is no longer required ([50e749c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/50e749c183def5e97affa7e6ae9f3ceb69247825))
|
||||
* fix camera for baking mesh ([6395a4f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/6395a4fa744a46551593185711d6545a94d8b456))
|
||||
* support .Net Framework 3.5 (again) ([23fcb06](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/23fcb06bf9169ee160ccd8adb2cc3aab1a30186a))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 3.0.0 updater ([f99292b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f99292b9a15c9c085efacc0330d6b848669fadfa))
|
||||
* add menu to create UIParticle ([14f1c78](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/14f1c782ff0f2b67d85d7c9ad0cf662da1dd1fc6))
|
||||
* Combine baked meshes to improve performance ([633d058](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/633d058756fde776a7e5192a0f023adf6eb0ca7b))
|
||||
* improve performance ([77c056a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/77c056ad5f2918efe457883f3b0361f952600568))
|
||||
* optimization for vertices transforms and adding node for trails ([e070e8d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e070e8d5ee205c25a1e3be5d3178821d4a8265d0)), closes [#75](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/75)
|
||||
* option to ignoring canvas scaling ([fe85fed](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/fe85fed3c0ad2881578ff68722863d65dfa4db7a))
|
||||
* support 3d scaling ([42a84bc](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/42a84bc5e130aed3cf5e57dcd6a9d8dc94deb641))
|
||||
* support custom simulation space ([a83e647](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a83e64761c008e88ff328a2609118806e97f19cf)), closes [#78](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/78)
|
||||
* support for particle systems including trail only ([f389d39](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f389d39953c85b97482b12d1c8578ecaeddacd18)), closes [#61](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/61)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* The bake-task has changed significantly. It may look different from previous versions.
|
||||
|
||||
# [3.0.0-preview.17](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.16...v3.0.0-preview.17) (2020-08-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* The type or namespace name 'U2D' does not exist in the namespace 'UnityEditor.Experimental' in Unity 2019.3 or later ([930199e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/930199e5e42920825b27d5bf3e2b2a4bda77fa14)), closes [#82](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/82)
|
||||
|
||||
# [3.0.0-preview.16](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.15...v3.0.0-preview.16) (2020-08-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* texture sheet animation module Sprite mode not working ([30d1d5d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/30d1d5d3cc67234a8cd985e98f181aff2a8bd8ef)), closes [#79](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/79)
|
||||
|
||||
# [3.0.0-preview.15](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.14...v3.0.0-preview.15) (2020-08-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* An exception in the OnSceneGUI caused the scale of the transformation to change unintentionally ([75413e0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/75413e0e2cff42a85b73b33e17e0bb6344ecc8f6))
|
||||
|
||||
# [3.0.0-preview.14](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.13...v3.0.0-preview.14) (2020-08-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* read-only properties in the inspector ([f012b23](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f012b238d97aad3fdc3107b1f9a197de869c43e6))
|
||||
|
||||
# [3.0.0-preview.13](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.12...v3.0.0-preview.13) (2020-08-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Added CanvasRenderer as a required component ([a8950f6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a8950f65c817be04b0be222c9728c716fdd7c658))
|
||||
* inspector is broken in Unity 2020.1 ([26c5395](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/26c5395a45ff00e99e46ee4aae85c51df6c3641f))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update OSC to 1.0.0-preview.25 ([22e116e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/22e116e11d3b8cf13b941e9a02a0ffce24e3e99f))
|
||||
|
||||
# [3.0.0-preview.12](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.11...v3.0.0-preview.12) (2020-08-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Profiler.BeginSample -> Profiler.EndSample if a canvas is disabled or a camera doesn't found ([4a0a5d1](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4a0a5d13be68e38d5b2e225156740aed27c52d12))
|
||||
|
||||
# [3.0.0-preview.11](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.10...v3.0.0-preview.11) (2020-05-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* If sprite is null, a null exception is thrown ([50c6e98](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/50c6e980ca37dda1bece5252162fa05ca3472ee8))
|
||||
|
||||
# [3.0.0-preview.10](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.9...v3.0.0-preview.10) (2020-04-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add support for SpriteAtlas ([b31e325](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b31e325bb1ef0856cb1ac4c4b0c4da0f1578b8ba))
|
||||
|
||||
# [3.0.0-preview.9](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.8...v3.0.0-preview.9) (2020-03-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix displayed version in readme ([c29bbdd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c29bbddf8ad9a251d5f472b77cf85b3d432bba71))
|
||||
|
||||
# [3.0.0-preview.8](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.7...v3.0.0-preview.8) (2020-03-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* abnormal Mesh Bounds with Particle Trails ([518a749](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/518a7497105a114a0f6b1782df0c35ba0aecfab2)), closes [#61](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/61)
|
||||
* multiple UIParticleOverlayCamera in scene ([3f09395](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3f093958b3353463d6c5bd29ef3338203d4e41d7)), closes [#73](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/73)
|
||||
|
||||
# [3.0.0-preview.7](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.6...v3.0.0-preview.7) (2020-03-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add package keywords ([49d8f3f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/49d8f3fe4c76cf6bd2cd5b6134ee23134532da8e))
|
||||
* fix sample path ([57ee210](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/57ee21005e114fdf186b5db55ca2b77b7b7c441a))
|
||||
|
||||
# [3.0.0-preview.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.5...v3.0.0-preview.6) (2020-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* sample version ([ed18032](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ed18032be43397debbd538cae258c226ebeeb2e9))
|
||||
|
||||
# [3.0.0-preview.5](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.4...v3.0.0-preview.5) (2020-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* particles not visible if scale.z is 0 ([35718e0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/35718e099acbb04fdadf131c7e4d2e6c3f4a1756)), closes [#64](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/64)
|
||||
|
||||
# [3.0.0-preview.4](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.3...v3.0.0-preview.4) (2020-02-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* compile error in Unity 2019.1 or later ([28ca922](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/28ca922167afff3ef8341fa747968357d4487d1f)), closes [#70](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/70) [#71](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/71)
|
||||
|
||||
# [3.0.0-preview.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.2...v3.0.0-preview.3) (2020-02-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove unnecessary scripts ([0a43740](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0a4374099dc3151e7f1a3a24a6ce6c39a968e163))
|
||||
* workaround for [#70](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/70) ([4bbcc33](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/4bbcc334abb7cd6db2897fad0bda219d5ea73530))
|
||||
|
||||
# [3.0.0-preview.2](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.1...v3.0.0-preview.2) (2020-02-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* compile error ([e2c5c7b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e2c5c7b05d1307877e2f37555d4845932d542930))
|
||||
|
||||
# [3.0.0-preview.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v2.3.0...v3.0.0-preview.1) (2020-02-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* change the text in the inspector to make it more understandable. ([7ca0b6f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/7ca0b6fa34c1168ef103992e1c69b68631b3bc60)), closes [#66](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/66)
|
||||
* editor crashes when mesh is set to null when ParticleSystem.RenderMode=Mesh ([e5ebadd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e5ebadd84731716f82c63ac5ba3eb676720e3ad6)), closes [#69](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/69)
|
||||
* getting massive errors on editor ([ef82fa8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ef82fa82a69894e643f0d257f99eb9177785f697)), closes [#67](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/67)
|
||||
* heavy editor UI ([d3b470a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/d3b470a2be3a21add9e126b357e46bdfaa6f16c8))
|
||||
* remove a menu to add overlay camera ([f5d3b6e](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/f5d3b6edb5687c4d465992ef5c3c0d54f7b36d74))
|
||||
* rotating the particle rect may cause out of bounds ([3439842](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3439842119f334b50910c0a983e561944cc792a2)), closes [#55](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/55)
|
||||
* scale will be decrease on editor ([0c59846](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0c59846f11438b12caad04ae5d5b544a28883ea6))
|
||||
* UI darker than normal when change to linear color space ([db4d8a7](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/db4d8a742ca36c8dd2de6936b9cf2912c72d4b9f)), closes [#57](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/57)
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* update develop environment ([9fcf169](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/9fcf169cd3ced519611b2ede7f98ad4d678027c6))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add menu to import sample ([b8b1827](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b8b18273185769235101da01f5bbadbac188e387))
|
||||
* add samples test ([287b5cc](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/287b5cc832f2899796227520bda4d11ad8e4fae9))
|
||||
* **editor:** add osc package (portable mode) ([6c7f880](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/6c7f8804350112505949c5c296f9e0340877a3e8))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* update develop environment to Unity 2018.3.
|
||||
Unity 2018.2 will continue to be supported.
|
||||
|
||||
# Changelog
|
||||
|
||||
## [2.0.0](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/2.0.0) (2019-01-17)
|
||||
## [v2.3.0](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/v2.3.0) (2019-05-12)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v1.3.3...2.0.0)
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v2.2.1...v2.3.0)
|
||||
|
||||
**Install UIParticle with Unity Package Manager!**
|
||||
|
||||
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
|
||||
```js
|
||||
{
|
||||
"dependencies": {
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#2.0.0",
|
||||
...
|
||||
},
|
||||
}
|
||||
```
|
||||
World simulation bug due to transform movement have been fixed
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- World simulation bug due to transform movement [\#47](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/47)
|
||||
|
||||
## [v2.2.1](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/v2.2.1) (2019-02-26)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v2.2.0...v2.2.1)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- v2.2.0 has 2 warnings [\#44](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/44)
|
||||
- Disable ParticleSystemRenderer on reset [\#45](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/45)
|
||||
|
||||
## [v2.2.0](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/v2.2.0) (2019-02-23)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v2.1.1...v2.2.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- Display warning when material does not support Mask [\#43](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/43)
|
||||
- Support changing material property by AnimationClip [\#42](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/42)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- UV Animation is not work. [\#41](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/41)
|
||||
|
||||
## [v2.1.1](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/v2.1.1) (2019-02-15)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v2.1.0...v2.1.1)
|
||||
|
||||
## [v2.1.0](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/v2.1.0) (2019-02-07)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v2.0.0...v2.1.0)
|
||||
|
||||
World simulation bug is fixed.
|
||||

|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- When moving the transform in world simulation mode, particles don't behave as expected [\#37](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/37)
|
||||
|
||||
## [v2.0.0](https://github.com/mob-sakai/ParticleEffectForUGUI/tree/v2.0.0) (2019-01-17)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v1.3.3...v2.0.0)
|
||||
|
||||
**Install UIParticle with Unity Package Manager!**
|
||||
|
||||
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
|
||||
```js
|
||||
{
|
||||
"dependencies": {
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#2.0.0",
|
||||
...
|
||||
},
|
||||
}
|
||||
```
|
||||
To update the package, change `#2.0.0` to the target version.
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -55,7 +659,7 @@ To update the package, change `#2.0.0` to the target version.
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v1.2.1...v1.3.0)
|
||||
|
||||
With Gizmo you can control the scaled Shape.
|
||||
With Gizmo you can control the scaled Shape.
|
||||

|
||||
|
||||
**Fixed bugs:**
|
||||
@@ -75,18 +679,18 @@ With Gizmo you can control the scaled Shape.
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v1.1.0...v1.2.0)
|
||||
|
||||
New scaling system solves the particle effect scaling problem in most cases.
|
||||
* All ParticleSystem.ScalingModes are supported
|
||||
* All Canvas.RenderModes are supported
|
||||
* They look almost the same in all modes
|
||||
|
||||
New scaling system scales particle effect well even if you change the following parameters:
|
||||
* Camera.FieldOfView
|
||||
* CanvasScaler.MatchWidthOrHeight
|
||||
* Canvas.PlaneDistance
|
||||
|
||||

|
||||
|
||||
New scaling system solves the particle effect scaling problem in most cases.
|
||||
* All ParticleSystem.ScalingModes are supported
|
||||
* All Canvas.RenderModes are supported
|
||||
* They look almost the same in all modes
|
||||
|
||||
New scaling system scales particle effect well even if you change the following parameters:
|
||||
* Camera.FieldOfView
|
||||
* CanvasScaler.MatchWidthOrHeight
|
||||
* Canvas.PlaneDistance
|
||||
|
||||

|
||||
|
||||
**NOTE: If upgrading from v1.1.0, readjust the UIParticle.Scale property.**
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -103,11 +707,11 @@ New scaling system scales particle effect well even if you change the following
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v1.0.0...v1.1.0)
|
||||
|
||||
Easily to use, easily to set up.
|
||||
|
||||
* Adjust the Scale property to change the size of the effect.
|
||||

|
||||
* If your effect consists of multiple ParticleSystems, you can quickly set up UIParticles by clicking "Fix".
|
||||
Easily to use, easily to set up.
|
||||
|
||||
* Adjust the Scale property to change the size of the effect.
|
||||

|
||||
* If your effect consists of multiple ParticleSystems, you can quickly set up UIParticles by clicking "Fix".
|
||||

|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -123,9 +727,9 @@ Easily to use, easily to set up.
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v0.1.0...v1.0.0)
|
||||
|
||||
Let's use particle for your UI!
|
||||
UIParticle is use easy.
|
||||
The particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.
|
||||
Let's use particle for your UI!
|
||||
UIParticle is use easy.
|
||||
The particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.
|
||||

|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -137,9 +741,9 @@ The particle rendering is maskable and sortable, without Camera, RenderTexture o
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/6b89c14a5144e290e55d041bc0ad03756a113ae0...v0.1.0)
|
||||
|
||||

|
||||
|
||||
This plugin uses new APIs `MeshBake/MashTrailBake` (added with Unity 2018.2) to render particles by CanvasRenderer.
|
||||

|
||||
|
||||
This plugin uses new APIs `MeshBake/MashTrailBake` (added with Unity 2018.2) to render particles by CanvasRenderer.
|
||||
You can mask and sort particles for uGUI without Camera, RenderTexture, Canvas.
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -148,4 +752,4 @@ You can mask and sort particles for uGUI without Camera, RenderTexture, Canvas.
|
||||
|
||||
|
||||
|
||||
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
||||
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
||||
|
||||
84
CODE_OF_CONDUCT.md
Normal file
84
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sakai861104@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
||||
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
||||
7
CODE_OF_CONDUCT.md.meta
Normal file
7
CODE_OF_CONDUCT.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dced951d19ddf4b2c8f4a6053d82125a
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
CONTRIBUTING.md
Normal file
30
CONTRIBUTING.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Contributing
|
||||
|
||||
## How to Contribute
|
||||
|
||||
#### Code of Conduct
|
||||
|
||||
This repository has adopted the Contributor Covenant as it's
|
||||
Code of Conduct. It is expected that participants adhere to it.
|
||||
|
||||
#### Proposing a Change
|
||||
|
||||
If you are unsure about whether or not a change is desired,
|
||||
you can create an issue. This is useful because it creates
|
||||
the possibility for a discussion that's visible to everyone.
|
||||
|
||||
When fixing a bug it is fine to submit a pull request right away.
|
||||
|
||||
#### Sending a Pull Request
|
||||
|
||||
Steps to be performed to submit a pull request:
|
||||
|
||||
1. Fork the repository and create your branch from `develop`.
|
||||
2. If you have fixed a bug or added code that should be tested, add tests.
|
||||
3. Click `Window > Generals > Test Runner` to test
|
||||
4. Commit with a massage based on [Angular Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153).
|
||||
5. Fill out the description, link any related issues and submit your pull request.
|
||||
|
||||
#### License
|
||||
|
||||
By contributing to this repository, you agree that your contributions will be licensed under its MIT license.
|
||||
7
CONTRIBUTING.md.meta
Normal file
7
CONTRIBUTING.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbeb9a981ffa640d7a1e88a19b66efb5
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
241
README.md
241
README.md
@@ -1,27 +1,27 @@
|
||||
ParticleEffectForUGUI
|
||||
Particle Effect For UGUI (UI Particle)
|
||||
===
|
||||
|
||||
This plugin provide a component to render particle effect for uGUI in Unity 2018.2+.
|
||||
**:warning: NOTE: Do not use [the obsolete tags and branches](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/108) to reference the package. They will be removed in near future. :warning:**
|
||||
|
||||
This plugin provide a component to render particle effect for uGUI in Unity 2018.2 or later.
|
||||
The particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.
|
||||
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/releases)
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/releases)
|
||||

|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/blob/upm/LICENSE.md)
|
||||
[](http://makeapullrequest.com)
|
||||
[](https://twitter.com/intent/follow?screen_name=mob_sakai)
|
||||
[](https://openupm.com/packages/com.coffee.ui-particle/)
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/releases)
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/releases) [](https://github.com/mob-sakai/ParticleEffectForUGUI/blob/master/LICENSE.txt)
|
||||
[](http://makeapullrequest.com)
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
|
||||
<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/ParticleEffectForUGUI/releases) | [Usage](#usage) | [Development Note](#development-note) | [Change log](https://github.com/mob-sakai/ParticleEffectForUGUI/blob/upm/CHANGELOG.md) >>
|
||||
|
||||
### What's new? Please see [See changelog ](https://github.com/mob-sakai/ParticleEffectForUGUI/blob/upm/CHANGELOG.md)
|
||||
### Do you want to receive notifications for new releases? [Watch this repo ](https://github.com/mob-sakai/ParticleEffectForUGUI/subscription)
|
||||
### Support me on Patreon! [](https://www.patreon.com/join/2343451?)
|
||||
<< [Description](#Description) | [Demo](#demo) | [Installation](#installation) | [Usage](#usage) | [Development Note](#development-note) | [Change log](https://github.com/mob-sakai/ParticleEffectForUGUI/blob/upm/CHANGELOG.md) >>
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## Description
|
||||
|
||||

|
||||
@@ -34,7 +34,7 @@ Compares this "Baking mesh" approach with the conventional approach:
|
||||
|
||||
|Approach|Good|Bad|Screenshot|
|
||||
|-|-|-|-|
|
||||
|Baking mesh<br>**\(UIParticle\)**|Rendered as is.<br>Maskable.<br>Sortable.<br>Less objects.|**Requires Unity 2018.2+.**<br>Requires UI shaders to use Mask.|<img src="https://user-images.githubusercontent.com/12690315/41765089-0302b9a2-763e-11e8-88b3-b6ffa306bbb0.gif" width="500px">|
|
||||
|Baking mesh<br>**\(UIParticle\)**|Rendered as is.<br>Maskable.<br>Sortable.<br>Less objects.|**Requires Unity 2018.2 or later.**<br>Requires UI shaders to use Mask.|<img src="https://user-images.githubusercontent.com/12690315/41765089-0302b9a2-763e-11e8-88b3-b6ffa306bbb0.gif" width="500px">|
|
||||
|Do nothing|Rendered as is.|**Looks like a glitch.**<br>Not maskable.<br>Not sortable.|<img src="https://user-images.githubusercontent.com/12690315/41765090-0329828a-763e-11e8-8d8a-f1d269ea3bc7.gif" width="500px">|
|
||||
|Convert particle to UIVertex<br>[\(UIParticleSystem\)](https://forum.unity.com/threads/free-script-particle-systems-in-ui-screen-space-overlay.406862/)|Maskable.<br>Sortable.<br>Less objects.|**Adjustment is difficult.**<br>Requires UI shaders.<br>Difficult to adjust scale.<br>Force hierarchy scalling.<br>Simulation results are incorrect.<br>Trail, rotation of transform, time scaling are not supported.<br>Generate heavy GC every frame.|<img src="https://user-images.githubusercontent.com/12690315/41765088-02deb9c6-763e-11e8-98d0-9e0c1766ef39.gif" width="500px">|
|
||||
|Use Canvas to sort|Rendered as is.<br>Sortable.|**You must to manage sorting orders.**<br>Not maskable.<br>More batches.|<img src="https://user-images.githubusercontent.com/12690315/41765087-02b866ea-763e-11e8-8c33-081c9ad852f8.gif" width="500px">|
|
||||
@@ -43,103 +43,225 @@ Compares this "Baking mesh" approach with the conventional approach:
|
||||
|
||||
#### Features
|
||||
|
||||
* Sort particle effects with uGUI
|
||||
* Easy to use: the package is out-of-the-box
|
||||
* Sort particle effects with UI
|
||||
* No Camera, RenderTexture or Canvas are required
|
||||
* Masking with Mask or RectMask2D
|
||||
* Easy to use
|
||||
* Support Trail module
|
||||
* Change alpha with CanvasGroup
|
||||
* Scaling independent of Transform
|
||||
* No heavy allocation every frame
|
||||
* All ParticleSystem.ScalingModes and all Canvas.RenderModes are supported. They look almost the same in all modes.
|
||||

|
||||
* Scaled gizmo
|
||||

|
||||
* Support overlay, camera space and world space
|
||||
* Support changing material property with AnimationClip (AnimatableProperty)
|
||||

|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## Demo
|
||||
|
||||
[WebGL Demo](http://mob-sakai.github.io/ParticleEffectForUGUI)
|
||||
* [WebGL Demo](https://mob-sakai.github.io/Demos/ParticleEffectForUGUI)
|
||||
* [WebGL Demo (Cartoon FX & War FX)](https://mob-sakai.github.io/Demos/ParticleEffectForUGUI_CFX)
|
||||
* [Cartoon FX Free][CFX] & [War FX][WFX] (by [Jean Moreno (JMO)][JMO]) with UIParticle
|
||||
|
||||
[CFX]: https://assetstore.unity.com/packages/vfx/particles/cartoon-fx-free-109565
|
||||
[WFX]: https://assetstore.unity.com/packages/vfx/particles/war-fx-5669
|
||||
[JMO]: https://assetstore.unity.com/publishers/1669
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
## Install
|
||||
|
||||
#### Using UnityPackageManager (for Unity 2018.3+)
|
||||
## Installation
|
||||
|
||||
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
|
||||
```js
|
||||
{
|
||||
"dependencies": {
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#2.0.0",
|
||||
...
|
||||
},
|
||||
}
|
||||
### Requirement
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
### Using OpenUPM
|
||||
|
||||
This package is available on [OpenUPM](https://openupm.com).
|
||||
You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
|
||||
```
|
||||
openupm add com.coffee.ui-particle
|
||||
```
|
||||
To update the package, change `#2.0.0` to the target version.
|
||||
|
||||
#### Using .unitypackage file (for Unity 2018.2+)
|
||||
### Using Git
|
||||
|
||||
Download `*.unitypackage` from [Releases](https://github.com/mob-sakai/ParticleEffectForUGUI/releases) and import the package into your Unity project.
|
||||
Select `Assets > Import Package > Custom Package` from the menu.
|
||||

|
||||
Find the manifest.json file in the Packages folder of your project and add a line to `dependencies` field.
|
||||
|
||||
* `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git"`
|
||||
|
||||
To update the package, change suffix `#{version}` to the target version.
|
||||
|
||||
* `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#3.3.0",`
|
||||
|
||||
Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to install and update the package.
|
||||
|
||||
### For Unity 2018.2
|
||||
|
||||
Unity 2018.2 supports embedded packages.
|
||||
|
||||
1. Download a source code zip file from [Releases](https://github.com/mob-sakai/ParticleEffectForUGUI/releases) page
|
||||
2. Extract it
|
||||
3. Import it under `Packages` directory in your Unity project
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## How to play demo
|
||||
|
||||
* Import `UIParticle_Demo.unitypackage` into your project.
|
||||
* The demo unitypackage exists in `Assets/Assets/Coffee/UIExtensions/UIParticle` or `Packages/UI Particle`.
|
||||
* Open UIParticle_Demo scene and play it.
|
||||
### For Unity 2019.1 or later
|
||||
|
||||
1. Open `Package Manager` window
|
||||
2. Select `UI Particle` package in package list
|
||||
3. Click `Import Sample` button
|
||||

|
||||
4. The demo project is imported into `Assets/Samples/UI Particle/{version}/Demo`
|
||||
5. Open `UIParticle_Demo` scene and play it
|
||||
|
||||
### For Unity 2018.4 or earlier
|
||||
|
||||
1. Select `Assets/Samples/UI Particle Demo` from menu
|
||||
2. The demo project is imported into `Assets/Samples/UI Particle/{version}/Demo`
|
||||
3. Open `UIParticle_Demo` scene and play it
|
||||
|
||||
### About `Cartoon FX & War Fx Demo`
|
||||
|
||||
* It requires free assets ([Cartoon FX Free][CFX] & [War FX][WFX])
|
||||
* by [Jean Moreno (JMO)][JMO]
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## Usage
|
||||
|
||||
1. Add your particle effect to canvas.
|
||||
2. (Option) If you want to mask particles, set a UI shader such as "UI/UIAdditive" to material for ParticleSystem.
|
||||

|
||||
3. Add `UIParticle` component to root particle system of your effect from `Add Component` in inspector.
|
||||

|
||||
4. If your effect consists of multiple ParticleSystems, click "Fix".
|
||||

|
||||
5. Adjust the Scale property to change the size of the effect.
|
||||

|
||||
6. Enjoy!
|
||||
### UIParticle component
|
||||
|
||||
`UIParticle` controls the ParticleSystems that is attached to its own game objects and child game objects.
|
||||
|
||||

|
||||
|
||||
| Properties | Description |
|
||||
| -- | -- |
|
||||
| Maskable | Does this graphic allow masking. |
|
||||
| Ignore Canvas Scale | Ignore the scale of the root canvas.<br>This prevents it from displaying small even in hierarchy scaling mode of `ParticleSystem`. |
|
||||
| Scale | Scale the rendering.<br>When the `3D` toggle is enabled, 3D scale (x,y,z) is supported. |
|
||||
| Animatable Properties | If you want update material properties (e.g. `_MainTex_ST`, `_Color`) in AnimationClip, use this to mark the changes. |
|
||||
| Shrink By Material | Shrink rendering by material.<br>Performance will be improved, but in some cases the rendering is not correct. |
|
||||
| Rendering Order | The ParticleSystems to be rendered.<br>You can change the rendering order and the materials. |
|
||||
|
||||
NOTE: Press `Refresh` button to reconstruct rendering order based on children ParticleSystem's sorting order and z position.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Basically usage
|
||||
|
||||
1. Select `Game Object/UI/ParticleSystem` to create UIParticle with a ParticleSystem.
|
||||

|
||||
2. Adjust the ParticleSystem as you like.
|
||||

|
||||
|
||||
<br><br>
|
||||
|
||||
### With your ParticleSystem prefab
|
||||
|
||||
1. Select `Game Object/UI/ParticleSystem (Empty)` to create UIParticle.
|
||||

|
||||
2. Drag & drop your ParticleSystem prefab on UIParticle.
|
||||

|
||||
|
||||
<br><br>
|
||||
|
||||
### With `Mask` or `MaskRect2D` component
|
||||
|
||||
If you want to mask particles, set a stencil supported shader (such as `UI/UIAdditive`) to material for ParticleSystem.
|
||||
|
||||

|
||||
|
||||
|
||||
##### Requirement
|
||||
|
||||
* Unity 2018.2+ (Tested in Unity 2018.2.0f2)
|
||||
* No other SDK are required
|
||||
<br><br>
|
||||
|
||||
### Script usage
|
||||
|
||||
```cs
|
||||
// Instant ParticleSystem prefab with UIParticle on runtime.
|
||||
var go = GameObject.Instantiate(prefab);
|
||||
var uiParticle = go.AddComponent<UIParticle>();
|
||||
|
||||
// Play/Stop the controled ParticleSystems.
|
||||
uiParticle.Play();
|
||||
uiParticle.Stop();
|
||||
```
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## Development Note
|
||||
|
||||
### Animatable material property
|
||||
|
||||

|
||||
|
||||
Animation clips can change the material properties of the Renderer, such as ParticleSystemRenderer.
|
||||
It uses MaterialPropertyBlock so it does not create new material instances.
|
||||
Using material properties, you can change UV animation, scale and color etc.
|
||||
|
||||
Well, there is a component called CanvasRenderer.
|
||||
It is used by all Graphic components for UI (Text, Image, Raw Image, etc.) including UIParticle.
|
||||
However, It is **NOT** a Renderer.
|
||||
Therefore, in UIParticle, changing ParticleSystemRenderer's MaterialPropertyBlock by animation clip is ignored.
|
||||
|
||||
To prevent this, Use "Animatable Material Property".
|
||||
"Animatable Material Property" gets the necessary properties from ParticleSystemRenderer's MaterialPropertyBlock and sets them to the CanvasRenderer's material.
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## Contributing
|
||||
|
||||
### Issues
|
||||
|
||||
Issues are very valuable to this project.
|
||||
|
||||
- Ideas are a valuable source of contributions others can make
|
||||
- Problems show where this project is lacking
|
||||
- With a question you show where contributors can improve the user experience
|
||||
|
||||
### Pull Requests
|
||||
|
||||
Pull requests are, a great way to get your ideas into this repository.
|
||||
See [CONTRIBUTING.md](/../../blob/develop/CONTRIBUTING.md).
|
||||
|
||||
### Support
|
||||
|
||||
This is an open source project that I am developing in my spare time.
|
||||
If you like it, please support me.
|
||||
With your support, I can spend more time on development. :)
|
||||
|
||||
[](https://www.patreon.com/join/mob_sakai?)
|
||||
[](https://github.com/users/mob-sakai/sponsorship)
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
## License
|
||||
|
||||
* MIT
|
||||
* © UTJ/UCL
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
[mob-sakai](https://github.com/mob-sakai)
|
||||
[](https://twitter.com/intent/follow?screen_name=mob_sakai)
|
||||
[](https://www.patreon.com/join/2343451?)
|
||||
*  [mob-sakai](https://github.com/mob-sakai) [](https://twitter.com/intent/follow?screen_name=mob_sakai) 
|
||||
|
||||
|
||||
|
||||
@@ -148,5 +270,4 @@ Select `Assets > Import Package > Custom Package` from the menu.
|
||||
* GitHub page : https://github.com/mob-sakai/ParticleEffectForUGUI
|
||||
* Releases : https://github.com/mob-sakai/ParticleEffectForUGUI/releases
|
||||
* Issue tracker : https://github.com/mob-sakai/ParticleEffectForUGUI/issues
|
||||
* Current project : https://github.com/mob-sakai/ParticleEffectForUGUI/projects/1
|
||||
* Change log : https://github.com/mob-sakai/ParticleEffectForUGUI/blob/upm/CHANGELOG.md
|
||||
|
||||
8
Samples~/Cartoon FX & War FX Demo.meta
Normal file
8
Samples~/Cartoon FX & War FX Demo.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15e5409f0334e479e91e672ae14567d3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
5672
Samples~/Cartoon FX & War FX Demo/CFX Free Demo.unity
Normal file
5672
Samples~/Cartoon FX & War FX Demo/CFX Free Demo.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 064daa6b97d6846ec9334e98d642f081
|
||||
DefaultImporter:
|
||||
userData:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Coffee.CFX_Demo_With_UIParticle",
|
||||
"references": [
|
||||
"Coffee.UIParticle"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67b89587ad4f645e18aa12053a6cc9b7
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Coffee.UIExtensions;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public class CFX_Demo_With_UIParticle : MonoBehaviour
|
||||
{
|
||||
private UIParticle UiParticle;
|
||||
private Toggle spawnOnUI;
|
||||
private MonoBehaviour demo;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
UiParticle = GetComponentInChildren<UIParticle>();
|
||||
spawnOnUI = GetComponentInChildren<Toggle>();
|
||||
|
||||
demo = FindObjectOfType("CFX_Demo_New") as MonoBehaviour
|
||||
?? FindObjectOfType("WFX_Demo_New") as MonoBehaviour;
|
||||
|
||||
SetCanvasWidth(800);
|
||||
SetCanvasRenderOverlay(true);
|
||||
}
|
||||
|
||||
private Object FindObjectOfType(string typeName)
|
||||
{
|
||||
var type = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(x => x.GetTypes())
|
||||
.FirstOrDefault(x => x.Name == typeName);
|
||||
|
||||
return type == null ? null : FindObjectOfType(type);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (!spawnOnUI.isOn || !demo || !Input.GetMouseButtonDown(0)) return;
|
||||
|
||||
foreach (Transform child in UiParticle.transform)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
var particle = demo.GetType()
|
||||
.GetMethod("spawnParticle", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
.Invoke(demo, new object[0]) as GameObject;
|
||||
particle.transform.localScale = Vector3.one;
|
||||
UiParticle.SetParticleSystemInstance(particle);
|
||||
}
|
||||
|
||||
public void SetCanvasWidth(int width)
|
||||
{
|
||||
var scaler = GetComponentInParent<CanvasScaler>();
|
||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
|
||||
scaler.matchWidthOrHeight = 0;
|
||||
var resolution = scaler.referenceResolution;
|
||||
resolution.x = width;
|
||||
scaler.referenceResolution = resolution;
|
||||
}
|
||||
|
||||
public void SetCanvasRenderOverlay(bool enable)
|
||||
{
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
if (enable)
|
||||
{
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas.worldCamera = Camera.main;
|
||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
canvas.planeDistance = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadScene(string scene)
|
||||
{
|
||||
SceneManager.LoadScene(scene);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f69dfb25b53b14addbd71dbebdbaa132
|
||||
guid: a845100b226da488ab9037ad254b5860
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
4127
Samples~/Cartoon FX & War FX Demo/ParticleEffectForUGUI.prefab
Normal file
4127
Samples~/Cartoon FX & War FX Demo/ParticleEffectForUGUI.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3432d66abba624d4fad1150154199656
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
4
Samples~/Cartoon FX & War FX Demo/README.md
Normal file
4
Samples~/Cartoon FX & War FX Demo/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Cartoon FX & War FX Demo
|
||||
===
|
||||
|
||||
Please import assets "Cartoon FX Free" and/or "War FX Free" from Unity asset store.
|
||||
7
Samples~/Cartoon FX & War FX Demo/README.md.meta
Normal file
7
Samples~/Cartoon FX & War FX Demo/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f3407e8e4c3c4cf0a8717c25bc1c790
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
5661
Samples~/Cartoon FX & War FX Demo/WarFX Demo New.unity
Normal file
5661
Samples~/Cartoon FX & War FX Demo/WarFX Demo New.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a81f9cd434f104e1fad7ffa20eb7a3d4
|
||||
DefaultImporter:
|
||||
userData:
|
||||
8
Samples~/Demo.meta
Normal file
8
Samples~/Demo.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc0fe9e7fe61947fab1522ab29e2fc88
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Samples~/Demo/Light_Frame.png
Executable file
BIN
Samples~/Demo/Light_Frame.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
132
Samples~/Demo/Light_Frame.png.meta
Normal file
132
Samples~/Demo/Light_Frame.png.meta
Normal file
@@ -0,0 +1,132 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 077b84be6d052c34d933c79ef500be13
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: de8a1691f8aae4be18d66008040aa1a7
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
84
Samples~/Demo/UIAdditive.mat
Normal file
84
Samples~/Demo/UIAdditive.mat
Normal file
@@ -0,0 +1,84 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UIAdditive
|
||||
m_Shader: {fileID: 4800000, guid: ecfa8f5732b504ef98fba10aa18d0326, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 975570a90d56c477582e12d440dc9931, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
8
Samples~/Demo/UIAdditive.mat.meta
Normal file
8
Samples~/Demo/UIAdditive.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e44a36783dcfc43bdab399a1adcef4f5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
335
Samples~/Demo/UIParticleSystem_Demo.cs
Normal file
335
Samples~/Demo/UIParticleSystem_Demo.cs
Normal file
@@ -0,0 +1,335 @@
|
||||
/// Credit glennpow, Zarlang
|
||||
/// Sourced from - http://forum.unity3d.com/threads/free-script-particle-systems-in-ui-screen-space-overlay.406862/
|
||||
/// Updated by Zarlang with a more robust implementation, including TextureSheet annimation support
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions.Demos
|
||||
{
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(CanvasRenderer), typeof(ParticleSystem))]
|
||||
public class UIParticleSystem_Demo : MaskableGraphic
|
||||
{
|
||||
[Tooltip("Having this enabled run the system in LateUpdate rather than in Update making it faster but less precise (more clunky)")]
|
||||
public bool fixedTime = true;
|
||||
|
||||
private Transform _transform;
|
||||
private ParticleSystem pSystem;
|
||||
private ParticleSystem.Particle[] particles;
|
||||
private UIVertex[] _quad = new UIVertex[4];
|
||||
private Vector4 imageUV = Vector4.zero;
|
||||
private ParticleSystem.TextureSheetAnimationModule textureSheetAnimation;
|
||||
private int textureSheetAnimationFrames;
|
||||
private Vector2 textureSheetAnimationFrameSize;
|
||||
private ParticleSystemRenderer pRenderer;
|
||||
|
||||
private Material currentMaterial;
|
||||
|
||||
private Texture currentTexture;
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
private ParticleSystem.MainModule mainModule;
|
||||
#endif
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return currentTexture;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool Initialize()
|
||||
{
|
||||
// initialize members
|
||||
if (_transform == null)
|
||||
{
|
||||
_transform = transform;
|
||||
}
|
||||
if (pSystem == null)
|
||||
{
|
||||
pSystem = GetComponent<ParticleSystem>();
|
||||
|
||||
if (pSystem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
mainModule = pSystem.main;
|
||||
if (pSystem.main.maxParticles > 14000)
|
||||
{
|
||||
mainModule.maxParticles = 14000;
|
||||
}
|
||||
#else
|
||||
if (pSystem.maxParticles > 14000)
|
||||
pSystem.maxParticles = 14000;
|
||||
#endif
|
||||
|
||||
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
||||
if (pRenderer != null)
|
||||
pRenderer.enabled = false;
|
||||
|
||||
//Shader foundShader = Shader.Find("UI Extensions/Particles/Additive");
|
||||
//Material pMaterial = new Material(foundShader);
|
||||
|
||||
//if (material == null)
|
||||
//material = pMaterial;
|
||||
|
||||
currentMaterial = material;
|
||||
if (currentMaterial && currentMaterial.HasProperty("_MainTex"))
|
||||
{
|
||||
currentTexture = currentMaterial.mainTexture;
|
||||
if (currentTexture == null)
|
||||
currentTexture = Texture2D.whiteTexture;
|
||||
}
|
||||
material = currentMaterial;
|
||||
// automatically set scaling
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||
#else
|
||||
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||
#endif
|
||||
|
||||
particles = null;
|
||||
}
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
if (particles == null)
|
||||
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
||||
#else
|
||||
if (particles == null)
|
||||
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
||||
#endif
|
||||
|
||||
imageUV = new Vector4(0, 0, 1, 1);
|
||||
|
||||
// prepare texture sheet animation
|
||||
textureSheetAnimation = pSystem.textureSheetAnimation;
|
||||
textureSheetAnimationFrames = 0;
|
||||
textureSheetAnimationFrameSize = Vector2.zero;
|
||||
if (textureSheetAnimation.enabled)
|
||||
{
|
||||
textureSheetAnimationFrames = textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY;
|
||||
textureSheetAnimationFrameSize = new Vector2(1f / textureSheetAnimation.numTilesX, 1f / textureSheetAnimation.numTilesY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
if (!Initialize())
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
if (!Initialize())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// prepare vertices
|
||||
vh.Clear();
|
||||
|
||||
if (!gameObject.activeInHierarchy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 temp = Vector2.zero;
|
||||
Vector2 corner1 = Vector2.zero;
|
||||
Vector2 corner2 = Vector2.zero;
|
||||
// iterate through current particles
|
||||
int count = pSystem.GetParticles(particles);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
ParticleSystem.Particle particle = particles[i];
|
||||
|
||||
// get particle properties
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
Vector2 position = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
||||
#else
|
||||
Vector2 position = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
||||
#endif
|
||||
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
||||
float rotation90 = rotation + Mathf.PI / 2;
|
||||
Color32 color = particle.GetCurrentColor(pSystem);
|
||||
float size = particle.GetCurrentSize(pSystem) * 0.5f;
|
||||
|
||||
// apply scale
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
|
||||
position /= canvas.scaleFactor;
|
||||
#else
|
||||
if (pSystem.scalingMode == ParticleSystemScalingMode.Shape)
|
||||
position /= canvas.scaleFactor;
|
||||
#endif
|
||||
|
||||
// apply texture sheet animation
|
||||
Vector4 particleUV = imageUV;
|
||||
if (textureSheetAnimation.enabled)
|
||||
{
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime);
|
||||
|
||||
if (textureSheetAnimation.frameOverTime.curveMin != null)
|
||||
{
|
||||
frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
|
||||
}
|
||||
else if (textureSheetAnimation.frameOverTime.curve != null)
|
||||
{
|
||||
frameProgress = textureSheetAnimation.frameOverTime.curve.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
|
||||
}
|
||||
else if (textureSheetAnimation.frameOverTime.constant > 0)
|
||||
{
|
||||
frameProgress = textureSheetAnimation.frameOverTime.constant - (particle.remainingLifetime / particle.startLifetime);
|
||||
}
|
||||
#else
|
||||
float frameProgress = 1 - (particle.lifetime / particle.startLifetime);
|
||||
#endif
|
||||
|
||||
frameProgress = Mathf.Repeat(frameProgress * textureSheetAnimation.cycleCount, 1);
|
||||
int frame = 0;
|
||||
|
||||
switch (textureSheetAnimation.animation)
|
||||
{
|
||||
|
||||
case ParticleSystemAnimationType.WholeSheet:
|
||||
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimationFrames);
|
||||
break;
|
||||
|
||||
case ParticleSystemAnimationType.SingleRow:
|
||||
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
|
||||
|
||||
int row = textureSheetAnimation.rowIndex;
|
||||
// if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex?
|
||||
// row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed);
|
||||
// }
|
||||
frame += row * textureSheetAnimation.numTilesX;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
frame %= textureSheetAnimationFrames;
|
||||
|
||||
particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x;
|
||||
particleUV.y = Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.y;
|
||||
particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
|
||||
particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
|
||||
}
|
||||
|
||||
temp.x = particleUV.x;
|
||||
temp.y = particleUV.y;
|
||||
|
||||
_quad[0] = UIVertex.simpleVert;
|
||||
_quad[0].color = color;
|
||||
_quad[0].uv0 = temp;
|
||||
|
||||
temp.x = particleUV.x;
|
||||
temp.y = particleUV.w;
|
||||
_quad[1] = UIVertex.simpleVert;
|
||||
_quad[1].color = color;
|
||||
_quad[1].uv0 = temp;
|
||||
|
||||
temp.x = particleUV.z;
|
||||
temp.y = particleUV.w;
|
||||
_quad[2] = UIVertex.simpleVert;
|
||||
_quad[2].color = color;
|
||||
_quad[2].uv0 = temp;
|
||||
|
||||
temp.x = particleUV.z;
|
||||
temp.y = particleUV.y;
|
||||
_quad[3] = UIVertex.simpleVert;
|
||||
_quad[3].color = color;
|
||||
_quad[3].uv0 = temp;
|
||||
|
||||
if (rotation == 0)
|
||||
{
|
||||
// no rotation
|
||||
corner1.x = position.x - size;
|
||||
corner1.y = position.y - size;
|
||||
corner2.x = position.x + size;
|
||||
corner2.y = position.y + size;
|
||||
|
||||
temp.x = corner1.x;
|
||||
temp.y = corner1.y;
|
||||
_quad[0].position = temp;
|
||||
temp.x = corner1.x;
|
||||
temp.y = corner2.y;
|
||||
_quad[1].position = temp;
|
||||
temp.x = corner2.x;
|
||||
temp.y = corner2.y;
|
||||
_quad[2].position = temp;
|
||||
temp.x = corner2.x;
|
||||
temp.y = corner1.y;
|
||||
_quad[3].position = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
// apply rotation
|
||||
Vector2 right = new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size;
|
||||
Vector2 up = new Vector2(Mathf.Cos(rotation90), Mathf.Sin(rotation90)) * size;
|
||||
|
||||
_quad[0].position = position - right - up;
|
||||
_quad[1].position = position - right + up;
|
||||
_quad[2].position = position + right + up;
|
||||
_quad[3].position = position + right - up;
|
||||
}
|
||||
|
||||
vh.AddUIVertexQuad(_quad);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!fixedTime && Application.isPlaying)
|
||||
{
|
||||
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
||||
SetAllDirty();
|
||||
|
||||
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
||||
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
|
||||
{
|
||||
pSystem = null;
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
SetAllDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fixedTime)
|
||||
{
|
||||
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
||||
SetAllDirty();
|
||||
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
||||
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
|
||||
{
|
||||
pSystem = null;
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (material == currentMaterial)
|
||||
return;
|
||||
pSystem = null;
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
11
Samples~/Demo/UIParticleSystem_Demo.cs.meta
Normal file
11
Samples~/Demo/UIParticleSystem_Demo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5f85388e938d9e4599afc6d9441ed57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Samples~/Demo/UIParticle_Demo.asmdef
Normal file
10
Samples~/Demo/UIParticle_Demo.asmdef
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "Coffee.UIParticle.Demo",
|
||||
"references": [
|
||||
"Coffee.UIParticle"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false
|
||||
}
|
||||
7
Samples~/Demo/UIParticle_Demo.asmdef.meta
Normal file
7
Samples~/Demo/UIParticle_Demo.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2546af409064ee88073040a7454090
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Samples~/Demo/UIParticle_Demo.cs
Normal file
111
Samples~/Demo/UIParticle_Demo.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Coffee.UIExtensions.Demo
|
||||
{
|
||||
public class UIParticle_Demo : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ParticleSystem [] m_ParticleSystems = new ParticleSystem [0];
|
||||
[SerializeField] List<Transform> m_ScalingByTransforms = new List<Transform> ();
|
||||
[SerializeField] List<UIParticle> m_ScalingByUIParticles = new List<UIParticle> ();
|
||||
|
||||
public void SetTimeScale (float scale)
|
||||
{
|
||||
Time.timeScale = scale;
|
||||
}
|
||||
|
||||
public void EnableTrailRibbon (bool ribbonMode)
|
||||
{
|
||||
foreach (var p in m_ParticleSystems)
|
||||
{
|
||||
var trails = p.trails;
|
||||
trails.mode = ribbonMode ? ParticleSystemTrailMode.Ribbon : ParticleSystemTrailMode.PerParticle;
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableSprite (bool enabled)
|
||||
{
|
||||
foreach (var p in m_ParticleSystems)
|
||||
{
|
||||
var tex = p.textureSheetAnimation;
|
||||
tex.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableMask (bool enabled)
|
||||
{
|
||||
foreach (var m in FindObjectsOfType<Mask> ())
|
||||
{
|
||||
m.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableMask2D (bool enabled)
|
||||
{
|
||||
foreach (var m in FindObjectsOfType<RectMask2D> ())
|
||||
{
|
||||
m.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetScale (float scale)
|
||||
{
|
||||
m_ScalingByTransforms.ForEach (x => x.localScale = Vector3.one * (10 * scale));
|
||||
m_ScalingByUIParticles.ForEach (x => x.scale = scale);
|
||||
}
|
||||
|
||||
public void SetUIParticleScale (float scale)
|
||||
{
|
||||
foreach (var uip in FindObjectsOfType<UIParticle> ())
|
||||
{
|
||||
uip.scale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadScene (string name)
|
||||
{
|
||||
SceneManager.LoadScene (name);
|
||||
}
|
||||
|
||||
public void PlayAllParticleEffect ()
|
||||
{
|
||||
foreach (var animator in FindObjectsOfType<Animator> ())
|
||||
{
|
||||
animator.Play ("Play");
|
||||
}
|
||||
|
||||
foreach (var particle in FindObjectsOfType<ParticleSystem> ())
|
||||
{
|
||||
particle.Play ();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWorldSpase (bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
GetComponent<Canvas> ().renderMode = RenderMode.ScreenSpaceCamera;
|
||||
GetComponent<Canvas> ().renderMode = RenderMode.WorldSpace;
|
||||
transform.rotation = Quaternion.Euler (new Vector3 (0, 6, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetScreenSpase (bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
GetComponent<Canvas> ().renderMode = RenderMode.ScreenSpaceCamera;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOverlay (bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
GetComponent<Canvas> ().renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Samples~/Demo/UIParticle_Demo.cs.meta
Normal file
11
Samples~/Demo/UIParticle_Demo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eba3b7ce20b7f470a891c84def6be7e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Samples~/Demo/UIParticle_Demo.renderTexture
Normal file
33
Samples~/Demo/UIParticle_Demo.renderTexture
Normal file
@@ -0,0 +1,33 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!84 &8400000
|
||||
RenderTexture:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UIParticle_Demo
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_ForcedFallbackFormat: 4
|
||||
m_DownscaleFallback: 0
|
||||
m_Width: 256
|
||||
m_Height: 256
|
||||
m_AntiAliasing: 1
|
||||
m_DepthFormat: 0
|
||||
m_ColorFormat: 0
|
||||
m_MipMap: 0
|
||||
m_GenerateMips: 1
|
||||
m_SRGB: 0
|
||||
m_UseDynamicScale: 0
|
||||
m_BindMS: 0
|
||||
m_TextureSettings:
|
||||
serializedVersion: 2
|
||||
m_FilterMode: 1
|
||||
m_Aniso: 0
|
||||
m_MipBias: 0
|
||||
m_WrapU: 1
|
||||
m_WrapV: 1
|
||||
m_WrapW: 1
|
||||
m_Dimension: 2
|
||||
m_VolumeDepth: 1
|
||||
8
Samples~/Demo/UIParticle_Demo.renderTexture.meta
Normal file
8
Samples~/Demo/UIParticle_Demo.renderTexture.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab4cc8f5f51c14175af41c4daa68cbf5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 8400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
5622
Samples~/Demo/UIParticle_Demo.unity
Normal file
5622
Samples~/Demo/UIParticle_Demo.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a4ce081d093247179eacb67ef049408
|
||||
guid: 1fc4d0f41c2bd3745b97b439cca95c22
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
8920
Samples~/Demo/UIParticle_Demo_Effect_Root.prefab
Normal file
8920
Samples~/Demo/UIParticle_Demo_Effect_Root.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Samples~/Demo/UIParticle_Demo_Effect_Root.prefab.meta
Normal file
7
Samples~/Demo/UIParticle_Demo_Effect_Root.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d682dd3e44264ff69bd02590123ea73
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
85
Samples~/Demo/UIParticle_Demo_Fire.mat
Normal file
85
Samples~/Demo/UIParticle_Demo_Fire.mat
Normal file
@@ -0,0 +1,85 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UIParticle_Demo_Fire
|
||||
m_Shader: {fileID: 4800000, guid: ecfa8f5732b504ef98fba10aa18d0326, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: df33a97a787f8a64a82b59ee073e7cd7, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _InvFade: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _TintColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
8
Samples~/Demo/UIParticle_Demo_Fire.mat.meta
Normal file
8
Samples~/Demo/UIParticle_Demo_Fire.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57cef6c0f7570214991e091275f08894
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Samples~/Demo/UIParticle_Demo_Fire_Atlas.png
Normal file
BIN
Samples~/Demo/UIParticle_Demo_Fire_Atlas.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 585 KiB |
121
Samples~/Demo/UIParticle_Demo_Fire_Atlas.png.meta
Normal file
121
Samples~/Demo/UIParticle_Demo_Fire_Atlas.png.meta
Normal file
@@ -0,0 +1,121 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df33a97a787f8a64a82b59ee073e7cd7
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 2
|
||||
aniso: 16
|
||||
mipBias: -100
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 4096
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 2
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 4096
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 2
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: Android
|
||||
maxTextureSize: 4096
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 2
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- serializedVersion: 2
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 4096
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 2
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
85
Samples~/Demo/UIParticle_Demo_Spread.mat
Normal file
85
Samples~/Demo/UIParticle_Demo_Spread.mat
Normal file
@@ -0,0 +1,85 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UIParticle_Demo_Spread
|
||||
m_Shader: {fileID: 4800000, guid: ecfa8f5732b504ef98fba10aa18d0326, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _InvFade: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _TintColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
8
Samples~/Demo/UIParticle_Demo_Spread.mat.meta
Normal file
8
Samples~/Demo/UIParticle_Demo_Spread.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 356b9d0e2cad849c3b53c7e9e1680cb7
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Samples~/Demo/Unity-chan.png
Normal file
BIN
Samples~/Demo/Unity-chan.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
88
Samples~/Demo/Unity-chan.png.meta
Normal file
88
Samples~/Demo/Unity-chan.png.meta
Normal file
@@ -0,0 +1,88 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 925f66fdcc9764b579413b7408c718f2
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: 16
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 84e9fd7e25cf94cfc81bd77bc4f1d566
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Scripts/AnimatableProperty.cs
Normal file
65
Scripts/AnimatableProperty.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
[System.Serializable]
|
||||
public class AnimatableProperty : ISerializationCallbackReceiver
|
||||
{
|
||||
public enum ShaderPropertyType
|
||||
{
|
||||
Color,
|
||||
Vector,
|
||||
Float,
|
||||
Range,
|
||||
Texture,
|
||||
}
|
||||
|
||||
[SerializeField] string m_Name = "";
|
||||
[SerializeField] ShaderPropertyType m_Type = ShaderPropertyType.Vector;
|
||||
public int id { get; private set; }
|
||||
|
||||
public ShaderPropertyType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
}
|
||||
|
||||
public void UpdateMaterialProperties(Material material, MaterialPropertyBlock mpb)
|
||||
{
|
||||
if (!material.HasProperty(id)) return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ShaderPropertyType.Color:
|
||||
var color = mpb.GetColor(id);
|
||||
if (color != default(Color))
|
||||
material.SetColor(id, color);
|
||||
break;
|
||||
case ShaderPropertyType.Vector:
|
||||
var vector = mpb.GetVector(id);
|
||||
if (vector != default(Vector4))
|
||||
material.SetVector(id, vector);
|
||||
break;
|
||||
case ShaderPropertyType.Float:
|
||||
case ShaderPropertyType.Range:
|
||||
var value = mpb.GetFloat(id);
|
||||
if (value != default(float))
|
||||
material.SetFloat(id, value);
|
||||
break;
|
||||
case ShaderPropertyType.Texture:
|
||||
var tex = mpb.GetTexture(id);
|
||||
if (tex != default(Texture))
|
||||
material.SetTexture(id, tex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
id = Shader.PropertyToID(m_Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/AnimatableProperty.cs.meta
Normal file
11
Scripts/AnimatableProperty.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c434da72184404a0cbdf8e7a529a41bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Scripts/BakingCamera.cs
Normal file
97
Scripts/BakingCamera.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
internal class BakingCamera : MonoBehaviour
|
||||
{
|
||||
static BakingCamera s_Instance;
|
||||
private static readonly Vector3 s_OrthoPosition = new Vector3(0, 0, -1000);
|
||||
private static readonly Quaternion s_OrthoRotation = Quaternion.identity;
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
static BakingCamera s_InstanceForPrefab;
|
||||
|
||||
private static BakingCamera InstanceForPrefab
|
||||
{
|
||||
get
|
||||
{
|
||||
// If current scene is prefab mode, create OverlayCamera for editor.
|
||||
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
|
||||
if (prefabStage == null || !prefabStage.scene.isLoaded) return null;
|
||||
if (s_InstanceForPrefab) return s_InstanceForPrefab;
|
||||
|
||||
s_InstanceForPrefab = Create();
|
||||
s_InstanceForPrefab.name += " (For Prefab Stage)";
|
||||
UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(s_InstanceForPrefab.gameObject, prefabStage.scene);
|
||||
|
||||
return s_InstanceForPrefab;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private static BakingCamera Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
var inst = InstanceForPrefab;
|
||||
if (inst) return inst;
|
||||
#endif
|
||||
// Find instance in scene, or create new one.
|
||||
return s_Instance
|
||||
? s_Instance
|
||||
: (s_Instance = Create());
|
||||
}
|
||||
}
|
||||
|
||||
private Camera _camera;
|
||||
|
||||
private static BakingCamera Create()
|
||||
{
|
||||
var gameObject = new GameObject(typeof(BakingCamera).Name);
|
||||
|
||||
// This camera object is just for internal use
|
||||
gameObject.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
var inst = gameObject.AddComponent<BakingCamera>();
|
||||
inst._camera = gameObject.AddComponent<Camera>();
|
||||
inst._camera.enabled = false;
|
||||
inst._camera.orthographic = true;
|
||||
|
||||
// Turn camera off because particle mesh baker will use only camera matrix
|
||||
gameObject.SetActive(false);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (this == s_Instance)
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
public static Camera GetCamera(Canvas canvas)
|
||||
{
|
||||
if (!canvas) return Camera.main;
|
||||
|
||||
canvas = canvas.rootCanvas;
|
||||
// Adjust camera orthographic size to canvas size
|
||||
// for canvas-based coordinates of particles' size and speed.
|
||||
var size = ((RectTransform) canvas.transform).rect.size;
|
||||
Instance._camera.orthographicSize = Mathf.Max(size.x, size.y) * canvas.scaleFactor;
|
||||
|
||||
var camera = canvas.worldCamera;
|
||||
var transform = Instance.transform;
|
||||
var rotation = canvas.renderMode != RenderMode.ScreenSpaceOverlay && camera
|
||||
? camera.transform.rotation
|
||||
: s_OrthoRotation;
|
||||
|
||||
transform.SetPositionAndRotation(s_OrthoPosition, rotation);
|
||||
Instance._camera.orthographic = true;
|
||||
Instance._camera.farClipPlane = 2000f;
|
||||
|
||||
return Instance._camera;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/BakingCamera.cs.meta
Normal file
11
Scripts/BakingCamera.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 999f0ea10cb5f48ed89190a0ca83dd53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Scripts/CombineInstanceEx.cs
Normal file
63
Scripts/CombineInstanceEx.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal class CombineInstanceEx
|
||||
{
|
||||
private int count;
|
||||
public long hash = -1;
|
||||
public int index = -1;
|
||||
private readonly List<CombineInstance> combineInstances = new List<CombineInstance>(32);
|
||||
public Mesh mesh;
|
||||
public Matrix4x4 transform;
|
||||
|
||||
public void Combine()
|
||||
{
|
||||
switch (count)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
mesh = combineInstances[0].mesh;
|
||||
transform = combineInstances[0].transform;
|
||||
return;
|
||||
default:
|
||||
{
|
||||
var cis = CombineInstanceArrayPool.Get(combineInstances);
|
||||
mesh = MeshPool.Rent();
|
||||
mesh.CombineMeshes(cis, true, true);
|
||||
transform = Matrix4x4.identity;
|
||||
cis.Clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
for (var i = 0; i < combineInstances.Count; i++)
|
||||
{
|
||||
var inst = combineInstances[i];
|
||||
MeshPool.Return(inst.mesh);
|
||||
inst.mesh = null;
|
||||
combineInstances[i] = inst;
|
||||
}
|
||||
|
||||
combineInstances.Clear();
|
||||
|
||||
MeshPool.Return(mesh);
|
||||
mesh = null;
|
||||
|
||||
count = 0;
|
||||
hash = -1;
|
||||
index = -1;
|
||||
}
|
||||
|
||||
public void Push(Mesh mesh, Matrix4x4 transform)
|
||||
{
|
||||
combineInstances.Add(new CombineInstance {mesh = mesh, transform = transform});
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/CombineInstanceEx.cs.meta
Normal file
11
Scripts/CombineInstanceEx.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0328b9fb8360e4f8e8a842f87d330466
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
123
Scripts/Editor/AnimatedPropertiesEditor.cs
Normal file
123
Scripts/Editor/AnimatedPropertiesEditor.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ShaderPropertyType = Coffee.UIExtensions.AnimatableProperty.ShaderPropertyType;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
internal class AnimatedPropertiesEditor
|
||||
{
|
||||
private static readonly List<string> s_ActiveNames = new List<string>();
|
||||
private static readonly System.Text.StringBuilder s_Sb = new System.Text.StringBuilder();
|
||||
private static readonly HashSet<string> s_Names = new HashSet<string>();
|
||||
|
||||
private string _name;
|
||||
private ShaderPropertyType _type;
|
||||
|
||||
static string CollectActiveNames(SerializedProperty sp, List<string> result)
|
||||
{
|
||||
result.Clear();
|
||||
for (var i = 0; i < sp.arraySize; i++)
|
||||
{
|
||||
var spName = sp.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name");
|
||||
if (spName == null) continue;
|
||||
|
||||
result.Add(spName.stringValue);
|
||||
}
|
||||
|
||||
s_Sb.Length = 0;
|
||||
if (result.Count == 0)
|
||||
{
|
||||
s_Sb.Append("Nothing");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Aggregate(s_Sb, (a, b) => s_Sb.AppendFormat("{0}, ", b));
|
||||
s_Sb.Length -= 2;
|
||||
}
|
||||
|
||||
return s_Sb.ToString();
|
||||
}
|
||||
|
||||
public static void DrawAnimatableProperties(SerializedProperty sp, Material[] mats)
|
||||
{
|
||||
bool isClicked;
|
||||
using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(false)))
|
||||
{
|
||||
var r = EditorGUI.PrefixLabel(EditorGUILayout.GetControlRect(true), new GUIContent(sp.displayName, sp.tooltip));
|
||||
var text = sp.hasMultipleDifferentValues ? "-" : CollectActiveNames(sp, s_ActiveNames);
|
||||
isClicked = GUI.Button(r, text, EditorStyles.popup);
|
||||
}
|
||||
|
||||
if (!isClicked) return;
|
||||
|
||||
var gm = new GenericMenu();
|
||||
gm.AddItem(new GUIContent("Nothing"), s_ActiveNames.Count == 0, () =>
|
||||
{
|
||||
sp.ClearArray();
|
||||
sp.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
|
||||
|
||||
if (!sp.hasMultipleDifferentValues)
|
||||
{
|
||||
for (var i = 0; i < sp.arraySize; i++)
|
||||
{
|
||||
var p = sp.GetArrayElementAtIndex(i);
|
||||
var name = p.FindPropertyRelative("m_Name").stringValue;
|
||||
var type = (ShaderPropertyType) p.FindPropertyRelative("m_Type").intValue;
|
||||
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = name, _type = type}, false);
|
||||
}
|
||||
}
|
||||
|
||||
s_Names.Clear();
|
||||
foreach (var mat in mats)
|
||||
{
|
||||
if (!mat || !mat.shader) continue;
|
||||
|
||||
for (var i = 0; i < ShaderUtil.GetPropertyCount(mat.shader); i++)
|
||||
{
|
||||
var pName = ShaderUtil.GetPropertyName(mat.shader, i);
|
||||
var type = (ShaderPropertyType) ShaderUtil.GetPropertyType(mat.shader, i);
|
||||
var name = string.Format("{0} ({1})", pName, type);
|
||||
if (s_Names.Contains(name)) continue;
|
||||
s_Names.Add(name);
|
||||
|
||||
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName, _type = type}, true);
|
||||
|
||||
if (type != ShaderPropertyType.Texture) continue;
|
||||
|
||||
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_ST", _type = ShaderPropertyType.Vector}, true);
|
||||
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_HDR", _type = ShaderPropertyType.Vector}, true);
|
||||
AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_TexelSize", _type = ShaderPropertyType.Vector}, true);
|
||||
}
|
||||
}
|
||||
|
||||
gm.ShowAsContext();
|
||||
}
|
||||
|
||||
private static void AddMenu(GenericMenu menu, SerializedProperty sp, AnimatedPropertiesEditor property, bool add)
|
||||
{
|
||||
if (add && s_ActiveNames.Contains(property._name)) return;
|
||||
|
||||
menu.AddItem(new GUIContent(string.Format("{0} ({1})", property._name, property._type)), s_ActiveNames.Contains(property._name), () =>
|
||||
{
|
||||
var index = s_ActiveNames.IndexOf(property._name);
|
||||
if (0 <= index)
|
||||
{
|
||||
sp.DeleteArrayElementAtIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp.InsertArrayElementAtIndex(sp.arraySize);
|
||||
var p = sp.GetArrayElementAtIndex(sp.arraySize - 1);
|
||||
p.FindPropertyRelative("m_Name").stringValue = property._name;
|
||||
p.FindPropertyRelative("m_Type").intValue = (int) property._type;
|
||||
}
|
||||
|
||||
sp.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/AnimatedPropertiesEditor.cs.meta
Normal file
11
Scripts/Editor/AnimatedPropertiesEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60feb9aeb134e4ec789c0e63b017997f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,5 +8,9 @@
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": []
|
||||
}
|
||||
79
Scripts/Editor/ImportSampleMenu.cs
Normal file
79
Scripts/Editor/ImportSampleMenu.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
internal static class ImportSampleMenu_UIParticle
|
||||
{
|
||||
private const string k_DisplayName = "UI Particle";
|
||||
private const string k_JsonGuid = "823dc693d087a4b559c7e1547274cc7d";
|
||||
|
||||
[MenuItem("Assets/Samples/" + k_DisplayName + "/Demo")]
|
||||
private static void ImportSample()
|
||||
{
|
||||
ImportSample(k_JsonGuid, "Demo");
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Samples/" + k_DisplayName + "/Cartoon FX & War FX Demo")]
|
||||
private static void ImportSample_CFX()
|
||||
{
|
||||
ImportSample(k_JsonGuid, "Cartoon FX & War FX Demo");
|
||||
}
|
||||
|
||||
private static void ImportSample(string jsonGuid, string sampleName)
|
||||
{
|
||||
var jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid);
|
||||
var packageRoot = Path.GetDirectoryName(jsonPath).Replace('\\', '/');
|
||||
var json = File.ReadAllText(jsonPath);
|
||||
var version = Regex.Match(json, "\"version\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value;
|
||||
var src = string.Format("{0}/Samples~/{1}", packageRoot, sampleName);
|
||||
var dst = string.Format("Assets/Samples/{0}/{1}/{2}", k_DisplayName, version, sampleName);
|
||||
var previousPath = GetPreviousSamplePath(k_DisplayName, sampleName);
|
||||
|
||||
// Remove the previous sample directory.
|
||||
if (!string.IsNullOrEmpty(previousPath))
|
||||
{
|
||||
var msg = "A different version of the sample is already imported at\n\n"
|
||||
+ previousPath
|
||||
+ "\n\nIt will be deleted when you update. Are you sure you want to continue?";
|
||||
if (!EditorUtility.DisplayDialog("Sample Importer", msg, "OK", "Cancel"))
|
||||
return;
|
||||
|
||||
FileUtil.DeleteFileOrDirectory(previousPath);
|
||||
|
||||
var metaFile = previousPath + ".meta";
|
||||
if (File.Exists(metaFile))
|
||||
FileUtil.DeleteFileOrDirectory(metaFile);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(dst))
|
||||
FileUtil.DeleteFileOrDirectory(dst);
|
||||
|
||||
var dstDir = Path.GetDirectoryName(dst);
|
||||
if (!Directory.Exists(dstDir))
|
||||
Directory.CreateDirectory(dstDir);
|
||||
|
||||
if (Directory.Exists(src))
|
||||
FileUtil.CopyFileOrDirectory(src, dst);
|
||||
else
|
||||
throw new DirectoryNotFoundException(src);
|
||||
|
||||
AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
|
||||
}
|
||||
|
||||
private static string GetPreviousSamplePath(string displayName, string sampleName)
|
||||
{
|
||||
var sampleRoot = string.Format("Assets/Samples/{0}", displayName);
|
||||
var sampleRootInfo = new DirectoryInfo(sampleRoot);
|
||||
if (!sampleRootInfo.Exists) return null;
|
||||
|
||||
return sampleRootInfo.GetDirectories()
|
||||
.Select(versionDir => Path.Combine(versionDir.ToString(), sampleName))
|
||||
.FirstOrDefault(Directory.Exists);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Scripts/Editor/ImportSampleMenu.cs.meta
Normal file
11
Scripts/Editor/ImportSampleMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07047cbd3c4af489fbd41f4303a26fe2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,533 +1,281 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
[CustomEditor (typeof (UIParticle))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIParticleEditor : GraphicEditor
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
static readonly GUIContent s_ContentParticleMaterial = new GUIContent ("Particle Material", "The material for rendering particles");
|
||||
static readonly GUIContent s_ContentTrailMaterial = new GUIContent ("Trail Material", "The material for rendering particle trails");
|
||||
static readonly List<ParticleSystem> s_ParticleSystems = new List<ParticleSystem> ();
|
||||
static readonly Matrix4x4 s_ArcHandleOffsetMatrix = Matrix4x4.TRS (Vector3.zero, Quaternion.AngleAxis (90f, Vector3.right) * Quaternion.AngleAxis (90f, Vector3.up), Vector3.one);
|
||||
static readonly Dictionary<string, MethodInfo> s_InternalMethods = new Dictionary<string, MethodInfo> ();
|
||||
static readonly Color s_GizmoColor = new Color (1f, 0.7f, 0.7f, 0.9f);
|
||||
static readonly Color s_ShapeGizmoThicknessTint = new Color (0.7f, 0.7f, 0.7f, 1.0f);
|
||||
static Material s_Material;
|
||||
[CustomEditor(typeof(UIParticle))]
|
||||
[CanEditMultipleObjects]
|
||||
internal class UIParticleEditor : GraphicEditor
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
private static readonly GUIContent s_ContentRenderingOrder = new GUIContent("Rendering Order");
|
||||
private static readonly GUIContent s_ContentRefresh = new GUIContent("Refresh");
|
||||
private static readonly GUIContent s_ContentFix = new GUIContent("Fix");
|
||||
private static readonly GUIContent s_ContentMaterial = new GUIContent("Material");
|
||||
private static readonly GUIContent s_ContentTrailMaterial = new GUIContent("Trail Material");
|
||||
private static readonly GUIContent s_Content3D = new GUIContent("3D");
|
||||
private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
|
||||
|
||||
private SerializedProperty _spMaskable;
|
||||
private SerializedProperty _spScale;
|
||||
private SerializedProperty _spIgnoreCanvasScaler;
|
||||
private SerializedProperty _spAnimatableProperties;
|
||||
private SerializedProperty _spShrinkByMaterial;
|
||||
|
||||
private ReorderableList _ro;
|
||||
private bool _xyzMode;
|
||||
private bool _showMaterials;
|
||||
|
||||
private static readonly List<string> s_MaskablePropertyNames = new List<string>
|
||||
{
|
||||
"_Stencil",
|
||||
"_StencilComp",
|
||||
"_StencilOp",
|
||||
"_StencilWriteMask",
|
||||
"_StencilReadMask",
|
||||
"_ColorMask",
|
||||
};
|
||||
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable ()
|
||||
{
|
||||
base.OnEnable ();
|
||||
_spParticleSystem = serializedObject.FindProperty ("m_ParticleSystem");
|
||||
_spTrailParticle = serializedObject.FindProperty ("m_TrailParticle");
|
||||
_spScale = serializedObject.FindProperty ("m_Scale");
|
||||
_spIgnoreParent = serializedObject.FindProperty ("m_IgnoreParent");
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
_spMaskable = serializedObject.FindProperty("m_Maskable");
|
||||
_spScale = serializedObject.FindProperty("m_Scale3D");
|
||||
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
|
||||
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
|
||||
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
|
||||
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
|
||||
|
||||
if (!s_Material)
|
||||
{
|
||||
s_Material = Call<Material> (typeof (Material), "GetDefaultMaterial");
|
||||
}
|
||||
var sp = serializedObject.FindProperty("m_Particles");
|
||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
|
||||
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
|
||||
_ro.elementHeightCallback = _ => _showMaterials
|
||||
? 3 * (EditorGUIUtility.singleLineHeight + 2)
|
||||
: EditorGUIUtility.singleLineHeight + 2;
|
||||
_ro.drawElementCallback = (rect, index, active, focused) =>
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
|
||||
rect.y += 1;
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
var p = sp.GetArrayElementAtIndex(index);
|
||||
EditorGUI.ObjectField(rect, p, GUIContent.none);
|
||||
if (!_showMaterials) return;
|
||||
|
||||
_particles = targets.Cast<UIParticle> ().ToArray ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI ()
|
||||
{
|
||||
serializedObject.Update ();
|
||||
|
||||
EditorGUILayout.PropertyField (_spParticleSystem);
|
||||
EditorGUI.indentLevel++;
|
||||
var ps = _spParticleSystem.objectReferenceValue as ParticleSystem;
|
||||
if (ps)
|
||||
{
|
||||
var pr = ps.GetComponent<ParticleSystemRenderer> ();
|
||||
var sp = new SerializedObject (pr).FindProperty ("m_Materials");
|
||||
|
||||
EditorGUILayout.PropertyField (sp.GetArrayElementAtIndex (0), s_ContentParticleMaterial);
|
||||
EditorGUILayout.PropertyField (sp.GetArrayElementAtIndex (1), s_ContentTrailMaterial);
|
||||
sp.serializedObject.ApplyModifiedProperties ();
|
||||
|
||||
if (!Application.isPlaying && pr.enabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox ("ParticleSystemRenderer will be disable on playing.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUI.BeginDisabledGroup (true);
|
||||
EditorGUILayout.PropertyField (_spTrailParticle);
|
||||
EditorGUI.EndDisabledGroup ();
|
||||
|
||||
var current = target as UIParticle;
|
||||
|
||||
EditorGUILayout.PropertyField (_spIgnoreParent);
|
||||
|
||||
EditorGUI.BeginDisabledGroup (!current.isRoot);
|
||||
EditorGUILayout.PropertyField (_spScale);
|
||||
EditorGUI.EndDisabledGroup ();
|
||||
|
||||
current.GetComponentsInChildren<ParticleSystem> (true, s_ParticleSystems);
|
||||
if (s_ParticleSystems.Any (x => x.GetComponent<UIParticle> () == null))
|
||||
{
|
||||
GUILayout.BeginHorizontal ();
|
||||
EditorGUILayout.HelpBox ("There are child ParticleSystems that does not have a UIParticle component.\nAdd UIParticle component to them.", MessageType.Warning);
|
||||
GUILayout.BeginVertical ();
|
||||
if (GUILayout.Button ("Fix"))
|
||||
{
|
||||
foreach (var p in s_ParticleSystems.Where (x => !x.GetComponent<UIParticle> ()))
|
||||
{
|
||||
p.gameObject.AddComponent<UIParticle> ();
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical ();
|
||||
GUILayout.EndHorizontal ();
|
||||
}
|
||||
s_ParticleSystems.Clear ();
|
||||
|
||||
serializedObject.ApplyModifiedProperties ();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spParticleSystem;
|
||||
SerializedProperty _spTrailParticle;
|
||||
SerializedProperty _spScale;
|
||||
SerializedProperty _spIgnoreParent;
|
||||
UIParticle [] _particles;
|
||||
ArcHandle _arcHandle = new ArcHandle ();
|
||||
BoxBoundsHandle _boxBoundsHandle = new BoxBoundsHandle ();
|
||||
SphereBoundsHandle _sphereBoundsHandle = new SphereBoundsHandle ();
|
||||
Mesh _spriteMesh;
|
||||
|
||||
static T Call<T> (Type type, string method, params object [] args)
|
||||
{
|
||||
MethodInfo mi;
|
||||
if (!s_InternalMethods.TryGetValue (method, out mi))
|
||||
{
|
||||
mi = type.GetMethod (method, BindingFlags.Static | BindingFlags.NonPublic);
|
||||
s_InternalMethods.Add (method, mi);
|
||||
}
|
||||
return (T)mi.Invoke (null, args);
|
||||
}
|
||||
|
||||
void OnSceneGUI ()
|
||||
{
|
||||
Color origCol = Handles.color;
|
||||
Handles.color = s_GizmoColor;
|
||||
|
||||
Matrix4x4 orgMatrix = Handles.matrix;
|
||||
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
|
||||
foreach (UIParticle uip in _particles)
|
||||
{
|
||||
ParticleSystem ps = uip.cachedParticleSystem;
|
||||
if (!ps || !uip.canvas)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var shapeModule = ps.shape;
|
||||
var mainModule = ps.main;
|
||||
|
||||
ParticleSystemShapeType type = shapeModule.shapeType;
|
||||
|
||||
Matrix4x4 transformMatrix = new Matrix4x4 ();
|
||||
if (mainModule.scalingMode == ParticleSystemScalingMode.Local)
|
||||
{
|
||||
transformMatrix.SetTRS (ps.transform.position, ps.transform.rotation, ps.transform.localScale);
|
||||
}
|
||||
else if (mainModule.scalingMode == ParticleSystemScalingMode.Hierarchy)
|
||||
{
|
||||
transformMatrix = ps.transform.localToWorldMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
transformMatrix.SetTRS (ps.transform.position, ps.transform.rotation, ps.transform.lossyScale);
|
||||
}
|
||||
|
||||
bool isBox = (type == ParticleSystemShapeType.Box || type == ParticleSystemShapeType.BoxShell || type == ParticleSystemShapeType.BoxEdge || type == ParticleSystemShapeType.Rectangle);
|
||||
|
||||
Vector3 emitterScale = isBox ? Vector3.one : shapeModule.scale;
|
||||
Matrix4x4 emitterMatrix = Matrix4x4.TRS (shapeModule.position, Quaternion.Euler (shapeModule.rotation), emitterScale);
|
||||
transformMatrix *= emitterMatrix;
|
||||
Handles.matrix = transformMatrix;
|
||||
|
||||
if(uip.canvas.renderMode == RenderMode.ScreenSpaceOverlay || ps.main.scalingMode == ParticleSystemScalingMode.Hierarchy)
|
||||
{
|
||||
Handles.matrix = Handles.matrix * Matrix4x4.Scale (Vector3.one * uip.scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
Handles.matrix = Handles.matrix * Matrix4x4.Scale (uip.canvas.rootCanvas.transform.localScale * uip.scale);
|
||||
}
|
||||
|
||||
if (type == ParticleSystemShapeType.Sphere)
|
||||
{
|
||||
// Thickness
|
||||
Handles.color *= s_ShapeGizmoThicknessTint;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
//float radiusThickness = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), false, shapeModule.arc);
|
||||
float radiusThickness = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), false);
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Sphere Thickness Handle Change");
|
||||
shapeModule.radiusThickness = 1.0f - (radiusThickness / shapeModule.radius);
|
||||
}
|
||||
|
||||
// Sphere
|
||||
Handles.color = s_GizmoColor;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
//float radius = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, false, shapeModule.arc);
|
||||
float radius = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, false);
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Sphere Handle Change");
|
||||
shapeModule.radius = radius;
|
||||
}
|
||||
|
||||
// Texture
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3.one * shapeModule.radius * 2.0f);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_SphereMesh, false, s_SphereTextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Circle)
|
||||
{
|
||||
// Thickness
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
|
||||
_arcHandle.angle = shapeModule.arc;
|
||||
_arcHandle.radius = shapeModule.radius * (1.0f - shapeModule.radiusThickness);
|
||||
_arcHandle.SetColorWithRadiusHandle (s_ShapeGizmoThicknessTint, 0f);
|
||||
_arcHandle.angleHandleColor = Color.clear;
|
||||
|
||||
using (new Handles.DrawingScope (Handles.matrix * s_ArcHandleOffsetMatrix))
|
||||
_arcHandle.DrawHandle ();
|
||||
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Circle Thickness Handle Change");
|
||||
shapeModule.radiusThickness = 1.0f - (_arcHandle.radius / shapeModule.radius);
|
||||
}
|
||||
|
||||
// Circle
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
|
||||
_arcHandle.radius = shapeModule.radius;
|
||||
_arcHandle.SetColorWithRadiusHandle (Color.white, 0f);
|
||||
|
||||
using (new Handles.DrawingScope (Handles.matrix * s_ArcHandleOffsetMatrix))
|
||||
_arcHandle.DrawHandle ();
|
||||
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Circle Handle Change");
|
||||
shapeModule.radius = _arcHandle.radius;
|
||||
shapeModule.arc = _arcHandle.angle;
|
||||
}
|
||||
|
||||
// Texture
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (Vector3.zero, Quaternion.Euler (90.0f, 0.0f, 180.0f), Vector3.one * shapeModule.radius * 2.0f);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_CircleMesh, true, s_TextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Hemisphere)
|
||||
{
|
||||
// Thickness
|
||||
Handles.color *= s_ShapeGizmoThicknessTint;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
//float radiusThickness = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true, shapeModule.arc);
|
||||
//float radiusThickness = Call<float> (typeof (Handles), "DoSimpleRadiusHandle", Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true, shapeModule.arc);
|
||||
float radiusThickness = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius * (1.0f - shapeModule.radiusThickness), true);
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Hemisphere Thickness Handle Change");
|
||||
shapeModule.radiusThickness = 1.0f - (radiusThickness / shapeModule.radius);
|
||||
}
|
||||
|
||||
// Hemisphere
|
||||
Handles.color = s_GizmoColor;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
//float radius = Handles.DoSimpleRadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, true, shapeModule.arc);
|
||||
float radius = Handles.RadiusHandle (Quaternion.identity, Vector3.zero, shapeModule.radius, true);
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Hemisphere Handle Change");
|
||||
shapeModule.radius = radius;
|
||||
}
|
||||
|
||||
// Texture
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3.one * shapeModule.radius * 2.0f);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_HemisphereMesh, false, s_SphereTextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Cone)
|
||||
{
|
||||
// Thickness
|
||||
Handles.color *= s_ShapeGizmoThicknessTint;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
float angleThickness = Mathf.Lerp (shapeModule.angle, 0.0f, shapeModule.radiusThickness);
|
||||
Vector3 radiusThicknessAngleRange = new Vector3 (shapeModule.radius * (1.0f - shapeModule.radiusThickness), angleThickness, mainModule.startSpeedMultiplier);
|
||||
//radiusThicknessAngleRange = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusThicknessAngleRange, Handles.ConeHandles.Radius);
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
radiusThicknessAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleRange, 1);
|
||||
#else
|
||||
radiusThicknessAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleRange);
|
||||
rect.x += 15;
|
||||
rect.width -= 15;
|
||||
var ps = p.objectReferenceValue as ParticleSystem;
|
||||
var materials = ps
|
||||
? new SerializedObject(ps.GetComponent<ParticleSystemRenderer>()).FindProperty("m_Materials")
|
||||
: null;
|
||||
rect.y += rect.height + 1;
|
||||
MaterialField(rect, s_ContentMaterial, materials, 0);
|
||||
rect.y += rect.height + 1;
|
||||
MaterialField(rect, s_ContentTrailMaterial, materials, 1);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
if (materials != null)
|
||||
{
|
||||
materials.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
};
|
||||
_ro.drawHeaderCallback += rect =>
|
||||
{
|
||||
#if !UNITY_2019_3_OR_NEWER
|
||||
rect.y -= 1;
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Cone Thickness Handle Change");
|
||||
shapeModule.radiusThickness = 1.0f - (radiusThicknessAngleRange.x / shapeModule.radius);
|
||||
}
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder);
|
||||
|
||||
var content = EditorGUIUtility.IconContent(_showMaterials ? "VisibilityOn" : "VisibilityOff");
|
||||
_showMaterials = GUI.Toggle(new Rect(rect.width - 55, rect.y, 24, 20), _showMaterials, content, EditorStyles.label);
|
||||
|
||||
if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton))
|
||||
{
|
||||
foreach (UIParticle t in targets)
|
||||
{
|
||||
t.RefreshParticles();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void MaterialField(Rect rect, GUIContent label, SerializedProperty sp, int index)
|
||||
{
|
||||
if (sp == null || sp.arraySize <= index)
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUI.ObjectField(rect, label, null, typeof(Material), true);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(rect, sp.GetArrayElementAtIndex(index), label);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var current = target as UIParticle;
|
||||
if (current == null) return;
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
// Maskable
|
||||
EditorGUILayout.PropertyField(_spMaskable);
|
||||
|
||||
// IgnoreCanvasScaler
|
||||
using (var ccs = new EditorGUI.ChangeCheckScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spIgnoreCanvasScaler);
|
||||
if (ccs.changed)
|
||||
{
|
||||
foreach (UIParticle p in targets)
|
||||
{
|
||||
p.ignoreCanvasScaler = _spIgnoreCanvasScaler.boolValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scale
|
||||
_xyzMode = DrawFloatOrVector3Field(_spScale, _xyzMode);
|
||||
|
||||
// AnimatableProperties
|
||||
var mats = current.particles
|
||||
.Where(x => x)
|
||||
.Select(x => x.GetComponent<ParticleSystemRenderer>().sharedMaterial)
|
||||
.Where(x => x)
|
||||
.ToArray();
|
||||
|
||||
// Animated properties
|
||||
EditorGUI.BeginChangeCheck();
|
||||
AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, mats);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (UIParticle t in targets)
|
||||
t.SetMaterialDirty();
|
||||
}
|
||||
|
||||
// ShrinkByMaterial
|
||||
EditorGUILayout.PropertyField(_spShrinkByMaterial);
|
||||
|
||||
// Target ParticleSystems.
|
||||
_ro.DoLayoutList();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
// Does the shader support UI masks?
|
||||
if (current.maskable && current.GetComponentInParent<Mask>())
|
||||
{
|
||||
foreach (var mat in current.materials)
|
||||
{
|
||||
if (!mat || !mat.shader) continue;
|
||||
var shader = mat.shader;
|
||||
foreach (var propName in s_MaskablePropertyNames)
|
||||
{
|
||||
if (mat.HasProperty(propName)) continue;
|
||||
|
||||
EditorGUILayout.HelpBox(string.Format("Shader '{0}' doesn't have '{1}' property. This graphic cannot be masked.", shader.name, propName), MessageType.Warning);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Does the shader support UI masks?
|
||||
|
||||
if (FixButton(current.m_IsTrail, "This UIParticle component should be removed. The UIParticle for trails is no longer needed."))
|
||||
{
|
||||
DestroyUIParticle(current);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false)
|
||||
{
|
||||
if (!p || ignoreCurrent && target == p) return;
|
||||
|
||||
var cr = p.canvasRenderer;
|
||||
DestroyImmediate(p);
|
||||
DestroyImmediate(cr);
|
||||
|
||||
// Cone
|
||||
Handles.color = s_GizmoColor;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
Vector3 radiusAngleRange = new Vector3 (shapeModule.radius, shapeModule.angle, mainModule.startSpeedMultiplier);
|
||||
//radiusAngleRange = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusAngleRange);
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
radiusAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleRange, 7);
|
||||
#else
|
||||
radiusAngleRange = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleRange);
|
||||
var stage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
|
||||
if (stage != null && stage.scene.isLoaded)
|
||||
{
|
||||
PrefabUtility.SaveAsPrefabAsset(stage.prefabContentsRoot, stage.prefabAssetPath);
|
||||
}
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Cone Handle Change");
|
||||
shapeModule.radius = radiusAngleRange.x;
|
||||
shapeModule.angle = radiusAngleRange.y;
|
||||
mainModule.startSpeedMultiplier = radiusAngleRange.z;
|
||||
}
|
||||
}
|
||||
|
||||
// Texture
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (Vector3.zero, Quaternion.Euler (90.0f, 0.0f, 180.0f), Vector3.one * shapeModule.radius * 2.0f);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_CircleMesh, true, s_TextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.ConeVolume)
|
||||
{
|
||||
// Thickness
|
||||
Handles.color *= s_ShapeGizmoThicknessTint;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
float angleThickness = Mathf.Lerp (shapeModule.angle, 0.0f, shapeModule.radiusThickness);
|
||||
Vector3 radiusThicknessAngleLength = new Vector3 (shapeModule.radius * (1.0f - shapeModule.radiusThickness), angleThickness, shapeModule.length);
|
||||
//radiusThicknessAngleLength = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusThicknessAngleLength, Handles.ConeHandles.Radius);
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
radiusThicknessAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleLength, 1);
|
||||
#else
|
||||
radiusThicknessAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusThicknessAngleLength);
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Cone Volume Thickness Handle Change");
|
||||
shapeModule.radiusThickness = 1.0f - (radiusThicknessAngleLength.x / shapeModule.radius);
|
||||
}
|
||||
bool FixButton(bool show, string text)
|
||||
{
|
||||
if (!show) return false;
|
||||
using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))
|
||||
{
|
||||
EditorGUILayout.HelpBox(text, MessageType.Warning, true);
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
return GUILayout.Button(s_ContentFix, GUILayout.Width(30));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cone
|
||||
Handles.color = s_GizmoColor;
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
Vector3 radiusAngleLength = new Vector3 (shapeModule.radius, shapeModule.angle, shapeModule.length);
|
||||
//radiusAngleLength = Handles.ConeFrustrumHandle (Quaternion.identity, Vector3.zero, radiusAngleLength);
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
radiusAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleLength, 7);
|
||||
#else
|
||||
radiusAngleLength = Call<Vector3> (typeof (Handles), "ConeFrustrumHandle", Quaternion.identity, Vector3.zero, radiusAngleLength);
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Cone Volume Handle Change");
|
||||
shapeModule.radius = radiusAngleLength.x;
|
||||
shapeModule.angle = radiusAngleLength.y;
|
||||
shapeModule.length = radiusAngleLength.z;
|
||||
}
|
||||
private static bool DrawFloatOrVector3Field(SerializedProperty sp, bool showXyz)
|
||||
{
|
||||
var x = sp.FindPropertyRelative("x");
|
||||
var y = sp.FindPropertyRelative("y");
|
||||
var z = sp.FindPropertyRelative("z");
|
||||
|
||||
// Texture
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (Vector3.zero, Quaternion.Euler (90.0f, 0.0f, 180.0f), Vector3.one * shapeModule.radius * 2.0f);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_CircleMesh, true, s_TextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Box || type == ParticleSystemShapeType.BoxShell || type == ParticleSystemShapeType.BoxEdge)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
showXyz |= !Mathf.Approximately(x.floatValue, y.floatValue) ||
|
||||
!Mathf.Approximately(y.floatValue, z.floatValue) ||
|
||||
y.hasMultipleDifferentValues ||
|
||||
z.hasMultipleDifferentValues;
|
||||
|
||||
_boxBoundsHandle.center = Vector3.zero;
|
||||
_boxBoundsHandle.size = shapeModule.scale;
|
||||
_boxBoundsHandle.DrawHandle ();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (showXyz)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(sp);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
x.floatValue = Mathf.Max(0.001f, x.floatValue);
|
||||
y.floatValue = Mathf.Max(0.001f, y.floatValue);
|
||||
z.floatValue = Mathf.Max(0.001f, z.floatValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(x, s_ContentScale);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
x.floatValue = Mathf.Max(0.001f, x.floatValue);
|
||||
y.floatValue = Mathf.Max(0.001f, x.floatValue);
|
||||
z.floatValue = Mathf.Max(0.001f, x.floatValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Box Handle Change");
|
||||
shapeModule.scale = _boxBoundsHandle.size;
|
||||
}
|
||||
EditorGUI.BeginChangeCheck();
|
||||
showXyz = GUILayout.Toggle(showXyz, s_Content3D, EditorStyles.miniButton, GUILayout.Width(30));
|
||||
if (EditorGUI.EndChangeCheck() && !showXyz)
|
||||
z.floatValue = y.floatValue = x.floatValue;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (new Vector3 (0.0f, 0.0f, -m_BoxBoundsHandle.size.z * 0.5f), Quaternion.identity, m_BoxBoundsHandle.size);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_QuadMesh, true, s_TextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Donut)
|
||||
{
|
||||
// Radius
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
|
||||
_arcHandle.radius = shapeModule.radius;
|
||||
_arcHandle.angle = shapeModule.arc;
|
||||
_arcHandle.SetColorWithRadiusHandle (Color.white, 0f);
|
||||
_arcHandle.wireframeColor = Color.clear;
|
||||
|
||||
using (new Handles.DrawingScope (Handles.matrix * s_ArcHandleOffsetMatrix))
|
||||
_arcHandle.DrawHandle ();
|
||||
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Donut Handle Change");
|
||||
shapeModule.radius = _arcHandle.radius;
|
||||
shapeModule.arc = _arcHandle.angle;
|
||||
}
|
||||
|
||||
// Donut extents
|
||||
using (new Handles.DrawingScope (Handles.matrix * s_ArcHandleOffsetMatrix))
|
||||
{
|
||||
float excessAngle = shapeModule.arc % 360f;
|
||||
float angle = Mathf.Abs (shapeModule.arc) >= 360f ? 360f : excessAngle;
|
||||
|
||||
Handles.DrawWireArc (new Vector3 (0.0f, shapeModule.donutRadius, 0.0f), Vector3.up, Vector3.forward, angle, shapeModule.radius);
|
||||
Handles.DrawWireArc (new Vector3 (0.0f, -shapeModule.donutRadius, 0.0f), Vector3.up, Vector3.forward, angle, shapeModule.radius);
|
||||
Handles.DrawWireArc (Vector3.zero, Vector3.up, Vector3.forward, angle, shapeModule.radius + shapeModule.donutRadius);
|
||||
Handles.DrawWireArc (Vector3.zero, Vector3.up, Vector3.forward, angle, shapeModule.radius - shapeModule.donutRadius);
|
||||
|
||||
if (shapeModule.arc != 360.0f)
|
||||
{
|
||||
Quaternion arcRotation = Quaternion.AngleAxis (shapeModule.arc, Vector3.up);
|
||||
Vector3 capCenter = arcRotation * Vector3.forward * shapeModule.radius;
|
||||
Handles.DrawWireDisc (capCenter, arcRotation * Vector3.right, shapeModule.donutRadius);
|
||||
}
|
||||
}
|
||||
|
||||
// Donut thickness
|
||||
_sphereBoundsHandle.axes = PrimitiveBoundsHandle.Axes.X | PrimitiveBoundsHandle.Axes.Y;
|
||||
_sphereBoundsHandle.radius = shapeModule.donutRadius * (1.0f - shapeModule.radiusThickness);
|
||||
_sphereBoundsHandle.center = Vector3.zero;
|
||||
_sphereBoundsHandle.SetColor (s_ShapeGizmoThicknessTint);
|
||||
|
||||
const float handleInterval = 90.0f;
|
||||
int numOuterRadii = Mathf.Max (1, (int)Mathf.Ceil (shapeModule.arc / handleInterval));
|
||||
Matrix4x4 donutRadiusStartMatrix = Matrix4x4.TRS (new Vector3 (shapeModule.radius, 0.0f, 0.0f), Quaternion.Euler (90.0f, 0.0f, 0.0f), Vector3.one);
|
||||
|
||||
for (int i = 0; i < numOuterRadii; i++)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
using (new Handles.DrawingScope (Handles.matrix * (Matrix4x4.Rotate (Quaternion.Euler (0.0f, 0.0f, handleInterval * i)) * donutRadiusStartMatrix)))
|
||||
_sphereBoundsHandle.DrawHandle ();
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Donut Radius Thickness Handle Change");
|
||||
shapeModule.radiusThickness = 1.0f - (_sphereBoundsHandle.radius / shapeModule.donutRadius);
|
||||
}
|
||||
}
|
||||
|
||||
// Donut radius
|
||||
_sphereBoundsHandle.radius = shapeModule.donutRadius;
|
||||
_sphereBoundsHandle.SetColor (Color.white);
|
||||
|
||||
for (int i = 0; i < numOuterRadii; i++)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
using (new Handles.DrawingScope (Handles.matrix * (Matrix4x4.Rotate (Quaternion.Euler (0.0f, 0.0f, handleInterval * i)) * donutRadiusStartMatrix)))
|
||||
_sphereBoundsHandle.DrawHandle ();
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Donut Radius Handle Change");
|
||||
shapeModule.donutRadius = _sphereBoundsHandle.radius;
|
||||
}
|
||||
}
|
||||
|
||||
// Texture
|
||||
//Matrix4x4 textureTransform = transformMatrix * Matrix4x4.TRS (new Vector3 (shapeModule.radius, 0.0f, 0.0f), Quaternion.Euler (180.0f, 0.0f, 180.0f), Vector3.one * shapeModule.donutRadius * 2.0f);
|
||||
//OnSceneViewTextureGUI (shapeModule, s_CircleMesh, true, s_TextureMaterial, textureTransform);
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.SingleSidedEdge)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
//float radius = Handles.DoSimpleEdgeHandle (Quaternion.identity, Vector3.zero, shapeModule.radius);
|
||||
float radius = Call<float> (typeof (Handles), "DoSimpleEdgeHandle", Quaternion.identity, Vector3.zero, shapeModule.radius);
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Edge Handle Change");
|
||||
shapeModule.radius = radius;
|
||||
}
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Mesh)
|
||||
{
|
||||
Mesh mesh = shapeModule.mesh;
|
||||
if (mesh)
|
||||
{
|
||||
bool orgWireframeMode = GL.wireframe;
|
||||
GL.wireframe = true;
|
||||
s_Material.SetPass (0);
|
||||
Graphics.DrawMeshNow (mesh, transformMatrix);
|
||||
GL.wireframe = orgWireframeMode;
|
||||
|
||||
//OnSceneViewTextureGUI (shapeModule, mesh, false, s_TextureMaterial, transformMatrix);
|
||||
}
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Rectangle)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
|
||||
_boxBoundsHandle.center = Vector3.zero;
|
||||
_boxBoundsHandle.size = new Vector3 (shapeModule.scale.x, shapeModule.scale.y, 0.0f);
|
||||
_boxBoundsHandle.DrawHandle ();
|
||||
|
||||
if (EditorGUI.EndChangeCheck ())
|
||||
{
|
||||
Undo.RecordObject (ps, "Rectangle Handle Change");
|
||||
shapeModule.scale = new Vector3 (_boxBoundsHandle.size.x, _boxBoundsHandle.size.y, 0.0f);
|
||||
}
|
||||
|
||||
//OnSceneViewTextureGUI (shapeModule, s_QuadMesh, true, s_TextureMaterial, transformMatrix * Matrix4x4.Scale (m_BoxBoundsHandle.size));
|
||||
}
|
||||
else if (type == ParticleSystemShapeType.Sprite)
|
||||
{
|
||||
Sprite sprite = shapeModule.sprite;
|
||||
if (sprite)
|
||||
{
|
||||
if (!_spriteMesh)
|
||||
{
|
||||
_spriteMesh = new Mesh ();
|
||||
_spriteMesh.name = "ParticleSpritePreview";
|
||||
_spriteMesh.hideFlags |= HideFlags.HideAndDontSave;
|
||||
}
|
||||
|
||||
_spriteMesh.vertices = Array.ConvertAll (sprite.vertices, i => (Vector3)i);
|
||||
_spriteMesh.uv = sprite.uv;
|
||||
_spriteMesh.triangles = Array.ConvertAll (sprite.triangles, i => (int)i);
|
||||
|
||||
bool orgWireframeMode = GL.wireframe;
|
||||
GL.wireframe = true;
|
||||
s_Material.SetPass (0);
|
||||
Graphics.DrawMeshNow (_spriteMesh, transformMatrix);
|
||||
GL.wireframe = orgWireframeMode;
|
||||
|
||||
//OnSceneViewTextureGUI (shapeModule, m_SpriteMesh, false, s_TextureMaterial, transformMatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
Handles.color = origCol;
|
||||
Handles.matrix = orgMatrix;
|
||||
}
|
||||
}
|
||||
}
|
||||
return showXyz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
46
Scripts/Editor/UIParticleMenu.cs
Normal file
46
Scripts/Editor/UIParticleMenu.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
internal class UIParticleMenu
|
||||
{
|
||||
[MenuItem("GameObject/UI/Particle System (Empty)", false, 2018)]
|
||||
private static void AddParticleEmpty(MenuCommand menuCommand)
|
||||
{
|
||||
// Create empty UI element.
|
||||
EditorApplication.ExecuteMenuItem("GameObject/UI/Image");
|
||||
var ui = Selection.activeGameObject;
|
||||
Object.DestroyImmediate(ui.GetComponent<Image>());
|
||||
|
||||
// Add UIParticle.
|
||||
var uiParticle = ui.AddComponent<UIParticle>();
|
||||
uiParticle.name = "UIParticle";
|
||||
uiParticle.scale = 10;
|
||||
uiParticle.rectTransform.sizeDelta = Vector2.zero;
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI/Particle System", false, 2019)]
|
||||
private static void AddParticle(MenuCommand menuCommand)
|
||||
{
|
||||
// Create empty UIEffect.
|
||||
AddParticleEmpty(menuCommand);
|
||||
var uiParticle = Selection.activeGameObject.GetComponent<UIParticle>();
|
||||
|
||||
// Create ParticleSystem.
|
||||
EditorApplication.ExecuteMenuItem("GameObject/Effects/Particle System");
|
||||
var ps = Selection.activeGameObject;
|
||||
ps.transform.SetParent(uiParticle.transform, false);
|
||||
ps.transform.localPosition = Vector3.zero;
|
||||
|
||||
// Assign default material.
|
||||
var renderer = ps.GetComponent<ParticleSystemRenderer>();
|
||||
var defaultMat = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Particle.mat");
|
||||
renderer.material = defaultMat ? defaultMat : renderer.material;
|
||||
|
||||
// Refresh particles.
|
||||
uiParticle.RefreshParticles();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/UIParticleMenu.cs.meta
Normal file
11
Scripts/Editor/UIParticleMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ad158a8abf7646d6b540eed4a91a2dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Scripts/MeshHelper.cs
Normal file
106
Scripts/MeshHelper.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal static class MeshHelper
|
||||
{
|
||||
public static List<bool> activeMeshIndices { get; private set; }
|
||||
private static readonly List<CombineInstanceEx> s_CachedInstance;
|
||||
private static int count;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
activeMeshIndices = new List<bool>();
|
||||
}
|
||||
|
||||
static MeshHelper()
|
||||
{
|
||||
s_CachedInstance = new List<CombineInstanceEx>(8);
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
s_CachedInstance.Add(new CombineInstanceEx());
|
||||
}
|
||||
}
|
||||
|
||||
private static CombineInstanceEx Get(int index, long hash)
|
||||
{
|
||||
if (0 < count && s_CachedInstance[count - 1].hash == hash)
|
||||
return s_CachedInstance[count - 1];
|
||||
|
||||
if (s_CachedInstance.Count <= count)
|
||||
{
|
||||
var newInst = new CombineInstanceEx();
|
||||
s_CachedInstance.Add(newInst);
|
||||
}
|
||||
|
||||
var inst = s_CachedInstance[count];
|
||||
inst.hash = hash;
|
||||
if (inst.index != -1) return inst;
|
||||
|
||||
inst.index = index;
|
||||
count++;
|
||||
return inst;
|
||||
}
|
||||
|
||||
public static Mesh GetTemporaryMesh()
|
||||
{
|
||||
return MeshPool.Rent();
|
||||
}
|
||||
|
||||
public static void Push(int index, long hash, Mesh mesh, Matrix4x4 transform)
|
||||
{
|
||||
if (mesh.vertexCount <= 0)
|
||||
{
|
||||
DiscardTemporaryMesh(mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
Profiler.BeginSample("[UIParticle] MeshHelper > Get CombineInstanceEx");
|
||||
var inst = Get(index, hash);
|
||||
Profiler.EndSample();
|
||||
|
||||
Profiler.BeginSample("[UIParticle] MeshHelper > Push To Mesh Helper");
|
||||
inst.Push(mesh, transform);
|
||||
Profiler.EndSample();
|
||||
|
||||
activeMeshIndices[inst.index] = true;
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
count = 0;
|
||||
activeMeshIndices.Clear();
|
||||
foreach (var inst in s_CachedInstance)
|
||||
{
|
||||
inst.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void CombineMesh(Mesh result)
|
||||
{
|
||||
if (count == 0) return;
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
Profiler.BeginSample("[UIParticle] MeshHelper > Combine Mesh Internal");
|
||||
s_CachedInstance[i].Combine();
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
Profiler.BeginSample("[UIParticle] MeshHelper > Combine Mesh");
|
||||
var cis = CombineInstanceArrayPool.Get(s_CachedInstance, count);
|
||||
result.CombineMeshes(cis, false, true);
|
||||
cis.Clear();
|
||||
Profiler.EndSample();
|
||||
|
||||
result.RecalculateBounds();
|
||||
}
|
||||
|
||||
public static void DiscardTemporaryMesh(Mesh mesh)
|
||||
{
|
||||
MeshPool.Return(mesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/MeshHelper.cs.meta
Normal file
11
Scripts/MeshHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f689ea5a2e9f140288c8874127aa9ee0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Scripts/ModifiedMaterial.cs
Normal file
74
Scripts/ModifiedMaterial.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal class ModifiedMaterial
|
||||
{
|
||||
private static readonly List<MatEntry> s_Entries = new List<MatEntry>();
|
||||
|
||||
public static Material Add(Material baseMat, Texture texture, int id)
|
||||
{
|
||||
MatEntry e;
|
||||
for (var i = 0; i < s_Entries.Count; ++i)
|
||||
{
|
||||
e = s_Entries[i];
|
||||
if (e.baseMat != baseMat || e.texture != texture || e.id != id) continue;
|
||||
++e.count;
|
||||
return e.customMat;
|
||||
}
|
||||
|
||||
e = new MatEntry();
|
||||
e.count = 1;
|
||||
e.baseMat = baseMat;
|
||||
e.texture = texture;
|
||||
e.id = id;
|
||||
e.customMat = new Material(baseMat);
|
||||
e.customMat.hideFlags = HideFlags.HideAndDontSave;
|
||||
if (texture)
|
||||
e.customMat.mainTexture = texture;
|
||||
s_Entries.Add(e);
|
||||
// Debug.LogFormat(">>>> ModifiedMaterial.Add -> count = {0} {1} {2} {3}", s_Entries.Count, baseMat, texture, id);
|
||||
return e.customMat;
|
||||
}
|
||||
|
||||
public static void Remove(Material customMat)
|
||||
{
|
||||
if (!customMat) return;
|
||||
|
||||
for (var i = 0; i < s_Entries.Count; ++i)
|
||||
{
|
||||
var e = s_Entries[i];
|
||||
if (e.customMat != customMat) continue;
|
||||
if (--e.count == 0)
|
||||
{
|
||||
// Debug.LogFormat(">>>> ModifiedMaterial.Add -> count = {0} {1} {2} {3}", s_Entries.Count - 1, e.customMat, e.texture, e.id);
|
||||
DestroyImmediate(e.customMat);
|
||||
e.baseMat = null;
|
||||
e.texture = null;
|
||||
s_Entries.RemoveAt(i);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DestroyImmediate(Object obj)
|
||||
{
|
||||
if (!obj) return;
|
||||
if (Application.isEditor)
|
||||
Object.DestroyImmediate(obj);
|
||||
else
|
||||
Object.Destroy(obj);
|
||||
}
|
||||
|
||||
private class MatEntry
|
||||
{
|
||||
public Material baseMat;
|
||||
public Material customMat;
|
||||
public int count;
|
||||
public Texture texture;
|
||||
public int id;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/ModifiedMaterial.cs.meta
Normal file
11
Scripts/ModifiedMaterial.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0beae5bb1cb142b9ab90dc0d371f026
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,407 +1,524 @@
|
||||
using System.Collections;
|
||||
#if UNITY_2019_3_11 || UNITY_2019_3_12 || UNITY_2019_3_13 || UNITY_2019_3_14 || UNITY_2019_3_15 || UNITY_2019_4_OR_NEWER
|
||||
#define SERIALIZE_FIELD_MASKABLE
|
||||
#endif
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Render maskable and sortable particle effect ,without Camera, RenderTexture or Canvas.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public class UIParticle : MaskableGraphic
|
||||
{
|
||||
//################################
|
||||
// Constant or Readonly Static Members.
|
||||
//################################
|
||||
static readonly int s_IdMainTex = Shader.PropertyToID ("_MainTex");
|
||||
static readonly List<Vector3> s_Vertices = new List<Vector3> ();
|
||||
static readonly List<UIParticle> s_TempRelatables = new List<UIParticle> ();
|
||||
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle> ();
|
||||
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[Tooltip ("The ParticleSystem rendered by CanvasRenderer")]
|
||||
[SerializeField] ParticleSystem m_ParticleSystem;
|
||||
[Tooltip ("The UIParticle to render trail effect")]
|
||||
[SerializeField] UIParticle m_TrailParticle;
|
||||
[HideInInspector] [SerializeField] bool m_IsTrail = false;
|
||||
[Tooltip ("Particle effect scale")]
|
||||
[SerializeField] float m_Scale = 1;
|
||||
[Tooltip ("Ignore parent scale")]
|
||||
[SerializeField] bool m_IgnoreParent = false;
|
||||
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
Texture tex = null;
|
||||
if (!m_IsTrail && cachedParticleSystem)
|
||||
{
|
||||
Profiler.BeginSample ("Check TextureSheetAnimation module");
|
||||
var textureSheet = cachedParticleSystem.textureSheetAnimation;
|
||||
if (textureSheet.enabled && textureSheet.mode == ParticleSystemAnimationMode.Sprites && 0 < textureSheet.spriteCount)
|
||||
{
|
||||
tex = textureSheet.GetSprite (0).texture;
|
||||
}
|
||||
Profiler.EndSample ();
|
||||
}
|
||||
if (!tex && _renderer)
|
||||
{
|
||||
Profiler.BeginSample ("Check material");
|
||||
var mat = m_IsTrail
|
||||
? _renderer.trailMaterial
|
||||
: _renderer.sharedMaterial;
|
||||
if (mat && mat.HasProperty (s_IdMainTex))
|
||||
{
|
||||
tex = mat.mainTexture;
|
||||
}
|
||||
Profiler.EndSample ();
|
||||
}
|
||||
return tex ?? s_WhiteTexture;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Particle effect scale.
|
||||
/// </summary>
|
||||
public float scale { get { return _parent ? _parent.scale : m_Scale; } set { m_Scale = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Should the soft mask ignore parent soft masks?
|
||||
/// </summary>
|
||||
/// <value>If set to true the soft mask will ignore any parent soft mask settings.</value>
|
||||
public bool ignoreParent
|
||||
{
|
||||
get { return m_IgnoreParent; }
|
||||
set
|
||||
{
|
||||
if (m_IgnoreParent != value)
|
||||
{
|
||||
m_IgnoreParent = value;
|
||||
OnTransformParentChanged ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is this the root UIParticle?
|
||||
/// </summary>
|
||||
public bool isRoot
|
||||
{
|
||||
get { return !_parent; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should this graphic be considered a target for raycasting?
|
||||
/// </summary>
|
||||
public override bool raycastTarget { get { return false; } set { base.raycastTarget = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// ParticleSystem.
|
||||
/// </summary>
|
||||
public ParticleSystem cachedParticleSystem { get { return m_ParticleSystem ? m_ParticleSystem : (m_ParticleSystem = GetComponent<ParticleSystem> ()); } }
|
||||
|
||||
/// <summary>
|
||||
/// Perform material modification in this function.
|
||||
/// </summary>
|
||||
/// <returns>Modified material.</returns>
|
||||
/// <param name="baseMaterial">Configured Material.</param>
|
||||
public override Material GetModifiedMaterial (Material baseMaterial)
|
||||
{
|
||||
return base.GetModifiedMaterial (_renderer ? _renderer.sharedMaterial : baseMaterial);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable ()
|
||||
{
|
||||
// Register.
|
||||
if (s_ActiveParticles.Count == 0)
|
||||
{
|
||||
Canvas.willRenderCanvases += UpdateMeshes;
|
||||
}
|
||||
s_ActiveParticles.Add (this);
|
||||
|
||||
// Reset the parent-child relation.
|
||||
GetComponentsInChildren<UIParticle> (false, s_TempRelatables);
|
||||
for (int i = s_TempRelatables.Count - 1; 0 <= i; i--)
|
||||
{
|
||||
s_TempRelatables [i].OnTransformParentChanged ();
|
||||
}
|
||||
s_TempRelatables.Clear ();
|
||||
|
||||
_renderer = cachedParticleSystem ? cachedParticleSystem.GetComponent<ParticleSystemRenderer> () : null;
|
||||
if (_renderer && Application.isPlaying)
|
||||
{
|
||||
_renderer.enabled = false;
|
||||
}
|
||||
|
||||
// Create objects.
|
||||
_mesh = new Mesh ();
|
||||
_mesh.MarkDynamic ();
|
||||
CheckTrail ();
|
||||
|
||||
base.OnEnable ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the behaviour becomes disabled.
|
||||
/// </summary>
|
||||
protected override void OnDisable ()
|
||||
{
|
||||
// Unregister.
|
||||
s_ActiveParticles.Remove (this);
|
||||
if (s_ActiveParticles.Count == 0)
|
||||
{
|
||||
Canvas.willRenderCanvases -= UpdateMeshes;
|
||||
}
|
||||
|
||||
// Reset the parent-child relation.
|
||||
for (int i = _children.Count - 1; 0 <= i; i--)
|
||||
{
|
||||
_children [i].SetParent (_parent);
|
||||
}
|
||||
_children.Clear ();
|
||||
SetParent (null);
|
||||
|
||||
// Destroy objects.
|
||||
DestroyImmediate (_mesh);
|
||||
_mesh = null;
|
||||
CheckTrail ();
|
||||
|
||||
base.OnDisable ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to update the geometry of the Graphic onto the CanvasRenderer.
|
||||
/// </summary>
|
||||
protected override void UpdateGeometry ()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the parent property of the transform of the GameObject has changed.
|
||||
/// </summary>
|
||||
protected override void OnTransformParentChanged ()
|
||||
{
|
||||
UIParticle newParent = null;
|
||||
if (isActiveAndEnabled && !m_IgnoreParent)
|
||||
{
|
||||
var parentTransform = transform.parent;
|
||||
while (parentTransform && (!newParent || !newParent.enabled))
|
||||
{
|
||||
newParent = parentTransform.GetComponent<UIParticle> ();
|
||||
parentTransform = parentTransform.parent;
|
||||
}
|
||||
}
|
||||
SetParent (newParent);
|
||||
|
||||
base.OnTransformParentChanged ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when properties have been changed by animation.
|
||||
/// </summary>
|
||||
protected override void OnDidApplyAnimationProperties ()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Render maskable and sortable particle effect ,without Camera, RenderTexture or Canvas.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
public class UIParticle : MaskableGraphic
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// This function is called when the script is loaded or a value is changed in the inspector(Called in the editor only).
|
||||
/// </summary>
|
||||
protected override void OnValidate ()
|
||||
{
|
||||
OnTransformParentChanged ();
|
||||
base.OnValidate ();
|
||||
}
|
||||
, ISerializationCallbackReceiver
|
||||
#endif
|
||||
{
|
||||
[HideInInspector] [SerializeField] internal bool m_IsTrail = false;
|
||||
|
||||
[Tooltip("Ignore canvas scaler")] [SerializeField] [FormerlySerializedAs("m_IgnoreParent")]
|
||||
bool m_IgnoreCanvasScaler = true;
|
||||
|
||||
[Tooltip("Particle effect scale")] [SerializeField]
|
||||
float m_Scale = 100;
|
||||
|
||||
[Tooltip("Particle effect scale")] [SerializeField]
|
||||
private Vector3 m_Scale3D;
|
||||
|
||||
[Tooltip("Animatable material properties. If you want to change the material properties of the ParticleSystem in Animation, enable it.")] [SerializeField]
|
||||
internal AnimatableProperty[] m_AnimatableProperties = new AnimatableProperty[0];
|
||||
|
||||
[Tooltip("Particles")] [SerializeField]
|
||||
private List<ParticleSystem> m_Particles = new List<ParticleSystem>();
|
||||
|
||||
[Tooltip("Shrink rendering by material on refresh.\nNOTE: Performance will be improved, but in some cases the rendering is not correct.")] [SerializeField]
|
||||
bool m_ShrinkByMaterial = false;
|
||||
|
||||
#if !SERIALIZE_FIELD_MASKABLE
|
||||
[SerializeField] private bool m_Maskable = true;
|
||||
#endif
|
||||
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
Mesh _mesh;
|
||||
ParticleSystemRenderer _renderer;
|
||||
UIParticle _parent;
|
||||
List<UIParticle> _children = new List<UIParticle> ();
|
||||
Matrix4x4 scaleaMatrix = default (Matrix4x4);
|
||||
|
||||
/// <summary>
|
||||
/// Update meshes.
|
||||
/// </summary>
|
||||
static void UpdateMeshes ()
|
||||
{
|
||||
for (int i = 0; i < s_ActiveParticles.Count; i++)
|
||||
{
|
||||
if (s_ActiveParticles [i])
|
||||
{
|
||||
s_ActiveParticles [i].UpdateMesh ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update meshe.
|
||||
/// </summary>
|
||||
void UpdateMesh ()
|
||||
{
|
||||
try
|
||||
{
|
||||
Profiler.BeginSample ("CheckTrail");
|
||||
CheckTrail ();
|
||||
Profiler.EndSample ();
|
||||
|
||||
if (m_ParticleSystem && canvas)
|
||||
{
|
||||
if (canvas.renderMode != RenderMode.ScreenSpaceOverlay)
|
||||
{
|
||||
Vector3 pos = rectTransform.localPosition;
|
||||
if (Mathf.Abs (pos.z) < 0.01f)
|
||||
{
|
||||
pos.z = 0.01f;
|
||||
rectTransform.localPosition = pos;
|
||||
}
|
||||
}
|
||||
|
||||
var rootCanvas = canvas.rootCanvas;
|
||||
Profiler.BeginSample ("Disable ParticleSystemRenderer");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
_renderer.enabled = false;
|
||||
}
|
||||
Profiler.EndSample ();
|
||||
|
||||
Profiler.BeginSample ("Make Matrix");
|
||||
scaleaMatrix = m_ParticleSystem.main.scalingMode == ParticleSystemScalingMode.Hierarchy
|
||||
? Matrix4x4.Scale (scale * Vector3.one)
|
||||
: Matrix4x4.Scale (scale * rootCanvas.transform.localScale);
|
||||
Matrix4x4 matrix = default (Matrix4x4);
|
||||
switch (m_ParticleSystem.main.simulationSpace)
|
||||
{
|
||||
case ParticleSystemSimulationSpace.Local:
|
||||
matrix =
|
||||
scaleaMatrix
|
||||
* Matrix4x4.Rotate (m_ParticleSystem.transform.rotation).inverse
|
||||
* Matrix4x4.Scale (m_ParticleSystem.transform.lossyScale).inverse;
|
||||
break;
|
||||
case ParticleSystemSimulationSpace.World:
|
||||
matrix =
|
||||
scaleaMatrix
|
||||
* m_ParticleSystem.transform.worldToLocalMatrix;
|
||||
break;
|
||||
case ParticleSystemSimulationSpace.Custom:
|
||||
break;
|
||||
}
|
||||
Profiler.EndSample ();
|
||||
|
||||
_mesh.Clear ();
|
||||
if (0 < m_ParticleSystem.particleCount)
|
||||
{
|
||||
Profiler.BeginSample ("Bake Mesh");
|
||||
var cam = rootCanvas.renderMode == RenderMode.ScreenSpaceOverlay
|
||||
? UIParticleOverlayCamera.GetCameraForOvrelay (rootCanvas)
|
||||
: canvas.worldCamera ?? Camera.main;
|
||||
|
||||
if (!cam)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_IsTrail)
|
||||
{
|
||||
_renderer.BakeTrailsMesh (_mesh, cam, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_renderer.BakeMesh (_mesh, cam, true);
|
||||
}
|
||||
Profiler.EndSample ();
|
||||
|
||||
// Apply matrix.
|
||||
Profiler.BeginSample ("Apply matrix to position");
|
||||
_mesh.GetVertices (s_Vertices);
|
||||
var count = s_Vertices.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
s_Vertices [i] = matrix.MultiplyPoint3x4 (s_Vertices [i]);
|
||||
}
|
||||
_mesh.SetVertices (s_Vertices);
|
||||
s_Vertices.Clear ();
|
||||
Profiler.EndSample ();
|
||||
}
|
||||
private bool _shouldBeRemoved;
|
||||
private DrivenRectTransformTracker _tracker;
|
||||
private Mesh _bakedMesh;
|
||||
private readonly List<Material> _modifiedMaterials = new List<Material>();
|
||||
private readonly List<Material> _maskMaterials = new List<Material>();
|
||||
private readonly List<bool> _activeMeshIndices = new List<bool>();
|
||||
private Vector3 _cachedPosition;
|
||||
private static readonly List<Material> s_TempMaterials = new List<Material>(2);
|
||||
private static MaterialPropertyBlock s_Mpb;
|
||||
private static readonly List<Material> s_PrevMaskMaterials = new List<Material>();
|
||||
private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>();
|
||||
private static readonly List<Component> s_Components = new List<Component>();
|
||||
private static readonly List<ParticleSystem> s_ParticleSystems = new List<ParticleSystem>();
|
||||
|
||||
|
||||
// Set mesh to CanvasRenderer.
|
||||
Profiler.BeginSample ("Set mesh and texture to CanvasRenderer");
|
||||
canvasRenderer.SetMesh (_mesh);
|
||||
canvasRenderer.SetTexture (mainTexture);
|
||||
Profiler.EndSample ();
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogException (e);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Should this graphic be considered a target for raycasting?
|
||||
/// </summary>
|
||||
public override bool raycastTarget
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the trail.
|
||||
/// </summary>
|
||||
void CheckTrail ()
|
||||
{
|
||||
if (isActiveAndEnabled && !m_IsTrail && m_ParticleSystem && m_ParticleSystem.trails.enabled)
|
||||
{
|
||||
if (!m_TrailParticle)
|
||||
{
|
||||
m_TrailParticle = new GameObject ("[UIParticle] Trail").AddComponent<UIParticle> ();
|
||||
var trans = m_TrailParticle.transform;
|
||||
trans.SetParent (transform);
|
||||
trans.localPosition = Vector3.zero;
|
||||
trans.localRotation = Quaternion.identity;
|
||||
trans.localScale = Vector3.one;
|
||||
public bool ignoreCanvasScaler
|
||||
{
|
||||
get { return m_IgnoreCanvasScaler; }
|
||||
set
|
||||
{
|
||||
// if (m_IgnoreCanvasScaler == value) return;
|
||||
m_IgnoreCanvasScaler = value;
|
||||
_tracker.Clear();
|
||||
if (isActiveAndEnabled && m_IgnoreCanvasScaler)
|
||||
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
|
||||
}
|
||||
}
|
||||
|
||||
m_TrailParticle._renderer = GetComponent<ParticleSystemRenderer> ();
|
||||
m_TrailParticle.m_ParticleSystem = GetComponent<ParticleSystem> ();
|
||||
m_TrailParticle.m_IsTrail = true;
|
||||
}
|
||||
m_TrailParticle.enabled = true;
|
||||
}
|
||||
else if (m_TrailParticle)
|
||||
{
|
||||
m_TrailParticle.enabled = false;
|
||||
}
|
||||
}
|
||||
public bool shrinkByMaterial
|
||||
{
|
||||
get { return m_ShrinkByMaterial; }
|
||||
set
|
||||
{
|
||||
if (m_ShrinkByMaterial == value) return;
|
||||
m_ShrinkByMaterial = value;
|
||||
RefreshParticles();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the parent of the soft mask.
|
||||
/// </summary>
|
||||
/// <param name="newParent">The parent soft mask to use.</param>
|
||||
void SetParent (UIParticle newParent)
|
||||
{
|
||||
if (_parent != newParent && this != newParent)
|
||||
{
|
||||
if (_parent && _parent._children.Contains (this))
|
||||
{
|
||||
_parent._children.Remove (this);
|
||||
_parent._children.RemoveAll (x => x == null);
|
||||
}
|
||||
_parent = newParent;
|
||||
}
|
||||
/// <summary>
|
||||
/// Particle effect scale.
|
||||
/// </summary>
|
||||
public float scale
|
||||
{
|
||||
get { return m_Scale3D.x; }
|
||||
set
|
||||
{
|
||||
m_Scale = Mathf.Max(0.001f, value);
|
||||
m_Scale3D = new Vector3(m_Scale, m_Scale, m_Scale);
|
||||
}
|
||||
}
|
||||
|
||||
if (_parent && !_parent._children.Contains (this))
|
||||
{
|
||||
_parent._children.Add (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Particle effect scale.
|
||||
/// </summary>
|
||||
public Vector3 scale3D
|
||||
{
|
||||
get { return m_Scale3D; }
|
||||
set
|
||||
{
|
||||
if (m_Scale3D == value) return;
|
||||
m_Scale3D.x = Mathf.Max(0.001f, value.x);
|
||||
m_Scale3D.y = Mathf.Max(0.001f, value.y);
|
||||
m_Scale3D.z = Mathf.Max(0.001f, value.z);
|
||||
}
|
||||
}
|
||||
|
||||
internal Mesh bakedMesh
|
||||
{
|
||||
get { return _bakedMesh; }
|
||||
}
|
||||
|
||||
public List<ParticleSystem> particles
|
||||
{
|
||||
get { return m_Particles; }
|
||||
}
|
||||
|
||||
public IEnumerable<Material> materials
|
||||
{
|
||||
get { return _modifiedMaterials; }
|
||||
}
|
||||
|
||||
public override Material materialForRendering
|
||||
{
|
||||
get { return canvasRenderer.GetMaterial(0); }
|
||||
}
|
||||
|
||||
public List<bool> activeMeshIndices
|
||||
{
|
||||
get { return _activeMeshIndices; }
|
||||
set
|
||||
{
|
||||
if (_activeMeshIndices.SequenceEqualFast(value)) return;
|
||||
_activeMeshIndices.Clear();
|
||||
_activeMeshIndices.AddRange(value);
|
||||
UpdateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
internal Vector3 cachedPosition
|
||||
{
|
||||
get { return _cachedPosition; }
|
||||
set { _cachedPosition = value; }
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
particles.Exec(p => p.Play());
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
particles.Exec(p => p.Pause());
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
particles.Exec(p => p.Stop());
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
particles.Exec(p => p.Clear());
|
||||
}
|
||||
|
||||
public void SetParticleSystemInstance(GameObject instance)
|
||||
{
|
||||
SetParticleSystemInstance(instance, true);
|
||||
}
|
||||
|
||||
public void SetParticleSystemInstance(GameObject instance, bool destroyOldParticles)
|
||||
{
|
||||
if (!instance) return;
|
||||
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
var go = child.gameObject;
|
||||
go.SetActive(false);
|
||||
if (!destroyOldParticles) continue;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
DestroyImmediate(go);
|
||||
else
|
||||
#endif
|
||||
Destroy(go);
|
||||
}
|
||||
|
||||
var tr = instance.transform;
|
||||
tr.SetParent(transform, false);
|
||||
tr.localPosition = Vector3.zero;
|
||||
|
||||
RefreshParticles(instance);
|
||||
}
|
||||
|
||||
public void SetParticleSystemPrefab(GameObject prefab)
|
||||
{
|
||||
if (!prefab) return;
|
||||
|
||||
SetParticleSystemInstance(Instantiate(prefab.gameObject), true);
|
||||
}
|
||||
|
||||
public void RefreshParticles()
|
||||
{
|
||||
RefreshParticles(gameObject);
|
||||
}
|
||||
|
||||
public void RefreshParticles(GameObject root)
|
||||
{
|
||||
if (!root) return;
|
||||
root.GetComponentsInChildren(particles);
|
||||
particles.RemoveAll(x => x.GetComponentInParent<UIParticle>() != this);
|
||||
|
||||
foreach (var ps in particles)
|
||||
{
|
||||
var tsa = ps.textureSheetAnimation;
|
||||
if (tsa.mode == ParticleSystemAnimationMode.Sprites && tsa.uvChannelMask == (UVChannelFlags) 0)
|
||||
tsa.uvChannelMask = UVChannelFlags.UV0;
|
||||
}
|
||||
|
||||
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = !enabled);
|
||||
particles.SortForRendering(transform, m_ShrinkByMaterial);
|
||||
|
||||
SetMaterialDirty();
|
||||
}
|
||||
|
||||
protected override void UpdateMaterial()
|
||||
{
|
||||
// Clear mask materials.
|
||||
s_PrevMaskMaterials.AddRange(_maskMaterials);
|
||||
_maskMaterials.Clear();
|
||||
|
||||
// Clear modified materials.
|
||||
s_PrevModifiedMaterials.AddRange(_modifiedMaterials);
|
||||
_modifiedMaterials.Clear();
|
||||
|
||||
// Recalculate stencil value.
|
||||
if (m_ShouldRecalculateStencil)
|
||||
{
|
||||
var rootCanvas = MaskUtilities.FindRootSortOverrideCanvas(transform);
|
||||
m_StencilValue = maskable ? MaskUtilities.GetStencilDepth(transform, rootCanvas) : 0;
|
||||
m_ShouldRecalculateStencil = false;
|
||||
}
|
||||
|
||||
// No mesh to render.
|
||||
var count = activeMeshIndices.CountFast();
|
||||
if (count == 0 || !isActiveAndEnabled || particles.Count == 0)
|
||||
{
|
||||
canvasRenderer.Clear();
|
||||
ClearPreviousMaterials();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
GetComponents(typeof(IMaterialModifier), s_Components);
|
||||
var materialCount = Mathf.Min(8, count);
|
||||
canvasRenderer.materialCount = materialCount;
|
||||
var j = 0;
|
||||
for (var i = 0; i < particles.Count; i++)
|
||||
{
|
||||
if (materialCount <= j) break;
|
||||
var ps = particles[i];
|
||||
if (!ps) continue;
|
||||
|
||||
var r = ps.GetComponent<ParticleSystemRenderer>();
|
||||
r.GetSharedMaterials(s_TempMaterials);
|
||||
|
||||
// Main
|
||||
var index = i * 2;
|
||||
if (activeMeshIndices.Count <= index) break;
|
||||
if (activeMeshIndices[index] && 0 < s_TempMaterials.Count)
|
||||
{
|
||||
var mat = GetModifiedMaterial(s_TempMaterials[0], ps.GetTextureForSprite());
|
||||
for (var k = 1; k < s_Components.Count; k++)
|
||||
mat = (s_Components[k] as IMaterialModifier).GetModifiedMaterial(mat);
|
||||
canvasRenderer.SetMaterial(mat, j);
|
||||
UpdateMaterialProperties(r, j);
|
||||
j++;
|
||||
}
|
||||
|
||||
// Trails
|
||||
index++;
|
||||
if (activeMeshIndices.Count <= index || materialCount <= j) break;
|
||||
if (activeMeshIndices[index] && 1 < s_TempMaterials.Count)
|
||||
{
|
||||
var mat = GetModifiedMaterial(s_TempMaterials[1], null);
|
||||
for (var k = 1; k < s_Components.Count; k++)
|
||||
mat = (s_Components[k] as IMaterialModifier).GetModifiedMaterial(mat);
|
||||
canvasRenderer.SetMaterial(mat, j++);
|
||||
}
|
||||
}
|
||||
|
||||
ClearPreviousMaterials();
|
||||
}
|
||||
|
||||
private void ClearPreviousMaterials()
|
||||
{
|
||||
foreach (var m in s_PrevMaskMaterials)
|
||||
StencilMaterial.Remove(m);
|
||||
s_PrevMaskMaterials.Clear();
|
||||
|
||||
foreach (var m in s_PrevModifiedMaterials)
|
||||
ModifiedMaterial.Remove(m);
|
||||
s_PrevModifiedMaterials.Clear();
|
||||
}
|
||||
|
||||
private Material GetModifiedMaterial(Material baseMaterial, Texture2D texture)
|
||||
{
|
||||
if (0 < m_StencilValue)
|
||||
{
|
||||
baseMaterial = StencilMaterial.Add(baseMaterial, (1 << m_StencilValue) - 1, StencilOp.Keep, CompareFunction.Equal, ColorWriteMask.All, (1 << m_StencilValue) - 1, 0);
|
||||
_maskMaterials.Add(baseMaterial);
|
||||
}
|
||||
|
||||
if (texture == null && m_AnimatableProperties.Length == 0) return baseMaterial;
|
||||
|
||||
var id = m_AnimatableProperties.Length == 0 ? 0 : GetInstanceID();
|
||||
baseMaterial = ModifiedMaterial.Add(baseMaterial, texture, id);
|
||||
_modifiedMaterials.Add(baseMaterial);
|
||||
|
||||
return baseMaterial;
|
||||
}
|
||||
|
||||
internal void UpdateMaterialProperties()
|
||||
{
|
||||
if (m_AnimatableProperties.Length == 0) return;
|
||||
|
||||
//
|
||||
var count = activeMeshIndices.CountFast();
|
||||
var materialCount = Mathf.Max(8, count);
|
||||
canvasRenderer.materialCount = materialCount;
|
||||
var j = 0;
|
||||
for (var i = 0; i < particles.Count; i++)
|
||||
{
|
||||
if (materialCount <= j) break;
|
||||
var ps = particles[i];
|
||||
if (!ps) continue;
|
||||
|
||||
var r = ps.GetComponent<ParticleSystemRenderer>();
|
||||
r.GetSharedMaterials(s_TempMaterials);
|
||||
|
||||
// Main
|
||||
if (activeMeshIndices[i * 2] && 0 < s_TempMaterials.Count)
|
||||
{
|
||||
UpdateMaterialProperties(r, j);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdateMaterialProperties(Renderer r, int index)
|
||||
{
|
||||
if (m_AnimatableProperties.Length == 0 || canvasRenderer.materialCount <= index) return;
|
||||
|
||||
r.GetPropertyBlock(s_Mpb ?? (s_Mpb = new MaterialPropertyBlock()));
|
||||
if (s_Mpb.isEmpty) return;
|
||||
|
||||
// #41: Copy the value from MaterialPropertyBlock to CanvasRenderer
|
||||
var mat = canvasRenderer.GetMaterial(index);
|
||||
if (!mat) return;
|
||||
|
||||
foreach (var ap in m_AnimatableProperties)
|
||||
{
|
||||
ap.UpdateMaterialProperties(mat, s_Mpb);
|
||||
}
|
||||
|
||||
s_Mpb.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
#if !SERIALIZE_FIELD_MASKABLE
|
||||
maskable = m_Maskable;
|
||||
#endif
|
||||
activeMeshIndices.Clear();
|
||||
|
||||
UIParticleUpdater.Register(this);
|
||||
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = false);
|
||||
|
||||
if (isActiveAndEnabled && m_IgnoreCanvasScaler)
|
||||
{
|
||||
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
|
||||
}
|
||||
|
||||
// Create objects.
|
||||
_bakedMesh = MeshPool.Rent();
|
||||
|
||||
base.OnEnable();
|
||||
|
||||
InitializeIfNeeded();
|
||||
}
|
||||
|
||||
private new IEnumerator Start()
|
||||
{
|
||||
// #147: ParticleSystem creates Particles in wrong position during prewarm
|
||||
// #148: Particle Sub Emitter not showing when start game
|
||||
var delayToPlay = particles.AnyFast(ps =>
|
||||
{
|
||||
ps.GetComponentsInChildren(false, s_ParticleSystems);
|
||||
return s_ParticleSystems.AnyFast(p => p.isPlaying && (p.subEmitters.enabled || p.main.prewarm));
|
||||
});
|
||||
s_ParticleSystems.Clear();
|
||||
if (!delayToPlay) yield break;
|
||||
|
||||
Stop();
|
||||
Clear();
|
||||
yield return null;
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the behaviour becomes disabled.
|
||||
/// </summary>
|
||||
protected override void OnDisable()
|
||||
{
|
||||
UIParticleUpdater.Unregister(this);
|
||||
if (!_shouldBeRemoved)
|
||||
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = true);
|
||||
_tracker.Clear();
|
||||
|
||||
// Destroy object.
|
||||
MeshPool.Return(_bakedMesh);
|
||||
_bakedMesh = null;
|
||||
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to update the geometry of the Graphic onto the CanvasRenderer.
|
||||
/// </summary>
|
||||
protected override void UpdateGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when properties have been changed by animation.
|
||||
/// </summary>
|
||||
protected override void OnDidApplyAnimationProperties()
|
||||
{
|
||||
}
|
||||
|
||||
private void InitializeIfNeeded()
|
||||
{
|
||||
if (enabled && m_IsTrail)
|
||||
{
|
||||
UnityEngine.Debug.LogWarningFormat(this, "[UIParticle] The UIParticle component should be removed: {0}\nReason: UIParticle for trails is no longer needed.", name);
|
||||
gameObject.hideFlags = HideFlags.None;
|
||||
_shouldBeRemoved = true;
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this || particles.AnyFast()) return;
|
||||
|
||||
// refresh.
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
UnityEditor.EditorApplication.delayCall += () =>
|
||||
{
|
||||
if (this) RefreshParticles();
|
||||
};
|
||||
else
|
||||
#endif
|
||||
RefreshParticles();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
SetLayoutDirty();
|
||||
SetVerticesDirty();
|
||||
m_ShouldRecalculateStencil = true;
|
||||
RecalculateClipping();
|
||||
#if !SERIALIZE_FIELD_MASKABLE
|
||||
maskable = m_Maskable;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
if (Application.isPlaying) return;
|
||||
InitializeIfNeeded();
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (m_Scale3D == Vector3.zero)
|
||||
{
|
||||
scale = m_Scale;
|
||||
}
|
||||
|
||||
UnityEditor.EditorApplication.delayCall += () =>
|
||||
{
|
||||
if (Application.isPlaying || !this) return;
|
||||
InitializeIfNeeded();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
using PrefabStageUtility = UnityEditor.Experimental.SceneManagement.PrefabStageUtility;
|
||||
#endif
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public class UIParticleOverlayCamera : MonoBehaviour
|
||||
{
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Get instance object.
|
||||
/// If instance does not exist, Find instance in scene, or create new one.
|
||||
/// </summary>
|
||||
public static UIParticleOverlayCamera instance
|
||||
{
|
||||
get
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
// If current scene is prefab mode, create OverlayCamera for editor.
|
||||
var prefabStage = PrefabStageUtility.GetCurrentPrefabStage ();
|
||||
if (prefabStage != null && prefabStage.scene.isLoaded)
|
||||
{
|
||||
if (!s_InstanceForPrefabMode)
|
||||
{
|
||||
// This GameObject is not saved in prefab.
|
||||
// This GameObject is not shown in the hierarchy view.
|
||||
// When you exit prefab mode, this GameObject is destroyed automatically.
|
||||
var go = new GameObject (typeof (UIParticleOverlayCamera).Name + "_ForEditor")
|
||||
{
|
||||
hideFlags = HideFlags.HideAndDontSave,
|
||||
tag = "EditorOnly",
|
||||
};
|
||||
UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene (go, prefabStage.scene);
|
||||
s_InstanceForPrefabMode = go.AddComponent<UIParticleOverlayCamera> ();
|
||||
}
|
||||
return s_InstanceForPrefabMode;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find instance in scene, or create new one.
|
||||
if (object.ReferenceEquals (s_Instance, null))
|
||||
{
|
||||
s_Instance = FindObjectOfType<UIParticleOverlayCamera> () ?? new GameObject (typeof (UIParticleOverlayCamera).Name, typeof (UIParticleOverlayCamera)).GetComponent<UIParticleOverlayCamera> ();
|
||||
s_Instance.gameObject.SetActive (true);
|
||||
s_Instance.enabled = true;
|
||||
}
|
||||
return s_Instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static Camera GetCameraForOvrelay (Canvas canvas)
|
||||
{
|
||||
var i = instance;
|
||||
var rt = canvas.rootCanvas.transform as RectTransform;
|
||||
var cam = i.cameraForOvrelay;
|
||||
var trans = i.transform;
|
||||
cam.enabled = false;
|
||||
|
||||
var pos = rt.localPosition;
|
||||
cam.orthographic = true;
|
||||
cam.orthographicSize = Mathf.Max (pos.x, pos.y);
|
||||
cam.nearClipPlane = 0.3f;
|
||||
cam.farClipPlane = 1000f;
|
||||
pos.z -= 100;
|
||||
trans.localPosition = pos;
|
||||
|
||||
return cam;
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
Camera cameraForOvrelay { get { return m_Camera ? m_Camera : (m_Camera = GetComponent<Camera> ()) ? m_Camera : (m_Camera = gameObject.AddComponent<Camera> ()); } }
|
||||
Camera m_Camera;
|
||||
static UIParticleOverlayCamera s_Instance;
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
static UIParticleOverlayCamera s_InstanceForPrefabMode;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Awake is called when the script instance is being loaded.
|
||||
/// </summary>
|
||||
void Awake ()
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
// OverlayCamera for editor.
|
||||
if (hideFlags == HideFlags.HideAndDontSave || s_InstanceForPrefabMode == this)
|
||||
{
|
||||
s_InstanceForPrefabMode = GetComponent<UIParticleOverlayCamera> ();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Hold the instance.
|
||||
if (s_Instance == null)
|
||||
{
|
||||
s_Instance = GetComponent<UIParticleOverlayCamera> ();
|
||||
}
|
||||
// If the instance is duplicated, destroy itself.
|
||||
else if (s_Instance != this)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning ("Multiple " + typeof (UIParticleOverlayCamera).Name + " in scene.", this.gameObject);
|
||||
enabled = false;
|
||||
#if UNITY_EDITOR
|
||||
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
DestroyImmediate (gameObject);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Destroy (gameObject);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cameraForOvrelay.enabled = false;
|
||||
|
||||
// Singleton has DontDestroy flag.
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
DontDestroyOnLoad (gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the MonoBehaviour will be destroyed.
|
||||
/// </summary>
|
||||
void OnDestroy ()
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
|
||||
if (s_InstanceForPrefabMode == this)
|
||||
{
|
||||
s_InstanceForPrefabMode = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Clear instance on destroy.
|
||||
if (s_Instance == this)
|
||||
{
|
||||
s_Instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
295
Scripts/UIParticleUpdater.cs
Executable file
295
Scripts/UIParticleUpdater.cs
Executable file
@@ -0,0 +1,295 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
internal static class UIParticleUpdater
|
||||
{
|
||||
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
|
||||
static MaterialPropertyBlock s_Mpb;
|
||||
static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048];
|
||||
private static int frameCount = 0;
|
||||
|
||||
|
||||
public static void Register(UIParticle particle)
|
||||
{
|
||||
if (!particle) return;
|
||||
s_ActiveParticles.Add(particle);
|
||||
}
|
||||
|
||||
public static void Unregister(UIParticle particle)
|
||||
{
|
||||
if (!particle) return;
|
||||
s_ActiveParticles.Remove(particle);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoadMethod]
|
||||
#endif
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void InitializeOnLoad()
|
||||
{
|
||||
MeshHelper.Init();
|
||||
MeshPool.Init();
|
||||
CombineInstanceArrayPool.Init();
|
||||
|
||||
Canvas.willRenderCanvases -= Refresh;
|
||||
Canvas.willRenderCanvases += Refresh;
|
||||
}
|
||||
|
||||
private static void Refresh()
|
||||
{
|
||||
// Do not allow it to be called in the same frame.
|
||||
if (frameCount == Time.frameCount) return;
|
||||
frameCount = Time.frameCount;
|
||||
|
||||
Profiler.BeginSample("[UIParticle] Refresh");
|
||||
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Refresh(s_ActiveParticles[i]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
private static void Refresh(UIParticle particle)
|
||||
{
|
||||
if (!particle || !particle.bakedMesh || !particle.canvas || !particle.canvasRenderer) return;
|
||||
|
||||
Profiler.BeginSample("[UIParticle] Modify scale");
|
||||
ModifyScale(particle);
|
||||
Profiler.EndSample();
|
||||
|
||||
Profiler.BeginSample("[UIParticle] Bake mesh");
|
||||
BakeMesh(particle);
|
||||
Profiler.EndSample();
|
||||
|
||||
// if (QualitySettings.activeColorSpace == ColorSpace.Linear)
|
||||
// {
|
||||
// Profiler.BeginSample("[UIParticle] Modify color space to linear");
|
||||
// particle.bakedMesh.ModifyColorSpaceToLinear();
|
||||
// Profiler.EndSample();
|
||||
// }
|
||||
|
||||
Profiler.BeginSample("[UIParticle] Set mesh to CanvasRenderer");
|
||||
particle.canvasRenderer.SetMesh(particle.bakedMesh);
|
||||
Profiler.EndSample();
|
||||
|
||||
Profiler.BeginSample("[UIParticle] Update Animatable Material Properties");
|
||||
particle.UpdateMaterialProperties();
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
private static void ModifyScale(UIParticle particle)
|
||||
{
|
||||
if (!particle.ignoreCanvasScaler || !particle.canvas) return;
|
||||
|
||||
// Ignore Canvas scaling.
|
||||
var s = particle.canvas.rootCanvas.transform.localScale;
|
||||
var modifiedScale = new Vector3(
|
||||
Mathf.Approximately(s.x, 0) ? 1 : 1 / s.x,
|
||||
Mathf.Approximately(s.y, 0) ? 1 : 1 / s.y,
|
||||
Mathf.Approximately(s.z, 0) ? 1 : 1 / s.z);
|
||||
|
||||
// Scale is already modified.
|
||||
var transform = particle.transform;
|
||||
if (Mathf.Approximately((transform.localScale - modifiedScale).sqrMagnitude, 0)) return;
|
||||
|
||||
transform.localScale = modifiedScale;
|
||||
}
|
||||
|
||||
private static Matrix4x4 GetScaledMatrix(ParticleSystem particle)
|
||||
{
|
||||
var transform = particle.transform;
|
||||
var main = particle.main;
|
||||
var space = main.simulationSpace;
|
||||
if (space == ParticleSystemSimulationSpace.Custom && !main.customSimulationSpace)
|
||||
space = ParticleSystemSimulationSpace.Local;
|
||||
|
||||
switch (space)
|
||||
{
|
||||
case ParticleSystemSimulationSpace.Local:
|
||||
return Matrix4x4.Rotate(transform.rotation).inverse
|
||||
* Matrix4x4.Scale(transform.lossyScale).inverse;
|
||||
case ParticleSystemSimulationSpace.World:
|
||||
return transform.worldToLocalMatrix;
|
||||
case ParticleSystemSimulationSpace.Custom:
|
||||
// #78: Support custom simulation space.
|
||||
return transform.worldToLocalMatrix
|
||||
* Matrix4x4.Translate(main.customSimulationSpace.position);
|
||||
default:
|
||||
return Matrix4x4.identity;
|
||||
}
|
||||
}
|
||||
|
||||
private static void BakeMesh(UIParticle particle)
|
||||
{
|
||||
// Clear mesh before bake.
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Clear mesh before bake");
|
||||
MeshHelper.Clear();
|
||||
particle.bakedMesh.Clear(false);
|
||||
Profiler.EndSample();
|
||||
|
||||
// Get camera for baking mesh.
|
||||
var camera = BakingCamera.GetCamera(particle.canvas);
|
||||
var root = particle.transform;
|
||||
var rootMatrix = Matrix4x4.Rotate(root.rotation).inverse
|
||||
* Matrix4x4.Scale(root.lossyScale).inverse;
|
||||
var scale = particle.ignoreCanvasScaler
|
||||
? Vector3.Scale(particle.canvas.rootCanvas.transform.localScale, particle.scale3D)
|
||||
: particle.scale3D;
|
||||
var scaleMatrix = Matrix4x4.Scale(scale);
|
||||
|
||||
// Cache position
|
||||
var position = particle.transform.position;
|
||||
var diff = position - particle.cachedPosition;
|
||||
diff.x *= 1f - 1f / Mathf.Max(0.001f, scale.x);
|
||||
diff.y *= 1f - 1f / Mathf.Max(0.001f, scale.y);
|
||||
diff.z *= 1f - 1f / Mathf.Max(0.001f, scale.z);
|
||||
|
||||
particle.cachedPosition = position;
|
||||
|
||||
if (particle.activeMeshIndices.CountFast() == 0)
|
||||
diff = Vector3.zero;
|
||||
|
||||
for (var i = 0; i < particle.particles.Count; i++)
|
||||
{
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Push index");
|
||||
MeshHelper.activeMeshIndices.Add(false);
|
||||
MeshHelper.activeMeshIndices.Add(false);
|
||||
Profiler.EndSample();
|
||||
|
||||
// No particle to render.
|
||||
var currentPs = particle.particles[i];
|
||||
if (!currentPs || !currentPs.IsAlive() || currentPs.particleCount == 0) continue;
|
||||
var r = currentPs.GetComponent<ParticleSystemRenderer>();
|
||||
if (!r.sharedMaterial && !r.trailMaterial) continue;
|
||||
|
||||
// Calc matrix.
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Calc matrix");
|
||||
var matrix = rootMatrix;
|
||||
if (currentPs.transform != root)
|
||||
{
|
||||
if (currentPs.main.simulationSpace == ParticleSystemSimulationSpace.Local)
|
||||
{
|
||||
var relativePos = root.InverseTransformPoint(currentPs.transform.position);
|
||||
matrix = Matrix4x4.Translate(relativePos) * matrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix = matrix * Matrix4x4.Translate(-root.position);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix = GetScaledMatrix(currentPs);
|
||||
}
|
||||
|
||||
matrix = scaleMatrix * matrix;
|
||||
Profiler.EndSample();
|
||||
|
||||
// Extra world simulation.
|
||||
if (currentPs.main.simulationSpace == ParticleSystemSimulationSpace.World && 0 < diff.sqrMagnitude)
|
||||
{
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Extra world simulation");
|
||||
var count = currentPs.particleCount;
|
||||
if (s_Particles.Length < count)
|
||||
{
|
||||
var size = Mathf.NextPowerOfTwo(count);
|
||||
s_Particles = new ParticleSystem.Particle[size];
|
||||
}
|
||||
|
||||
currentPs.GetParticles(s_Particles);
|
||||
for (var j = 0; j < count; j++)
|
||||
{
|
||||
var p = s_Particles[j];
|
||||
p.position += diff;
|
||||
s_Particles[j] = p;
|
||||
}
|
||||
|
||||
currentPs.SetParticles(s_Particles, count);
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
// #102: Do not bake particle system to mesh when the alpha is zero.
|
||||
if (Mathf.Approximately(particle.canvasRenderer.GetInheritedAlpha(), 0))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
// Bake main particles.
|
||||
if (CanBakeMesh(r))
|
||||
{
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Main Particles");
|
||||
var hash = currentPs.GetMaterialHash(false);
|
||||
if (hash != 0)
|
||||
{
|
||||
var m = MeshHelper.GetTemporaryMesh();
|
||||
r.BakeMesh(m, camera, true);
|
||||
MeshHelper.Push(i * 2, hash, m, matrix);
|
||||
}
|
||||
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
// Bake trails particles.
|
||||
if (currentPs.trails.enabled)
|
||||
{
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Trails Particles");
|
||||
var hash = currentPs.GetMaterialHash(true);
|
||||
if (hash != 0)
|
||||
{
|
||||
matrix = currentPs.main.simulationSpace == ParticleSystemSimulationSpace.Local && currentPs.trails.worldSpace
|
||||
? matrix * Matrix4x4.Translate(-currentPs.transform.position)
|
||||
: matrix;
|
||||
|
||||
var m = MeshHelper.GetTemporaryMesh();
|
||||
try
|
||||
{
|
||||
r.BakeTrailsMesh(m, camera, true);
|
||||
MeshHelper.Push(i * 2 + 1, hash, m, matrix);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MeshHelper.DiscardTemporaryMesh(m);
|
||||
}
|
||||
}
|
||||
|
||||
Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
|
||||
// Set active indices.
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > Set active indices");
|
||||
particle.activeMeshIndices = MeshHelper.activeMeshIndices;
|
||||
Profiler.EndSample();
|
||||
|
||||
// Combine
|
||||
Profiler.BeginSample("[UIParticle] Bake Mesh > CombineMesh");
|
||||
MeshHelper.CombineMesh(particle.bakedMesh);
|
||||
MeshHelper.Clear();
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
private static bool CanBakeMesh(ParticleSystemRenderer renderer)
|
||||
{
|
||||
// #69: Editor crashes when mesh is set to null when `ParticleSystem.RenderMode = Mesh`
|
||||
if (renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.mesh == null) return false;
|
||||
|
||||
// #61: When `ParticleSystem.RenderMode = None`, an error occurs
|
||||
if (renderer.renderMode == ParticleSystemRenderMode.None) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/UIParticleUpdater.cs.meta
Normal file
11
Scripts/UIParticleUpdater.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0e708dc2e3034ba9a5c51db4252c7e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -100
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
299
Scripts/Utils.cs
Normal file
299
Scripts/Utils.cs
Normal file
@@ -0,0 +1,299 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
internal static class SpriteExtensions
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
private static Type tSpriteEditorExtension =
|
||||
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
||||
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
|
||||
|
||||
private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension
|
||||
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
|
||||
public static Texture2D GetActualTexture(this Sprite self)
|
||||
{
|
||||
if (!self) return null;
|
||||
|
||||
if (Application.isPlaying) return self.texture;
|
||||
var ret = miGetActiveAtlasTexture.Invoke(null, new[] {self}) as Texture2D;
|
||||
return ret ? ret : self.texture;
|
||||
}
|
||||
#else
|
||||
internal static Texture2D GetActualTexture(this Sprite self)
|
||||
{
|
||||
return self ? self.texture : null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static class ListExtensions
|
||||
{
|
||||
public static bool SequenceEqualFast(this List<bool> self, List<bool> value)
|
||||
{
|
||||
if (self.Count != value.Count) return false;
|
||||
for (var i = 0; i < self.Count; ++i)
|
||||
{
|
||||
if (self[i] != value[i]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int CountFast(this List<bool> self)
|
||||
{
|
||||
var count = 0;
|
||||
for (var i = 0; i < self.Count; ++i)
|
||||
{
|
||||
if (self[i]) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static bool AnyFast<T>(this List<T> self) where T : Object
|
||||
{
|
||||
for (var i = 0; i < self.Count; ++i)
|
||||
{
|
||||
if (self[i]) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool AnyFast<T>(this List<T> self, Predicate<T> predicate) where T : Object
|
||||
{
|
||||
for (var i = 0; i < self.Count; ++i)
|
||||
{
|
||||
if (self[i] && predicate(self[i])) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class MeshExtensions
|
||||
{
|
||||
// static readonly List<Color32> s_Colors = new List<Color32>();
|
||||
|
||||
// public static void ModifyColorSpaceToLinear(this Mesh self)
|
||||
// {
|
||||
// self.GetColors(s_Colors);
|
||||
//
|
||||
// for (var i = 0; i < s_Colors.Count; i++)
|
||||
// s_Colors[i] = ((Color) s_Colors[i]).gamma;
|
||||
//
|
||||
// self.SetColors(s_Colors);
|
||||
// s_Colors.Clear();
|
||||
// }
|
||||
|
||||
public static void Clear(this CombineInstance[] self)
|
||||
{
|
||||
for (var i = 0; i < self.Length; i++)
|
||||
{
|
||||
MeshPool.Return(self[i].mesh);
|
||||
self[i].mesh = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class MeshPool
|
||||
{
|
||||
private static readonly Stack<Mesh> s_Pool = new Stack<Mesh>(32);
|
||||
private static readonly HashSet<int> s_HashPool = new HashSet<int>();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
}
|
||||
|
||||
static MeshPool()
|
||||
{
|
||||
for (var i = 0; i < 32; i++)
|
||||
{
|
||||
var m = new Mesh();
|
||||
m.MarkDynamic();
|
||||
s_Pool.Push(m);
|
||||
s_HashPool.Add(m.GetInstanceID());
|
||||
}
|
||||
}
|
||||
|
||||
public static Mesh Rent()
|
||||
{
|
||||
Mesh m;
|
||||
while (0 < s_Pool.Count)
|
||||
{
|
||||
m = s_Pool.Pop();
|
||||
if (m)
|
||||
{
|
||||
s_HashPool.Remove(m.GetInstanceID());
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
m = new Mesh();
|
||||
m.MarkDynamic();
|
||||
return m;
|
||||
}
|
||||
|
||||
public static void Return(Mesh mesh)
|
||||
{
|
||||
if (!mesh) return;
|
||||
|
||||
var id = mesh.GetInstanceID();
|
||||
if (s_HashPool.Contains(id)) return;
|
||||
|
||||
mesh.Clear(false);
|
||||
s_Pool.Push(mesh);
|
||||
s_HashPool.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class CombineInstanceArrayPool
|
||||
{
|
||||
private static readonly Dictionary<int, CombineInstance[]> s_Pool;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
s_Pool.Clear();
|
||||
}
|
||||
|
||||
static CombineInstanceArrayPool()
|
||||
{
|
||||
s_Pool = new Dictionary<int, CombineInstance[]>();
|
||||
}
|
||||
|
||||
public static CombineInstance[] Get(List<CombineInstance> src)
|
||||
{
|
||||
CombineInstance[] dst;
|
||||
var count = src.Count;
|
||||
if (!s_Pool.TryGetValue(count, out dst))
|
||||
{
|
||||
dst = new CombineInstance[count];
|
||||
s_Pool.Add(count, dst);
|
||||
}
|
||||
|
||||
for (var i = 0; i < src.Count; i++)
|
||||
{
|
||||
dst[i].mesh = src[i].mesh;
|
||||
dst[i].transform = src[i].transform;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
public static CombineInstance[] Get(List<CombineInstanceEx> src, int count)
|
||||
{
|
||||
CombineInstance[] dst;
|
||||
if (!s_Pool.TryGetValue(count, out dst))
|
||||
{
|
||||
dst = new CombineInstance[count];
|
||||
s_Pool.Add(count, dst);
|
||||
}
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
dst[i].mesh = src[i].mesh;
|
||||
dst[i].transform = src[i].transform;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ParticleSystemExtensions
|
||||
{
|
||||
public static void SortForRendering(this List<ParticleSystem> self, Transform transform, bool sortByMaterial)
|
||||
{
|
||||
self.Sort((a, b) =>
|
||||
{
|
||||
var tr = transform;
|
||||
var aRenderer = a.GetComponent<ParticleSystemRenderer>();
|
||||
var bRenderer = b.GetComponent<ParticleSystemRenderer>();
|
||||
|
||||
// Render queue: ascending
|
||||
var aMat = aRenderer.sharedMaterial ?? aRenderer.trailMaterial;
|
||||
var bMat = bRenderer.sharedMaterial ?? bRenderer.trailMaterial;
|
||||
if (!aMat && !bMat) return 0;
|
||||
if (!aMat) return -1;
|
||||
if (!bMat) return 1;
|
||||
|
||||
if (sortByMaterial)
|
||||
return aMat.GetInstanceID() - bMat.GetInstanceID();
|
||||
|
||||
if (aMat.renderQueue != bMat.renderQueue)
|
||||
return aMat.renderQueue - bMat.renderQueue;
|
||||
|
||||
// Sorting layer: ascending
|
||||
if (aRenderer.sortingLayerID != bRenderer.sortingLayerID)
|
||||
return aRenderer.sortingLayerID - bRenderer.sortingLayerID;
|
||||
|
||||
// Sorting order: ascending
|
||||
if (aRenderer.sortingOrder != bRenderer.sortingOrder)
|
||||
return aRenderer.sortingOrder - bRenderer.sortingOrder;
|
||||
|
||||
// Z position & sortingFudge: descending
|
||||
var aTransform = a.transform;
|
||||
var bTransform = b.transform;
|
||||
var aPos = tr.InverseTransformPoint(aTransform.position).z + aRenderer.sortingFudge;
|
||||
var bPos = tr.InverseTransformPoint(bTransform.position).z + bRenderer.sortingFudge;
|
||||
if (!Mathf.Approximately(aPos, bPos))
|
||||
return (int) Mathf.Sign(bPos - aPos);
|
||||
|
||||
return (int) Mathf.Sign(GetIndex(self, a) - GetIndex(self, b));
|
||||
});
|
||||
}
|
||||
|
||||
private static int GetIndex(IList<ParticleSystem> list, Object ps)
|
||||
{
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (list[i].GetInstanceID() == ps.GetInstanceID()) return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static long GetMaterialHash(this ParticleSystem self, bool trail)
|
||||
{
|
||||
if (!self) return 0;
|
||||
|
||||
var r = self.GetComponent<ParticleSystemRenderer>();
|
||||
var mat = trail ? r.trailMaterial : r.sharedMaterial;
|
||||
|
||||
if (!mat) return 0;
|
||||
|
||||
var tex = trail ? null : self.GetTextureForSprite();
|
||||
return ((long) mat.GetHashCode() << 32) + (tex ? tex.GetHashCode() : 0);
|
||||
}
|
||||
|
||||
public static Texture2D GetTextureForSprite(this ParticleSystem self)
|
||||
{
|
||||
if (!self) return null;
|
||||
|
||||
// Get sprite's texture.
|
||||
var tsaModule = self.textureSheetAnimation;
|
||||
if (!tsaModule.enabled || tsaModule.mode != ParticleSystemAnimationMode.Sprites) return null;
|
||||
|
||||
for (var i = 0; i < tsaModule.spriteCount; i++)
|
||||
{
|
||||
var sprite = tsaModule.GetSprite(i);
|
||||
if (!sprite) continue;
|
||||
|
||||
return sprite.GetActualTexture();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Exec(this List<ParticleSystem> self, Action<ParticleSystem> action)
|
||||
{
|
||||
self.RemoveAll(p => !p);
|
||||
self.ForEach(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Utils.cs.meta
Normal file
11
Scripts/Utils.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d188d31b140094ebc84a9caafbc7ac71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -77,7 +77,7 @@
|
||||
v2f OUT;
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
||||
OUT.texcoord = IN.texcoord;
|
||||
OUT.texcoord = TRANSFORM_TEX(IN.texcoord, _MainTex);
|
||||
#ifdef UNITY_HALF_TEXEL_OFFSET
|
||||
OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
|
||||
#endif
|
||||
|
||||
Binary file not shown.
31
package.json
31
package.json
@@ -1,19 +1,30 @@
|
||||
{
|
||||
"name": "com.coffee.ui-particle",
|
||||
"displayName": "UI Particle",
|
||||
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
|
||||
"version": "2.0.0",
|
||||
"unity": "2018.2",
|
||||
"displayName": "UI Particle",
|
||||
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
|
||||
"version": "3.3.8",
|
||||
"unity": "2018.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mob-sakai/ParticleEffectForUGUI.git"
|
||||
},
|
||||
"src": "Assets/Coffee/UIExtensions/UIParticle",
|
||||
"author": "mob-sakai <sakai861104@gmail.com> (https://github.com/mob-sakai)",
|
||||
"editorOnly": false,
|
||||
"upmSupport": true,
|
||||
"dependencies": {
|
||||
}
|
||||
"dependencies": {},
|
||||
"keywords": [
|
||||
"ui",
|
||||
"particle"
|
||||
],
|
||||
"samples": [
|
||||
{
|
||||
"displayName": "Demo",
|
||||
"description": "UI Particle Demo",
|
||||
"path": "Samples~/Demo"
|
||||
},
|
||||
{
|
||||
"displayName": "Cartoon FX & War FX Demo",
|
||||
"description": "Cartoon FX & War FX Demo",
|
||||
"path": "Samples~/Cartoon FX & War FX Demo"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user