mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2024-12-22 22:47:24 +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);
|
||||
|
||||
material = target as Material;
|
||||
material = target.TryCast<Material>();
|
||||
|
||||
if (material.mainTexture)
|
||||
SetActiveTexture(material.mainTexture);
|
||||
|
||||
string[] propNames = mi_GetTexturePropertyNames.Invoke(material, ArgumentUtility.EmptyArgs) as string[];
|
||||
foreach (string property in propNames)
|
||||
if (mi_GetTexturePropertyNames.Invoke(material, ArgumentUtility.EmptyArgs) is IEnumerable<string> propNames)
|
||||
{
|
||||
if (material.GetTexture(property) is Texture texture)
|
||||
foreach (string property in propNames)
|
||||
{
|
||||
if (texture.TryCast<Texture2D>() is null && texture.TryCast<Cubemap>() is null)
|
||||
continue;
|
||||
if (material.GetTexture(property) is Texture texture)
|
||||
{
|
||||
if (texture.TryCast<Texture2D>() is null && texture.TryCast<Cubemap>() is null)
|
||||
continue;
|
||||
|
||||
textures.Add(property, texture);
|
||||
textures.Add(property, texture);
|
||||
|
||||
if (!activeTexture)
|
||||
SetActiveTexture(texture);
|
||||
if (!activeTexture)
|
||||
SetActiveTexture(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ namespace UnityExplorer.UI.Widgets
|
||||
{
|
||||
base.OnBorrowed(target, targetType, inspector);
|
||||
|
||||
if (target is Cubemap cubemap)
|
||||
if (target.TryCast<Cubemap>() is Cubemap cubemap)
|
||||
{
|
||||
texture = TextureHelper.UnwrapCubemap(cubemap);
|
||||
shouldDestroyTexture = true;
|
||||
}
|
||||
else if (target is Sprite sprite)
|
||||
else if (target.TryCast<Sprite>() is Sprite sprite)
|
||||
{
|
||||
if (sprite.packingMode == SpritePackingMode.Tight)
|
||||
texture = sprite.texture;
|
||||
@ -47,7 +47,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
shouldDestroyTexture = true;
|
||||
}
|
||||
}
|
||||
else if (target is Image image)
|
||||
else if (target.TryCast<Image>() is Image image)
|
||||
{
|
||||
if (image.sprite.packingMode == SpritePackingMode.Tight)
|
||||
texture = image.sprite.texture;
|
||||
@ -58,7 +58,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
}
|
||||
}
|
||||
else
|
||||
texture = target as Texture2D;
|
||||
texture = target.TryCast<Texture2D>();
|
||||
|
||||
if (textureViewerRoot)
|
||||
textureViewerRoot.transform.SetParent(inspector.UIRoot.transform);
|
||||
|
Loading…
Reference in New Issue
Block a user