Compare commits

...

27 Commits

Author SHA1 Message Date
semantic-release-bot
5a8f1263ef chore(release): 3.3.10 [skip ci]
## [3.3.10](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.9...3.3.10) (2022-02-17)

### Bug Fixes

* annoying warning for [ExecuteInEditMode] ([b6b2c72](b6b2c72b19)), closes [#180](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/180)
* PrefabStageUtility class is not experimental after 2021.2 ([0fd5d7a](0fd5d7affe))
2022-02-17 20:45:55 +00:00
mob-sakai
b6b2c72b19 fix: annoying warning for [ExecuteInEditMode]
Close #180
2022-02-18 04:57:27 +09:00
talessampaio-kazoo
0fd5d7affe fix: PrefabStageUtility class is not experimental after 2021.2 2022-02-18 04:46:01 +09:00
semantic-release-bot
2e4d80bc1c chore(release): 3.3.9 [skip ci]
## [3.3.9](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.8...3.3.9) (2021-08-02)

### Bug Fixes

* fix for warning CS0618 ([61760d9](61760d940c))
2021-08-02 17:49:09 +00:00
shadeAlex
6b87db7ac7 style: tab to space 2021-08-03 02:48:12 +09:00
shadeAlex
61760d940c fix: fix for warning CS0618 2021-08-03 02:48:12 +09:00
semantic-release-bot
f43d4c38ea chore(release): 3.3.8 [skip ci]
## [3.3.8](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.7...3.3.8) (2021-06-08)

### Bug Fixes

* improve performance ([e352d15](e352d153ce))
2021-06-08 17:28:36 +00:00
mob-sakai
ccb8386672 refactor: fix warning 2021-06-09 02:25:41 +09:00
mob-sakai
e15319a46e change: remove color space modifier 2021-06-09 02:25:41 +09:00
mob-sakai
e352d153ce fix: improve performance 2021-06-09 02:25:41 +09:00
semantic-release-bot
4f9bbf57bc chore(release): 3.3.7 [skip ci]
## [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](0b9d80da93))
2021-06-02 18:15:36 +00:00
mob-sakai
0b9d80da93 fix: Refresh() will be called multiple times in the same frame, due to external assets 2021-06-03 03:04:07 +09:00
semantic-release-bot
24d32d8441 chore(release): 3.3.6 [skip ci]
## [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](12c748a8cd))
* remove from "Add Component" menu ([476c402](476c4027ff))
2021-05-11 08:24:08 +00:00
mob-sakai
476c4027ff fix: remove from "Add Component" menu 2021-05-11 17:22:02 +09:00
mob-sakai
12c748a8cd fix: In rare cases, the generated camera (for baking) will not be deactivated 2021-05-11 17:21:10 +09:00
mob-sakai
0259ad2464 refactor 2021-05-11 16:20:50 +09:00
semantic-release-bot
5f3ead2086 chore(release): 3.3.5 [skip ci]
## [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](e3f42d747a))
* ParticleSystem creates particles in wrong position during pre-warm ([b93e0e4](b93e0e4701)), closes [#147](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/147)
2021-02-28 04:21:18 +00:00
mob-sakai
e3f42d747a fix: fix cached position for pre-warmed particles 2021-02-24 16:22:37 +09:00
mob-sakai
b93e0e4701 fix: ParticleSystem creates particles in wrong position during pre-warm
Close #147
2021-02-23 13:30:46 +09:00
semantic-release-bot
9f9e04724d chore(release): 3.3.4 [skip ci]
## [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](13223b2d74))
* support sub emitter with 'PlayOnAwake' ([d5ce78a](d5ce78ae5a))
* The maximum material count is 8 ([3bb5241](3bb5241275))
2021-02-22 12:24:08 +00:00
mob-sakai
5981af6c0a build: update release workflow 2021-02-22 18:32:39 +09:00
mob-sakai
f38240f527 test: update test workflow 2021-02-22 18:32:39 +09:00
mob-sakai
d775e805fb Merge pull request #150 from Tointer/fix_multiselecting_bug
fix: Multiselecting sets all scales to the same value
2021-02-19 09:57:37 +09:00
mob-sakai
d9eb91c120 refactor: modify the value when the field is changed 2021-02-19 09:57:02 +09:00
ibragimov.i
13223b2d74 fix: Multiselecting sets all scales to the same value 2021-02-18 23:28:06 +03:00
mob-sakai
d5ce78ae5a fix: support sub emitter with 'PlayOnAwake' 2021-02-18 13:48:37 +09:00
mob-sakai
3bb5241275 fix: The maximum material count is 8 2021-02-18 13:44:47 +09:00
11 changed files with 196 additions and 45 deletions

View File

@@ -12,12 +12,13 @@ on:
jobs: jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: "! contains(github.event.head_commit.message, '[skip ci]') && ! contains(github.event.head_commit.message, '[ci skip]')"
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: | - uses: cycjimmy/semantic-release-action@v2
npm i --no-save https://gist.github.com/mob-sakai/c90044338361af97a7e8c8a78425bdb3 with:
npx semantic-release -e @mob-sakai/semantic-release-upm extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}

View File

@@ -29,8 +29,6 @@ jobs:
"2020.1.17f1", "2020.1.17f1",
"2020.2.1f1", "2020.2.1f1",
] ]
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
steps: steps:
# Checkout sandbox project # Checkout sandbox project
@@ -64,9 +62,9 @@ jobs:
uses: game-ci/unity-test-runner@main uses: game-ci/unity-test-runner@main
with: with:
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }} customParameters: -nographics -enableCodeCoverage -coverageOptions assemblyFilters:+Coffee.UIParticle.*Tests
customParameters: -enableCodeCoverage env:
# customParameters: -enableCodeCoverage -coverageOptions assemblyFilters:+CSharpCompilerSettings_,-*-CSharp,-*.Tests,-IgnoreAccessibility UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
if: always() if: always()

25
.releaserc.json Normal file
View 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"
]
}

View File

@@ -1,3 +1,57 @@
## [3.3.10](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.9...3.3.10) (2022-02-17)
### Bug Fixes
* annoying warning for [ExecuteInEditMode] ([b6b2c72](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/b6b2c72b198566e2880a22831c937eff7e9eff28)), closes [#180](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/180)
* PrefabStageUtility class is not experimental after 2021.2 ([0fd5d7a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0fd5d7affe707fa9e92abd6e192bf400dfb1a80a))
## [3.3.9](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.8...3.3.9) (2021-08-02)
### Bug Fixes
* fix for warning CS0618 ([61760d9](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/61760d940cdd4baacaa196ac1631a0a1a40b7204))
## [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) ## [3.3.3](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.2...3.3.3) (2021-02-03)

View File

@@ -7,7 +7,7 @@ using UnityEngine.UI;
namespace Coffee.UIExtensions.Demos namespace Coffee.UIExtensions.Demos
{ {
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
[ExecuteInEditMode] [ExecuteAlways]
[RequireComponent(typeof(CanvasRenderer), typeof(ParticleSystem))] [RequireComponent(typeof(CanvasRenderer), typeof(ParticleSystem))]
public class UIParticleSystem_Demo : MaskableGraphic public class UIParticleSystem_Demo : MaskableGraphic
{ {

View File

@@ -2,6 +2,7 @@
namespace Coffee.UIParticleExtensions namespace Coffee.UIParticleExtensions
{ {
[AddComponentMenu("")]
internal class BakingCamera : MonoBehaviour internal class BakingCamera : MonoBehaviour
{ {
static BakingCamera s_Instance; static BakingCamera s_Instance;
@@ -16,7 +17,11 @@ namespace Coffee.UIParticleExtensions
get get
{ {
// If current scene is prefab mode, create OverlayCamera for editor. // If current scene is prefab mode, create OverlayCamera for editor.
#if UNITY_2021_2_OR_NEWER
var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#else
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#endif
if (prefabStage == null || !prefabStage.scene.isLoaded) return null; if (prefabStage == null || !prefabStage.scene.isLoaded) return null;
if (s_InstanceForPrefab) return s_InstanceForPrefab; if (s_InstanceForPrefab) return s_InstanceForPrefab;
@@ -40,12 +45,11 @@ namespace Coffee.UIParticleExtensions
// Find instance in scene, or create new one. // Find instance in scene, or create new one.
return s_Instance return s_Instance
? s_Instance ? s_Instance
: (s_Instance = FindObjectOfType<BakingCamera>() ?? Create()); : (s_Instance = Create());
} }
} }
private Camera _camera; private Camera _camera;
// private int _refCount;
private static BakingCamera Create() private static BakingCamera Create()
{ {
@@ -56,6 +60,7 @@ namespace Coffee.UIParticleExtensions
var inst = gameObject.AddComponent<BakingCamera>(); var inst = gameObject.AddComponent<BakingCamera>();
inst._camera = gameObject.AddComponent<Camera>(); inst._camera = gameObject.AddComponent<Camera>();
inst._camera.enabled = false;
inst._camera.orthographic = true; inst._camera.orthographic = true;
// Turn camera off because particle mesh baker will use only camera matrix // Turn camera off because particle mesh baker will use only camera matrix

View File

@@ -22,8 +22,6 @@ namespace Coffee.UIExtensions
private static readonly GUIContent s_ContentTrailMaterial = new GUIContent("Trail 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_Content3D = new GUIContent("3D");
private static readonly GUIContent s_ContentScale = new GUIContent("Scale"); private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
private static readonly List<UIParticle> s_TempParents = new List<UIParticle>();
private static readonly List<UIParticle> s_TempChildren = new List<UIParticle>();
private SerializedProperty _spMaskable; private SerializedProperty _spMaskable;
private SerializedProperty _spScale; private SerializedProperty _spScale;
@@ -214,11 +212,20 @@ namespace Coffee.UIExtensions
DestroyImmediate(p); DestroyImmediate(p);
DestroyImmediate(cr); DestroyImmediate(cr);
#if UNITY_2018_3_OR_NEWER #if UNITY_2021_2_OR_NEWER
var stage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#elif UNITY_2018_3_OR_NEWER
var stage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); var stage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
#endif
#if UNITY_2018_3_OR_NEWER
if (stage != null && stage.scene.isLoaded) if (stage != null && stage.scene.isLoaded)
{ {
PrefabUtility.SaveAsPrefabAsset(stage.prefabContentsRoot, stage.prefabAssetPath); #if UNITY_2020_1_OR_NEWER
string prefabAssetPath = stage.assetPath;
#else
string prefabAssetPath = stage.prefabAssetPath;
#endif
PrefabUtility.SaveAsPrefabAsset(stage.prefabContentsRoot, prefabAssetPath);
} }
#endif #endif
} }
@@ -250,20 +257,27 @@ namespace Coffee.UIExtensions
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
if (showXyz) if (showXyz)
{ {
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(sp); 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 else
{ {
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(x, s_ContentScale); EditorGUILayout.PropertyField(x, s_ContentScale);
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck())
z.floatValue = y.floatValue = x.floatValue; {
x.floatValue = Mathf.Max(0.001f, x.floatValue);
y.floatValue = Mathf.Max(0.001f, x.floatValue);
z.floatValue = Mathf.Max(0.001f, x.floatValue);
}
} }
x.floatValue = Mathf.Max(0.001f, x.floatValue);
y.floatValue = Mathf.Max(0.001f, y.floatValue);
z.floatValue = Mathf.Max(0.001f, z.floatValue);
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
showXyz = GUILayout.Toggle(showXyz, s_Content3D, EditorStyles.miniButton, GUILayout.Width(30)); showXyz = GUILayout.Toggle(showXyz, s_Content3D, EditorStyles.miniButton, GUILayout.Width(30));
if (EditorGUI.EndChangeCheck() && !showXyz) if (EditorGUI.EndChangeCheck() && !showXyz)

View File

@@ -1,6 +1,7 @@
#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 #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 #define SERIALIZE_FIELD_MASKABLE
#endif #endif
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Coffee.UIParticleExtensions; using Coffee.UIParticleExtensions;
@@ -16,7 +17,7 @@ namespace Coffee.UIExtensions
/// <summary> /// <summary>
/// Render maskable and sortable particle effect ,without Camera, RenderTexture or Canvas. /// Render maskable and sortable particle effect ,without Camera, RenderTexture or Canvas.
/// </summary> /// </summary>
[ExecuteInEditMode] [ExecuteAlways]
[RequireComponent(typeof(RectTransform))] [RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))] [RequireComponent(typeof(CanvasRenderer))]
public class UIParticle : MaskableGraphic public class UIParticle : MaskableGraphic
@@ -60,6 +61,7 @@ namespace Coffee.UIExtensions
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>(); private static readonly List<Component> s_Components = new List<Component>();
private static readonly List<ParticleSystem> s_ParticleSystems = new List<ParticleSystem>();
/// <summary> /// <summary>
@@ -176,6 +178,11 @@ namespace Coffee.UIExtensions
particles.Exec(p => p.Stop()); particles.Exec(p => p.Stop());
} }
public void Clear()
{
particles.Exec(p => p.Clear());
}
public void SetParticleSystemInstance(GameObject instance) public void SetParticleSystemInstance(GameObject instance)
{ {
SetParticleSystemInstance(instance, true); SetParticleSystemInstance(instance, true);
@@ -266,7 +273,7 @@ namespace Coffee.UIExtensions
// //
GetComponents(typeof(IMaterialModifier), s_Components); GetComponents(typeof(IMaterialModifier), s_Components);
var materialCount = Mathf.Max(8, count); var materialCount = Mathf.Min(8, count);
canvasRenderer.materialCount = materialCount; canvasRenderer.materialCount = materialCount;
var j = 0; var j = 0;
for (var i = 0; i < particles.Count; i++) for (var i = 0; i < particles.Count; i++)
@@ -388,7 +395,6 @@ namespace Coffee.UIExtensions
#if !SERIALIZE_FIELD_MASKABLE #if !SERIALIZE_FIELD_MASKABLE
maskable = m_Maskable; maskable = m_Maskable;
#endif #endif
_cachedPosition = transform.position;
activeMeshIndices.Clear(); activeMeshIndices.Clear();
UIParticleUpdater.Register(this); UIParticleUpdater.Register(this);
@@ -407,6 +413,25 @@ namespace Coffee.UIExtensions
InitializeIfNeeded(); 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> /// <summary>
/// This function is called when the behaviour becomes disabled. /// This function is called when the behaviour becomes disabled.
/// </summary> /// </summary>

View File

@@ -11,6 +11,7 @@ namespace Coffee.UIExtensions
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>(); static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
static MaterialPropertyBlock s_Mpb; static MaterialPropertyBlock s_Mpb;
static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048]; static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048];
private static int frameCount = 0;
public static void Register(UIParticle particle) public static void Register(UIParticle particle)
@@ -41,6 +42,10 @@ namespace Coffee.UIExtensions
private static void 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"); Profiler.BeginSample("[UIParticle] Refresh");
for (var i = 0; i < s_ActiveParticles.Count; i++) for (var i = 0; i < s_ActiveParticles.Count; i++)
{ {
@@ -69,12 +74,12 @@ namespace Coffee.UIExtensions
BakeMesh(particle); BakeMesh(particle);
Profiler.EndSample(); Profiler.EndSample();
if (QualitySettings.activeColorSpace == ColorSpace.Linear) // if (QualitySettings.activeColorSpace == ColorSpace.Linear)
{ // {
Profiler.BeginSample("[UIParticle] Modify color space to linear"); // Profiler.BeginSample("[UIParticle] Modify color space to linear");
particle.bakedMesh.ModifyColorSpaceToLinear(); // particle.bakedMesh.ModifyColorSpaceToLinear();
Profiler.EndSample(); // Profiler.EndSample();
} // }
Profiler.BeginSample("[UIParticle] Set mesh to CanvasRenderer"); Profiler.BeginSample("[UIParticle] Set mesh to CanvasRenderer");
particle.canvasRenderer.SetMesh(particle.bakedMesh); particle.canvasRenderer.SetMesh(particle.bakedMesh);
@@ -154,6 +159,9 @@ namespace Coffee.UIExtensions
particle.cachedPosition = position; particle.cachedPosition = position;
if (particle.activeMeshIndices.CountFast() == 0)
diff = Vector3.zero;
for (var i = 0; i < particle.particles.Count; i++) for (var i = 0; i < particle.particles.Count; i++)
{ {
Profiler.BeginSample("[UIParticle] Bake Mesh > Push index"); Profiler.BeginSample("[UIParticle] Bake Mesh > Push index");

View File

@@ -65,22 +65,32 @@ namespace Coffee.UIParticleExtensions
return false; 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 internal static class MeshExtensions
{ {
static readonly List<Color32> s_Colors = new List<Color32>(); // static readonly List<Color32> s_Colors = new List<Color32>();
public static void ModifyColorSpaceToLinear(this Mesh self) // public static void ModifyColorSpaceToLinear(this Mesh self)
{ // {
self.GetColors(s_Colors); // self.GetColors(s_Colors);
//
for (var i = 0; i < s_Colors.Count; i++) // for (var i = 0; i < s_Colors.Count; i++)
s_Colors[i] = ((Color) s_Colors[i]).gamma; // s_Colors[i] = ((Color) s_Colors[i]).gamma;
//
self.SetColors(s_Colors); // self.SetColors(s_Colors);
s_Colors.Clear(); // s_Colors.Clear();
} // }
public static void Clear(this CombineInstance[] self) public static void Clear(this CombineInstance[] self)
{ {
@@ -94,7 +104,8 @@ namespace Coffee.UIParticleExtensions
internal static class MeshPool internal static class MeshPool
{ {
private static readonly Stack<Mesh> s_Pool = new Stack<Mesh>(); 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() public static void Init()
{ {
@@ -107,6 +118,7 @@ namespace Coffee.UIParticleExtensions
var m = new Mesh(); var m = new Mesh();
m.MarkDynamic(); m.MarkDynamic();
s_Pool.Push(m); s_Pool.Push(m);
s_HashPool.Add(m.GetInstanceID());
} }
} }
@@ -116,7 +128,11 @@ namespace Coffee.UIParticleExtensions
while (0 < s_Pool.Count) while (0 < s_Pool.Count)
{ {
m = s_Pool.Pop(); m = s_Pool.Pop();
if (m) return m; if (m)
{
s_HashPool.Remove(m.GetInstanceID());
return m;
}
} }
m = new Mesh(); m = new Mesh();
@@ -126,9 +142,14 @@ namespace Coffee.UIParticleExtensions
public static void Return(Mesh mesh) public static void Return(Mesh mesh)
{ {
if (!mesh || s_Pool.Contains(mesh)) return; if (!mesh) return;
var id = mesh.GetInstanceID();
if (s_HashPool.Contains(id)) return;
mesh.Clear(false); mesh.Clear(false);
s_Pool.Push(mesh); s_Pool.Push(mesh);
s_HashPool.Add(id);
} }
} }

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.3.3", "version": "3.3.10",
"unity": "2018.2", "unity": "2018.2",
"license": "MIT", "license": "MIT",
"repository": { "repository": {