parent
429ff2dd09
commit
d11cd0a06d
|
@ -9,8 +9,9 @@ namespace Coffee.UIParticleExtensions
|
||||||
internal static class SpriteExtensions
|
internal static class SpriteExtensions
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
private static Type tSpriteEditorExtension = Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
private static Type tSpriteEditorExtension =
|
||||||
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
|
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
||||||
|
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
|
||||||
|
|
||||||
private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension
|
private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension
|
||||||
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
|
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
|
@ -222,29 +223,41 @@ namespace Coffee.UIParticleExtensions
|
||||||
if (!Mathf.Approximately(aPos, bPos))
|
if (!Mathf.Approximately(aPos, bPos))
|
||||||
return (int) Mathf.Sign(bPos - aPos);
|
return (int) Mathf.Sign(bPos - aPos);
|
||||||
|
|
||||||
|
return (int) Mathf.Sign(GetIndex(self, a) - GetIndex(self, b));
|
||||||
|
|
||||||
// Material instance ID: match
|
// Material instance ID: match
|
||||||
if (aMat.GetInstanceID() == bMat.GetInstanceID())
|
// if (aMat.GetInstanceID() == bMat.GetInstanceID())
|
||||||
return 0;
|
// return 0;
|
||||||
|
|
||||||
// Transform: ascending
|
// Transform: ascending
|
||||||
return TransformCompare(aTransform, bTransform);
|
// return TransformCompare(aTransform, bTransform);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int TransformCompare(Transform a, Transform b)
|
private static int GetIndex(IReadOnlyList<ParticleSystem> list, Object ps)
|
||||||
{
|
{
|
||||||
while (true)
|
for (var i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
if (!a && !b) return 0;
|
if (list[i].GetInstanceID() == ps.GetInstanceID()) return i;
|
||||||
if (!a) return -1;
|
|
||||||
if (!b) return 1;
|
|
||||||
if (a.parent == b.parent) return a.GetSiblingIndex() - b.GetSiblingIndex();
|
|
||||||
|
|
||||||
a = a.parent;
|
|
||||||
b = b.parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private static int TransformCompare(Transform a, Transform b)
|
||||||
|
// {
|
||||||
|
// while (true)
|
||||||
|
// {
|
||||||
|
// if (!a && !b) return 0;
|
||||||
|
// if (!a) return -1;
|
||||||
|
// if (!b) return 1;
|
||||||
|
// if (a.parent == b.parent) return a.GetSiblingIndex() - b.GetSiblingIndex();
|
||||||
|
//
|
||||||
|
// a = a.parent;
|
||||||
|
// b = b.parent;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public static long GetMaterialHash(this ParticleSystem self, bool trail)
|
public static long GetMaterialHash(this ParticleSystem self, bool trail)
|
||||||
{
|
{
|
||||||
if (!self) return 0;
|
if (!self) return 0;
|
||||||
|
|
Loading…
Reference in New Issue