parent
1a748f19d0
commit
95235a929b
|
@ -17,11 +17,15 @@ namespace Coffee.UIParticleInternal
|
||||||
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
Type.GetType("UnityEditor.Experimental.U2D.SpriteEditorExtension, UnityEditor")
|
||||||
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
|
?? Type.GetType("UnityEditor.U2D.SpriteEditorExtension, UnityEditor");
|
||||||
|
|
||||||
private static readonly MethodInfo s_GetActiveAtlasTextureMethod = s_SpriteEditorExtensionType
|
private static readonly Func<Sprite, Texture2D> s_GetActiveAtlasTextureMethod =
|
||||||
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic);
|
(Func<Sprite, Texture2D>)Delegate.CreateDelegate(typeof(Func<Sprite, Texture2D>),
|
||||||
|
s_SpriteEditorExtensionType
|
||||||
|
.GetMethod("GetActiveAtlasTexture", BindingFlags.Static | BindingFlags.NonPublic));
|
||||||
|
|
||||||
private static readonly MethodInfo s_GetActiveAtlasMethod = s_SpriteEditorExtensionType
|
private static readonly Func<Sprite, SpriteAtlas> s_GetActiveAtlasMethod =
|
||||||
.GetMethod("GetActiveAtlas", BindingFlags.Static | BindingFlags.NonPublic);
|
(Func<Sprite, SpriteAtlas>)Delegate.CreateDelegate(typeof(Func<Sprite, SpriteAtlas>),
|
||||||
|
s_SpriteEditorExtensionType
|
||||||
|
.GetMethod("GetActiveAtlas", BindingFlags.Static | BindingFlags.NonPublic));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the actual texture of a sprite in play mode or edit mode.
|
/// Get the actual texture of a sprite in play mode or edit mode.
|
||||||
|
@ -30,9 +34,7 @@ namespace Coffee.UIParticleInternal
|
||||||
{
|
{
|
||||||
if (!self) return null;
|
if (!self) return null;
|
||||||
|
|
||||||
if (Application.isPlaying) return self.texture;
|
var ret = s_GetActiveAtlasTextureMethod(self);
|
||||||
|
|
||||||
var ret = s_GetActiveAtlasTextureMethod.Invoke(null, new object[] { self }) as Texture2D;
|
|
||||||
return ret ? ret : self.texture;
|
return ret ? ret : self.texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ namespace Coffee.UIParticleInternal
|
||||||
{
|
{
|
||||||
if (!self) return null;
|
if (!self) return null;
|
||||||
|
|
||||||
return s_GetActiveAtlasMethod.Invoke(null, new object[] { self }) as SpriteAtlas;
|
return s_GetActiveAtlasMethod(self);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue