Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 104288a

Browse files
committed
Add support for Cubemaps in Texture2DWidget
1 parent ef4bc75 commit 104288a

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

src/UI/Widgets/UnityObjects/Texture2DWidget.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public override void OnBorrowed(object target, Type targetType, ReflectionInspec
3333
{
3434
base.OnBorrowed(target, targetType, inspector);
3535

36-
TextureRef = target.TryCast<Texture2D>();
36+
if (target.TryCast<Cubemap>() is Cubemap cubemap)
37+
TextureRef = TextureHelper.UnwrapCubemap(cubemap);
38+
else
39+
TextureRef = target.TryCast<Texture2D>();
3740

3841
realWidth = TextureRef.width;
3942
realHeight = TextureRef.height;
@@ -175,18 +178,7 @@ private void OnSaveTextureClicked()
175178
if (File.Exists(path))
176179
File.Delete(path);
177180

178-
Texture2D tex = TextureRef;
179-
if (!TextureHelper.IsReadable(tex))
180-
tex = TextureHelper.ForceReadTexture(tex);
181-
182-
byte[] data = TextureHelper.EncodeToPNG(tex);
183-
File.WriteAllBytes(path, data);
184-
185-
if (tex != TextureRef)
186-
{
187-
// cleanup temp texture if we had to force-read it.
188-
GameObject.Destroy(tex);
189-
}
181+
TextureHelper.SaveTextureAsPNG(TextureRef, path);
190182
}
191183

192184
public override GameObject CreateContent(GameObject uiRoot)

src/UI/Widgets/UnityObjects/UnityObjectWidget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static UnityObjectWidget GetUnityWidget(object target, Type targetType, R
3030

3131
UnityObjectWidget widget = target switch
3232
{
33-
Texture2D => Pool<Texture2DWidget>.Borrow(),
33+
Texture2D or Cubemap => Pool<Texture2DWidget>.Borrow(),
3434
AudioClip => Pool<AudioClipWidget>.Borrow(),
3535
_ => Pool<UnityObjectWidget>.Borrow()
3636
};

src/UnityExplorer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@
7979
<!-- il2cpp nuget -->
8080
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
8181
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.22" />
82-
<PackageReference Include="UniverseLib.IL2CPP" Version="1.3.14" />
82+
<PackageReference Include="UniverseLib.IL2CPP" Version="1.3.15" />
8383
</ItemGroup>
8484
<!-- mono nuget -->
8585
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
86-
<PackageReference Include="UniverseLib.Mono" Version="1.3.14" />
86+
<PackageReference Include="UniverseLib.Mono" Version="1.3.15" />
8787
</ItemGroup>
8888

8989
<!-- ~~~~~ ASSEMBLY REFERENCES ~~~~~ -->

0 commit comments

Comments
 (0)