Compare commits

...

31 Commits
3.3.4 ... 3.x

Author SHA1 Message Date
semantic-release-bot
6394eee4de chore(release): 3.3.14 [skip ci]
## [3.3.14](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.13...3.3.14) (2023-08-15)

### Bug Fixes

* error on InitializeIfNeeded ([1f1fb2a](1f1fb2a62a)), closes [#264](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/264)
2023-08-15 02:04:46 +00:00
mob-sakai
1f1fb2a62a fix: error on InitializeIfNeeded
close #264
2023-08-15 11:02:19 +09:00
semantic-release-bot
640cee9e34 chore(release): 3.3.13 [skip ci]
## [3.3.13](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.12...3.3.13) (2023-05-18)

### Bug Fixes

* memory leak when using AnimatableProperty ([3849a9f](3849a9f697))
2023-05-18 12:38:06 +00:00
mob-sakai
9dedbfb48f build: update release workflow 2023-05-18 21:37:23 +09:00
mob-sakai
3849a9f697 fix: memory leak when using AnimatableProperty 2023-05-18 21:29:36 +09:00
semantic-release-bot
69bde2cf3d chore(release): 3.3.12 [skip ci]
## [3.3.12](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.11...3.3.12) (2022-06-10)

### Bug Fixes

* always display materials in inspector ([a10042d](a10042d989))
* UNITY_UI_ALPHACLIP in UIAdditive shader is not working ([e817e8d](e817e8d3c7))
2022-06-10 11:32:11 +00:00
mob-sakai
a10042d989 fix: always display materials in inspector 2022-06-10 19:55:49 +09:00
mob-sakai
dd2d185e4a style: tab to space 2022-06-10 17:06:34 +09:00
mob-sakai
e817e8d3c7 fix: UNITY_UI_ALPHACLIP in UIAdditive shader is not working 2022-06-10 17:06:34 +09:00
semantic-release-bot
aaac2b71a3 chore(release): 3.3.11 [skip ci]
## [3.3.11](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.10...3.3.11) (2022-06-10)

### Bug Fixes

* sorting by layer does not work properly ([ccc09e6](ccc09e6aca))
* when using linear color space, the particle colors are not output correctly ([11c3a7b](11c3a7b374)), closes [#203](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/203)
2022-06-10 07:21:00 +00:00
mob-sakai
11c3a7b374 fix: when using linear color space, the particle colors are not output correctly
To fix, set 'Apply Active Color Space' in renderer module to false.

close #203
2022-06-10 16:12:15 +09:00
micromang
ccc09e6aca fix: sorting by layer does not work properly 2022-06-10 16:10:13 +09:00
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
10 changed files with 292 additions and 138 deletions

View File

@@ -5,7 +5,7 @@ on:
branches:
- preview
- main
- v*.x
- "*.x"
tags-ignore:
- "**"
@@ -13,9 +13,9 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: cycjimmy/semantic-release-action@v2
- uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/changelog

View File

@@ -1,3 +1,78 @@
## [3.3.14](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.13...3.3.14) (2023-08-15)
### Bug Fixes
* error on InitializeIfNeeded ([1f1fb2a](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1f1fb2a62a9d2ca6562e1b1e70d528aaf52bfc82)), closes [#264](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/264)
## [3.3.13](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.12...3.3.13) (2023-05-18)
### Bug Fixes
* memory leak when using AnimatableProperty ([3849a9f](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/3849a9f6977bc6d2474001c8154a8e201f7e8b7b))
## [3.3.12](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.11...3.3.12) (2022-06-10)
### Bug Fixes
* always display materials in inspector ([a10042d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/a10042d989dea18ff010bdbe970aa434e2bdf117))
* UNITY_UI_ALPHACLIP in UIAdditive shader is not working ([e817e8d](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/e817e8d3c75188f3243243855b135bd840699199))
## [3.3.11](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.10...3.3.11) (2022-06-10)
### Bug Fixes
* sorting by layer does not work properly ([ccc09e6](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/ccc09e6aca2fa3d7bc887e6c733e66706e40ae0f))
* when using linear color space, the particle colors are not output correctly ([11c3a7b](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/11c3a7b37415d78e1b8ba3988a6e043c9f1861e0)), closes [#203](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/203)
## [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)

View File

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

View File

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

View File

@@ -22,8 +22,6 @@ namespace Coffee.UIExtensions
private static readonly GUIContent s_ContentTrailMaterial = new GUIContent("Trail Material");
private static readonly GUIContent s_Content3D = new GUIContent("3D");
private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
private static readonly List<UIParticle> s_TempParents = new List<UIParticle>();
private static readonly List<UIParticle> s_TempChildren = new List<UIParticle>();
private SerializedProperty _spMaskable;
private SerializedProperty _spScale;
@@ -32,8 +30,7 @@ namespace Coffee.UIExtensions
private SerializedProperty _spShrinkByMaterial;
private ReorderableList _ro;
private bool _xyzMode;
private bool _showMaterials;
static private bool _xyzMode;
private static readonly List<string> s_MaskablePropertyNames = new List<string>
{
@@ -60,14 +57,11 @@ namespace Coffee.UIExtensions
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
_ro.elementHeightCallback = _ => _showMaterials
? 3 * (EditorGUIUtility.singleLineHeight + 2)
: EditorGUIUtility.singleLineHeight + 2;
_ro.elementHeightCallback = _ => 3 * (EditorGUIUtility.singleLineHeight + 2);
_ro.drawElementCallback = (rect, index, active, focused) =>
{
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
@@ -75,8 +69,6 @@ namespace Coffee.UIExtensions
rect.height = EditorGUIUtility.singleLineHeight;
var p = sp.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(rect, p, GUIContent.none);
if (!_showMaterials) return;
rect.x += 15;
rect.width -= 15;
var ps = p.objectReferenceValue as ParticleSystem;
@@ -100,9 +92,6 @@ namespace Coffee.UIExtensions
#endif
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder);
var content = EditorGUIUtility.IconContent(_showMaterials ? "VisibilityOn" : "VisibilityOff");
_showMaterials = GUI.Toggle(new Rect(rect.width - 55, rect.y, 24, 20), _showMaterials, content, EditorStyles.label);
if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton))
{
foreach (UIParticle t in targets)
@@ -204,6 +193,24 @@ namespace Coffee.UIExtensions
DestroyUIParticle(current);
return;
}
// #203: When using linear color space, the particle colors are not output correctly.
// To fix, set 'Apply Active Color Space' in renderer module to false.
var allPsRenderers = targets.OfType<UIParticle>()
.SelectMany(x => x.particles)
.Where(x => x)
.Select(x => x.GetComponent<ParticleSystemRenderer>())
.ToArray();
if (0 < allPsRenderers.Length)
{
var so = new SerializedObject(allPsRenderers);
var sp = so.FindProperty("m_ApplyActiveColorSpace");//.boolValue = false;
if (FixButton(sp.boolValue || sp.hasMultipleDifferentValues, "When using linear color space, the particle colors are not output correctly.\nTo fix, set 'Apply Active Color Space' in renderer module to false."))
{
sp.boolValue = false;
so.ApplyModifiedProperties();
}
}
}
void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false)
@@ -214,11 +221,20 @@ namespace Coffee.UIExtensions
DestroyImmediate(p);
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();
#endif
#if UNITY_2018_3_OR_NEWER
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
}

View File

@@ -17,7 +17,7 @@ namespace Coffee.UIExtensions
/// <summary>
/// Render maskable and sortable particle effect ,without Camera, RenderTexture or Canvas.
/// </summary>
[ExecuteInEditMode]
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))]
public class UIParticle : MaskableGraphic
@@ -178,6 +178,11 @@ namespace Coffee.UIExtensions
particles.Exec(p => p.Stop());
}
public void Clear()
{
particles.Exec(p => p.Clear());
}
public void SetParticleSystemInstance(GameObject instance)
{
SetParticleSystemInstance(instance, true);
@@ -308,6 +313,20 @@ namespace Coffee.UIExtensions
ClearPreviousMaterials();
}
private void ClearMaterials()
{
// Clear mask materials.
s_PrevMaskMaterials.AddRange(_maskMaterials);
_maskMaterials.Clear();
// Clear modified materials.
s_PrevModifiedMaterials.AddRange(_modifiedMaterials);
_modifiedMaterials.Clear();
canvasRenderer.Clear();
ClearPreviousMaterials();
}
private void ClearPreviousMaterials()
{
foreach (var m in s_PrevMaskMaterials)
@@ -390,7 +409,6 @@ namespace Coffee.UIExtensions
#if !SERIALIZE_FIELD_MASKABLE
maskable = m_Maskable;
#endif
_cachedPosition = transform.position;
activeMeshIndices.Clear();
UIParticleUpdater.Register(this);
@@ -411,17 +429,20 @@ namespace Coffee.UIExtensions
private new IEnumerator Start()
{
// #147: ParticleSystem creates Particles in wrong position during prewarm
// #148: Particle Sub Emitter not showing when start game
var hasPlayingSubEmitter = particles.AnyFast(ps =>
var delayToPlay = particles.AnyFast(ps =>
{
ps.GetComponentsInChildren(false, s_ParticleSystems);
return s_ParticleSystems.AnyFast(p => p.isPlaying && p.subEmitters.enabled);
return s_ParticleSystems.AnyFast(p => p.isPlaying && (p.subEmitters.enabled || p.main.prewarm));
});
s_ParticleSystems.Clear();
if (!hasPlayingSubEmitter) yield break;
if (!delayToPlay) yield break;
Stop();
Clear();
yield return null;
Play();
}
@@ -440,6 +461,7 @@ namespace Coffee.UIExtensions
_bakedMesh = null;
base.OnDisable();
ClearMaterials();
}
/// <summary>
@@ -458,6 +480,7 @@ namespace Coffee.UIExtensions
private void InitializeIfNeeded()
{
if (!this) return;
if (enabled && m_IsTrail)
{
UnityEngine.Debug.LogWarningFormat(this, "[UIParticle] The UIParticle component should be removed: {0}\nReason: UIParticle for trails is no longer needed.", name);

View File

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

View File

@@ -79,18 +79,18 @@ namespace Coffee.UIParticleExtensions
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)
{
self.GetColors(s_Colors);
for (var i = 0; i < s_Colors.Count; i++)
s_Colors[i] = ((Color) s_Colors[i]).gamma;
self.SetColors(s_Colors);
s_Colors.Clear();
}
// public static void ModifyColorSpaceToLinear(this Mesh self)
// {
// self.GetColors(s_Colors);
//
// for (var i = 0; i < s_Colors.Count; i++)
// s_Colors[i] = ((Color) s_Colors[i]).gamma;
//
// self.SetColors(s_Colors);
// s_Colors.Clear();
// }
public static void Clear(this CombineInstance[] self)
{
@@ -104,7 +104,8 @@ namespace Coffee.UIParticleExtensions
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()
{
@@ -117,6 +118,7 @@ namespace Coffee.UIParticleExtensions
var m = new Mesh();
m.MarkDynamic();
s_Pool.Push(m);
s_HashPool.Add(m.GetInstanceID());
}
}
@@ -126,7 +128,11 @@ namespace Coffee.UIParticleExtensions
while (0 < s_Pool.Count)
{
m = s_Pool.Pop();
if (m) return m;
if (m)
{
s_HashPool.Remove(m.GetInstanceID());
return m;
}
}
m = new Mesh();
@@ -136,9 +142,14 @@ namespace Coffee.UIParticleExtensions
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);
s_Pool.Push(mesh);
s_HashPool.Add(id);
}
}
@@ -219,7 +230,7 @@ namespace Coffee.UIParticleExtensions
// Sorting layer: ascending
if (aRenderer.sortingLayerID != bRenderer.sortingLayerID)
return aRenderer.sortingLayerID - bRenderer.sortingLayerID;
return SortingLayer.GetLayerValueFromID(aRenderer.sortingLayerID) - SortingLayer.GetLayerValueFromID(bRenderer.sortingLayerID);
// Sorting order: ascending
if (aRenderer.sortingOrder != bRenderer.sortingOrder)

View File

@@ -1,101 +1,117 @@
Shader "UI/Additive"
{
Properties
{
_MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
Properties
{
_MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_ColorMask ("Color Mask", Float) = 15
_ClipRect ("Clip Rect", Vector) = (-32767, -32767, 32767, 32767)
}
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
_ColorMask ("Color Mask", Float) = 15
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog { Mode Off }
Blend One One
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
}
ColorMask [_ColorMask]
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityUI.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
};
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _ClipRect;
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog { Mode Off }
Blend One One
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.worldPosition = IN.vertex;
OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.texcoord = TRANSFORM_TEX(IN.texcoord, _MainTex);
#ifdef UNITY_HALF_TEXEL_OFFSET
OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
#endif
OUT.color = IN.color * _Color;
return OUT;
}
ColorMask [_ColorMask]
fixed4 frag(v2f IN) : SV_Target
{
half4 color = tex2D(_MainTex, IN.texcoord) * IN.color;
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
color.rgb *= color.a;
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.01);
#endif
return color;
}
ENDCG
}
}
Pass
{
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile __ UNITY_UI_CLIP_RECT
#pragma multi_compile __ UNITY_UI_ALPHACLIP
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
v2f vert(appdata_t v)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
OUT.worldPosition = v.vertex;
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
OUT.color = v.color * _Color;
return OUT;
}
fixed4 frag(v2f IN) : SV_Target
{
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
#ifdef UNITY_UI_CLIP_RECT
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif
color.rgb *= color.a;
return color;
}
ENDCG
}
}
}

View File

@@ -2,7 +2,7 @@
"name": "com.coffee.ui-particle",
"displayName": "UI Particle",
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
"version": "3.3.4",
"version": "3.3.14",
"unity": "2018.2",
"license": "MIT",
"repository": {