Real-Serious-Games / Unity-Weld

MVVM-style data-binding system for Unity.
MIT License
499 stars 81 forks source link

Image Binder #10

Open Avatarchik opened 6 years ago

Avatarchik commented 6 years ago

Hello! Thanks for the project, is there a possibility of binding a picture or for the next it is necessary to write your adapter? Is there still an option to make a list with a pool of objects so as not to load everything into the UI and load it like that?

RoryDungan commented 6 years ago

In the past I've done this by exposing a property of type Texture on my view model and binding to it directly.

I like the idea of being able to have an adapter that takes something like a string and loads a texture from resources based on the string identifier though. Adapters are quite simple to write if you want to try this yourself. Have a look at the existing ones in UnityWeld/Binding/Adapters/ for some examples.

Resource pooling is a good idea but you would need to implement your own class for managing that. Managing pools of objects is probably outside the scope of this library.

RoryDungan commented 6 years ago

Sorry I should have specified, when I did this I used a RawImage component and a one way property binding to bind its texture property to a property on my view model.

image

If you wanted to use an adapter you would have to create something like a StringToTexture2DAdapter that calls Resources.Load in its Convert function.