Compare commits

...

19 Commits

Author SHA1 Message Date
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
9 changed files with 226 additions and 129 deletions

View File

@@ -1,3 +1,48 @@
## [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) ## [3.3.6](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/3.3.5...3.3.6) (2021-05-11)

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

@@ -17,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;

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;
@@ -32,8 +30,7 @@ namespace Coffee.UIExtensions
private SerializedProperty _spShrinkByMaterial; private SerializedProperty _spShrinkByMaterial;
private ReorderableList _ro; private ReorderableList _ro;
private bool _xyzMode; static private bool _xyzMode;
private bool _showMaterials;
private static readonly List<string> s_MaskablePropertyNames = new List<string> private static readonly List<string> s_MaskablePropertyNames = new List<string>
{ {
@@ -60,14 +57,11 @@ namespace Coffee.UIExtensions
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler"); _spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); _spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial"); _spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
var sp = serializedObject.FindProperty("m_Particles"); var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true); _ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4; _ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
_ro.elementHeightCallback = _ => _showMaterials _ro.elementHeightCallback = _ => 3 * (EditorGUIUtility.singleLineHeight + 2);
? 3 * (EditorGUIUtility.singleLineHeight + 2)
: EditorGUIUtility.singleLineHeight + 2;
_ro.drawElementCallback = (rect, index, active, focused) => _ro.drawElementCallback = (rect, index, active, focused) =>
{ {
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues); EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
@@ -75,8 +69,6 @@ namespace Coffee.UIExtensions
rect.height = EditorGUIUtility.singleLineHeight; rect.height = EditorGUIUtility.singleLineHeight;
var p = sp.GetArrayElementAtIndex(index); var p = sp.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(rect, p, GUIContent.none); EditorGUI.ObjectField(rect, p, GUIContent.none);
if (!_showMaterials) return;
rect.x += 15; rect.x += 15;
rect.width -= 15; rect.width -= 15;
var ps = p.objectReferenceValue as ParticleSystem; var ps = p.objectReferenceValue as ParticleSystem;
@@ -100,9 +92,6 @@ namespace Coffee.UIExtensions
#endif #endif
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder); 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)) if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton))
{ {
foreach (UIParticle t in targets) foreach (UIParticle t in targets)
@@ -204,6 +193,24 @@ namespace Coffee.UIExtensions
DestroyUIParticle(current); DestroyUIParticle(current);
return; 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) void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false)
@@ -214,11 +221,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
} }

View File

@@ -17,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

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);

View File

@@ -79,18 +79,18 @@ namespace Coffee.UIParticleExtensions
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)
{ {
@@ -104,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()
{ {
@@ -117,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());
} }
} }
@@ -126,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();
@@ -136,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);
} }
} }
@@ -219,7 +230,7 @@ namespace Coffee.UIParticleExtensions
// Sorting layer: ascending // Sorting layer: ascending
if (aRenderer.sortingLayerID != bRenderer.sortingLayerID) if (aRenderer.sortingLayerID != bRenderer.sortingLayerID)
return aRenderer.sortingLayerID - bRenderer.sortingLayerID; return SortingLayer.GetLayerValueFromID(aRenderer.sortingLayerID) - SortingLayer.GetLayerValueFromID(bRenderer.sortingLayerID);
// Sorting order: ascending // Sorting order: ascending
if (aRenderer.sortingOrder != bRenderer.sortingOrder) if (aRenderer.sortingOrder != bRenderer.sortingOrder)

View File

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