You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-15 04:30:09 +00:00
Compare commits
3 Commits
v4.10.0
...
v5.0.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1e3d68f60 | ||
|
|
a1ea8785bc | ||
|
|
2ee69d0424 |
@@ -1,3 +1,10 @@
|
||||
## [4.10.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.10.0...v4.10.1) (2024-09-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* mainTex will be ignored ([2ee69d0](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2ee69d04245fabce185f67dc9bd68c870e556564))
|
||||
|
||||
# [4.10.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.1...v4.10.0) (2024-09-29)
|
||||
|
||||
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIParticleInternal
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for Graphic class.
|
||||
/// </summary>
|
||||
internal static class GraphicExtensions
|
||||
{
|
||||
private static readonly Vector3[] s_WorldCorners = new Vector3[4];
|
||||
private static readonly Bounds s_ScreenBounds = new Bounds(new Vector3(0.5f, 0.5f, 0.5f), new Vector3(1, 1, 1));
|
||||
|
||||
/// <summary>
|
||||
/// Check if a Graphic component is currently in the screen view.
|
||||
/// </summary>
|
||||
public static void GetMaterialsForRendering(this Graphic self, List<Material> result)
|
||||
{
|
||||
result.Clear();
|
||||
if (!self) return;
|
||||
|
||||
var cr = self.canvasRenderer;
|
||||
var count = cr.materialCount;
|
||||
var popCount = cr.popMaterialCount;
|
||||
|
||||
if (result.Capacity < count + popCount)
|
||||
{
|
||||
result.Capacity = count + popCount;
|
||||
}
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
result.Add(cr.GetMaterial(i));
|
||||
}
|
||||
|
||||
for (var i = 0; i < popCount; i++)
|
||||
{
|
||||
result.Add(cr.GetPopMaterial(i));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a Graphic component is currently in the screen view.
|
||||
/// </summary>
|
||||
public static bool IsInScreen(this Graphic self)
|
||||
{
|
||||
if (!self || !self.canvas) return false;
|
||||
|
||||
if (FrameCache.TryGet(self, nameof(IsInScreen), out bool result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
Profiler.BeginSample("(COF)[GraphicExt] IsInScreen");
|
||||
var cam = self.canvas.renderMode != RenderMode.ScreenSpaceOverlay
|
||||
? self.canvas.worldCamera
|
||||
: null;
|
||||
var min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
|
||||
var max = new Vector3(float.MinValue, float.MinValue, float.MinValue);
|
||||
self.rectTransform.GetWorldCorners(s_WorldCorners);
|
||||
var screenSize = GetScreenSize();
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
if (cam)
|
||||
{
|
||||
s_WorldCorners[i] = cam.WorldToViewportPoint(s_WorldCorners[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_WorldCorners[i] = RectTransformUtility.WorldToScreenPoint(null, s_WorldCorners[i]);
|
||||
s_WorldCorners[i].x /= screenSize.x;
|
||||
s_WorldCorners[i].y /= screenSize.y;
|
||||
}
|
||||
|
||||
s_WorldCorners[i].z = 0;
|
||||
min = Vector3.Min(s_WorldCorners[i], min);
|
||||
max = Vector3.Max(s_WorldCorners[i], max);
|
||||
}
|
||||
|
||||
var bounds = new Bounds(min, Vector3.zero);
|
||||
bounds.Encapsulate(max);
|
||||
result = bounds.Intersects(s_ScreenBounds);
|
||||
FrameCache.Set(self, nameof(IsInScreen), result);
|
||||
Profiler.EndSample();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the actual main texture of a Graphic component.
|
||||
/// </summary>
|
||||
public static Texture GetActualMainTexture(this Graphic self)
|
||||
{
|
||||
var image = self as Image;
|
||||
if (image == null) return self.mainTexture;
|
||||
|
||||
var sprite = image.overrideSprite;
|
||||
return sprite ? sprite.GetActualTexture() : self.mainTexture;
|
||||
}
|
||||
|
||||
private static Vector2Int GetScreenSize()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying && !Camera.current)
|
||||
{
|
||||
var res = UnityStats.screenRes.Split('x');
|
||||
return new Vector2Int(int.Parse(res[0]), int.Parse(res[1]));
|
||||
}
|
||||
#endif
|
||||
return new Vector2Int(Screen.width, Screen.height);
|
||||
}
|
||||
|
||||
public static float GetParentGroupAlpha(this Graphic self)
|
||||
{
|
||||
var alpha = self.canvasRenderer.GetAlpha();
|
||||
if (Mathf.Approximately(alpha, 0)) return 1;
|
||||
|
||||
var inheritedAlpha = self.canvasRenderer.GetInheritedAlpha();
|
||||
return Mathf.Clamp01(inheritedAlpha / alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3803b037cd2ed45459dd660072f223dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,7 +24,6 @@ namespace Coffee.UIExtensions
|
||||
private static readonly CombineInstance[] s_CombineInstances = { new CombineInstance() };
|
||||
private static readonly List<Material> s_Materials = new List<Material>(2);
|
||||
private static MaterialPropertyBlock s_Mpb;
|
||||
private static readonly List<Color32> s_Colors = new List<Color32>();
|
||||
private static readonly Vector3[] s_Corners = new Vector3[4];
|
||||
private bool _delay;
|
||||
private int _index;
|
||||
@@ -189,7 +188,6 @@ namespace Coffee.UIExtensions
|
||||
if (!IsActive() || !_parent)
|
||||
{
|
||||
MaterialRepository.Release(ref _modifiedMaterial);
|
||||
_modifiedMaterial = null;
|
||||
return baseMaterial;
|
||||
}
|
||||
|
||||
@@ -215,10 +213,11 @@ namespace Coffee.UIExtensions
|
||||
);
|
||||
if (!MaterialRepository.Valid(hash, _modifiedMaterial))
|
||||
{
|
||||
MaterialRepository.Get(hash, ref _modifiedMaterial, () => new Material(modifiedMaterial)
|
||||
MaterialRepository.Get(hash, ref _modifiedMaterial, x => new Material(x.mat)
|
||||
{
|
||||
hideFlags = HideFlags.HideAndDontSave
|
||||
});
|
||||
hideFlags = HideFlags.HideAndDontSave,
|
||||
mainTexture = x.texture ? x.texture : x.mat.mainTexture
|
||||
}, (mat: modifiedMaterial, texture));
|
||||
}
|
||||
|
||||
return _modifiedMaterial;
|
||||
|
||||
@@ -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.10.0",
|
||||
"version": "4.10.1",
|
||||
"unity": "2018.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user