mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
Fix some casts for IL2CPP
This commit is contained in:
parent
5a1676fb84
commit
dbe993a7c7
Binary file not shown.
@ -48,23 +48,25 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
{
|
{
|
||||||
base.OnBorrowed(target, targetType, inspector);
|
base.OnBorrowed(target, targetType, inspector);
|
||||||
|
|
||||||
material = target as Material;
|
material = target.TryCast<Material>();
|
||||||
|
|
||||||
if (material.mainTexture)
|
if (material.mainTexture)
|
||||||
SetActiveTexture(material.mainTexture);
|
SetActiveTexture(material.mainTexture);
|
||||||
|
|
||||||
string[] propNames = mi_GetTexturePropertyNames.Invoke(material, ArgumentUtility.EmptyArgs) as string[];
|
if (mi_GetTexturePropertyNames.Invoke(material, ArgumentUtility.EmptyArgs) is IEnumerable<string> propNames)
|
||||||
foreach (string property in propNames)
|
|
||||||
{
|
{
|
||||||
if (material.GetTexture(property) is Texture texture)
|
foreach (string property in propNames)
|
||||||
{
|
{
|
||||||
if (texture.TryCast<Texture2D>() is null && texture.TryCast<Cubemap>() is null)
|
if (material.GetTexture(property) is Texture texture)
|
||||||
continue;
|
{
|
||||||
|
if (texture.TryCast<Texture2D>() is null && texture.TryCast<Cubemap>() is null)
|
||||||
|
continue;
|
||||||
|
|
||||||
textures.Add(property, texture);
|
textures.Add(property, texture);
|
||||||
|
|
||||||
if (!activeTexture)
|
if (!activeTexture)
|
||||||
SetActiveTexture(texture);
|
SetActiveTexture(texture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
{
|
{
|
||||||
base.OnBorrowed(target, targetType, inspector);
|
base.OnBorrowed(target, targetType, inspector);
|
||||||
|
|
||||||
if (target is Cubemap cubemap)
|
if (target.TryCast<Cubemap>() is Cubemap cubemap)
|
||||||
{
|
{
|
||||||
texture = TextureHelper.UnwrapCubemap(cubemap);
|
texture = TextureHelper.UnwrapCubemap(cubemap);
|
||||||
shouldDestroyTexture = true;
|
shouldDestroyTexture = true;
|
||||||
}
|
}
|
||||||
else if (target is Sprite sprite)
|
else if (target.TryCast<Sprite>() is Sprite sprite)
|
||||||
{
|
{
|
||||||
if (sprite.packingMode == SpritePackingMode.Tight)
|
if (sprite.packingMode == SpritePackingMode.Tight)
|
||||||
texture = sprite.texture;
|
texture = sprite.texture;
|
||||||
@ -47,7 +47,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
shouldDestroyTexture = true;
|
shouldDestroyTexture = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (target is Image image)
|
else if (target.TryCast<Image>() is Image image)
|
||||||
{
|
{
|
||||||
if (image.sprite.packingMode == SpritePackingMode.Tight)
|
if (image.sprite.packingMode == SpritePackingMode.Tight)
|
||||||
texture = image.sprite.texture;
|
texture = image.sprite.texture;
|
||||||
@ -58,7 +58,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
texture = target as Texture2D;
|
texture = target.TryCast<Texture2D>();
|
||||||
|
|
||||||
if (textureViewerRoot)
|
if (textureViewerRoot)
|
||||||
textureViewerRoot.transform.SetParent(inspector.UIRoot.transform);
|
textureViewerRoot.transform.SetParent(inspector.UIRoot.transform);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user