FabianFG / CUE4Parse

Apache License 2.0
279 stars 114 forks source link

Cannot decode UTexture2D #13

Closed TheNaeem closed 3 years ago

TheNaeem commented 3 years ago

Hello, I'm trying to export a texture icon as UTexture2D, and when calling Decode() it throws this exception: System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable 1 source, Func 2 predicate, Boolean& found) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable 1 source, Func 2 predicate)

The exception is thrown at line 113 of UTexture2D.cs

And this is how I'm loading the texture:

var texture = provider.LoadObject(@"FortniteGame/Content/UI/Foundation/Textures/Icons/Backpacks/T-Icon-Backpacks-773-Carabus-L");

var image = texture.Decode();

Thank you, I hope I was able to be descriptive on my issue, and hopefully it's just me doing something wrong.

4sval commented 3 years ago

what's the full code

TheNaeem commented 3 years ago

error is fixed now but thank you anyways :)

TheNaeem commented 3 years ago

The issue is happening again after verifying my game files, here is the full code:

var provider = new DefaultFileProvider(@"C:\Program Files\Epic Games\Fortnite\FortniteGame\Content\Paks", SearchOption.TopDirectoryOnly, true);
                provider.Initialize();

                var guid = new FGuid("00000000000000000000000000000000");
                var aes = new FAesKey("3FE5C589D219E71EE15FEB8FA9BC6B6224BB58AA826A0FA1D997D92E0D8DB23A");
                provider.SubmitKey(guid, aes);
                var texture = provider.LoadObject<UTexture2D>(@"/Game/UI/Foundation/Textures/Icons/Backpacks/T-Icon-Backpacks-773-Carabus-L"); //error throws on this line
4sval commented 3 years ago

provider.LoadMappings() after submitkey

TheNaeem commented 3 years ago

the exception still gets thrown

4sval commented 3 years ago

I just tested it and there's absolutely no issue if you do everything right initialize the provider, submit keys, load mappings, load object

TheNaeem commented 3 years ago

Did I do everything correctly in the code I provided above? I'm really not sure what else there is to do. Is your working code different than mine?

TheNaeem commented 3 years ago

Also, you can't see it in the code snippet but as I mentioned earlier, the exception isn't thrown when the texture is loaded, it's thrown when I called the Decode method

4sval commented 3 years ago

because you have no mappings

TheNaeem commented 3 years ago

idk man, even with loading the mappings the exception still throws:


            var provider = new DefaultFileProvider(@"C:\Program Files\Epic Games\Fortnite\FortniteGame\Content\Paks", SearchOption.TopDirectoryOnly, true);
            provider.Initialize();
            provider.LoadMappings();

            var guid = new FGuid("00000000000000000000000000000000");
            var aes = new FAesKey("0x3FE5C589D219E71EE15FEB8FA9BC6B6224BB58AA826A0FA1D997D92E0D8DB23A");
            provider.SubmitKey(guid, aes);
            var texture = provider.LoadObject<UTexture2D>(@"/Game/UI/Foundation/Textures/Icons/Backpacks/T-Icon-Backpacks-773-Carabus-L");
            texture.Decode();
4sval commented 3 years ago

provider.LoadMappings() after submitkey

...

TheNaeem commented 3 years ago

still throws even if i put it after submitkey lol

4sval commented 3 years ago

then paste and edit https://github.com/FabianFG/CUE4Parse/blob/master/CUE4Parse.Example/Program.cs