Compare commits

...

4 Commits

Author SHA1 Message Date
mob-sakai
67c7e816a7 fix: when using mesh sharing, the Transform.scale of the primary UIParticle affects the replicas.
close #333

NOTE: This fix may cause changes in the rendering of existing UIParticles.
2024-09-26 18:15:42 +09:00
semantic-release-bot
109caed657 chore(release): 4.9.1 [skip ci]
## [4.9.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.0...v4.9.1) (2024-08-07)

### Bug Fixes

* ParticleSystem trails gain offset on parent canvas change ([2a1cd50](2a1cd502b4)), closes [#323](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/323)
2024-08-07 17:13:07 +00:00
mob-sakai
2a1cd502b4 fix: ParticleSystem trails gain offset on parent canvas change
close #323
2024-08-08 02:00:40 +09:00
mob-sakai
78d0219235 update demo 2024-07-18 14:56:49 +09:00
5 changed files with 40 additions and 18 deletions

View File

@@ -31,3 +31,10 @@ MonoBehaviour:
m_Path: UnityEngine.Screen, UnityEngine.CoreModule;height
m_Arg2:
m_Path:
- m_Format: UIParticles:{0} Materials:{1}
m_Arg0:
m_Path: Coffee.UIExtensions.UIParticleUpdater, Coffee.UIParticle;uiParticleCount
m_Arg1:
m_Path: Coffee.UIParticleInternal.MaterialRepository, Coffee.UIParticle;count
m_Arg2:
m_Path:

View File

@@ -1,3 +1,10 @@
## [4.9.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.0...v4.9.1) (2024-08-07)
### Bug Fixes
* ParticleSystem trails gain offset on parent canvas change ([2a1cd50](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2a1cd502b452b5b56edf8bcfe91adf99d1bb5147)), closes [#323](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/323)
# [4.9.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.8.1...v4.9.0) (2024-07-18)

View File

@@ -355,13 +355,6 @@ 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()
{
}
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
}
@@ -593,7 +586,7 @@ namespace Coffee.UIExtensions
}
}
internal void UpdateTransformScale()
internal void UpdateTransformScale(Vector3 ratio)
{
_tracker.Clear();
canvasScale = canvas.rootCanvas.transform.localScale.Inverse();
@@ -617,7 +610,7 @@ namespace Coffee.UIExtensions
}
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
var newScale = parentScale.Inverse();
var newScale = parentScale.GetScaled(ratio).Inverse();
if (currentScale != newScale)
{
transform.localScale = newScale;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Coffee.UIParticleExtensions;
using UnityEditor;
using UnityEngine;
@@ -8,7 +9,7 @@ namespace Coffee.UIExtensions
{
private static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
private static readonly List<UIParticleAttractor> s_ActiveAttractors = new List<UIParticleAttractor>();
private static readonly HashSet<int> s_UpdatedGroupIds = new HashSet<int>();
private static readonly Dictionary<int, Vector3> s_GroupScales = new Dictionary<int, Vector3>();
private static int s_FrameCount;
public static int uiParticleCount => s_ActiveParticles.Count;
@@ -53,14 +54,17 @@ namespace Coffee.UIExtensions
// Do not allow it to be called in the same frame.
if (s_FrameCount == Time.frameCount) return;
s_FrameCount = Time.frameCount;
s_GroupScales.Clear();
// Simulate -> Primary
for (var i = 0; i < s_ActiveParticles.Count; i++)
{
// Process only primary UIParticles.
var uip = s_ActiveParticles[i];
if (!uip || !uip.canvas || !uip.isPrimary || !s_UpdatedGroupIds.Add(uip.groupId)) continue;
if (!uip || !uip.canvas || !uip.isPrimary || s_GroupScales.ContainsKey(uip.groupId)) continue;
uip.UpdateTransformScale();
s_GroupScales.Add(uip.groupId, uip.transform.parent.lossyScale);
uip.UpdateTransformScale(Vector3.one);
uip.UpdateRenderers();
}
@@ -70,20 +74,31 @@ namespace Coffee.UIExtensions
var uip = s_ActiveParticles[i];
if (!uip || !uip.canvas) continue;
uip.UpdateTransformScale();
// Case 1: Not using mesh sharing.
if (!uip.useMeshSharing)
{
uip.UpdateTransformScale(Vector3.one);
uip.UpdateRenderers();
}
else if (s_UpdatedGroupIds.Add(uip.groupId))
// Case 2: Using mesh sharing as primary.
else if (!s_GroupScales.TryGetValue(uip.groupId, out var groupScale))
{
s_GroupScales.Add(uip.groupId, uip.transform.parent.lossyScale);
uip.UpdateTransformScale(Vector3.one);
uip.UpdateRenderers();
}
// Case 3: Using mesh sharing as replica. (Only scaling)
else
{
var parentScale = uip.transform.parent.lossyScale;
var ratio = parentScale.IsVisible()
? groupScale.GetScaled(parentScale.Inverse())
: Vector3.one;
ratio = Vector3.one;
uip.UpdateTransformScale(ratio);
}
}
s_UpdatedGroupIds.Clear();
// Attract
for (var i = 0; i < s_ActiveAttractors.Count; i++)
{

View File

@@ -2,7 +2,7 @@
"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.9.0",
"version": "4.9.1",
"unity": "2018.2",
"license": "MIT",
"repository": {