mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2024-12-23 01:59:40 +08:00
Add support for Cubemaps in Texture2DWidget
This commit is contained in:
parent
ef4bc75d5e
commit
104288a912
@ -33,7 +33,10 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
{
|
{
|
||||||
base.OnBorrowed(target, targetType, inspector);
|
base.OnBorrowed(target, targetType, inspector);
|
||||||
|
|
||||||
TextureRef = target.TryCast<Texture2D>();
|
if (target.TryCast<Cubemap>() is Cubemap cubemap)
|
||||||
|
TextureRef = TextureHelper.UnwrapCubemap(cubemap);
|
||||||
|
else
|
||||||
|
TextureRef = target.TryCast<Texture2D>();
|
||||||
|
|
||||||
realWidth = TextureRef.width;
|
realWidth = TextureRef.width;
|
||||||
realHeight = TextureRef.height;
|
realHeight = TextureRef.height;
|
||||||
@ -175,18 +178,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
File.Delete(path);
|
File.Delete(path);
|
||||||
|
|
||||||
Texture2D tex = TextureRef;
|
TextureHelper.SaveTextureAsPNG(TextureRef, path);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override GameObject CreateContent(GameObject uiRoot)
|
public override GameObject CreateContent(GameObject uiRoot)
|
||||||
|
@ -30,7 +30,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
UnityObjectWidget widget = target switch
|
UnityObjectWidget widget = target switch
|
||||||
{
|
{
|
||||||
Texture2D => Pool<Texture2DWidget>.Borrow(),
|
Texture2D or Cubemap => Pool<Texture2DWidget>.Borrow(),
|
||||||
AudioClip => Pool<AudioClipWidget>.Borrow(),
|
AudioClip => Pool<AudioClipWidget>.Borrow(),
|
||||||
_ => Pool<UnityObjectWidget>.Borrow()
|
_ => Pool<UnityObjectWidget>.Borrow()
|
||||||
};
|
};
|
||||||
|
@ -79,11 +79,11 @@
|
|||||||
<!-- il2cpp nuget -->
|
<!-- il2cpp nuget -->
|
||||||
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
|
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
|
||||||
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.22" />
|
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.22" />
|
||||||
<PackageReference Include="UniverseLib.IL2CPP" Version="1.3.14" />
|
<PackageReference Include="UniverseLib.IL2CPP" Version="1.3.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- mono nuget -->
|
<!-- mono nuget -->
|
||||||
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
|
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
|
||||||
<PackageReference Include="UniverseLib.Mono" Version="1.3.14" />
|
<PackageReference Include="UniverseLib.Mono" Version="1.3.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- ~~~~~ ASSEMBLY REFERENCES ~~~~~ -->
|
<!-- ~~~~~ ASSEMBLY REFERENCES ~~~~~ -->
|
||||||
|
Loading…
Reference in New Issue
Block a user