xamarin / urho

Code to integrate with the Urho3D engine
Other
462 stars 122 forks source link

Resource isn't found when calling ResourceCache.GetTexture2D() #162

Closed matachi closed 8 years ago

matachi commented 8 years ago

Hi,

I have an Xamarin.Forms app where I'm using UrhoSharp.Forms. I'm trying to load a .bmp image into UrhoSharp, but it's failing on both iOS and Android.

On Android, I'm getting the following error message in Visual Studio's Output panel: 10-19 16:41:31.213 E/Urho3D (24046): Could not find resource my_texture.bmp. And on iOS I'm getting the error: 2016-10-19 18:44:11.814 TestApp.iOS[12302:212152] Could not find resource my_texture.bmp.

I cannot figure out what I'm doing wrong. I'm simply starting the Urho application with the following code:

protected override async void OnAppearing()
{
    await UrhoSurface.Show<UrhoApp>(new ApplicationOptions("Data"));
}

And I'm then trying to get the texture with:

var text = ResourceCache.GetTexture2D("my_texture.bmp");

I have made a basic project at https://github.com/matachi/urhosharp-load-resources where the error occurs. As a reference I looked at the FeatureSamples project. But I guess I failed at including the asset correctly into the two projects, or maybe I'm not using ApplicationOptions correctly.

EgorBo commented 8 years ago

@matachi let me explain it in a screenshot: ios_droid

Therzok commented 8 years ago

@EgorBo It actually is there as an AndroidAsset: https://github.com/matachi/urhosharp-load-resources/blob/master/TestApp/TestApp.Droid/TestApp.Droid.csproj#L141-L146

matachi commented 8 years ago

@EgorBo Yeah, as @Therzok says, the image is already included as an AndroidAsset in the Android project. And it's included as a BundledResource on iOS.

Here's a screenshot which might better explain the current state:

9

matachi commented 8 years ago

I have made a simpler example at https://github.com/matachi/urhosharp-load-resources/tree/master/TestApp.Droid2 where it's still not working. It doesn't reference the PCL project, so it's just a stand-alone project. This attempt is also more similar to the FeatureSamples project; for instance, it uses standard UrhoSharp (not Forms). I hope this makes it easier to debug the problem.

EgorBo commented 8 years ago

@matachi @Therzok oh I didn't notice, everything is OK with assets, but the problem is - lack of ctor with the given signature: public UrhoApp(ApplicationOptions opts) : base(opts) {} UrhoSurface didn't find it and decided you are fine with default options (which don't include custom assets). it's not ok, i'll make this ctor mandatory to implement.

ghost commented 7 years ago

@EgorBo,

This is closed but still putting comment here, correct me if I am wrong.

I am facing this issue with UWP using Urho.Forms.

Could not find resource Textures/SomeFile.png., can you please guide me for same.

Note: I am able to load the .mdl file from Data/Models folder. Texture & Material folder exist in the same Data folder.

koehlera99 commented 6 years ago

With Visual Studio on Windows, I had to set it to "Always Copy" to output directory. Else, be sure the file is in the Debug bin folder.