NVentimiglia / Unity3d-Databinding-Mvvm-Mvc

Unity3d uGUI Observable library for Mvvm / Mvc
http://unity3dfoundation.com
63 stars 16 forks source link

Discussion: WinRT Support #4

Closed negue closed 9 years ago

negue commented 9 years ago

Since WinRT (Windows Store & Phone) don't use the normal .Net Subset, this Package (and its dependencies) doesn't work for WinRT

For example.

System.Type.GetFields()
AppDomain
System.Reflection.Assembly.GetTypes()

and also my #3 Set-Method doesn't work (yet)

I think many workarounds / helper methods will need an own package / base project so that all other packages can use them.

What do you think?

I'll help to fix as much as possible^^

NVentimiglia commented 9 years ago

I will look into this sometime in the next week.

Most of the reflection stuff is encapsulated in the Foundation.Databinding.Model.dll. The solution would be a new VS class library targeting the correct subset. I will probably reuse the same code files and use compiler directives for switching between the two api's.

negue commented 9 years ago

I managed it to be compiled for WinRT but for now the binding doesn't work :smile:

I'll clean up and create a pull request tomorrow with my first changes.

NVentimiglia commented 9 years ago

I have a prototype fork for Windows Store. It builds but when I run the scene nothing happens. I tried building as a "Unity C# application" so that I could get debug support, however this resulted in missing reference exceptions. Take a look.

https://github.com/NVentimiglia/Unity3d-Databinding-Mvvm-Mvc/tree/WinSA

https://github.com/NVentimiglia/Unity3d-Databinding-Mvvm-Mvc/blob/WinSA/Foundation.Databinding%203.22.2015b.unitypackage

Edit

I managed it to be compiled for WinRT but for now the binding doesn't work :smile:

Nice. I have included support for Tasks and FullSerializer in my branch if you haven't.

NVentimiglia commented 9 years ago

I added a new test method. I confirmed that the bug we are seeing is in the view portion of the code.

 IEnumerator Start()
    {
        Output.text = "Starting Tests";

        yield return StartCoroutine(TestEvent());
        yield return StartCoroutine(Update1());
        yield return StartCoroutine(Update2());
        yield return StartCoroutine(Update3());

        Log = "Ending Tests";
        Log = string.Format("Average {0} {1} {2}", average1, average2, average3);
    }

    IEnumerator TestEvent()
    {
        Log = "Testing Event";
        yield return new WaitForSeconds(2);
        OnBindingUpdate += DatabindingTester_OnBindingUpdate;

        Property1 = 1;
        yield return new WaitForSeconds(2);
        Property2 = 2;
        yield return new WaitForSeconds(2);
        Property3 = 3;
        yield return new WaitForSeconds(2);

        OnBindingUpdate -= DatabindingTester_OnBindingUpdate;

    }

    void DatabindingTester_OnBindingUpdate(ObservableMessage obj)
    {
        Log = string.Format("{0} : {1}", obj.Name, obj.Value);
    }
NVentimiglia commented 9 years ago

Did some more research.

The BindingInfo (responsible for facilitating a property binding for the Binders) are not being serialized for WindowsStore. As a result, their values are deleted. If you look at the scene view, all 'values' are empty... the scene is totally unbound.

It is insane that WSA does not support editor serialization. I will need to think of a new way of serializing bindings within the editor.

NVentimiglia commented 9 years ago

Got it working.

I added a reference to the WinRTLegacy dll to the Databinding class library. After that everything worked even the [Serializable] annotation's used outside that library.

negue commented 9 years ago

Oh nice! gonna try it right away

negue commented 9 years ago

Finally it works on my end too xD

WinRTLegacy is added automatically by Unity Editor? (for the Build & Run Step)

NVentimiglia commented 9 years ago