push-pop / Unity-MVVM

Lightweight MVVM Framework for Unity3D
MIT License
323 stars 27 forks source link

Convert should be a ScriptableObject #69

Open push-pop opened 3 years ago

push-pop commented 3 years ago

This one I am less convinced on...

I am unsure how exactly this would work. i.e. how do you set parameters of the converter?

push-pop commented 3 years ago

Can we find a way to support MultiValueConverters?

https://www.c-sharpcorner.com/UploadFile/87b416/wpf-multivalue-converters/

AAAYaKo commented 3 years ago

I think the converters should be ScriptableObject because,

  1. they don't use the functionality of the components
  2. This will allow you to reuse one converter between different bindings and scenes. For example on the loading screen in the menu and when passing a level, I show the competition percentage And here I can use the same converter
push-pop commented 3 years ago

I can see the value here for re-use, however I think it is really useful to be able to easily create instances in the editor and change parameters easily.

Maybe we can have it both ways?

Make...

SerializedValueConverter : SerializedObject : IValueConverter {}

Then change public ValueConverterBase Converter; in DataBinding.cs to public IValueConverter Converter;

I think that would work and you could either re-use an existing Converter or create an instance in the editor.

This is similar to the idea of StaticResource in WPF.