parent
429ff2dd09
commit
d11cd0a06d
|
@ -9,7 +9,8 @@ namespace Coffee.UIParticleExtensions
|
|||
internal static class SpriteExtensions
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
private static Type tSpriteEditorExtension = Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
||||
private static Type tSpriteEditorExtension =
|
||||
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
||||
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
|
||||
|
||||
private static MethodInfo miGetActiveAtlasTexture = tSpriteEditorExtension
|
||||
|
@ -222,29 +223,41 @@ namespace Coffee.UIParticleExtensions
|
|||
if (!Mathf.Approximately(aPos, bPos))
|
||||
return (int) Mathf.Sign(bPos - aPos);
|
||||
|
||||
return (int) Mathf.Sign(GetIndex(self, a) - GetIndex(self, b));
|
||||
|
||||
// Material instance ID: match
|
||||
if (aMat.GetInstanceID() == bMat.GetInstanceID())
|
||||
return 0;
|
||||
// if (aMat.GetInstanceID() == bMat.GetInstanceID())
|
||||
// return 0;
|
||||
|
||||
// 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 (!a) return -1;
|
||||
if (!b) return 1;
|
||||
if (a.parent == b.parent) return a.GetSiblingIndex() - b.GetSiblingIndex();
|
||||
if (list[i].GetInstanceID() == ps.GetInstanceID()) return i;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!self) return 0;
|
||||
|
|
Loading…
Reference in New Issue