Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Data Bind for Unity

Discussion in 'Assets and Asset Store' started by coeing, Feb 16, 2015.

  1. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    You can use the same context on multiple context holders and you can have data properties in contexts which are contexts themselves.

    So what you can have for your ship:
    ShipContext
    - Inventory (InventoryContext)
    - Other data...

    Let's say you have a ship prefab. This prefab has a ContextHolder on its root game object. When you instantiate your ship you set the context on the ContextHolder of the instantiated game object.

    To access the inventory from a behaviour on the ship prefab you just have to set the whole path (e.g. Inventory.Items.Count or Inventory.MaxCount).
     
  2. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    @MaddoScientisto

    You might also want to take a look at a pattern called the Singleton -- As seen in this video (for example)

     
  3. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    Can you please elaborate more on this?
    I have my contextholder on the root of the UI canvas so the UI can access it
    and now just placed a contextholder on the ship prefab set to the same context.
    What's the next step exactly?
    "To access the inventory from a behaviour on the ship prefab you just have to set the whole path (e.g. Inventory.Items.Count or Inventory.MaxCount)."
    where do I do this exactly through code?
     
    Last edited: May 16, 2016
  4. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    You don't have to do this via code, but can use the Drop Down field in the TextTextSetter script you put on the UI Text which should show the information. Check out the Label/TextTextSetter example in the package and at http://slashgames.org:8090/display/DBFU/Label+Setter (Step "Specifying which controls visualize which data")
     
  5. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    I'm already visualizing the data, I need to access the context from my gameobjects to set those values in the first place and I have no idea how to get a hold of a reference to it
     
  6. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    As I said before, you can use a singleton. Which is only one way of several. Have you watched the video?
     
  7. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    I know how to use singletons and I also know that they are not what I'm looking for.

    Let's say I want to have more than one ship with more than one hud, with a singleton I can't do that easily.

    Also even if I were to use the singleton the problem still stands: how do I get a reference to the context in any situation other than setting up the UI?
    How woul I get that reference to the singleton?

    What if I want to have multiple datacontexts of the same type for multiple objects?
     
  8. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    You are not understanding what a singleton is. You have an object that is STATIC and can be reached ANYWHERE in your code. If your context is static you have a reference to it whenever you need it.

    update:
    Here's some more info.

    If you are creating the context via code, then you have a reference to the context. Just make it a singleton.

    If you are not create the context via code, then you checked the create on the Context Holder ***COMPONENT*** on some ***OBJECT***. You can, like with any other component, find the object it is attached to and then get the component and then grab the context. If you need help finding the object it is attached to then set a tag.

    As you can see the best option is to create the context yourself, via code, and Bob's your uncle.

    Hope that helps.
     
    Last edited: May 17, 2016
  9. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    Thanks this is a bit more helpful, although if I create my context through code how would the view know about it?
    Would I have to manually tell the component on the view about the correct instance?

    Edit: I managed to grab the context as you said by searching the hierarchy for the correct object, for now that's fine but I'll eventually need to figure out how to properly manage multiple contexts, multiple objects using them and binding the multiple UI interfaces to them
     
    Last edited: May 18, 2016
  10. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @MaddoScientisto,

    Nice to see that you already had a discussion with @Tinjaw and he could help you a bit.

    In our projects we don't let the context holders create their contexts (so we turn the toggle "Create Context" off), but we set the context when we instantiate the game object or UI from the prefab or load the UI scene. As soon as we have the game object we check it with GetComponent<ContextHolder>() for an existing context holder or add one with AddComponent<ContextHolder>() Than we set the context on the context holder with contextHolder.Context = context.

    The global management of the contexts depends a bit on the kind of contexts. We had some that were only used were they were instantiated. Others were used in multiple places, but they were for specific units, so we put them in a ContextManager and have a GetOrCreateContext(int unitId) method there.

    Hope those information help :)
     
    MaddoScientisto likes this.
  11. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    Thank you, now I have another issue with my datacontext:
    There's a single ShipInventoryCollection context, which contains a collection of InventoryItem

    I made InventoryItem as another context which contains a Name property and an Amount property

    Code (CSharp):
    1.  [Serializable]
    2.     public class InventoryItem : Context
    3.     {
    4.         public string Name {get { return _nameProperty.Value; } set { _nameProperty.Value = value; } }
    5.         public Type ItemType;
    6.         public int Amount { get { return _amountProperty.Value; } set { _amountProperty.Value = value; } }
    7.  
    8.         private readonly Property<string> _nameProperty = new Property<string>();
    9.         private readonly Property<int> _amountProperty = new Property<int>();
    10.        
    11.     }
    Adding InventoryItems to the ShipInventoryCollection is fine, the UI reflects the new data but if I try to change the Amount value then the UI doesn't update that value.

    Maybe it's how I change the value, basically I do this:

    Code (CSharp):
    1. var i = _shipInventoryCollection.Items.FirstOrDefault(x => x.Name == "Copper");
    2.  
    3. i.Amount += 5;
    Maybe linq is interfering with the updating mechanism?
     
  12. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    It's probably your naming, use names like nameProperty instead of _nameProperty for the fields, than it should work. See http://slashgames.org:8090/display/DBFU/Data+Context,+Property+and+Collection "Naming Conventions" for more details :)
     
    MaddoScientisto likes this.
  13. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
  14. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am wondering if I have messed something up or if I have hit a limitation of Data Bind. Let's start with a screen capture of the Inspector



    I have GameboardDataContext, which contains a collection of FactionContext, which, in turn, contains a collection of ObjectiveContext, which in turn, contains several ResourceNeededContext.

    In the inspector, 1)GameboardDataContext, 2)FactionContext, 3) and ObjectiveContext display properly in the Inspector. However, 4) ResourceNeededContext doesn't properly display in the Inspector.

    Is this a limit of Data Bind, or should I be looking at my code for some mistake?
     
  15. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @Tinjaw!

    Sorry, just saw your post :/ It's possible that you reached the maximum level. Could you try to increase the value of the MaxLevel field in the ContextHolderEditor class and see if that fixes it? I introduced the field to not run into an infinite loop if one has circular references in his contexts.
     
  16. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    That fixed it. Thank you.
     
  17. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    This raises an enhancement request. Can you start out having the context fully collapsed in the Inspector? Then I can expand only the things I am interested in. Right now a large context is unwieldy.
     
  18. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @coeing ,

    Could you outline how this Asset could be used to assist with inventories, statistics, storage of stats, in an rpg?
     
  19. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @Duffer123,

    What you could have is a data context structure like this:

    • InventoryContext
      • Collection<InventoryItem>

    • InventoryItemContext
      • LocaTag
      • IconName
      • Amount
    The inventory window would use these data contexts to visualize an inventory, e.g. via a scroll rect. The window will automatically refresh its contents when you add or remove an inventory item or change its Amount property (or even LocaTag/IconName, but that probably never happens).

    With the stats you could have a similar structure (e.g. StatItem containing LocaTag and Value property). Data Bind is pretty generic. You should first choose a data context structure that works for you. Afterwards the UI in your game can use those context to bind their UI elements to the data properties. The contexts can also be accessed by multiple UI, e.g. in the main UI you could have an element showing how many items your inventory currently contains.

    Hope this helps, let me know if you have further questions!
     
  20. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @coeing ,

    Thanks for responding. Much to consider.

    Thanks.
     
  21. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am about to start a new project and I was going to use this asset. However, I see that Slash Games has been dissolved. What does that mean for the future of this asset?
     
  22. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hey @Tinjaw!
    Yes, the information is true, my co-founder went back to his former employer as a Technical Director. But I'm still self-employed and will continue the development of our Slash Framework as well as Data Bind for Unity. For my current project (VR demo) I use the asset as well, so there will even be another update soon :) If you have any wishes for the update, let me know and I will see if I can include them!
     
  23. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hi,

    Huge fan of your asset.

    I have a question about the good pratices.

    I'm doing a project where there is a ingame editor.
    The player can place an object and edit his properties.

    Lets pretend that my object has a class "Entity".

    The thing is, I'm pretty much always doing both the work, because I'm having properties in my class "Entity" that I need to save/load and the same ones in a Context class for the object.

    When the user change a property in the context via the UI, I need to update the "Entity" class to reflect the changes and being able to save them.

    In a more simple example, you could think of a Settings menu where the player modify like Shadow Distance via a context, but you would need to save those values.

    Do you have a good workflow for that ?

    I'm sure you had this situation your self, do you save directly the context instead of the holder class ?

    Thanks

    Edit: I saw your post and you said that you will do an update and ask for wishes, I would like to see more example, like more real world example. You added a lot of stuff during the updates, but never really showcases them. I want my company to use the asset, but the learning curve is not easy, so more examples will be very cool for new users
     
  24. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @Ziboo,

    Thanks for using my asset (and liking it :) ). About your use case: My first thought was to create a little editor tool to generate the code for the context class from a data class via reflection. This way you would prevent to have the context class in your serialization logic which wouldn't be very clean in my opinion.

    Alright, I put it on my agenda for the next update. You are totally right with the learning curve. This is something I should have in mind a bit more. But it's always hard to see the difficult parts in code that you create :)
    I can't promise a date for an update, the next months will be a bit busy. But hopefully I can manage to upload one till the end of January.
     
  25. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Thanks for the reply.

    Yes it could work.
    But that would only resolve writing script.
    There is no easy way to update the model when the context change I think.
     
  26. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Well, you could also generate the code for a UpdateData() method which is registered as a callback for all the ValueChanged events of the context properties, e.g. in the Constructor of the context. Right now there is no event in the context class when one of its properties changed, but I put it on my ideas list.
     
  27. vet-cat

    vet-cat

    Joined:
    May 29, 2013
    Posts:
    37
    hi, great Asset.
    I have 2 scenes, each have ContextHolder creating the context of the scene.
    Question: How can I remove the context of a scene when loading another scene (otherwise, there is the creation of a context each time you boot stage) ?
     
  28. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi!
    Thanks, nice to hear that you like it.

    The context holder is destroyed when the scene is unloaded, so its context should be removed as well. Or is the context still hanging around in your case? Maybe there are some other references left, so the context can't be garbage collected?
     
  29. vet-cat

    vet-cat

    Joined:
    May 29, 2013
    Posts:
    37
    Thanks for the quick response

    perhaps - I'll check on an empty project.

    Loading between scenes, I'm trying to clear the memory - but the context is not deleted (also not removed and normal class establishment in the first scene):
    private IEnumerator ProcessGarbageCollection()
    {
    Debug.Log("ProcessGarbageCollection start");
    // sync garbage collection - can be done async if needed
    AsyncOperation async = Resources.UnloadUnusedAssets();
    yield return async;
    GC.Collect();
    GC.WaitForPendingFinalizers();
    Debug.Log("ProcessGarbageCollection finish");
    StartLoading();//loading next scene
    }

    Another question is how can I manually assign existing context to ContextHolder ?
     
  30. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Okay, this could have serveral reasons, because one reference to the context is enough so the garbage collector doesn't clean up the context. Do you have a test scene for me where this occurs? Than I will have a look into it.

    You just need a reference to the context holder from somewhere. Than you just do:

    Code (CSharp):
    1. contextHolder.Context = myExistingContext;
    There is also a ContextHolderContextSetter which I use to set sub contexts from other contexts and a ContextHolderInitializer to set dummy contexts in test scenes.
     
  31. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hey there!

    It's been quite a while since the last Data Bind update, so I am very happy to announce the version 1.0.7 which has been submitted to the Asset Store yesterday :)
    It should be available soon at https://www.assetstore.unity3d.com/en/#!/content/28301

    We use our asset in our current projects as well, so there have been some improvements that we made. I hope that they will be helpful for others as well!

    Here is the change log for the current version:
    * Add event ClearedItems to Collection to get the items that were removed as an observer

    * Use binding instead of reference in GameObjectSingleSetter

    * Add provider which checks if a camera is pointing at a collider

    * Add PrefabInstantiator to instantiate a game object from a provided prefab

    * Add check for empty key in GameObjectMapping to not cause NullReferenceException in inspector

    * Add data provider for the main camera

    * Add data provider for a component's transform and game object

    * Allow data binding for target of ComponentSingleGetter

    * Add base class for component data providers and add provider for a transform rotation

    * Add component selection when referencing a game object in a Data Binding

    * Add setter for transform rotation

    * Fix wrong check for if target binding is set in ComponentSingleSetter

    * Add TransformPositionSetter to use it instead of obsolete PositionSetter

    * Use binding for target of ComponentSingleSetter instead of reference e.g. to feed target from a data provider

    * Add editing for Vector fields in context holder editor

    * Add GameObjectTransformProvider to get the transform component of a specific game object

    * Add FindGameObjectWithTagGetter to find a game object with a specific tag

    * Show "Invoke" button in inspector next to context methods for debugging

    * Add StrangeIoC extension classes

    * Add GestureInput extension commands

    * Make string data properties editable in ContextHolderEditor by passing the member type to DrawContextData

    * Add setter for a material float property

    * Add converter for 3 single numbers to a Vector3

    * Only show current value in data provider inspector if active and enabled

    * Deactivate prefab of GameObjectItemsSetter on Awake, so it isn't visible even if a scene game object is used

    * Setters - Added GameObjectItemsSetter as a non-generic class, using MonoBehaviour as type.

    * Lookups - Added lookup to find an item from a collection that has a specific value at the specified path.

    * Loaders - Added warning if sprite resource can't be found.

    * Core - Using common interface for property, collection and other data providers.

    * Data Bind - Using context type drawer in context holder editor. Using enum popup when drawing context data for an enum member.

    * Data Bind - Added buttons to context inspector to add/remove items from a collection.

    * Collection - Added base AddNewItem and Remove method to data collection.

    * Path Drawer - Added maximum path depth to avoid infinite loops.

    * Examples - Adjusted ContextProperty example to use GameObjectItemSetter.

    * Utils - Not preserving world position when adding child from prefab to game object in UnityUtils.

    * Switches - Removed obsolete RangeOption.cs

    * Context - ValueChanged event for data node is also thrown when collection changes internally (e.g. item added, removed, cleared). This way child nodes are informed about a parent value change.

    If you have any questions regarding a change, just write it here. If you like to see some other additions or have found a bug, please use the issue tracker at https://bitbucket.org/coeing/data-bind/issues

    Thanks everybody for using Data Bind for Unity. It is so fulfilling to see an asset not being useful for yourself, but for other devs as well.
     
  32. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    That's good news.
    Any plan to add more samples / examples ?
    Thanks
     
  33. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @Ziboo,

    Yes, definitively. It's still on my list (and in the issue tracker), but I had no time to add it in the last weeks and didn't want to wait with the update. I hope to do more smaller updates in the future (goal is every 2 months), so I will try to add some to the next one.
     
  34. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
  35. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hello,

    How's going ?

    Any news on new documentation or samples ?

    Some questions in the meantime:

    - Is it possible to apply filters to collection ? something like in WPF
    - How do you handle Refactoring property yourself ? I'm using Resharper, but it doesn't refactor the private property field name, because of the "Property" suffix..
    - Active Setter is cool, but need to be on a different gameobject of the Target, or else it will never reactivate again. Do you have a workaround ? I would like to have it on the gameobject I want to toggle directly.
    - "Deactivate prefab of GameObjectItemsSetter on Awake, so it isn't visible even if a scene game object is used". That's cool but you actually deactive the prefab it self, which mean, the prefab in the project tab get deactivate too. Annoying if you use it somewhere else . Could you talk a look for a fix.

    Thanks
     
  36. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @Ziboo
    All fine, thanks for asking :) Hope you are doing good, too?

    About your questions:
    - I added some more examples, they will ship with the next release which is planned for April
    - Collection Filters: What kind of filters are you thinking of? There is always the possibility to have a data provider that takes a collection, adjusts it and passes it on. But I guess you are thinking of something generic?
    - Refactoring: I have no special way to do it (I use ReSharper as well). I rename the public property and adjust the field manually.
    - Active Setter: I added this as an issue to the issue tracker (https://bitbucket.org/coeing/data-bind/issues/21/make-activesetter-work-even-if-it-is-on-a) and will have a look at it. I know that it's a common source for a bug. But on the other side it is more logical that scripts on inactive game objects won't work in my opinion.
    - GameObjectItemsSetter: True, I had that thing in a project as well where the prefab was deactivated. Maybe there is a way to do this only for scene objects (the check would be only required in the editor, so no runtime performance loss). I add it as an issue as well (https://bitbucket.org/coeing/data-bind/issues/22/dont-disable-prefabs-that-are-used-in)

    Thanks for your questions, reports and ideas. It's much nicer to work on issues that are relevant to other devs than to have to think of what might be required :)
     
  37. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hey,

    Thanks for the quick response.

    - For collection, yes something more generic I guess. You can take a look at this maybe : https://wpftutorial.net/DataViews.html.
    For my specific case, I have a collection of InventorySlotContext, and I want to filter them by ItemType, but right now the only way is to modify the all collection.
    - For the ActiveSetter, I guess what could be usefull is to have a checkbox for classes that derives from "SingleSetter", and change this line based on the checkbox:
    protected override void OnDisable()
    {
    base.OnDisable();
    this.Data.ValueChanged -= new DataBinding.ValueChangedDelegate(this.OnObjectValueChanged);
    }

    - The other issue I can think of, is that most of the time you will have the ActiveSetter on the same gameobject that your ContextHolder, and I know that this doesn't work right now, it revert back to a custom path.
    Anyway for setters, getters, .. to check if there is a context holder next to it ?

    - Any plan to have a editor interface when you want to add a custom path, that would look contextholder up hierarchy. Instead of struggling with #1.xxx, #2.xxx, #3.xxx

    Cheers
     
  38. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Thanks for the link, I will check it out. I added an issue and hope I find the time to tackle it (https://bitbucket.org/coeing/data-bind/issues/23/implement-an-easy-way-to-add-filters-for).

    Yes, I was thinking about something like that as well. Maybe just as a special case for the ActiveSetter instead of all setters.

    My setup is most of the time:
    Root with ContextHolder
    - View/Visualization Node
    - (View) Logic Node
    -- Node with Active Setter (Target: View/Visualization Node)
    -- Node with Setter X
    -- Node with Command Y
    -- ...

    This way the view logic can access the context and the visualization easily.

    I had this in mind a few times as well. In the current project I setup the contexts a lot more self-contained and added C# events to them which are listened to by a parent context or some other logic if necessary. This way I completely avoided access to parent contexts.
    But I will add an issue for this thing as well and see if it is easy to do.
     
  39. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Just submitted version 1.0.8 of Data Bind :)

    Thanks especially to @Ziboo for the valuable feedback, it always helps for development to make sure the asset moves in the right direction. There is a public issue tracker where everybody can add their wishes, bug reports, ideas, feedback,...:

    https://bitbucket.org/coeing/data-bind/issues

    The main additions:
    - Two new examples
    - The GameObjectItemsSetter now takes a Transform as a target (might require updating some references in existing projects!)
    - The GameObjectItemsSetter doesn't disable a prefab anymore in the editor, only if it is a scene object
    - Some more providers that were created for a current project
    - Some adjustements in the inspectors to make usage faster

    Here is the full changelog:
    * Add test to check if value of method node is updated when object changed

    * Issue #22 Activate prefab again when deactivating it before instantiation of item game object

    * Make Enable, Disable, Init and Deinit methods of DataBindingOperator public so they can be called from unit tests

    * Issue #22 Don't disable the template of a GameObjectItemsSetter if it is a prefab and running in the editor

    * Add formatter to adjust texture of a material

    * Add setter for the material of a skybox

    * Add provider to get Input Tracking Position

    * Add base class to get a data value from a bound context.

    * Add property ItemContexts to GameObjectItemsSetter to get all item contexts in a derived class

    * Add base class to invert a data value and added inversion operations for a number and Vector3 as well

    * Add Provider for the Skybox of a game object

    * Add Setter for the text of a TextMeshPro script

    * Add UpdateTargetValue method to ComponentSingleSetter which derived classes have to implement instead of using OnValueChanged which is sealed now - This makes sure that the target value is updated as well if the target binding changed, not only if the data value changed.

    * Issue #14 Combining nodes in the popup for choosing a context type if there is only one choice anyway

    * Use Velocity for smootheners instead of minimum step - There is no fixed amount of steps as the Update method is called with a different delta time each turn

    * Add and use base class for Smootheners

    * Issue #9 Add special path (#) to reference context itself

    * Add component selection for Provider of data binding

    * Issue #2 - Add settings to specify the format of the data providers in a context, so underscores are possible as well - The data property/collection fields should follow the naming conventions of the project they are used in, so there has to be a possibility to define how their names are formatted.

    * Add base Formatter, MaterialMainTextureFormatter and MeshRendererMaterialSetter

    * Add button in inspector to create a context on a context holder at runtime for debugging

    * Issue #15 Add example with notifications that are automatically removed when they were displayed for a specific duration

    * Add provider for InputTracking.GetLocalPosition

    * Add setters for Transform.localPosition and Transform.localRotation

    * Add setter for context of data context mediator

    * Connect DataContextView with context holder in Start instead of Awake - Otherwise other behaviours may not be ready for the initialization steps that are involved in registering the context

    * Add foldouts to collection/sub-context/data dictionary fields in ContextHolderEditor

    * Only set new target binding in OnAfterDeserialize in editor if constantTarget is still set - OnAfterDeserialize is also called when doing changes in inspector which makes it impossible to set the type to Context if there is no path set

    * Add base class to provide a component from a game object

    * Implement missing methods of IList<T> interface for Data Collection

    * Use Transform as target for ItemsSetter - A generic version is not necessary as the target is only used to define the parent of the items, which has to be a Transform

    * Add property to get a debug name of a data binding for easier debugging

    * GameObjectItemsSetter - Inform derived classes about destroyed item when collection is completely cleared

    * Don't show obsolete constantTarget field of ComponentSingleGetter

    * Issue #12 #13 Add example with many boolean formatters/setters/getters and some ActiveSetters

    * Sync context of DataContextView with context holder correctly - OnRegister of the mediator may be called before Awake. If setting the initial context there it would be erased again in DataContextView.Awake

    * Add proxy for command - E.g. to switch between different commands depending on another provider

    The new version will be available in a few days in the Unity Asset Store:

    https://www.assetstore.unity3d.com/#!/content/28301
     
  40. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
  41. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hi,

    Imported the package from the AssetStore in an empty project.
    There is errors in the ContextTest.cs

    upload_2017-4-11_10-34-15.png
     
  42. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Which Unity version are you using and on which platform are you? In general the tests shouldn't be in the package, so I will anyway upload a new one (and you can delete the Tests folder). When I import it in an empty project on my side there are no errors, so it might depend on the Unity version or platform.

    Oh, and thanks of course for the report :)
     
  43. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    The last one: 5.6f3. Standalone platform
     
  44. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Okay, that's what I thought. I already submitted a package without the tests, but as I said, just delete them and it should work.
     
  45. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Documentation is dead ?
     
  46. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
  47. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hey there!
    Thanks for your interest in Data Bind. There are several examples included in the asset. But they won't help before you purchase it, of course.

    About your worries: What you are writing data contexts are two things:
    1. Data structures of your objects in the application which define what data is available on the view side.
    2. Interface classes that lie in front of your presentation/view logic and contain methods that are called by the UI and the data structures from 1. to be visualized by the UI.

    What I always offer is to give a full refund if the asset doesn't fulfill your needs. So feel free to purchase it and let me know if you have any questions or like to have a refund :)
     
  48. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Hi. Does use of Data Bind make the use of a DI/IoC asset like Zenject redundant and meaningless or do the two compliment each other?
     
  49. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Hi @TokyoDan,
    It depends where you use Zenject or something similar. In some of our projects we use StrangeIoC in addition to data bind (Data Bind even has an add on included with some utility classes to use with StrangeIoC). Data Bind takes over the last frontier between UI/presentation and your code. So if you use the other asset just there, it might get replaced. But as DI/IoC can be used more general I would say they should be used together.
     
  50. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Thanks for the quick reply. I was worried that they might interfere with each other.