KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
67 stars 8 forks source link

Pack Texture Failed at Unity Version 2023.2.20f1 #360

Closed q393980062 closed 1 week ago

q393980062 commented 1 month ago

Environment

Description

When I use Pack Texture to pack any file, I get the following error:

Texture must have width greater than 0. UnityEngine.Texture2D:.ctor (int,int,UnityEngine.TextureFormat,bool) Animancer.Editor.Tools.PackTexturesTool:Pack () (at ./Packages/com.kybernetik.animancer/Editor/Animancer Tools/PackTexturesTool.cs:184) Animancer.Editor.Tools.PackTexturesTool:DoBodyGUI () (at ./Packages/com.kybernetik.animancer/Editor/Animancer Tools/PackTexturesTool.cs:122) Animancer.Editor.Tools.AnimancerToolsWindow/Tool:DoGUI () (at ./Packages/com.kybernetik.animancer/Editor/Animancer Tools/Tool.cs:115) Animancer.Editor.Tools.AnimancerToolsWindow:OnGUI () (at ./Packages/com.kybernetik.animancer/Editor/Animancer Tools/AnimancerToolsWindow.cs:127) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

It seems that in the current version of Unity, creating a 0x0 texture is not allowed.

var packedTexture = new Texture2D(0, 0, TextureFormat.ARGB32, false);

After changing the texture size to 1x1, the Pack Texture works correctly.

var packedTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);

KybernetikGames commented 1 month ago

I've confirmed the same in Unity 6. Your fix looks like the way to go so it will be in the next version of Animancer.

KybernetikGames commented 1 week ago

Animancer v8.0.2 is now available with this fix in it.