DragonBones / DragonBonesCSharp

DragonBones C# Runtime
MIT License
533 stars 198 forks source link

Load non GUI texture when loading GUI texture #54

Closed eduardbosch closed 6 years ago

eduardbosch commented 6 years ago

Hi to all šŸŽ‰,

I was having trouble with loading assets from code in GUI mode. I don't know if I'm loading the data in a wrong way, but I just wanted to expose how I solved my problem.

The problem was that If I load the data like this:

            UnityFactory.factory.LoadDragonBonesData("path/to/name_ske");
            UnityFactory.factory.LoadTextureAtlasData("path/to/name_tex", isUGUI: true);

            UnityFactory.factory.BuildArmatureComponent("armatureName", isUGUI: true);

The loading process crashes here https://github.com/DragonBones/DragonBonesCSharp/blob/11bf7b74174a0cfc1dc71be138bba645d0a01ad2/Unity/Demos/Assets/DragonBones/Scripts/unity/UnityTextureAtlasData.cs#L171 because my DragonBones data had some slots with blending mode different than BlendModel.Normal, which causes the method _GetUIMaterial to search for the textureinstead of the uiTexture which is not loaded.

So, when loading the UI texture, I think that we should also load the normal texture.

Let me know if I'm loading the data in a wrong way or this is a current bug.

Thanks a lot!

eduardbosch commented 6 years ago

I think that this commit 11bf7b74174a0cfc1dc71be138bba645d0a01ad2 might fix the bug I tried to solve with this PR, so I close it.