diff --git a/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll b/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll index 71182e9..81271bc 100644 Binary files a/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll and b/UnityEditorPackage/Runtime/UnityExplorer.STANDALONE.Mono.dll differ diff --git a/src/UI/Widgets/UnityObjects/MaterialWidget.cs b/src/UI/Widgets/UnityObjects/MaterialWidget.cs index e1fbabc..4104eab 100644 --- a/src/UI/Widgets/UnityObjects/MaterialWidget.cs +++ b/src/UI/Widgets/UnityObjects/MaterialWidget.cs @@ -48,23 +48,25 @@ namespace UnityExplorer.UI.Widgets { base.OnBorrowed(target, targetType, inspector); - material = target as Material; + material = target.TryCast(); 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 propNames) { - if (material.GetTexture(property) is Texture texture) + foreach (string property in propNames) { - if (texture.TryCast() is null && texture.TryCast() is null) - continue; + if (material.GetTexture(property) is Texture texture) + { + if (texture.TryCast() is null && texture.TryCast() is null) + continue; - textures.Add(property, texture); + textures.Add(property, texture); - if (!activeTexture) - SetActiveTexture(texture); + if (!activeTexture) + SetActiveTexture(texture); + } } } diff --git a/src/UI/Widgets/UnityObjects/Texture2DWidget.cs b/src/UI/Widgets/UnityObjects/Texture2DWidget.cs index 39bf9fc..f458f04 100644 --- a/src/UI/Widgets/UnityObjects/Texture2DWidget.cs +++ b/src/UI/Widgets/UnityObjects/Texture2DWidget.cs @@ -32,12 +32,12 @@ namespace UnityExplorer.UI.Widgets { base.OnBorrowed(target, targetType, inspector); - if (target is Cubemap cubemap) + if (target.TryCast() is Cubemap cubemap) { texture = TextureHelper.UnwrapCubemap(cubemap); shouldDestroyTexture = true; } - else if (target is Sprite sprite) + else if (target.TryCast() 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() 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(); if (textureViewerRoot) textureViewerRoot.transform.SetParent(inspector.UIRoot.transform);