diff --git a/src/UI/Widgets/UnityObjects/Texture2DWidget.cs b/src/UI/Widgets/UnityObjects/Texture2DWidget.cs index f00a894..411f4cf 100644 --- a/src/UI/Widgets/UnityObjects/Texture2DWidget.cs +++ b/src/UI/Widgets/UnityObjects/Texture2DWidget.cs @@ -33,7 +33,10 @@ namespace UnityExplorer.UI.Widgets { base.OnBorrowed(target, targetType, inspector); - TextureRef = target.TryCast(); + if (target.TryCast() is Cubemap cubemap) + TextureRef = TextureHelper.UnwrapCubemap(cubemap); + else + TextureRef = target.TryCast(); realWidth = TextureRef.width; realHeight = TextureRef.height; @@ -175,18 +178,7 @@ namespace UnityExplorer.UI.Widgets if (File.Exists(path)) File.Delete(path); - Texture2D tex = TextureRef; - if (!TextureHelper.IsReadable(tex)) - tex = TextureHelper.ForceReadTexture(tex); - - byte[] data = TextureHelper.EncodeToPNG(tex); - File.WriteAllBytes(path, data); - - if (tex != TextureRef) - { - // cleanup temp texture if we had to force-read it. - GameObject.Destroy(tex); - } + TextureHelper.SaveTextureAsPNG(TextureRef, path); } public override GameObject CreateContent(GameObject uiRoot) diff --git a/src/UI/Widgets/UnityObjects/UnityObjectWidget.cs b/src/UI/Widgets/UnityObjects/UnityObjectWidget.cs index 1c7ea67..fa2c2e8 100644 --- a/src/UI/Widgets/UnityObjects/UnityObjectWidget.cs +++ b/src/UI/Widgets/UnityObjects/UnityObjectWidget.cs @@ -30,7 +30,7 @@ namespace UnityExplorer.UI.Widgets UnityObjectWidget widget = target switch { - Texture2D => Pool.Borrow(), + Texture2D or Cubemap => Pool.Borrow(), AudioClip => Pool.Borrow(), _ => Pool.Borrow() }; diff --git a/src/UnityExplorer.csproj b/src/UnityExplorer.csproj index 3ef7c58..08ca6dc 100644 --- a/src/UnityExplorer.csproj +++ b/src/UnityExplorer.csproj @@ -79,11 +79,11 @@ - + - +