You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e4d80bc1c | ||
|
|
6b87db7ac7 | ||
|
|
61760d940c | ||
|
|
f43d4c38ea | ||
|
|
ccb8386672 | ||
|
|
e15319a46e | ||
|
|
e352d153ce | ||
|
|
4f9bbf57bc | ||
|
|
0b9d80da93 | ||
|
|
24d32d8441 | ||
|
|
476c4027ff | ||
|
|
12c748a8cd | ||
|
|
0259ad2464 | ||
|
|
5f3ead2086 | ||
|
|
e3f42d747a | ||
|
|
b93e0e4701 |
37
CHANGELOG.md
37
CHANGELOG.md
@@ -1,3 +1,40 @@
|
||||
## [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)
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
internal class BakingCamera : MonoBehaviour
|
||||
{
|
||||
static BakingCamera s_Instance;
|
||||
@@ -40,12 +41,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 +56,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
|
||||
|
||||
@@ -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;
|
||||
@@ -218,7 +216,12 @@ namespace Coffee.UIExtensions
|
||||
var stage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -390,7 +395,6 @@ namespace Coffee.UIExtensions
|
||||
#if !SERIALIZE_FIELD_MASKABLE
|
||||
maskable = m_Maskable;
|
||||
#endif
|
||||
_cachedPosition = transform.position;
|
||||
activeMeshIndices.Clear();
|
||||
|
||||
UIParticleUpdater.Register(this);
|
||||
@@ -411,17 +415,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.9",
|
||||
"unity": "2018.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user