Compare commits

...

27 Commits
3.0.1 ... 3.3.2

Author SHA1 Message Date
semantic-release-bot
ba3b80db7a chore(release): 3.3.2 [skip ci]
## [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](c0aa89bd6f)), closes [#121](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/121)
* submeshes can't over 8 ([2a1f334](2a1f3345ba)), closes [#122](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/122)
2021-02-01 15:39:59 +00:00
mob-sakai
2a1f3345ba fix: submeshes can't over 8
Close #122
2021-02-02 00:38:19 +09:00
mob-sakai
c0aa89bd6f fix: _cachedPosition defaults to localPosition
Close #121
2021-02-01 23:51:35 +09:00
semantic-release-bot
501aa7b7f1 chore(release): 3.3.1 [skip ci]
## [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](d11cd0a06d)), closes [#119](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/119)
* the trail is incorrect in SimulationSpace.Local ([9313489](9313489552))
2021-02-01 14:43:01 +00:00
mob-sakai
9313489552 fix: the trail is incorrect in SimulationSpace.Local 2021-02-01 23:33:06 +09:00
mob-sakai
63b36a45b9 fix for .Net 3.5 2021-01-06 17:43:14 +09:00
mob-sakai
087dbe99b9 test: update test workflow 2021-01-06 17:22:37 +09:00
LacusCon
d11cd0a06d fix: ignore material check and transform check
Add default sort by index.

Close #119
2021-01-06 16:50:48 +09:00
semantic-release-bot
429ff2dd09 chore(release): 3.3.0 [skip ci]
# [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](2ec81da048)), 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](08c4aba8ab)), closes [#118](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/118)
* show/hide materials in inspector ([4b4aebf](4b4aebff8c))
* shrink rendering by material ([46a7ddd](46a7dddd11)), closes [#113](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/113)
2020-11-20 07:28:45 +00:00
mob-sakai
3f16943ccd docs: update readme 2020-11-20 16:25:37 +09:00
mob-sakai
4b4aebff8c feat: show/hide materials in inspector 2020-11-20 16:25:37 +09:00
mob-sakai
46a7dddd11 feat: shrink rendering by material
NOTE: Performance will be improved, but in some cases the rendering is not correct.

Close #113
2020-11-20 15:17:43 +09:00
mob-sakai
2ec81da048 fix: the particles may disappear unintentionally
Close #117
2020-11-20 13:12:07 +09:00
mob-sakai
08c4aba8ab feat: ignore rendering of particle systems that do not have a SharedMaterial and TrailMaterial
Close #118
2020-11-20 13:12:07 +09:00
mob-sakai
44889c8a33 build: support main branch 2020-11-16 03:12:06 +09:00
semantic-release-bot
6884c62687 chore(release): 3.2.0 [skip ci]
# [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](08273cb0c3)), closes [#115](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/115)
2020-11-15 18:08:38 +00:00
mob-sakai
fc4bd708fd refactor: refactor 2020-11-16 03:07:35 +09:00
mob-sakai
08273cb0c3 feat: compatibility with other IMaterialModifier
Close #115
2020-11-16 03:07:24 +09:00
semantic-release-bot
06d8fae58f chore(release): 3.1.1 [skip ci]
## [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](68669c7396)), closes [#114](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/114)
* null Reference when creating New Scene after Prefab was open in PrefabMode ([22bcecd](22bcecd0ab)), closes [#111](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/111)
2020-11-09 16:52:34 +00:00
mob-sakai
22bcecd0ab fix: null Reference when creating New Scene after Prefab was open in PrefabMode
Close #111
2020-11-10 01:51:24 +09:00
mob-sakai
68669c7396 fix: error on build in Unity 2019.3.11-15
Close #114
2020-11-10 01:44:24 +09:00
mob-sakai
1b1ca56461 docs: update readme 2020-10-29 02:13:45 +09:00
semantic-release-bot
b322db3ca9 chore(release): 3.1.0 [skip ci]
# [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](82f81efd7e))

### Features

* maskable option to ignore masking ([af5f7e9](af5f7e90b0)), closes [#109](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/109)
2020-10-28 17:05:39 +00:00
mob-sakai
44beab0de8 test: update test workflow 2020-10-29 01:57:17 +09:00
mob-sakai
82f81efd7e fix: compile error in 2018.2 2020-10-29 01:57:17 +09:00
mob-sakai
af5f7e90b0 feat: maskable option to ignore masking
Close #109
2020-10-28 22:19:15 +09:00
mob-sakai
3d8f11ba82 docs: add warning for the obsolete tags and branches 2020-10-28 13:13:11 +09:00
10 changed files with 271 additions and 205 deletions

View File

@@ -4,7 +4,7 @@ on:
push: push:
branches: branches:
- preview - preview
- master - main
- v*.x - v*.x
tags-ignore: tags-ignore:
- "**" - "**"

96
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,96 @@
# 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",
]
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
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 }}
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
customParameters: -enableCodeCoverage
# customParameters: -enableCodeCoverage -coverageOptions assemblyFilters:+CSharpCompilerSettings_,-*-CSharp,-*.Tests,-IgnoreAccessibility
- 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' ' '`

View File

@@ -1,133 +0,0 @@
# Secrets
# ULF_REPO: Git repository url contains ulf files. https://mob-sakai:{{token}}@github.com/mob-sakai/ulfs.git
name: unity-test
on:
push:
branches:
- develop
tags:
- "!*"
pull_request:
types:
- opened
- synchronize
jobs:
release-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
npm i --no-save https://gist.github.com/mob-sakai/c90044338361af97a7e8c8a78425bdb3
npx semantic-release -e @mob-sakai/semantic-release-upm --dry-run --branches develop
env:
GITHUB_TOKEN: ${{ github.token }}
unity-test:
strategy:
fail-fast: false
matrix:
unity:
[
"2018.4.25f1",
"2019.4.10f1",
"2020.1.5f1",
]
env:
RUN_UNITY: "xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath ."
runs-on: ubuntu-latest
container:
# Use Unity image from https://hub.docker.com/r/gableroux/unity3d/tags
image: gableroux/unity3d:${{ matrix.unity }}
steps:
# Activate Unity Editor
- name: Activate Unity Editor
id: activation
run: |
# Clone ulfs.
apt-get update
apt-get install software-properties-common -y
apt-add-repository ppa:git-core/ppa -y
apt-get update
apt-get install git -y
git clone --depth 1 ${ULF_REPO} .ulfs
# Activate with ulf.
ULF_FILE=.ulfs/Unity_v${UNITY_VERSION}.ulf
echo $ULF_FILE
if [ -e ${ULF_FILE} ]; then
/opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -manualLicenseFile ${ULF_FILE} \
| grep -E 'LICENSE SYSTEM.*\w{32} != \w{32}' && FAILED=true
else
echo "::error:: ulf file '${ULF_FILE}' is not found."
FAILED=true
fi
# Activation failed.
if [ $FAILED ]; then
echo "::error:: the unity activation may have failed. manual activation is required.%0A \
1. download the artifact's .alf file.%0A \
2. Go to https://license.unity3d.com/manual to activate manually.%0A \
3. Generate a .ulf file from the .alf file and download it.%0A \
4. Rename .ulf to 'Unity_v${UNITY_VERSION}.ulf'.%0A \
5. Add file to ulfs repository.%0A \
5. Re-run the jobs."
/opt/Unity/Editor/Unity -quit -batchmode -nographics -logFile -createManualActivationFile
exit 1
fi
env:
ULF_REPO: ${{ secrets.ULF_REPO }}
UNITY_VERSION: ${{ matrix.unity }}
# (On failed activation) Upload unity activation file
- name: Upload unity activation file
uses: actions/upload-artifact@v2
if: failure()
with:
name: Unity_v${{ matrix.unity }}.alf
path: ./*.alf
# Setup testspace
- uses: testspace-com/setup-testspace@v1
with:
domain: ${{ github.repository_owner }}
# Checkout sandbox project
- uses: actions/checkout@v2
with:
ref: "sandbox"
submodules: "true"
fetch-depth: "1"
# Update package submodule
- name: "Update package submodule"
working-directory: Packages/dev
run: git checkout ${{ github.head_ref }}
# Run playmode tests
- name: "Run playmode tests"
if: always() && steps.activation.conclusion == 'success'
run: |
# Install codecoverage
if [ -z "`echo ${{ matrix.unity }} | grep 2018.`" ]; then
npm i -g openupm-cli
openupm add com.unity.testtools.codecoverage
fi
$RUN_UNITY -runTests -testPlatform playmode -enableCodeCoverage || exit 0
# Run editmode tests
- name: "Run editmode tests"
if: always() && steps.activation.conclusion == 'success'
run: |
$RUN_UNITY -runTests -testPlatform editmode -enableCodeCoverage || exit 0
# Push test results
- name: Push test results
if: always() && steps.activation.conclusion == 'success'
run: testspace "[${{ matrix.unity }}]TestResults-*.xml" "[Code Coverage]CodeCoverage/**/TestCoverageResults_*.xml"

View File

@@ -1,3 +1,60 @@
## [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) ## [3.0.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.0.0...3.0.1) (2020-10-28)

View File

@@ -1,6 +1,8 @@
Particle Effect For UGUI (UI Particle) Particle Effect For UGUI (UI Particle)
=== ===
**: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. 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. The particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.
@@ -58,7 +60,7 @@ Compares this "Baking mesh" approach with the conventional approach:
## Demo ## 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) * [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 * [Cartoon FX Free][CFX] & [War FX][WFX] (by [Jean Moreno (JMO)][JMO]) with UIParticle
@@ -93,14 +95,11 @@ openupm add com.coffee.ui-particle
Find the manifest.json file in the Packages folder of your project and add a line to `dependencies` field. Find the manifest.json file in the Packages folder of your project and add a line to `dependencies` field.
* Major version: ![](https://img.shields.io/github/v/release/mob-sakai/ParticleEffectForUGUI) * `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git"`
`"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git"`
* Preview version: ![](https://img.shields.io/github/v/release/mob-sakai/ParticleEffectForUGUI?include_prereleases)
`"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#preview"`
To update the package, change suffix `#{version}` to the target version. To update the package, change suffix `#{version}` to the target version.
* e.g. `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#3.0.0",` * `"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. Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to install and update the package.
@@ -148,11 +147,16 @@ Unity 2018.2 supports embedded packages.
`UIParticle` controls the ParticleSystems that is attached to its own game objects and child game objects. `UIParticle` controls the ParticleSystems that is attached to its own game objects and child game objects.
| Properties | Screenshot | ![](https://user-images.githubusercontent.com/12690315/99765566-af129a80-2b42-11eb-88f6-661182d0b619.png)
| -- | -- |
| **Ignore Canvas Scale:** Ignore the scale of the root canvas. This prevents it from displaying small even in hierarchy scaling mode of ParticleSystem. <br>**Scale:** Scale the rendering. When the `3D` toggle is enabled, 3D scale (x,y,z) is supported. <br>**AnimatableProperties:** If you want update material properties (e.g. `_MainTex_ST`, `_Color`) in AnimationClip, use this to mark the changes. <br>**Rendering Order:** The ParticleSystems to be rendered. You can change the rendering order and the materials. | ![][inspector] |
[inspector]:https://user-images.githubusercontent.com/12690315/95017219-1cea2c00-0693-11eb-9490-c52b8d0fdbb6.png | 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. NOTE: Press `Refresh` button to reconstruct rendering order based on children ParticleSystem's sorting order and z position.

View File

@@ -25,12 +25,15 @@ namespace Coffee.UIExtensions
private static readonly List<UIParticle> s_TempParents = new List<UIParticle>(); private static readonly List<UIParticle> s_TempParents = new List<UIParticle>();
private static readonly List<UIParticle> s_TempChildren = new List<UIParticle>(); private static readonly List<UIParticle> s_TempChildren = new List<UIParticle>();
private SerializedProperty _spMaskable;
private SerializedProperty _spScale; private SerializedProperty _spScale;
private SerializedProperty _spIgnoreCanvasScaler; private SerializedProperty _spIgnoreCanvasScaler;
private SerializedProperty _spAnimatableProperties; private SerializedProperty _spAnimatableProperties;
private SerializedProperty _spShrinkByMaterial;
private ReorderableList _ro; private ReorderableList _ro;
private bool _xyzMode; private bool _xyzMode;
private bool _showMaterials;
private static readonly List<string> s_MaskablePropertyNames = new List<string> private static readonly List<string> s_MaskablePropertyNames = new List<string>
{ {
@@ -52,13 +55,19 @@ namespace Coffee.UIExtensions
protected override void OnEnable() protected override void OnEnable()
{ {
base.OnEnable(); base.OnEnable();
_spMaskable = serializedObject.FindProperty("m_Maskable");
_spScale = serializedObject.FindProperty("m_Scale3D"); _spScale = serializedObject.FindProperty("m_Scale3D");
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler"); _spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); _spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
var sp = serializedObject.FindProperty("m_Particles"); var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true); _ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4; _ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
_ro.elementHeightCallback = _ => _showMaterials
? 3 * (EditorGUIUtility.singleLineHeight + 2)
: EditorGUIUtility.singleLineHeight + 2;
_ro.drawElementCallback = (rect, index, active, focused) => _ro.drawElementCallback = (rect, index, active, focused) =>
{ {
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues); EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
@@ -66,6 +75,7 @@ namespace Coffee.UIExtensions
rect.height = EditorGUIUtility.singleLineHeight; rect.height = EditorGUIUtility.singleLineHeight;
var p = sp.GetArrayElementAtIndex(index); var p = sp.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(rect, p, GUIContent.none); EditorGUI.ObjectField(rect, p, GUIContent.none);
if (!_showMaterials) return;
rect.x += 15; rect.x += 15;
rect.width -= 15; rect.width -= 15;
@@ -85,15 +95,15 @@ namespace Coffee.UIExtensions
}; };
_ro.drawHeaderCallback += rect => _ro.drawHeaderCallback += rect =>
{ {
#if !UNITY_2019_3_OR_NEWER
rect.y -= 1;
#endif
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder); EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder);
#if UNITY_2019_3_OR_NEWER var content = EditorGUIUtility.IconContent(_showMaterials ? "VisibilityOn" : "VisibilityOff");
rect = new Rect(rect.width - 55, rect.y, 80, rect.height); _showMaterials = GUI.Toggle(new Rect(rect.width - 55, rect.y, 24, 20), _showMaterials, content, EditorStyles.label);
#else
rect = new Rect(rect.width - 55, rect.y - 1, 80, rect.height);
#endif
if (GUI.Button(rect, s_ContentRefresh, EditorStyles.miniButton)) if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton))
{ {
foreach (UIParticle t in targets) foreach (UIParticle t in targets)
{ {
@@ -127,6 +137,9 @@ namespace Coffee.UIExtensions
serializedObject.Update(); serializedObject.Update();
// Maskable
EditorGUILayout.PropertyField(_spMaskable);
// IgnoreCanvasScaler // IgnoreCanvasScaler
using (var ccs = new EditorGUI.ChangeCheckScope()) using (var ccs = new EditorGUI.ChangeCheckScope())
{ {
@@ -159,6 +172,9 @@ namespace Coffee.UIExtensions
t.SetMaterialDirty(); t.SetMaterialDirty();
} }
// ShrinkByMaterial
EditorGUILayout.PropertyField(_spShrinkByMaterial);
// Target ParticleSystems. // Target ParticleSystems.
_ro.DoLayoutList(); _ro.DoLayoutList();
@@ -188,19 +204,6 @@ namespace Coffee.UIExtensions
DestroyUIParticle(current); DestroyUIParticle(current);
return; return;
} }
current.GetComponentsInParent(true, s_TempParents);
if (FixButton(1 < s_TempParents.Count, "This UIParticle component should be removed. The parent UIParticle exists."))
{
DestroyUIParticle(current);
return;
}
current.GetComponentsInChildren(true, s_TempChildren);
if (FixButton(1 < s_TempChildren.Count, "The children UIParticle component should be removed."))
{
s_TempChildren.ForEach(child => DestroyUIParticle(child, true));
}
} }
void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false) void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false)

View File

@@ -1,3 +1,6 @@
#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.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Coffee.UIParticleExtensions; using Coffee.UIParticleExtensions;
@@ -38,6 +41,13 @@ namespace Coffee.UIExtensions
[Tooltip("Particles")] [SerializeField] [Tooltip("Particles")] [SerializeField]
private List<ParticleSystem> m_Particles = new List<ParticleSystem>(); 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 bool _shouldBeRemoved; private bool _shouldBeRemoved;
private DrivenRectTransformTracker _tracker; private DrivenRectTransformTracker _tracker;
private Mesh _bakedMesh; private Mesh _bakedMesh;
@@ -49,6 +59,7 @@ namespace Coffee.UIExtensions
private static MaterialPropertyBlock s_Mpb; private static MaterialPropertyBlock s_Mpb;
private static readonly List<Material> s_PrevMaskMaterials = new List<Material>(); private static readonly List<Material> s_PrevMaskMaterials = new List<Material>();
private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>(); private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>();
private static readonly List<Component> s_Components = new List<Component>();
/// <summary> /// <summary>
@@ -73,6 +84,17 @@ namespace Coffee.UIExtensions
} }
} }
public bool shrinkByMaterial
{
get { return m_ShrinkByMaterial; }
set
{
if (m_ShrinkByMaterial == value) return;
m_ShrinkByMaterial = value;
RefreshParticles();
}
}
/// <summary> /// <summary>
/// Particle effect scale. /// Particle effect scale.
/// </summary> /// </summary>
@@ -116,6 +138,11 @@ namespace Coffee.UIExtensions
get { return _modifiedMaterials; } get { return _modifiedMaterials; }
} }
public override Material materialForRendering
{
get { return canvasRenderer.GetMaterial(0); }
}
public List<bool> activeMeshIndices public List<bool> activeMeshIndices
{ {
get { return _activeMeshIndices; } get { return _activeMeshIndices; }
@@ -195,6 +222,7 @@ namespace Coffee.UIExtensions
{ {
if (!root) return; if (!root) return;
root.GetComponentsInChildren(particles); root.GetComponentsInChildren(particles);
particles.RemoveAll(x => x.GetComponentInParent<UIParticle>() != this);
foreach (var ps in particles) foreach (var ps in particles)
{ {
@@ -204,7 +232,7 @@ namespace Coffee.UIExtensions
} }
particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = !enabled); particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = !enabled);
particles.SortForRendering(transform); particles.SortForRendering(transform, m_ShrinkByMaterial);
SetMaterialDirty(); SetMaterialDirty();
} }
@@ -232,16 +260,12 @@ namespace Coffee.UIExtensions
if (count == 0 || !isActiveAndEnabled || particles.Count == 0) if (count == 0 || !isActiveAndEnabled || particles.Count == 0)
{ {
canvasRenderer.Clear(); canvasRenderer.Clear();
ClearPreviousMaterials();
foreach (var m in s_PrevMaskMaterials)
StencilMaterial.Remove(m);
foreach (var m in s_PrevModifiedMaterials)
ModifiedMaterial.Remove(m);
return; return;
} }
// //
GetComponents(typeof(IMaterialModifier), s_Components);
var materialCount = Mathf.Max(8, count); var materialCount = Mathf.Max(8, count);
canvasRenderer.materialCount = materialCount; canvasRenderer.materialCount = materialCount;
var j = 0; var j = 0;
@@ -260,6 +284,8 @@ namespace Coffee.UIExtensions
if (activeMeshIndices[index] && 0 < s_TempMaterials.Count) if (activeMeshIndices[index] && 0 < s_TempMaterials.Count)
{ {
var mat = GetModifiedMaterial(s_TempMaterials[0], ps.GetTextureForSprite()); 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); canvasRenderer.SetMaterial(mat, j);
UpdateMaterialProperties(r, j); UpdateMaterialProperties(r, j);
j++; j++;
@@ -271,15 +297,24 @@ namespace Coffee.UIExtensions
if (activeMeshIndices[index] && 1 < s_TempMaterials.Count) if (activeMeshIndices[index] && 1 < s_TempMaterials.Count)
{ {
var mat = GetModifiedMaterial(s_TempMaterials[1], null); 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++); canvasRenderer.SetMaterial(mat, j++);
} }
} }
ClearPreviousMaterials();
}
private void ClearPreviousMaterials()
{
foreach (var m in s_PrevMaskMaterials) foreach (var m in s_PrevMaskMaterials)
StencilMaterial.Remove(m); StencilMaterial.Remove(m);
s_PrevMaskMaterials.Clear();
foreach (var m in s_PrevModifiedMaterials) foreach (var m in s_PrevModifiedMaterials)
ModifiedMaterial.Remove(m); ModifiedMaterial.Remove(m);
s_PrevModifiedMaterials.Clear();
} }
private Material GetModifiedMaterial(Material baseMaterial, Texture2D texture) private Material GetModifiedMaterial(Material baseMaterial, Texture2D texture)
@@ -350,7 +385,10 @@ namespace Coffee.UIExtensions
/// </summary> /// </summary>
protected override void OnEnable() protected override void OnEnable()
{ {
_cachedPosition = transform.localPosition; #if !SERIALIZE_FIELD_MASKABLE
maskable = m_Maskable;
#endif
_cachedPosition = transform.position;
activeMeshIndices.Clear(); activeMeshIndices.Clear();
UIParticleUpdater.Register(this); UIParticleUpdater.Register(this);
@@ -410,14 +448,6 @@ namespace Coffee.UIExtensions
enabled = false; enabled = false;
return; return;
} }
else if (enabled && transform.parent && transform.parent.GetComponentInParent<UIParticle>())
{
UnityEngine.Debug.LogWarningFormat(this, "[UIParticle] The UIParticle component should be removed: {0}\nReason: The parent UIParticle exists.", name);
gameObject.hideFlags = HideFlags.None;
_shouldBeRemoved = true;
enabled = false;
return;
}
if (!this || particles.AnyFast()) return; if (!this || particles.AnyFast()) return;
@@ -440,6 +470,9 @@ namespace Coffee.UIExtensions
SetVerticesDirty(); SetVerticesDirty();
m_ShouldRecalculateStencil = true; m_ShouldRecalculateStencil = true;
RecalculateClipping(); RecalculateClipping();
#if !SERIALIZE_FIELD_MASKABLE
maskable = m_Maskable;
#endif
} }
void ISerializationCallbackReceiver.OnBeforeSerialize() void ISerializationCallbackReceiver.OnBeforeSerialize()

View File

@@ -59,7 +59,7 @@ namespace Coffee.UIExtensions
private static void Refresh(UIParticle particle) private static void Refresh(UIParticle particle)
{ {
if (!particle || !particle.canvas || !particle.canvasRenderer) return; if (!particle || !particle.bakedMesh || !particle.canvas || !particle.canvasRenderer) return;
Profiler.BeginSample("[UIParticle] Modify scale"); Profiler.BeginSample("[UIParticle] Modify scale");
ModifyScale(particle); ModifyScale(particle);
@@ -164,6 +164,8 @@ namespace Coffee.UIExtensions
// No particle to render. // No particle to render.
var currentPs = particle.particles[i]; var currentPs = particle.particles[i];
if (!currentPs || !currentPs.IsAlive() || currentPs.particleCount == 0) continue; if (!currentPs || !currentPs.IsAlive() || currentPs.particleCount == 0) continue;
var r = currentPs.GetComponent<ParticleSystemRenderer>();
if (!r.sharedMaterial && !r.trailMaterial) continue;
// Calc matrix. // Calc matrix.
Profiler.BeginSample("[UIParticle] Bake Mesh > Calc matrix"); Profiler.BeginSample("[UIParticle] Bake Mesh > Calc matrix");
@@ -211,12 +213,13 @@ namespace Coffee.UIExtensions
Profiler.EndSample(); Profiler.EndSample();
} }
#if UNITY_2018_3_OR_NEWER
// #102: Do not bake particle system to mesh when the alpha is zero. // #102: Do not bake particle system to mesh when the alpha is zero.
if (Mathf.Approximately(particle.canvasRenderer.GetInheritedAlpha(), 0)) if (Mathf.Approximately(particle.canvasRenderer.GetInheritedAlpha(), 0))
continue; continue;
#endif
// Bake main particles. // Bake main particles.
var r = currentPs.GetComponent<ParticleSystemRenderer>();
if (CanBakeMesh(r)) if (CanBakeMesh(r))
{ {
Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Main Particles"); Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Main Particles");
@@ -238,6 +241,10 @@ namespace Coffee.UIExtensions
var hash = currentPs.GetMaterialHash(true); var hash = currentPs.GetMaterialHash(true);
if (hash != 0) if (hash != 0)
{ {
matrix = currentPs.main.simulationSpace == ParticleSystemSimulationSpace.Local
? matrix * Matrix4x4.Translate(-currentPs.transform.position)
: matrix;
var m = MeshHelper.GetTemporaryMesh(); var m = MeshHelper.GetTemporaryMesh();
try try
{ {

View File

@@ -9,8 +9,9 @@ namespace Coffee.UIParticleExtensions
internal static class SpriteExtensions internal static class SpriteExtensions
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
private static Type tSpriteEditorExtension = Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor") private static Type tSpriteEditorExtension =
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor"); Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic); .GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
@@ -185,7 +186,7 @@ namespace Coffee.UIParticleExtensions
internal static class ParticleSystemExtensions internal static class ParticleSystemExtensions
{ {
public static void SortForRendering(this List<ParticleSystem> self, Transform transform) public static void SortForRendering(this List<ParticleSystem> self, Transform transform, bool sortByMaterial)
{ {
self.Sort((a, b) => self.Sort((a, b) =>
{ {
@@ -194,8 +195,15 @@ namespace Coffee.UIParticleExtensions
var bRenderer = b.GetComponent<ParticleSystemRenderer>(); var bRenderer = b.GetComponent<ParticleSystemRenderer>();
// Render queue: ascending // Render queue: ascending
var aMat = aRenderer.sharedMaterial; var aMat = aRenderer.sharedMaterial ?? aRenderer.trailMaterial;
var bMat = bRenderer.sharedMaterial; 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) if (aMat.renderQueue != bMat.renderQueue)
return aMat.renderQueue - bMat.renderQueue; return aMat.renderQueue - bMat.renderQueue;
@@ -210,32 +218,23 @@ namespace Coffee.UIParticleExtensions
// Z position & sortingFudge: descending // Z position & sortingFudge: descending
var aTransform = a.transform; var aTransform = a.transform;
var bTransform = b.transform; var bTransform = b.transform;
var aPos = tr.InverseTransformPoint(aTransform.position).z+ aRenderer.sortingFudge; var aPos = tr.InverseTransformPoint(aTransform.position).z + aRenderer.sortingFudge;
var bPos = tr.InverseTransformPoint(bTransform.position).z+ bRenderer.sortingFudge; var bPos = tr.InverseTransformPoint(bTransform.position).z + bRenderer.sortingFudge;
if (!Mathf.Approximately(aPos, bPos)) if (!Mathf.Approximately(aPos, bPos))
return (int)Mathf.Sign(bPos - aPos); return (int) Mathf.Sign(bPos - aPos);
// Material instance ID: match return (int) Mathf.Sign(GetIndex(self, a) - GetIndex(self, b));
if (aMat.GetInstanceID() == bMat.GetInstanceID())
return 0;
// Transform: ascending
return TransformCompare(aTransform, bTransform);
}); });
} }
private static int TransformCompare(Transform a, Transform b) private static int GetIndex(IList<ParticleSystem> list, Object ps)
{ {
while (true) for (var i = 0; i < list.Count; i++)
{ {
if (!a && !b) return 0; if (list[i].GetInstanceID() == ps.GetInstanceID()) return i;
if (!a) return -1;
if (!b) return 1;
if (a.parent == b.parent) return a.GetSiblingIndex() - b.GetSiblingIndex();
a = a.parent;
b = b.parent;
} }
return 0;
} }
public static long GetMaterialHash(this ParticleSystem self, bool trail) public static long GetMaterialHash(this ParticleSystem self, bool trail)

View File

@@ -2,7 +2,7 @@
"name": "com.coffee.ui-particle", "name": "com.coffee.ui-particle",
"displayName": "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.", "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.0.1", "version": "3.3.2",
"unity": "2018.2", "unity": "2018.2",
"license": "MIT", "license": "MIT",
"repository": { "repository": {