You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-06-26 08:23:45 +00:00
Compare commits
27 Commits
v4.13.0
...
develop-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34453a0163 | ||
|
|
6b54e7cce8 | ||
|
|
5393947b3b | ||
|
|
bad976cf01 | ||
|
|
26fd3da20b | ||
|
|
6dae890b3b | ||
|
|
946254d4f5 | ||
|
|
cf402745f6 | ||
|
|
9dbd16920f | ||
|
|
cc339fb3f0 | ||
|
|
4f79848a7c | ||
|
|
a92d0b9280 | ||
|
|
a79ffb2c2b | ||
|
|
37fb189d72 | ||
|
|
9523ae12c0 | ||
|
|
96106370e5 | ||
|
|
73d208e9b8 | ||
|
|
bfac4d4e2f | ||
|
|
88d956ece8 | ||
|
|
2842b3db7d | ||
|
|
c2958d5d7d | ||
|
|
7456b5d555 | ||
|
|
9955eefdc2 | ||
|
|
c09bfb81ab | ||
|
|
fab2ed1697 | ||
|
|
ef4dbc3cba | ||
|
|
27551a4d47 |
28
.github/workflows/deploy.yml
vendored
Normal file
28
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: 🚀 Deploy with Zip
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
zip:
|
||||
description: "The url to the zip file"
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: 🚀 Deploy
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
steps:
|
||||
- name: 📦 Download zip file To '_site'
|
||||
run: |
|
||||
curl -L ${{ github.event.inputs.zip }} -o _site.zip
|
||||
unzip _site.zip -d _site
|
||||
find _site -name __MACOSX | xargs rm -rf
|
||||
|
||||
- name: 📦 Upload '_site'
|
||||
uses: actions/upload-pages-artifact@v5
|
||||
|
||||
- name: 🚀 Deploy To GitHub Pages
|
||||
uses: actions/deploy-pages@v5
|
||||
65
.github/workflows/release.yml
vendored
65
.github/workflows/release.yml
vendored
@@ -5,8 +5,9 @@ on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
- release-*
|
||||
- preview
|
||||
- main
|
||||
- v*.x
|
||||
tags-ignore:
|
||||
- "**"
|
||||
|
||||
@@ -22,9 +23,6 @@ jobs:
|
||||
channel: ${{ steps.release.outputs.new_release_channel }}
|
||||
released: ${{ steps.release.outputs.new_release_published }}
|
||||
tag: ${{ steps.release.outputs.new_release_git_tag }}
|
||||
version: ${{ steps.release.outputs.new_release_version }}
|
||||
merge_to: ${{ steps.summary.outputs.merge_to }}
|
||||
split_to: ${{ steps.summary.outputs.split_to }}
|
||||
steps:
|
||||
- name: 🚚 Checkout (${{ github.ref_name }})
|
||||
uses: actions/checkout@v6
|
||||
@@ -40,62 +38,7 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- id: summary
|
||||
run: |
|
||||
- run: |
|
||||
echo "🔖 New release published: '${{ steps.release.outputs.new_release_published }}'" | tee -a $GITHUB_STEP_SUMMARY
|
||||
echo "🔖 New release version: '${{ steps.release.outputs.new_release_version }}'" | tee -a $GITHUB_STEP_SUMMARY
|
||||
echo "🔖 New release channel: '${{ steps.release.outputs.new_release_channel }}'" | tee -a $GITHUB_STEP_SUMMARY
|
||||
echo "🔖 New release git tag: '${{ steps.release.outputs.new_release_git_tag }}'" | tee -a $GITHUB_STEP_SUMMARY
|
||||
|
||||
if [ '${{ steps.release.outputs.new_release_published }}' = 'false' ]; then
|
||||
echo "No new release published." | tee -a $GITHUB_STEP_SUMMARY
|
||||
elif [ '${{ github.ref_name }}' = 'release' ]; then
|
||||
echo "merge_to=develop" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
||||
echo "split_to=main" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
channel=$(echo ${{ github.ref_name }} | sed 's/^release-//')
|
||||
echo "merge_to=develop-${channel}" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
||||
echo "split_to=${channel}" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
merge-to:
|
||||
if: needs.release.outputs.merge_to != ''
|
||||
needs: release
|
||||
name: 🔀 Merge to ${{ needs.release.outputs.merge_to }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: 🚚 Checkout (${{ needs.release.outputs.merge_to }})
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ needs.release.outputs.merge_to }}
|
||||
fetch-depth: 0
|
||||
- name: 🔀 Merge '${{ needs.release.outputs.tag }}' into '${{ needs.release.outputs.merge_to }}'
|
||||
run: |
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
|
||||
git merge ${{ needs.release.outputs.tag }}
|
||||
git push origin ${{ needs.release.outputs.merge_to }}
|
||||
|
||||
split-to:
|
||||
if: needs.release.outputs.split_to != ''
|
||||
needs: release
|
||||
name: 🔀 Split package to ${{ needs.release.outputs.split_to }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: 🚚 Checkout (${{ needs.release.outputs.tag }})
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ needs.release.outputs.tag }}
|
||||
fetch-depth: 0
|
||||
- name: 🔀 Split subtree 'Packages/src' to '${{ needs.release.outputs.split_to }}'
|
||||
run: |
|
||||
split_to=${{ needs.release.outputs.split_to }}
|
||||
git branch $split_to origin/$split_to
|
||||
git subtree split --prefix=Packages/src --branch $split_to
|
||||
git tag ${{ needs.release.outputs.version }} $split_to
|
||||
git push origin ${{ needs.release.outputs.version }} $split_to:$split_to
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{
|
||||
"branches": [
|
||||
"release",
|
||||
"release-4.x",
|
||||
"main",
|
||||
"[0-9]+.x",
|
||||
{
|
||||
"name": "release-preview",
|
||||
"prerelease": "preview"
|
||||
"name": "preview",
|
||||
"prerelease": true
|
||||
}
|
||||
],
|
||||
"tagFormat": "${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
# [5.0.0-preview.18](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/5.0.0-preview.17...5.0.0-preview.18) (2026-06-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `ParticleSystemPreviewer` is no longer included in build ([bad976c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/bad976cf01180bdabf5cd2f1760e069afdcb644a))
|
||||
* `UI/Additive` shader does not support RectMask2D softness. ([83145d3](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/83145d3a6ede3831d1f7c49afde6ef7d8a498d21))
|
||||
* add support for Unity 6.7 ([26fd3da](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/26fd3da20b6b07f7a26df662358c53757a7cc5f5)), closes [#408](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/408)
|
||||
* rename `UIParticleProjectSettings.enableLinearToGamma` to `autoColorCorrection` ([10f82a8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/10f82a8579a2d055f897e7a8d6f3b5ba1fc43ae8))
|
||||
* Support for skipping "reload domain" ([b7bb112](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b7bb1124f6921ebca1b48991462637767b95e504)), closes [#406](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/406)
|
||||
* there is a compilation error in Unity 2019.2 or earlier ([c327632](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/c327632e1eb203351ba1a1087a19eb7838c22530)), closes [#407](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/407)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add fields located outside the `Properties` block in the shader as `Animatable Properties` ([ea2fcfd](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ea2fcfd8099a24b92624d34600beb519fb9d2b38)), closes [#399](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/399)
|
||||
* preview the ParticleSystem playback when selecting a UIParticle in the Editor ([108bcfb](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/108bcfbd246960dc730546dc334424cf2e17bfd4))
|
||||
* project-wide default view size for baking ([8e0ff10](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/8e0ff10c7344d9f53d2f4f096ddeb7392b67f930)), closes [#360](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/360)
|
||||
|
||||
## [4.13.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.13.0...v4.13.1) (2026-06-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `ParticleSystemPreviewer` is no longer included in build ([bad976c](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/bad976cf01180bdabf5cd2f1760e069afdcb644a))
|
||||
* add support for Unity 6.7 ([26fd3da](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/26fd3da20b6b07f7a26df662358c53757a7cc5f5)), closes [#408](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/408)
|
||||
|
||||
# [4.13.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.12.2...v4.13.0) (2026-06-25)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
@@ -26,7 +25,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
[CustomEditor(typeof(UIParticle))]
|
||||
[CanEditMultipleObjects]
|
||||
internal class UIParticleEditor : GraphicEditor
|
||||
internal class UIParticleEditor : Editor
|
||||
{
|
||||
internal class State : ScriptableSingleton<State>
|
||||
{
|
||||
@@ -89,10 +88,8 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
private void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
_maskable = serializedObject.FindProperty("m_Maskable");
|
||||
_scale3D = serializedObject.FindProperty("m_Scale3D");
|
||||
_animatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
|
||||
@@ -488,9 +485,11 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
if (!p || (ignoreCurrent && target == p)) return;
|
||||
|
||||
var cr = p.canvasRenderer;
|
||||
DestroyImmediate(p);
|
||||
DestroyImmediate(cr);
|
||||
Misc.DestroyImmediate(p);
|
||||
if (p.TryGetComponent<CanvasRenderer>(out var cr))
|
||||
{
|
||||
Misc.DestroyImmediate(cr);
|
||||
}
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
var stage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# <img alt="UIParticleIcon" src="https://github.com/mob-sakai/ParticleEffectForUGUI/assets/12690315/d76e105e-a840-4f61-a1f6-8cf311c0812d" width="26"/> Particle Effect For UGUI (UI Particle) <!-- omit in toc -->
|
||||
# <img alt="UIParticleIcon" src="https://github.com/mob-sakai/ParticleEffectForUGUI/assets/12690315/d76e105e-a840-4f61-a1f6-8cf311c0812d" width="26"/> UI Particle v5 <!-- omit in toc -->
|
||||
|
||||
[](https://openupm.com/packages/com.coffee.ui-particle/)
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/releases)
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/blob/main/LICENSE.md)
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
@@ -11,7 +11,7 @@
|
||||
[](https://github.com/mob-sakai/ParticleEffectForUGUI/subscription)
|
||||
[](https://twitter.com/intent/follow?screen_name=mob_sakai)
|
||||
|
||||
<< [📝 Description](#-description-) | [📌 Key Features](#-key-features) | [🎮 Demo](#-demo) | [⚙ Installation](#-installation) | [🚀 Usage](#-usage) | [🛠 Development Note](#-development-note) | [🤝 Contributing](#-contributing) >>
|
||||
<< [📝 Description](#-description-) | [📌 Key Features](#-key-features) | [🎮 Demo](#-demo) | [⚙ Installation](#-installation) | [🔄 Upgrading to 5.x](#-upgrading-from-3x4x-to-5x) | [🚀 Usage](#-usage) | [🛠 Development Note](#-development-note) | [🤝 Contributing](#-contributing) >>
|
||||
|
||||
## 📝 Description <!-- omit in toc -->
|
||||
|
||||
@@ -26,7 +26,9 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
|
||||
- [Install via OpenUPM](#install-via-openupm)
|
||||
- [Install via UPM (with Package Manager UI)](#install-via-upm-with-package-manager-ui)
|
||||
- [Install via UPM (Manually)](#install-via-upm-manually)
|
||||
- [Install as Embedded Package](#install-as-embedded-package)
|
||||
- [Install as Embedded Package](#install-as-embedded-package)
|
||||
- [🔄 Upgrading from v3/v4 to v5](#-upgrading-from-v3v4-to-v5)
|
||||
- [Breaking Changes](#breaking-changes)
|
||||
- [🚀 Usage](#-usage)
|
||||
- [Component: UIParticle](#component-uiparticle)
|
||||
- [Basic Usage](#basic-usage)
|
||||
@@ -34,6 +36,7 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
|
||||
- [Usage with `Mask` or `RectMask2D` Component](#usage-with-mask-or-rectmask2d-component)
|
||||
- [Usage with Script](#usage-with-script)
|
||||
- [Component: UIParticleAttractor](#component-uiparticleattractor)
|
||||
- [Component: ParticleSystemPreviewer](#component-particlesystempreviewer)
|
||||
- [Project Settings](#project-settings)
|
||||
- [🛠 Development Note](#-development-note)
|
||||
- [Compares the Baking mesh approach with the conventional approach](#compares-the-baking-mesh-approach-with-the-conventional-approach)
|
||||
@@ -104,7 +107,7 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
|
||||
|
||||
## ⚙ Installation
|
||||
|
||||
_This package requires **Unity 2018.3 or later**._
|
||||
_This package requires **Unity 2019.3 or later**._
|
||||
|
||||
#### Install via OpenUPM
|
||||
|
||||
@@ -116,16 +119,16 @@ _This package requires **Unity 2018.3 or later**._
|
||||
```
|
||||
- To update the package, use Package Manager UI (`Window > Package Manager`) or run the following command with `@{version}`:
|
||||
```
|
||||
openupm add com.coffee.ui-particle@4.9.0
|
||||
openupm add com.coffee.ui-particle@5.0.0
|
||||
```
|
||||
|
||||
#### Install via UPM (with Package Manager UI)
|
||||
|
||||
- Click `Window > Package Manager` to open Package Manager UI.
|
||||
- Click `+ > Add package from git URL...` and input the repository URL: `https://github.com/mob-sakai/ParticleEffectForUGUI.git`
|
||||
- Click `+ > Add package from git URL...` and input the repository URL: `https://github.com/mob-sakai/ParticleEffectForUGUI.git?path=Packages/src`
|
||||

|
||||
- To update the package, change suffix `#{version}` to the target version.
|
||||
- e.g. `https://github.com/mob-sakai/ParticleEffectForUGUI.git#4.9.0`
|
||||
- e.g. `https://github.com/mob-sakai/ParticleEffectForUGUI.git?path=Packages/src#5.0.0`
|
||||
|
||||
#### Install via UPM (Manually)
|
||||
|
||||
@@ -133,22 +136,41 @@ _This package requires **Unity 2018.3 or later**._
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git",
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git?path=Packages/src",
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- To update the package, change suffix `#{version}` to the target version.
|
||||
- e.g. `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git#4.9.0",`
|
||||
- e.g. `"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git?path=Packages/src#5.0.0",`
|
||||
|
||||
#### Install as Embedded Package
|
||||
### Install as Embedded Package
|
||||
|
||||
1. Download a source code zip file from [Releases](https://github.com/mob-sakai/ParticleEffectForUGUI/releases) and extract it.
|
||||
2. Place it in your project's `Packages` directory.
|
||||

|
||||
- If you want to fix bugs or add features, install it as an embedded package.
|
||||
- To update the package, you need to re-download it and replace the contents.
|
||||
1. Download the `Source code (zip)` file from [Releases](https://github.com/mob-sakai/ParticleEffectForUGUI/releases) and
|
||||
extract it.
|
||||
2. Move the `<extracted_dir>/Packages/src` directory into your project's `Packages` directory.
|
||||

|
||||
- You can rename the `src` directory if needed.
|
||||
- If you intend to fix bugs or add features, installing it as an embedded package is recommended.
|
||||
- To update the package, re-download it and replace the existing contents.
|
||||
|
||||
<br><br>
|
||||
|
||||
## 🔄 Upgrading from v3/v4 to v5
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- The default value of `UIParticle.scale` has been changed from `10` to `1`.
|
||||
- `UIParticle` no longer inherits from `MaskableGraphic`.
|
||||
- If you are installing via git URL, add `?path=Packages/src`.
|
||||
```json
|
||||
// v3/v4
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git",
|
||||
|
||||
// v5
|
||||
"com.coffee.ui-particle": "https://github.com/mob-sakai/ParticleEffectForUGUI.git?path=Packages/src",
|
||||
```
|
||||
|
||||
<br><br>
|
||||
|
||||
@@ -271,16 +293,17 @@ uiParticle.Stop();
|
||||
- **Unscaled Time:** Update with unscaled delta time.
|
||||
- **OnAttracted**: An event called when attracting is complete (per particle).
|
||||
|
||||
|
||||
<br><br>
|
||||
|
||||
### Component: ParticleSystemPreviewer
|
||||
|
||||
`ParticleSystemPreviewer` is used to preview a ParticleSystem in the editor.
|
||||
`ParticleSystemPreviewer` is used to preview a `ParticleSystem` in the editor.
|
||||
|
||||

|
||||
|
||||
- When a `GameObject` with this component is selected in the editor, a temporary `ParticleSystem` is added if needed so you can preview the effect in the Scene view.
|
||||
- The generated `ParticleSystem` is marked with `HideFlags.DontSave`, so it is neither saved nor included in builds.
|
||||
|
||||
- This component will be removed in builds.
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
153
Packages/src/Runtime/Internal/Extensions/MeshExtensions.cs
Normal file
153
Packages/src/Runtime/Internal/Extensions/MeshExtensions.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIParticleInternal
|
||||
{
|
||||
internal static class MeshExtensions
|
||||
{
|
||||
internal static readonly InternalObjectPool<Mesh> s_MeshPool = new InternalObjectPool<Mesh>(
|
||||
() =>
|
||||
{
|
||||
var mesh = new Mesh
|
||||
{
|
||||
hideFlags = HideFlags.DontSave | HideFlags.NotEditable
|
||||
};
|
||||
mesh.MarkDynamic();
|
||||
return mesh;
|
||||
},
|
||||
mesh => mesh,
|
||||
mesh =>
|
||||
{
|
||||
if (mesh != null)
|
||||
{
|
||||
mesh.Clear();
|
||||
}
|
||||
});
|
||||
|
||||
public static Mesh Rent()
|
||||
{
|
||||
return s_MeshPool.Rent();
|
||||
}
|
||||
|
||||
public static void Return(ref Mesh mesh)
|
||||
{
|
||||
s_MeshPool.Return(ref mesh);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Mesh self, Mesh dst)
|
||||
{
|
||||
if (self == null || dst == null) return;
|
||||
|
||||
var vector3List = InternalListPool<Vector3>.Rent();
|
||||
var vector4List = InternalListPool<Vector4>.Rent();
|
||||
var color32List = InternalListPool<Color32>.Rent();
|
||||
var intList = InternalListPool<int>.Rent();
|
||||
|
||||
dst.Clear(false);
|
||||
|
||||
self.GetVertices(vector3List);
|
||||
dst.SetVertices(vector3List);
|
||||
|
||||
self.GetTriangles(intList, 0);
|
||||
dst.SetTriangles(intList, 0);
|
||||
|
||||
self.GetNormals(vector3List);
|
||||
dst.SetNormals(vector3List);
|
||||
|
||||
self.GetTangents(vector4List);
|
||||
dst.SetTangents(vector4List);
|
||||
|
||||
self.GetColors(color32List);
|
||||
dst.SetColors(color32List);
|
||||
|
||||
self.GetUVs(0, vector4List);
|
||||
dst.SetUVs(0, vector4List);
|
||||
|
||||
self.GetUVs(1, vector4List);
|
||||
dst.SetUVs(1, vector4List);
|
||||
|
||||
self.GetUVs(2, vector4List);
|
||||
dst.SetUVs(2, vector4List);
|
||||
|
||||
self.GetUVs(3, vector4List);
|
||||
dst.SetUVs(3, vector4List);
|
||||
|
||||
dst.RecalculateBounds();
|
||||
InternalListPool<Vector3>.Return(ref vector3List);
|
||||
InternalListPool<Vector4>.Return(ref vector4List);
|
||||
InternalListPool<Color32>.Return(ref color32List);
|
||||
InternalListPool<int>.Return(ref intList);
|
||||
}
|
||||
|
||||
public static void CopyTo(this VertexHelper self, Mesh dst)
|
||||
{
|
||||
if (self == null || dst == null) return;
|
||||
|
||||
self.FillMesh(dst);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Mesh self, VertexHelper dst)
|
||||
{
|
||||
if (self == null || dst == null) return;
|
||||
|
||||
var vertexCount = self.vertexCount;
|
||||
var indexCount = self.triangles.Length;
|
||||
self.CopyTo(dst, vertexCount, indexCount);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Mesh self, VertexHelper dst, int vertexCount, int indexCount)
|
||||
{
|
||||
if (self == null || dst == null) return;
|
||||
|
||||
var positions = InternalListPool<Vector3>.Rent();
|
||||
var normals = InternalListPool<Vector3>.Rent();
|
||||
var uv0 = InternalListPool<Vector4>.Rent();
|
||||
var uv1 = InternalListPool<Vector4>.Rent();
|
||||
var uv2 = InternalListPool<Vector4>.Rent();
|
||||
var uv3 = InternalListPool<Vector4>.Rent();
|
||||
var tangents = InternalListPool<Vector4>.Rent();
|
||||
var colors = InternalListPool<Color32>.Rent();
|
||||
var indices = InternalListPool<int>.Rent();
|
||||
self.GetVertices(positions);
|
||||
self.GetColors(colors);
|
||||
self.GetUVs(0, uv0);
|
||||
self.GetUVs(1, uv1);
|
||||
self.GetUVs(2, uv1);
|
||||
self.GetUVs(3, uv1);
|
||||
self.GetNormals(normals);
|
||||
self.GetTangents(tangents);
|
||||
self.GetIndices(indices, 0);
|
||||
|
||||
dst.Clear();
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
{
|
||||
dst.AddVert(positions.GetOrDefault(i), colors.GetOrDefault(i), uv0.GetOrDefault(i), uv1.GetOrDefault(i),
|
||||
uv2.GetOrDefault(i), uv3.GetOrDefault(i), normals.GetOrDefault(i), tangents.GetOrDefault(i));
|
||||
}
|
||||
|
||||
var count = Mathf.Clamp(indexCount, 0, indices.Count);
|
||||
for (var i = 0; i < count - 2; i += 3)
|
||||
{
|
||||
dst.AddTriangle(indices[i], indices[i + 1], indices[i + 2]);
|
||||
}
|
||||
|
||||
InternalListPool<Vector3>.Return(ref positions);
|
||||
InternalListPool<Vector3>.Return(ref normals);
|
||||
InternalListPool<Vector4>.Return(ref uv0);
|
||||
InternalListPool<Vector4>.Return(ref uv1);
|
||||
InternalListPool<Vector4>.Return(ref uv2);
|
||||
InternalListPool<Vector4>.Return(ref uv3);
|
||||
InternalListPool<Vector4>.Return(ref tangents);
|
||||
InternalListPool<Color32>.Return(ref colors);
|
||||
InternalListPool<int>.Return(ref indices);
|
||||
}
|
||||
|
||||
private static T GetOrDefault<T>(this List<T> self, int index)
|
||||
{
|
||||
return 0 <= index && index < self.Count
|
||||
? self[index]
|
||||
: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c949d47f5c6d4d22bd7baebc60d48f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,4 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Coffee.UIParticleInternal;
|
||||
@@ -13,7 +14,6 @@ namespace Coffee.UIExtensions
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(ParticleSystemPreviewer))]
|
||||
[CanEditMultipleObjects]
|
||||
internal class ParticleSystemPreviewerEditor : Editor
|
||||
@@ -29,6 +29,7 @@ namespace Coffee.UIExtensions
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
EditorGUILayout.HelpBox("ParticleSystemPreviewer will be removed in build.", MessageType.Warning);
|
||||
ParticleSystemPreviewSystem.DrawWarningForTemporary(_gameObjects);
|
||||
ParticleSystemPreviewSystem.DrawWarningForPermanent(_gameObjects);
|
||||
}
|
||||
@@ -43,6 +44,12 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
private const HideFlags k_TemporaryHideFlags = HideFlags.DontSave | HideFlags.NotEditable;
|
||||
|
||||
private const string k_TemporaryMesssage = "The temporary ParticleSystem for preview is attached.\n" +
|
||||
"It will be removed when exiting edit mode.";
|
||||
|
||||
private const string k_PermanentMesssage = "The permanent ParticleSystem is attached.\n" +
|
||||
"It will be included in build.";
|
||||
|
||||
[SerializeField]
|
||||
private List<GameObject> m_PreviewObjects = new List<GameObject>();
|
||||
|
||||
@@ -192,8 +199,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
if (gameObjects == null || gameObjects.Length == 0 || !gameObjects.Any(HasTemporaryParticleSystem)) return;
|
||||
|
||||
if (WarningButton("The temporary ParticleSystem for preview is attached.\n" +
|
||||
"It will be removed when exiting edit mode.", "Remove"))
|
||||
if (HelpBoxButton(MessageType.Warning, k_TemporaryMesssage, "Remove"))
|
||||
{
|
||||
foreach (var go in gameObjects)
|
||||
{
|
||||
@@ -209,8 +215,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
if (gameObjects == null || gameObjects.Length == 0 || !gameObjects.Any(HasPermanentParticleSystem)) return;
|
||||
|
||||
if (WarningButton("The permanent ParticleSystem is attached.\n" +
|
||||
"It will be included in build.", "Remove"))
|
||||
if (HelpBoxButton(MessageType.Info, k_PermanentMesssage, "Remove"))
|
||||
{
|
||||
foreach (var go in gameObjects)
|
||||
{
|
||||
@@ -224,14 +229,14 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
}
|
||||
|
||||
private static bool WarningButton(string message, string buttonText)
|
||||
private static bool HelpBoxButton(MessageType messageType, string message, string buttonText)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.HelpBox(message, MessageType.Warning, true);
|
||||
EditorGUILayout.HelpBox(message, messageType, true);
|
||||
var clicked = GUILayout.Button(EditorGUIUtility.TrTempContent(buttonText));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
return clicked;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Coffee.UIParticleInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
|
||||
@@ -22,7 +22,7 @@ namespace Coffee.UIExtensions
|
||||
[ExecuteAlways]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
public class UIParticle : MaskableGraphic, ISerializationCallbackReceiver
|
||||
public class UIParticle : UIBehaviour, ISerializationCallbackReceiver
|
||||
{
|
||||
public enum AutoScalingMode
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace Coffee.UIExtensions
|
||||
|
||||
[Tooltip("Scale the rendering particles. When the `3D` toggle is enabled, 3D scale (x, y, z) is supported.")]
|
||||
[SerializeField]
|
||||
private Vector3 m_Scale3D = new Vector3(10, 10, 10);
|
||||
private Vector3 m_Scale3D = new Vector3(1, 1, 1);
|
||||
|
||||
[Tooltip("If you want to update material properties (e.g. _MainTex_ST, _Color) in AnimationClip, " +
|
||||
"use this to mark as animatable.")]
|
||||
@@ -125,20 +125,48 @@ namespace Coffee.UIExtensions
|
||||
[Tooltip("Time scale multiplier.")]
|
||||
private float m_TimeScaleMultiplier = 1;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_Maskable = true;
|
||||
|
||||
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
|
||||
private Camera _bakeCamera;
|
||||
private Canvas _canvas;
|
||||
private int _groupId;
|
||||
private bool _isScaleStored;
|
||||
private Vector3 _storedScale;
|
||||
private DrivenRectTransformTracker _tracker;
|
||||
|
||||
/// <summary>
|
||||
/// Should this graphic be considered a target for ray-casting?
|
||||
/// </summary>
|
||||
public override bool raycastTarget
|
||||
public RectTransform rectTransform => transform as RectTransform;
|
||||
|
||||
public Canvas canvas
|
||||
{
|
||||
get => false;
|
||||
set { }
|
||||
get
|
||||
{
|
||||
if (_canvas) return _canvas;
|
||||
|
||||
var tr = transform;
|
||||
while (tr && !_canvas)
|
||||
{
|
||||
if (tr.TryGetComponent(out _canvas)) return _canvas;
|
||||
tr = tr.parent;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does this graphic allow masking.
|
||||
/// </summary>
|
||||
public bool maskable
|
||||
{
|
||||
get => m_Maskable;
|
||||
set
|
||||
{
|
||||
if (value == m_Maskable) return;
|
||||
m_Maskable = value;
|
||||
UpdateRendererMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -331,15 +359,15 @@ namespace Coffee.UIExtensions
|
||||
|
||||
public Vector3 parentScale { get; private set; }
|
||||
|
||||
public Vector3 canvasScale { get; private set; }
|
||||
private Vector3 canvasScale { get; set; }
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_isScaleStored = false;
|
||||
ResetGroupId();
|
||||
UIParticleUpdater.Register(this);
|
||||
RegisterDirtyMaterialCallback(UpdateRendererMaterial);
|
||||
|
||||
//
|
||||
if (0 < particles.Count)
|
||||
{
|
||||
RefreshParticles(particles);
|
||||
@@ -349,7 +377,7 @@ namespace Coffee.UIExtensions
|
||||
RefreshParticles();
|
||||
}
|
||||
|
||||
base.OnEnable();
|
||||
UpdateRendererMaterial();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -367,9 +395,15 @@ namespace Coffee.UIExtensions
|
||||
UIParticleUpdater.Unregister(this);
|
||||
_renderers.RemoveAll(r => r == null);
|
||||
_renderers.ForEach(r => r.Reset());
|
||||
UnregisterDirtyMaterialCallback(UpdateRendererMaterial);
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
base.OnDisable();
|
||||
/// <summary>
|
||||
/// Called when the state of the parent Canvas is changed.
|
||||
/// </summary>
|
||||
protected override void OnCanvasHierarchyChanged()
|
||||
{
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -379,6 +413,14 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when a direct or indirect parent of the transform of the GameObject has changed.
|
||||
/// </summary>
|
||||
protected override void OnTransformParentChanged()
|
||||
{
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
@@ -678,17 +720,6 @@ namespace Coffee.UIExtensions
|
||||
: Random.Range(m_GroupId, m_GroupMaxId + 1);
|
||||
}
|
||||
|
||||
protected override void UpdateMaterial()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to update the geometry of the Graphic onto the CanvasRenderer.
|
||||
/// </summary>
|
||||
protected override void UpdateGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
private void UpdateRendererMaterial()
|
||||
{
|
||||
for (var i = 0; i < _renderers.Count; i++)
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Coffee.UIExtensions
|
||||
private static readonly List<Material> s_Materials = new List<Material>(2);
|
||||
private static MaterialPropertyBlock s_Mpb;
|
||||
private static readonly Vector3[] s_Corners = new Vector3[4];
|
||||
private static readonly VertexHelper s_VertexHelper = new VertexHelper();
|
||||
private bool _delay;
|
||||
private int _index;
|
||||
private bool _isPrevStored;
|
||||
@@ -451,11 +452,15 @@ namespace Coffee.UIExtensions
|
||||
|
||||
var components = InternalListPool<Component>.Rent();
|
||||
GetComponents(typeof(IMeshModifier), components);
|
||||
for (var i = 0; i < components.Count; i++)
|
||||
if (0 < components.Count)
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
((IMeshModifier)components[i]).ModifyMesh(workerMesh);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
workerMesh.CopyTo(s_VertexHelper);
|
||||
for (var i = 0; i < components.Count; i++)
|
||||
{
|
||||
((IMeshModifier)components[i]).ModifyMesh(s_VertexHelper);
|
||||
}
|
||||
|
||||
s_VertexHelper.FillMesh(workerMesh);
|
||||
}
|
||||
|
||||
InternalListPool<Component>.Return(ref components);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"name": "com.coffee.ui-particle",
|
||||
"displayName": "UI Particle",
|
||||
"description": "This package provides a component to render particle effects for uGUI.\nThe particle rendering is maskable and sortable, without the need for an extra Camera, RenderTexture, or Canvas.",
|
||||
"version": "4.13.0",
|
||||
"unity": "2018.2",
|
||||
"version": "5.0.0-preview.18",
|
||||
"unity": "2019.3",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user