Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

NData - MVVM framework for NGUI

Discussion in 'Assets and Asset Store' started by Art Of Bytes, Mar 15, 2012.

  1. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    In fact, if you use your player data only for loading purposes, you can modify loading so that everything gets loaded directly to contexts.
    Regarding your question - you might be interested in StayingAlive example (it is located in Assets\NData\NDataExamples\StayingAlive). It demonstrates the complete game, with it's full state defined in data contexts starting with single root, and the scene is just a view that reflects the underlying state.
     
  2. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Thanks for the help!

    StayingAlive is a very useful demo for me. There is a lot more you can do with this than I even expected at first :) And the code snippets for visual studio are great! Nice job!
     
  3. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Something I haven't figured out: Does checked binding have two way binding?

    I'm trying to add a Remember Me checkbox to my login screen. When I bind the value from PlayerPrefs at the start it works, but the property doesn't get updated interaction with the GUI so its always stuck on the default value.
     
  4. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Checked binding is indeed two-way, but only in case when you bind to bool property and check type is BOOLEAN. Example can be found in Assets\NData\NDataExamples\VisibilityCheckboxes\. It uses regular properties, but it will work with PersistentProperty<bool> too.
     
  5. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    I'm experiencing some strange behavior now..

    I have created a Player context and in the root context I have added a variable context of type Player called LocalPlayer. I'm using this context to do text and multi text bindings to display information about the player in a panel.

    When I validate the bindings, everything is clear (I checked with misspelled bindings too). But when I play, only some of the bindings will actually work. The strangest part is that when I closed/reopened the project, some bindings started to work and some that did previously work stopped working... all were created with property snippets.

    When I debug the values from the root context script to the console, everything appears to be initialized correctly. Here is an image of whats happening:



    Notice how the username "test_player" and the SP bar current/max values are not being displayed even though all the values show up in the console (and PlayerID and HP, Stamina are binding).

    The weirdest thing is that the username was working, and the stamina was not working. Once I restarted unity, the username stopped binding and the stamina began to bind.

    I've tried checking spelling and whatnot.. the validator tool shows no problems.. they appear to be initializing the properties correctly but no binding.. any advice?
     
    Last edited: Aug 26, 2013
  6. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    This randomness in behavior indicate that it may be related to scripts execution order, or something similar. If you could send your test project, we'd take a look into it for possible reason of the bug.
     
  7. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    I have a weird issue and workaround that might give some sort of insight on some of these randomly working binding issues.

    This property is completely broken, the bindings show weird data. Not a lack of data, simply incorrect data.
    Code (csharp):
    1.     #region Property CurrentShieldPower
    2.     private readonly EZData.Property<int> _privateCurrentShieldPowerProperty = new EZData.Property<int>();
    3.     public EZData.Property<int> CurrentShieldPowerProperty { get { return _privateCurrentShieldPowerProperty; } }
    4.     public int CurrentShieldPower {
    5.         get    { return CurrentShieldPowerProperty.GetValue(); }
    6.         set    { CurrentShieldPowerProperty.SetValue(value); }
    7.     }
    8.     #endregion

    This code works perfectly without changing anything else. All i did was change the names of the EZData Property variables. I did not change the scene or binding paths only the variable names.
    Code (csharp):
    1.     #region Property CurrShieldPower
    2.     private readonly EZData.Property<int> _privateCurrShieldPowerProperty = new EZData.Property<int>();
    3.     public EZData.Property<int> CurrShieldPowerProperty { get { return _privateCurrShieldPowerProperty; } }
    4.     public int CurrentShieldPower {
    5.         get    { return CurrShieldPowerProperty.GetValue(); }
    6.         set    { CurrShieldPowerProperty.SetValue(value); }
    7.     }
    8.     #endregion
    I cannot figure out whats happening here, but its seems like NData dislikes the variable names for some odd reason.
     
  8. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Interesting. I think the issue might be related to property name length? In the above I have a deep nested context so my paths are quite long and I suspected that might have been part of the issue.

    AOB, I'll send you a PM with more info.
     
  9. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    This is the binding we are using for this, which gives you an idea of the depth. "Story.CombatEncounter.EnemyShip.CurrentShieldPower"

    Also we found other instances at the same depth that still display incorrect data, even after changing the name of the underlying variables. The binding updates, but the data is faulty, sometimes jumping -2 when it should only change -1, it usually eventually synchronizes, but not at first.
     
    Last edited: Aug 31, 2013
  10. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    After checking the example it's now clear what's the reason of this behavior. Here's the thing - you are setting context for the view in your Start function.
    Code (csharp):
    1.  
    2.     void Start()
    3.     {
    4.         Context = RootContext.Instance;
    5.         View.SetContext(Context);
    6.     }
    7.  
    Since bindings are initially resolved in Start too, and Starts are executed in unpredicted order, you only see correct values for View objects that started after context was set. Two possible solutions:
    1. perforn View.SetContext in Awake rather than Start, or
    2. and ViewContext and move it to the top of the list in "Scripts Execution Order"

    both will guarantee that context will be set before any bindings resolution.
     
  11. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    Soooo.... check this. I imported ngui and ndata into a clean project. I opened your health bar example and changed the damage function to this...

    Code (csharp):
    1.         public void Damage()
    2.         {
    3.             Health -=1;
    4.         }
    Then i ran the project and it acted VERY weird. It starts ok...
    Click: 119/120
    Click: 118/120
    Click: 117/120
    Click: 112/120....wha?
    Click: 111/120
    Click: 110/120
    Click: 109/120
    Click: 105/120 ...uh?

    Yeah i dunno if its just me or what. I also added another button called heal, it works at first but once i click damage enough to make it drop unexpectedly it no long works correctly.

    Code (csharp):
    1.         public void Heal(){
    2.             Health +=1;
    3.         }

    I hope its just something on my end.
     
    Last edited: Sep 2, 2013
  12. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    Added a debug log to this.
    Code (csharp):
    1.         public void Damage()
    2.         {
    3.             Health -=1;
    4.             Debug.Log(Health.ToString());
    5.         }
    Output:
    119
    118
    117
    116 ... Shows 112 in the health bar
    111
    110
    109
    108 ... Shows 105 in the health bar
    104
     
  13. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    changed all of the datatypes to float instead of int....works perfect.
     
  14. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Well thank you sir :D

    I managed to set up the player inspector further today. Here is the inspector initialized with some default values:


    And after a LoginEvent (who just happens to be a new level 1 player)


    I just create the new Player context object, swap it into the RootContext, and voila!

    I love NData xD.
     
    Last edited: Sep 3, 2013
  15. Nezabyte

    Nezabyte

    Joined:
    Aug 21, 2012
    Posts:
    110
    I tried the HealthBar demo as well with a clean project and had the same issue as schragnasher.
     
  16. YukariYakumo

    YukariYakumo

    Joined:
    Sep 29, 2012
    Posts:
    3
    I'm working dynamic table with NData
    All binding works well , but I must call UITable to reposition when add/remove element
    It also works well , but my code will be mess
    Is there more efficient method by data binding?
     
  17. Cobra Johnson

    Cobra Johnson

    Joined:
    Aug 30, 2013
    Posts:
    2
    What is the benefit between this MVVM pack and just programming along the principle of MVVM, as i am writing my program on the principle of MVVM.

    Say ive got my standard Unity GUI layer that only contains GUI content that just calls to an inbetween layer (second script) where the code does stuff and that drives the actual code (Third script)? and if you wanted to, say NGUI Button to access a button method, you attach a script to the NGUIButton that sends a call to the Second Script that would otherwise receive the Unity GUI scrips input, i skipped trough itbriefly as i am at work, so if i missed something, my bad.
     
  18. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Its only $45 so ask yourself is it worth a couple hours of your time (I'd say yes). By the way your example doesn't really have anything to do with NData's main functionality with data binding... its not really about calling event functions.
     
  19. Cobra Johnson

    Cobra Johnson

    Joined:
    Aug 30, 2013
    Posts:
    2
    Thanks for the reply, i can see the perks it brings to rapidly bind data like idd use in xaml i tought it was just an inbetween layer to send events towards that mimic MVVM, i am just wondering if theres any performance to gain there or if my way of doing it right now drops actual performance, i dont really mind the time spend on coding.
     
  20. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    It is still extremely strange how it works with int, we have a reproduce for that, so next update will have a fix. Thanks for highlighting that out.
     
  21. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi, NData is not necessarily required in any project. If you are developing in your way and feel that NData will be redundant, that's totally fine to not use it. NData doesn't give any magical performance gain, it's basically applies the values to controls on data change notifications, so your way should be as good for performance as ours.

    Example with button click handling indeed doesn't require NData, regular NGUI click handler does the pretty much the same thing that OnClickBinding. In WPF terms NGUI click handler would be an analog of "code-behind", and OnClickBinding will be a command analog that affects the ViewModel layer. However, commands are rather exceptional case. As jay correctly noted, NData main purpose is to make data transfers between View and ViewModel automatic, and allow designing the View in a way when it's mainly driven not by events invocations, but rather by data updates.
     
  22. Pythagoras

    Pythagoras

    Joined:
    Aug 9, 2013
    Posts:
    8
    Greetings,

    I love Ndata, it's wonderfully useful. I'm trying to extend on the inventory example by considering a party of two or more characters who would each have their own inventory. I would like to switch from a character to another by clicking on his portrait and display the corresponding inventory. Any pointers on how to do that with Ndata ?

    Thanks in advance.
     
  23. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    Hi. I was wondering if there's any updates on the win 8 issues. What's interesting is that an older version of ndata passed WACK fine and is in a shipped product of ours on win8. This was back when there was still an EZData.dll file was still around, so i'm not sure how that worked out.

     
  24. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Hey, let me help you. This is very easy to do.

    First, create your Inventory class as an EZData.Context object.
    Next, initialize your player characters and give them each a new Inventory object with whatever data you like.
    Then create an EZData VariableContext reference of type Inventory in your root context class and call it 'TargetInventory' or something similar.

    Then, bind your inventory viewer panel to the TargetInventory and whenever you select a new target, assign that player's inventory object to TargetInventory

    For more complex projects you might want the root target to be a Player object who holds an Inventory by composition. That way you could do TargetPlayer.Inventory, TargetPlayer.Vitals, TargetPlayer.Skills, etc and only have to assign once for each target switch
     
  25. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    Actually nm. I was able to do a very small bit of hacking and pass WACK on my own, so this is less of a priority for me now.

     
  26. YukariYakumo

    YukariYakumo

    Joined:
    Sep 29, 2012
    Posts:
    3
    Some feature request
    Ndata should also binding Tween and Animation
    It'll be better to control effect easily.
     
  27. Pythagoras

    Pythagoras

    Joined:
    Aug 9, 2013
    Posts:
    8
    I'm running though some problems deserializing xml data into an EZData.Collection.
    I have been running some tests with a simple xml file which looks like this :

    Code (csharp):
    1. <Location name="City">
    2.   <Cards>
    3.     <Card name="MainStreet"/>
    4.     <Card name="SideStreet"/>
    5.   </Cards>
    6. </Location>
    And I'm trying to deserialize it into an EZData.Collection as such :

    Code (csharp):
    1. public class Card : EZData.Context
    2. {
    3.     #region Property Name
    4.     private readonly EZData.Property<string> _privateNameProperty = new EZData.Property<string>();
    5.     public EZData.Property<string> NameProperty { get { return _privateNameProperty; } }
    6.    
    7.     [XmlAttribute("name")]
    8.     public string Name
    9.     {
    10.         get    { return NameProperty.GetValue();    }
    11.         set    { NameProperty.SetValue(value); }
    12.     }
    13.     #endregion
    14. }
    15.  
    16. [XmlRoot("Location")]
    17. public class Location : EZData.Context
    18. {
    19.     #region Property Name
    20.     private readonly EZData.Property<string> _privateNameProperty = new EZData.Property<string>();
    21.     public EZData.Property<string> NameProperty { get { return _privateNameProperty; } }
    22.     [XmlAttribute("name")]
    23.     public string Name
    24.     {
    25.     get    { return NameProperty.GetValue();    }
    26.     set    { NameProperty.SetValue(value); }
    27.     }
    28.     #endregion
    29.        
    30.     #region Collection Cards
    31.     private EZData.Collection<Card> _privateCards = new EZData.Collection<Card>(false);
    32.     [XmlArray("Cards"), XmlArrayItem("Card", typeof(Card))]
    33.     public EZData.Collection<Card> Cards
    34.     {
    35.         get { return _privateCards; }
    36.     }
    37.     #endregion
    38.            
    39.     public static Location Load(string path)
    40.     {
    41.         var serializer = new XmlSerializer(typeof(Location));
    42.        
    43.         using (var stream = new FileStream(path, FileMode.Open))
    44.             return serializer.Deserialize(stream) as Location;
    45.     }
    46. }
    47.  
    My problem is that the above code doesn't populate the Cards collection at all. No Card object are added to the collection during deserialization.

    Any ideas what I'm doing wrong ? This is driving me nuts.
     
  28. Pythagoras

    Pythagoras

    Joined:
    Aug 9, 2013
    Posts:
    8
    Great ! Thank you. Quite easy indeed when you think of it that way.
     
  29. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    Good question.. I'm looking for something to serialize data into Context objects as well. I haven't used Xml serializers before, was thinking JSON. System.Xml is 1MB which is way too much to have in a mobile or webplayer build IMO.

    I tried LitJson but it will only serialize properties that are not multi-layer. Has anyone found a good solution to serialize data into NData objects?
     
  30. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi, that might be useful functionality. What are the exact use-cases you would need this bindings for?
     
  31. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    It is most likely, because our collection is a custom class, that XmlArray doesn't know how to work with. We'll check if it's possible to support xml serialization similar to your use-case, and if it can be done, it'll be available with the next update.
     
  32. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    I would like to use this for tweening the color and alpha to create a dimmer fade. For example fading between scenes or a semi-fade of the background when displaying a modal popup.
     
  33. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    For objects fade in / fade out you can use NguiFadeVisibilityBinding it acts like visibility binding, but with fading support. Affects only alpha, but may be what you need.
     
  34. Raphy

    Raphy

    Joined:
    Feb 5, 2013
    Posts:
    2
    Hey, is NDATA compatible with NGUI3 ? I am having compiler errors when I am starting a new project and I import NGUI3 and then NDATA.

    Thanks !
     
  35. YukariYakumo

    YukariYakumo

    Joined:
    Sep 29, 2012
    Posts:
    3
    Play(ReversePlay) , Reset or Toggle when some conditions satisfy.
     
  36. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Working on that, NGUI 3 change list is solid.
     
  37. prototype7

    prototype7

    Joined:
    Aug 29, 2012
    Posts:
    12
    Hey there,
    Do you have any approximate time schedule when it will compatible with NGUI3 ? Because that help me to
    reschudule my upgrade time.
     
  38. prototype7

    prototype7

    Joined:
    Aug 29, 2012
    Posts:
    12
    I did review 5 stars to make your motivation up :D:D
     
  39. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Please add NGUI 3 support.

    Thank you.
     
  40. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Can there be support for nested MasterPaths? It feels like MasterPaths and VariableContexts are conceptually the same thing.

    I have a structure like this

    MyMenu (Master Path = MyMenu)
    --ButtonA (Master Path = ButtonA)
    ----Label
    --ButtonB (Master Path = ButtonB)
    ----Label
    --Other stuff


    also +1 for NGUI 3:)

    One of the best frameworks I've used.
     
  41. concave

    concave

    Joined:
    Aug 28, 2012
    Posts:
    49
    hi - any news on the "huge rich data" collection?
     
  42. concave

    concave

    Joined:
    Aug 28, 2012
    Posts:
    49
    it seems - and that is really bad - that the onselection change of the list binding isn't triggert all the time - how come?
     
  43. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    The possible reason that comes to mind is that you might be performing some action that change selection from within OnSelectionChange handler, in which case notification is not sent to prevent infinite loop. If that's not the case, then some sample scene with bug reproduce could help a lot.

    Regarding your question about "huge data" - the last time we had to process rather large data with non-trivial UI representation in our own project we ended up using heavily customized ItemsSource binding with a lot of very project specific caching etc. Evey time, when we were dealing with similar stuff, it didn't seem like a reusable solution. So, basically, the answer is - we're still looking for solution to that.
     
  44. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Oh, also, good news everyone!

    New NData version was approved unusually fast on AssetStore. So NGUI 3 support is already available.
    However, there's a small, but very important...

    Note: you have to manually define NGUI_3 macro in your project. It can be done by putting the line
    -define:NGUI_3
    to the file Assets/smcs.rsp in your project.

    Unfortunately, we didn't find any good way to detect NGUI version automatically, and we really wouldn't like to create two separate NData versions. So, it's like this. Maybe it makes sense to add a menu command that determines the actual NGUI version installed and defines / undefines NGUI_3 accordingly. Or if everybody migrates to NGUI 3 we'll just make it a default, and NGUI 2 will be turned through the special option. What do you, guys, think?
     
  45. concave

    concave

    Joined:
    Aug 28, 2012
    Posts:
    49
    do you have an idea why this View to model binding doen't work - i used the same script as you post for bool
    -> SetValue Gets Called -> is value different is true -> but i get no set on the viewmodel side -
    if i log on the setter of the property like this

    public int Foo
    {
    get { return FooProperty.GetValue(); }
    set {Debug.Log ("Foo is set " + value + " at " + System.DateTime.Now);
    FooProperty.SetValue(value); }
    }

    i get no output at all...

    if i log the IsClassDifferent(value) in the property class i get a null pointer:
    ...
    else
    {
    // Value types are handled differently via cached typeof(T).IsValueType checkup
    // ReSharper disable CompareNonConstrainedGenericWithNull
    changed = (value == null _value != null) ||
    (value != null _value == null) ||
    (_value != null IsClassDifferent(value));
    // ReSharper restore CompareNonConstrainedGenericWithNull
    UnityEngine.Debug.Log("is class different? "+ IsClassDifferent(value));
    }
    ...

    can you give me an example of a view to model int binding -> i thought it would look excatly the same as the bool
    as your whole structure is generic.


    using UnityEngine;
    using System.Collections;

    public class MNMIntViewToModelBinding : NguiBinding
    {
    private EZData.Property<int> _property;

    protected override void Unbind()
    {
    base.Unbind();

    if (_property != null)
    {
    _property.OnChange -= ModelToView;
    _property = null;
    }
    }

    protected override void Bind()
    {
    base.Bind();

    var context = GetContext(Path);
    if (context != null)
    {
    _property = context.FindProperty<int>(Path, this);
    if (_property != null)
    _property.OnChange += ModelToView;
    }
    }

    private bool _ignoreChange;

    protected void ModelToView()
    {
    base.OnChange();
    if (_ignoreChange)
    return;

    // Apply _property.Value to view
    }

    public void ViewToModel(int newValue) // Called by view to set property value
    {
    Debug.Log("Called View To Model of: " + gameObject.name + " set the property to " + newValue);

    if (_property == null)
    return;

    _ignoreChange = true;
    _property.SetValue(newValue);
    _ignoreChange = false;
    }
    }
     
  46. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    I think its fine if you have to do an NGUI_3 macro. I still haven't migrated my project to NGUI 3 yet.

    I'm getting a strange error with one of my Text Bindings. I've got a TargetPlayer variable context which I changed into another class recently, and I had bound a Target Window to its values. My new class has the same values, and the behaviour is working, except that I get a MissingReferenceException on the first target click saying "The object of type 'NguiTextBinding' has been destroyed but you are still trying to access it.

    I'm certain the problem is coming from my target window because when I disable it, there is no error on target switch. If I disable adn then enable after startup, there is no error. I think something is going on with the binding map because the stack is registering my change of value and then getting stuck somewhere in the UpdateBinding method.

    Doesn't make sense to me??

    Full Error:
    MissingReferenceException: The object of type 'NguiTextBinding' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Component.get_gameObject () (at C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:183)
    NguiBaseBinding.UpdateMasterPath () (at Assets/NData/NGUI/NData/NguiBaseBinding.cs:35)
    NguiBaseBinding.UpdateBinding () (at Assets/NData/NGUI/NData/NguiBaseBinding.cs:75)
    NguiBaseBinding.OnContextChange () (at Assets/NData/NGUI/NData/NguiBaseBinding.cs:93)
    EZData.VariableContext`1[SimplePlayerContext].set_Value (.SimplePlayerContext value) (at Assets/NData/NGUI/NData/Core/VariableContext.cs:56)
    RootContext.set_TargetPlayer (.SimplePlayerContext value) (at Assets/Thorium Code/ViewModel/RootContext.cs:98)
    TargetEnemy1.OnMouseDown () (at Assets/Scratch/TargetEnemy1.cs:28)
    UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32, Int32)

    Any suggestions?
     
    Last edited: Oct 15, 2013
  47. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Is there a way to do a polymorphic NguiListItemTemplate. So rather then giving it one item type we can have an array of gameobjects?
     
  48. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568

    I've converted JSON .NET to work with Unity and be compatible with iOS. It's available on the Asset Store:

    http://u3d.as/5q2


    Also, I saw awhile back a post about GetValue not working and Art Of Bytes was looking into a fix for it... I sent him a PM but never got a reply. So, essentially GetValue( ) on a PropertyInfo instance invokes the Get method, but in Mono this will fail with AOT. It's a known issue (not just a Unity one). This fix is to use PropertyInfo.GetGetMethod() to return the getter for the property and then call Invoke. This will even work for private Getters as long as they're marked with a Serializable attribute.
     
  49. Enzign

    Enzign

    Joined:
    Aug 20, 2010
    Posts:
    169
    I have been getting to know the tool and adding all kinds of bindings to my project and it's been pretty straight forward. I have some Text Bindings, Visibility Bindings, Items Source Binding and it all works great. There is one Text Binding that i can't get working however.

    I have a collection named ActionsList which i have populated with a bunch of items from a ActionItem Class that contains a bunch of Preferences.

    If i use "ActionsList.SelectedItem.Name" (Name is just a string Property) as the Path it works fine. But when i use "ActionsList.SelectedItem.Action.testString" (where the Action property is made up of a custom class) it doesn't work. If i print "ActionsList.SelectedItem.Action.testString" it prints the correct value, but when i put that same string in the Path of my Text Binding, it doesn't work.

    Here is how the Action property looks:
    #region Property Action
    private readonly EZData.Property<SkillAction> _privateActionProperty = new EZData.Property<SkillAction>();
    public EZData.Property<SkillAction> ActionProperty { get { return _privateActionProperty; } }
    public SkillAction Action {
    get { return ActionProperty.GetValue(); }
    set { ActionProperty.SetValue(value); }
    }
    #endregion

    Are there any restrictions to what the Path value can be?
     
  50. yustinusadika

    yustinusadika

    Joined:
    Sep 3, 2013
    Posts:
    8
    Hi guys, i am really new with NData, however i find it really interesting and useful to manage my unity project.
    Recently i had a problem while trying to make a simple friend request (Accept and Reject) function using the NData.
    To easily explain it, i made a simple picture for the layout. $Friend Requests.png

    By looking at the picture, my prefab structure is:
    *FriendRequestTemplate (as parent) :
    -> Accept Button (child)
    -> Reject Button (child)
    -> Friend Name (child)
    -> Friend Age (child)
    -> Friend Profile Picture(child)

    Then i added OnClickBinding component on the accept, reject and icon button (which are all children).
    If i clicked the button, the window for accept and reject is opened (using the visibility binding), but the problem is
    the data from the parent which are Name, Age and Profile Picture (which in each of the already binded using text and sprite binding) from the parent didn't show up in the child window.

    Do you have any idea how to solve this? It is similar to the quote below, but i don't want to click the parent collider first (only to get the selected item) before going to get value in the accept and reject window.
    I realized that the parent get NGUI Item Data Content when it is generated, and the children don't have it. Is that the problem why it can't get the selected item value?
    Thanks, sorry if it is such a beginner question and a quite messy post :)