Search Unity

NData - MVVM framework for NGUI

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

  1. pmws

    pmws

    Joined:
    Sep 18, 2012
    Posts:
    7
    Hi,

    i have a problem with my tables after upgrading to NGUI 2.3.3.
    On some lists, not all off them oddly enough, the items fly to the top on the containin panel when I hover over them with the mouse. I can't see any difference between the working ones and the once that don't. I that a known issue and if so is there a fix?

    Edit: Fixed it by commenting out everything in OnHover and OnPress in NGUId OnButtonOffset.cs. Still weird that it happend on some lists and on some not....

    thanx,

    paul
     
    Last edited: Feb 21, 2013
  2. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    trying to deploy game on iOS. i think it's implementation specific, as we have (or had) ndata working in a different project on iOS.
    but in editor/windows/macos things work fine, but then when we go to iOS, i get this in XCode. (and others). not sure what could be wrong?!

    Failed to find collection ItemsToCollect
    System.NullReferenceException: A null value was found where an object instance was required.
    at System.Reflection.MonoProperty.CreateGetterDelegate (System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0
    at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
    at EZData.Context.NodeToCollection (System.Object node, System.String path) [0x0001d] in /Volumes/MacintoshHD/ZombieDeathChase/Assets/NData/NGUI/NData/Core/Context.cs:69
    at EZData.Context.Find[Collection] (System.Object node, System.String path, IBinding binding, EZData.Converter`1 converter) [0x00000] in <filename unknown>:0
    at EZData.Context.FindCollection (System.String path, IBinding binding) [0x00000] in /Volumes/MacintoshHD/ZombieDeathChase/Assets/NData/NGUI/NData/Core/Context.cs:239
    at NguiDataContext.FindCollection (System.String path, IBinding binding) [0x0000d] in /Volumes/MacintoshHD/ZombieDeathChase/Assets/NData/NGUI/NData/NguiDataContext.cs:70
     
  3. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    argh. nevermind this was the .Net 2.0 subset thing again. i forgot i changed it to try to fix something else. =/
     
  4. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    It's a pity we can't do away with those butt ugly Dependency Property-esque blocks. Ideally, they'd simply be Property<T> auto properties with implicit conversion to and from T. One line instead of 4!
     
  5. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Well, yeah, single property would be much better, but unfortunately there's no way around it. It at least have to be a property with a backing field, so that it's initialized in default constructor and on the other hand acts like a regular property of type T to the users of the context. And also it should be available as a Dependency property too, for assigning custom change event handlers if needed. However, in both MonoDevelop and VisualStudio you can use code snippets for dependency properties and collections creation, they really help: http://tools.artofbytes.com/ndata/documentation#Code_Snippets
    As for readability - property blocks can be collapsed so they look like simple one-line properties. Not ideal, of-course, but that's the best option so far.
     
  6. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    Does NData support nested elements in a hierarchy? My experiments are showing that only partial support exists, but perhaps I'm doing something wrong. Additionally, nested tables aren't being repositioned after creation, so there's a bunch of overlapping elements. In my code from before I was using NData, I had encountered the same thing, and just repositioned all of my tables starting from the "most nested" and working up to the root table.

    I'm trying to make a hierarchy of buttons for the time being (using a button prefab with a label that says "Name", and is bound to CategoryUi.Name), and what I'm seeing is that all of the buttons are created correctly, in the correct hierarchy, but as for the labels on the buttons, only the root categories are displaying the labels correctly. The rest of the buttons have blank labels.

    The first thing I did was check to make sure that my data is actually in the view model as I expect it to be, and it is indeed there, so I believe the issue is not with my data.

    So I can see 2 things from this:
    1) NData can populate nested tables in a tree.
    2) NData is setting the labels to SOMETHING, but for anything except the root categories, that something is just a blank string.

    My viewmodel is as follows:
     
    Last edited: Mar 12, 2013
  7. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    Also, I found a bug in NguiLocalScaleBinding:
    GetValue() reads from localPosition instead of localScale
     
  8. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi, Nyxo!

    Thanks for pointing out a bug with LocalScaleBinding! It's fixed, and will be available in the next update, seems getValue wasn't very commonly used feature in this binding :)

    Empty values in text bindings (as well as zeros in numeric bindings and false in Boolean ones) are the expected behavior when control is bound to something, but for some reason binding path is unresolved, so it provides a default value.

    As for nested elements, they are supported and should work fine. Let's clarify, what exactly you mean by nested elements (buttons for example)? Please, check the screenshot and confirm that we have the right understanding.
    Two buttons (one of them is a child of another one in the hierarchy) have labels both bound to the same value, and the value is displayed correctly. You also mentioned creating buttons from a prefab, so buttons are created in run-time, is that the case?

    $NestedButtons.png

    Thank you!
     
    Last edited: Mar 15, 2013
  9. ChaseRLewis73003

    ChaseRLewis73003

    Joined:
    Apr 23, 2012
    Posts:
    85
    Hello I recently purchased this addon to streamline designing UI's for NGUI. I haven't really learned it yet so I was going to run your demo then look around the code a bit to help me understand what to do. Unfortunately, the demo seems to be broken on import (I have made sure to import both NGUI and NData). The exact error I get is "Attempting to print using an invalid font". There is a font file and texture of fonts made into a UIFont referenced prefab and loaded but there is an issue. Also none of the widgets appear to have any interactivity, in it. If this is fixed I'd love to try it out, but no working demo and no pdf is a deal breaker at the moment.
     
  10. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    Hi AoB!
    What I meant by nesting, is a recursive hierarchy:
    $screen.png
    In my image, the red highlights the recursive UITables (the root is "Category Table") that all use an NguiListItemTemplate set to the same template (highlighted in yellow) - as you can see, the template has the nested UITables that are being used for the recursively nested categories.

    The desired result is to have a hierarchy of categories that contain subcategories. (You can think of this like the tree view on the left side of windows explorer)
     
  11. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    Okay, I found the problem. It's not a bug in NData (although perhaps there's a way that NData can handle this situation for the developer?) - it's directly tied to how Unity handles references inside of a prefab:

    Using my above setup as an example, we can look at the CategoryExtender prefab (note that it's a PREFAB, not an instantiated GameObject- this behaviour is specific to prefabs!), and see that SubCategory Table contains a NguiListItemTemplate component with the Template property set to CategoryExtender again (basically making a loop of itself). Unity doesn't think of that Template reference as a reference to a prefab, it thinks of it as a reference to the prefab's this reference. What that means is that once you instantiate CategoryExtender (and name it myInstance), the NguiListItemTemplate component on myInstance will have the Template property set to myInstance, NOT CategoryExtender. That means that every time myInstance.SubCategory Table instantiates a GameObject using the NguiListItemTemplate, it will create a copy of ITSELF instead of the original prefab it was created from!

    The simple workaround that I'm using, although not ideal, is to have 2 identical copies of the "CategoryExtender" prefab, with the only difference being that each one references the other as the "Template" in it's "NguiListItemTemplate" component.
     
    Last edited: Mar 19, 2013
  12. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hello,

    We are investigating this issue, but cannot reproduce it. Could you please provide more information about your Unity version (3.x or 4.x), OS (Win or Mac), NGUI version (paid or free and is it the last one available) and any other relevant info?

    Thank you!
     
  13. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Thank you very much for the valuable finding, Nyxo!
    We used nested collections before without any problems all the time, but never did so with item templates that reference themselves as their sub-tables item templates. And it seems to be the situation when this unity mechanism kicks in, that maintains references between newly instantiated child objects when you duplicate sub-hierarchy. Workaround that you introduced seems to be reliable and should cause no problems. However if it'll work, we'll try to detect and somehow revert self-references modified on instantiation, so they reference prefabs and there's no need in a workaround.

    As for paths inside item templates, you most likely already figured out the path in the bindings withing item template are will have the collection item as their context, so to display a name of the item (that is CategoryUi in your first example) you should only specify "Name" as the binding path. Also you may find useful the bindings validation tool. It's an Alt-V shortcut or Tools->NData->Validate Binding from the menu. Editor script checks if all paths are resolved correctly in the selected game object and it's whole sub-hierarchy.

    Thanks again for your interest and help in improving NData. Good luck with your projects, we hope our tools will be helpful!
     
  14. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    Other than update polling (ugh) is there a way to use delegates to detect changes at the View Level so that I can do something at the game logic level? I know at can do this with button command calls but how about on drop down (UIPopuplist) and table selection changes? Is there some mechanism to inform my game logic model that the user changed something? Again I am trying to avoid update polling.

    My current solution is just to go in and add an extra path variable to the bindings that calls a method on ViewModel (ie OnSelectionPath), this is easy enough since you are already are detecting this on your Ngui UI objects anyway for the normal binding. Its just more work and I lose future compatibility by changing those binding files. I was wondering if you already had a built-in solution that I am not seeing?

    Great product and extremely useful for organizing front end UI.

    I made a small correction to get NguiPopupListSourceBinding.cs to work. I needed to make a change to Awake and here it is. I just needed to correctly map OnSelectionChange after that is worked like a charm:
    Code (csharp):
    1.  
    2. public override void Awake()
    3.     {
    4.         base.Awake();
    5.         _uiPopupList = GetComponent<UIPopupList>();
    6.         if (_uiPopupList != null)
    7.         {
    8.             _nativeEventReceiver = _uiPopupList.eventReceiver;
    9.             _nativeFunctionName = _uiPopupList.functionName;
    10.            
    11.             //_uiPopupList.eventReceiver = gameObject;
    12.             //_uiPopupList.functionName = "OnSelectionChange";
    13.             _uiPopupList.onSelectionChange = OnSelectionChange;
    14.         }
    15.     }
    16.  
     
  15. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi, Enoch. There's a way to do so, each property has OnChange event, it's triggered whenever value change occurs, including its changes by View. So you can add your custom handler to this event and there you go, if that's what you need. That works without polling, actually very few things in NData rely on polling (like two-way Vector3-based bindings to transform), we try to keep everything event-based.

    Thanks for a hint with PopupList binding. It seems like onSelectionChange delegate was added to popup list some time after we created the binding and we missed that change. That will be included to the next NData release.

    Regards and good luck.
     
  16. soulis6

    soulis6

    Joined:
    Apr 21, 2011
    Posts:
    22
    Related to the Nested Collections Nyxo was talking about, I can't seem to get nested collections to work with ItemSource binding, what's the right way to set it up? It works fine for the 'top' level collection, but nothing inside that one gets created.

    In this instance, I have a table with item source binding that's creating a Headline prefab. The Headline prefab has on itself another table and item source binding, referencing a 2nd prefab, called RegularLine
    .
    So the hierarchy should look like this;


    but what's happening is that it Headlines are getting created only. I can access the data of the regular lines, and see that it exists in code, but it's not getting instantiated by the ItemSourceBinding when it's created.

    Is it possible to use two nested collections with item source binding like this?
     
  17. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi, soulis. It's totally possible. Maybe the issue in your case is the path in inner itemsource bindings. For a case you described, you most likely have a viewmodel similar to that:
    Code (csharp):
    1.  
    2. public class Line : EZData.Context
    3. {
    4.     #region Property Text
    5.     private readonly EZData.Property<string> _privateTextProperty = new EZData.Property<string>();
    6.     public EZData.Property<string> TextProperty { get { return _privateTextProperty; } }
    7.     public string Text
    8.     {
    9.     get    { return TextProperty.GetValue();    }
    10.     set    { TextProperty.SetValue(value); }
    11.     }
    12.     #endregion
    13. }
    14.  
    15. public class Headline : EZData.Context
    16. {
    17.     #region Collection Lines
    18.     private readonly EZData.Collection<Line> _privateLines = new EZData.Collection<Line>(false);
    19.     public EZData.Collection<Line> Lines { get { return _privateLines; } }
    20.     #endregion
    21. }
    22.  
    23. public class Root : EZData.Context
    24. {
    25.     #region Collection Headlines
    26.     private readonly EZData.Collection<Headline> _privateHeadlines = new EZData.Collection<Headline>(false);
    27.     public EZData.Collection<Headline> Headlines { get { return _privateHeadlines; } }
    28.     #endregion 
    29. }
    30.  
    in that case UI objects hierarchy will be as you described with the following additions:
    It's like when you are referencing something in binding while being inside of an instantiated item template, your current context is this exact item and all paths start from it. Sometimes it's not obvious and paths like "Headlines.Lines" might come to mind, they are, however, wrong. Don't forget that you can always check yourself with bindings validation tool.

    Other than that, it should work as you expect, so if it won't, let's investigate the problem in more details.
     
  18. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    View attachment 47596

    I just purchased the NData v1.0.11 and imported to Unity3d 3.5.7 ( both Mac and Win ), NGUI is latest paid version, However the script highlighted with Red seems corrupted.

    Also mentioned by ChaseRLewis73003 , NDataDemo UIFont also corrupted as well.
     
    Last edited: Mar 21, 2013
  19. soulis6

    soulis6

    Joined:
    Apr 21, 2011
    Posts:
    22

    Thanks for the quick reply. It's set up just the way you described, and the validate bindings tool works, no errors, so I'm not sure why the 'Lines" aren't being instantiated.

    I've also tried creating the Line items several frames after adding the Headlines, but it didn't appear to make a difference.
     
  20. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    /NData/Editor/NData/SceneValidator.cs also corrupted in Unity Editor
     
  21. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi guys!

    Thank you very much for this issues reports!
    That is really very strange behavior, we have not seen anything like this before. We try to reproduce and investigate this problems with corrupted scripts with Unity support guys.

    As soon as we come up with the solution, we'll let you know.

    By the way, have you tried to re-import the package?

    If you have any other details related to this issue, please, let us know.

    Thank you!
     
  22. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    I tried to re-import again, doesn't help.
     
  23. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    In NData Documentation Page, the code snippet "Persistent Property" is valid ?

    Also, could u add more tutorial examples on how to use NData.
    e.g.
    1. click to popup a confirmation dialog panel and return yes or no.
    2. how to use Variable Context
    3. how can a ViewModel call another ViewModel ?
     
    Last edited: Mar 25, 2013
  24. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    How would I setup a context such that there is only one of 3 states available, and each one has common properties? It's a property visualisation, where the states are:

    Overview
    Stage (section of development)
    Lot (actual piece of land inside a stage)

    Each viewmodel has a tooltip text, back button text and so on. What would be the best way to handle this type of thing in NData?

    Edit: never mind. Implemented a common interface for all 3 viewmodels, and filtered my binding through an ActiveState property in the root vm. Still having to manually update that though.
     
    Last edited: Mar 24, 2013
  25. Mickman

    Mickman

    Joined:
    May 9, 2012
    Posts:
    153
    Hi all,
    I have NGUI last night purchased NData... I'm fairly new to C# realise NData at this stage is probably way out side of my learning zone since reading all the forum threads has left me a little lost but I get the general idea... but I'm hoping in time NData will become a valuable asset to me as I develop my interface.

    I'll go over the intro tuts.. they seem to be relatively straightforward.. at this stage my games are relatively simple in term of collecting populating the interface but I have a master plan, as such, hope in time I can learn a thing or 2 regarding data binding, collections etc..

    Perhaps someone can steer me in a good direction that will help build upon my C# ... then I guess I'll have a much better basis in regards to understanding how to implement NData effectively.
     
  26. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    So I'm still having a bit of trouble with the nested hierarchy. Everything seems to be populating correctly and binding to all of the correct values, however what I'm seeing is that the UITables I'm using aren't being repositioned after population. Or at least they're not being repositioned in the correct order..?

    Because of the nested design of my UI, the UITables need to be repositioned starting from the most nested, and ending with the least nested (Since each UITable needs to know how big it's child UITables are in order to correctly reposition itself). However, putting this single line at the beginning of UITable.Reposition()
    Code (csharp):
    1. Debug.Log("Reposition", gameObject);
    leads me to believe that the UITables are being requested to reposition themselves, but it seems they are doing it starting with the least nested and working it's way to the most nested, with a small amount of randomness thrown in for good measure.

    I'm not quite sure what to make of this, so I thought I'd take a stab at writing some of my own code that iterates thru the GameObjects and calls Reposition() on the UITables it finds, starting with the most nested, and working towards the least nested. This is the method I wrote:
    Code (csharp):
    1.  
    2.  
    3.     public void RepositionReverseRecursive()
    4.     {
    5.         var go = gameObject.transform.parent.gameObject;
    6.         while (go.GetComponent<UIRoot>() == null)
    7.         {
    8.             var tableComp = go.GetComponent<UITable>();
    9.  
    10.             if (tableComp != null)
    11.             {
    12.                 tableComp.Reposition();
    13.                 Debug.Log(string.Format("Repositioning Table \"{0}\" ({1})", go.GetFullName(), go.GetHashCode()), go);
    14.             }
    15.  
    16.             go = go.transform.parent.gameObject;
    17.         }
    18.     }
    19.  
    The thing to note about this method tho, is that it doesn't work unless you wait for a couple of Updates after assigning your data, before you call it, because some of the "binding" done in NData is via Update Polling. Which leads me to my next question: Is it possible to get NData set up to NOT use Update Polling for bindings? It's a real nuisance to have to delay my code for a couple updates because the UI won't be updated yet...

    TLDR:
    1) NData doesn't call Reposition() on nested UITables in the correct order (it should start with most nested and end with least nested)
    2) NData performs some of it's bindings via Update Polling, which makes writing code, that relies on the UI being populated after a model change, a pain.

    If (1) gets fixed, I suspect (2) will be less of an issue.
     
  27. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Could you ammend the ItemsSource tutorial where you color the selected item? I know you have a SelectedIndex property, but there's no way that I can see where you can do a binding like: "if this.index == Items.SelectedIndex".
     
  28. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Alllllso - how do I trigger a tween from the context? I want to trigger a fade out (alpha tween);
     
  29. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    Looking at NguiItemsSourceBinding.OnItemInsert(), I see that there's some lines that look like the following:
    Code (csharp):
    1.  
    2. tweenScale.SendMessage("Awake");
    3.  
    I'm going to take a shot in the dark and guess that the intent was to ONLY call TweenScale.Awake(), however since this is being done via Component.SendMessage(), it's actually calling the Awake() method on EVERY component on the GameObject, which is causing all sorts of problems for other scripts.

    For example, if you put a binding that derives from NguiBooleanBinding onto the same GameObject that will eventually get a TweenScale component, you'll start getting exceptions:
    Code (csharp):
    1.  
    2. ArgumentException: An element with the same key already exists in the dictionary.
    3.  
    This is because the NguiBooleanBinding.Awake() method is called by Unity automatically, but then NguiItemsSourceBinding is manually calling it a second time.

    What is the intended effect of the tweenScale.SendMessage() lines I mentioned above? I highly suspect they should be implemented differently, as they're causing major problems with other scripts.
     
  30. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I just bought this and I'm having the same problem when I run the demo scene. I'm using the latest of everything: Unity 4.1 in DX11 mode, and NGUI Pro 2.5.0c.
     
  31. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    Hello,

    I met AOT runtime error on iOS like the following:

    Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-native) System.Threading.Interlocked:CompareExchange (EZData.SelectionChangeDelegate,EZData.SelectionChangeDelegate,EZData.SelectionChangeDelegate)' while running with --aot-only.

    at EZData.Collection.add_OnSelectionChange (EZData.SelectionChangeDelegate value) [0x00000] in <filename unknown>:0
    at MissionViewModel.Awake () [0x00000] in <filename unknown>:0


    The related code snip what I've added for the item selection delegate like that:

    Code (csharp):
    1.  
    2. public class MissionList : EZData.Context
    3. {
    4.     #region Collection Mission Item
    5.     private readonly EZData.Collection<MissionItem> _privateMissionList = new EZData.Collection<MissionItem>(false);
    6.     public EZData.Collection<MissionItem> Missions { get {return _privateMissionList; } }
    7.     #endregion
    8. }
    9.  
    10. public class MissionViewModel : MonoBehaviour
    11. {
    12.     public NguiRootContext View;
    13.     public MissionList Context;
    14.  
    15.     void Awake()
    16.     {
    17.         Context = new MissionList();       
    18.         Context.Missions.OnSelectionChange += HandleSelectionChange;
    19.        
    20.         View.SetContext(Context);
    21.        
    22.         GfxMissionDatabase gfxMissionDB = DataManager.Instance.gfxMissionDatabase;
    23.         for (int i=0; i<gfxMissionDB.gfxMissionDataArray.Length; i++)
    24.         {
    25.             Context.Missions.Add (new MissionItem { ScreenName = gfxMissionDB.gfxMissionDataArray[i].ScreenName });
    26.          }
    27.     }
    28.    
    29.     private void HandleSelectionChange()
    30.     {
    31.         // called whenever the list item is selected.
    32.         // ...
    33.     }
    34. }
    35.  
    Ran NData version 1.0.7 with Unity 4.0.0f7. Xcode is 4.6


    As the release note, AOT problem was fixe on 1.0.7 but it occurs.

    Any ideas?

    Thank you.

    Best,

    -Kim
     
    Last edited: Mar 28, 2013
  32. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I fixed the demo by rebuilding the two fonts (NData24 and NData34) in the Font Maker and overwriting the prefabs. I noticed that the prefabs were missing most of the UIFont properties; they must have been based on an older version of NGUI. More recent versions of NGUI include new properties on fonts and handle the glyphs differently, so they should be updated.

    The demo mostly works now, though I get this error when I select an item in the top scores list:

    Scale of 0 is invalid! Zero cannot be divided by, which causes problems. Use a small value instead, such as 0.01
    (0.0, 0.0, 0.0)
    UnityEngine.Debug:LogError(Object, Object)
    UIPanel:UpdateTransforms() (at Assets/NGUI/Scripts/UI/UIPanel.cs:760)
    UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:971)


    Do you set the scale to Vector3.Zero when unselecting a previous item or something like that?
     
  33. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Checking this. Adding collection items to UI is for sure event based, new item is instantiated and added to the hierarchy exactly the moment it's notified about through OnItemInserted event. So it must be something different. Maybe it's because at first frame only the top level tables get initialized, then on the next frame the second level, and so on, so that it looks like a "update-polling"-like side effect... or maybe something else. Anyways, we're setting up the test environment for your use-case to nail it down, and also find a way to at least automate self-referencing item templates workaround. That will also be a base for the upcoming nested tables tutorial, for it seems to be non-trivial thing.
    As for tweenScale.SendMessage("Awake") - those lines should not be there at all, must be remnants of some experimental code slipped to the final version. We'll sort it out, thank you for very valuable observations. It really helps a lot.
     
  34. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    We're in investigation of this nested tables issue, highlighted by Nyxo. Your case might be related. Once finished it'll be available as a tutorial and added as a reference scene to the Ndata distribution package as well. For now it's hard to say for sure, if bindings paths are correct, then maybe something is wrong with Line item template or Line items are instantiated but not visible.
     
  35. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    "Persistent property will be available in the next update that'll be available next week. It was planned a bit earlier, but it turned out that it can-not be done during the madness, so the site is somewhat ahead of time on this one.

    1. It can be done in a quite straightforward manner, like:
    Code (csharp):
    1.  
    2.   #region Property QuitRequested
    3.   private readonly EZData.Property<bool> _privateQuitRequestedProperty = new EZData.Property<bool>();
    4.   public EZData.Property<bool> QuitRequestedProperty { get { return _privateQuitRequestedProperty; } }
    5.   public bool QuitRequested
    6.   {
    7.   get    { return QuitRequestedProperty.GetValue();    }
    8.   set    { QuitRequestedProperty.SetValue(value); }
    9.   }
    10.   #endregion
    11.  
    12.   public void ConfirmQuit()
    13.   {
    14.     Application.Quit();
    15.   }
    16.  
    17.   public void CancelQuit()
    18.   {
    19.    QuitRequested = false;
    20.   }
    21.  
    22.   public void RequestQuit()
    23.   {
    24.    if (QuitRequested)
    25.     ConfirmQuit();
    26.    QuitRequested = true;
    27.   }
    28.  
    Then you create UI panel (with the visibility bound to QuitRequested property) and two buttons with the command bindings referencing ConfirmQuit and CancelQuit. That's the short hint, so you can get the idea, meanwhile we are preparing a tutorial about new visibility control features, it'll be covered in more details there.

    2. Variable context is quite a minor, but yet useful in some cases feature, here's more on it: http://tools.artofbytes.com/ndata/documentation/variable-context

    3. It's totally up to you, there's no common use-case for that. For instance your view model contexts can have references to each other and the root context can initialize those references at startup, then view models can trigger public methods and change properties in other view models they are referencing. Is it something like that, you were looking for?"
     
  36. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Sometimes when something is a part of a binding path and you have to update something manually, it might be the case when VariableContext might be useful: http://tools.artofbytes.com/ndata/documentation/variable-context. Not sure, maybe that's matches your case somehow.

    There's an option in Boolean binding to do such a check. You should switch "Check Type" to IS_LIST_SELECTION, it'll be true for an UI element (and all its children) that correspond to the selected item in the collection.

    In our projects we usually do that via custom bindings that react to data change and start some visual activity. Some real-life example - score indicator that pulses when the score value increases. For that we have a customized numeric binding component that overrides ApplyNew value method and triggers a scaling effect. In the similar way you can do fade ins / fade outs. In the upcoming update visibility control will be re-factored a bit, so that custom visibility binding with fade in / fade out effect will be possible to include to the distribution package.
     
  37. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    AOT problem was only partially fixed in 1.0.7. It turned out that the run-time error could still happen under some undetectable circumstances. The final solution was to replace core functinality dll with a source code (happened in 1.0.9), after that it is known to be stable. Also please refer to the player settings here: http://tools.artofbytes.com/wp-content/uploads/2012/09/iOS-Player-Settings.png, iOS builds are sensitive to the highlighted options' values.
     
  38. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    We'll include the fonts fixes in the next update. Thanks for helping out with this one. As for zero scale error, it might be related to the corrupted fonts too, maybe scale was reset when makePixelPerfect was called on a label with a bad font or something like that.
     
  39. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Sorry for late replies lately, many new people trying out NData and we're a little bit overwhelmed with support requests, couple of nasty problems were discovered too. But no worries, we're tracking all the issues, many fixes and new cool features are coming very soon. Thank you for your valuable feedback and help, it really helps to improve NData. And despite all that support hassle we are very happy to see you all. Cheers!
     
  40. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Hi, we just bought the package and tried it in Unity 4.1.2 pro and getting 18 identical errors with the included example:

    Attempting to print using an invalid font!
    UnityEngine.Debug:LogError(Object)
    UIFont:print(String, Color32, BetterList`1, BetterList`1, BetterList`1, Boolean, SymbolStyle, Alignment, Int32, Boolean) (at Assets/NGUI/Scripts/UI/UIFont.cs:848)
    UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:606)
    UIWidget:UpdateGeometry(Matrix4x4, Boolean, Boolean) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:497)
    UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:848)
    UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:983)

    Thanks
     
  41. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Another newbie question: Does nData work on Flash ?
     
  42. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi rocki!

    Some people reported the same problem and we have found the source of it.
    We are publishing the new update tomorrow, all the fixes will be included

     
  43. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Would you be able to add a "NOT NULL" check type to the Visiblity/boolean binder?

    I'd like to display a control only if SomeItems.SelectedItem is not null.

    edit: duh, SomeItems.HasSelection does the trick. Still would be good to have for other situations!

    Also, what if I want to combine predicates, like if X Y?
     
    Last edited: Apr 3, 2013
  44. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Is Texture Binding expecting a Texture2D, or a string path, or what? I can't seem to get it to work with Texture2D.
     
  45. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    We bought this wonderful package thinking that it supports NGUI fully but to our surprise, it does not work for Flash. Our project exports to flash and really need for NData to truly support NGUI. Please let us know. Thanks.
     
  46. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Yep, for many cases HasSelection and HasItems work well. NotNull check type can be useful too, so you can count on it in one of the next versions.

    As for combined predicates, several times we were considering creating a Boolean multi-binding that would do something like that, but in most cases it seemed like an overkill. And since it was usually visibility binding and "" operation we needed, version 1.0.12 (that is already on its way) supports multiple visibility bindings in a single objects that need all to be true for object to be visible. So, if it's exactly X Y operation you need and if you need it for visibility bindings (or derived from them), then you've got it.

    It binds Texture2D property to UITexture control. Example of that can be found in NDataDemo, picture of a player is displayed using TextureBinding in the high scores table screen.
    There is also a SpriteBinding, it affects UISprite in the same game object and can be bound to either UIAtlas.Sprite property or to a string property with a sprite name in it.
     
  47. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    Hi, unfortunately NData relies on some reflection functionality, and while it's partially supported on iOS, it doesn't work for Flash at all. We'll update the description on asset store to avoid further confusions. However, as we see now, supporting such a functionality without reflection would be non-trivial at least, if possible at all. Sorry for inconvenience.
     
  48. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    As the makers of this package, can you suggest which sections of the code that would need to be tweaked to work with Flash. Perhaps by aiding and by enlisting the help of those who are using this package, a port to flash might be possible. We really like NData and the elegant way it works with NGUI, let's make this a complete solution. Thanks.
     
  49. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
    There are possible options, something like detecting all properties referenced in bindings in the editor script and putting them to some table, so the bindings can then be resolved in run-time without reflection, based on that properties table. This, however, is under investigation, it may go tricky with dynamically instantiated items, properties identification, and who knows what else, so no promises and guarantees for now. In case you want to dig into it yourself, good starting point would be a function that resolves bindings paths (EZData.Context.Find<T> in NData\NGUI\NData\Core\Context.cs).
     
  50. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Very glad to know that you are investigating options. Thanks for the pointer in Context.cs, we'll also have a look.