[RELEASED] Binding System

Nice - thank you.

I’m looking forward to 1.1 :slight_smile:

Hi everyone,
Version 1.1.0 is now live and brings path value preview to inspect the value pointed by the path, full support for Odin Inspector and a number of new modifiers.
Remarks for Path Value Preview: not all paths point to previewable values. When a value can be previewed, an eye toggle will appear, which triggers the preview when clicked.
For Odin support, to forward attributes to inner bind value, a [Bind] attribute needs to be added on top of other attributes. All attributes beneath that attribute will be forwarded to inner values.

1 Like

Looks good, @Geeorge . I especially like the new Odin support. Thank you!

@Geeorge This error happens when code is recompiled. It is intermittent. I don’t see it every time.

I am using Unity 6b12, so I understand if that’s unsupported, but I believe this error is also present in Unity 2022.3.x.

Just wanted to make you aware… Maybe you could add some defensive code at that point to stop the exception?

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index) (at <39c45ff4f5d74c13b13a42955ec1351b>:0)
Postica.BindingSystem.Serialization.BindDatabase.<RefreshPrefab>g__ReplacePrefab|19_0 (Postica.BindingSystem.Serialization.BindDatabase+PrefabFile old, Postica.BindingSystem.Serialization.BindDatabase+PrefabFile newFile) (at <cd5e5b215b4440998f733e20eea56a63>:0)
Postica.BindingSystem.Serialization.BindDatabase.RefreshPrefab (System.String guid, System.Collections.Generic.HashSet`1[T] processed) (at <cd5e5b215b4440998f733e20eea56a63>:0)
Postica.BindingSystem.Serialization.BindDatabase.RefreshPrefab (System.String guid, System.Collections.Generic.HashSet`1[T] processed) (at <cd5e5b215b4440998f733e20eea56a63>:0)
Postica.BindingSystem.Serialization.BindDatabase.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths, System.Boolean didDomainReload) (at <cd5e5b215b4440998f733e20eea56a63>:0)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <39c45ff4f5d74c13b13a42955ec1351b>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <39c45ff4f5d74c13b13a42955ec1351b>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <39c45ff4f5d74c13b13a42955ec1351b>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at /Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs:1168)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets, System.Boolean didDomainReload) (at /Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs:395)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[], Boolean) (at /Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs:408)

Thank you @Colin_MacLeod for letting me know about this error.
I Will work on it and will try to ship the fix with the next update.

1 Like

Hey @Geeorge How it going? Is there any update on version 1.2 of Binding System?

Hi @Colin_MacLeod ,
Thanks for asking, I resumed development last week with full speed, had to slow it significantly down because of some personal urgent matters, but right now everything’s going fine.

1 Like

I was just curious. It’s not holding back my project - tho the event binding would be nice.
Thanks for everything you have done with Binding System @Geeorge .

Hi,
this asset has GREAT potential, but it is still quite raw.

Firstly, I can’t get into the Binding System settings (Unity 2021.3.36)

Secondly, I couldn’t find a property of type BoxCollider in the dropdown list.

Thirdly, when I try to make a build I get errors in the AOT_Accessors class

Hi @sherzhen
I am sorry you are having issues with this asset, and as you have mentioned, it’s not perfect yet.

For the first issue: this happens when you install the package for Unity 2022 into Unity 2021. Please check again let me know if this is not the case.

For the second issue: can you specify which types of objects Vision gameobject has? (from the screenshot) so I can reproduce the issue?

Third issue, I am already working on it, will let you know when this is fixed.

P.S. I apologize for taking this long to respond. I tried to respond earlier but Forums were transitioning to Discussions and it was in read-only state.

Hey @Geeorge, I get a periodic exception:

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index) (at <ce95f63947c64e4bbf5929ebe610c440>:0)
Postica.BindingSystem.Serialization.BindDatabase.<RefreshPrefab>g__ReplacePrefab|19_0 (Postica.BindingSystem.Serialization.BindDatabase+PrefabFile old, Postica.BindingSystem.Serialization.BindDatabase+PrefabFile newFile) (at <cd5e5b215b4440998f733e20eea56a63>:0)
Postica.BindingSystem.Serialization.BindDatabase.RefreshPrefab (System.String guid, System.Collections.Generic.HashSet`1[T] processed) (at <cd5e5b215b4440998f733e20eea56a63>:0)
Postica.BindingSystem.Serialization.BindDatabase.RefreshPrefab (System.String guid, System.Collections.Generic.HashSet`1[T] processed) (at <cd5e5b215b4440998f733e20eea56a63>:0)

It looks like it comes from this code from ReplacePrefab:

        int index = BindDatabase.PrefabsDb.prefabs.IndexOf(old);
        BindDatabase.PrefabsDb.prefabs.RemoveAt(index);
        BindDatabase.PrefabsDb.prefabs.Insert(index, newFile);

Out of curiosity/idleness, I asked perplexity.ai what it thought the issue might be. Here’s the response, in case you find it useful:

The ArgumentOutOfRangeException in your C# code is likely being thrown because the index variable is either less than 0 or greater than or equal to the number of elements in the prefabs list. This can happen if old is not found in the list, resulting in IndexOf returning -1. Attempting to remove or insert at this invalid index will cause the exception.
To fix this issue, you should check if old exists in the list before attempting to remove or insert at the specified index. Here’s an updated version of your code with the necessary checks:

int index = BindDatabase.PrefabsDb.prefabs.IndexOf(old);
if (index >= 0)
{
    BindDatabase.PrefabsDb.prefabs.RemoveAt(index);
    BindDatabase.PrefabsDb.prefabs.Insert(index, newFile);
}
else
{
    // Handle the case where 'old' is not found in the list
    Console.WriteLine("The specified item was not found in the list.");
}

In this code:
We first find the index of old in the prefabs list.
We then check if the index is valid (i.e., not -1).
If the index is valid, we proceed to remove the item at that index and insert the new item.
If the index is not valid, we handle the case where old is not found in the list (e.g., by logging an error message).
This ensures that you only attempt to remove and insert items at valid indices, preventing the ArgumentOutOfRangeException from being thrown.

Hi @Colin_MacLeod,
thanks for the update. this bug is already fixed in the new version, it was indeed a similar solution. Stay tuned for this new version as it has some of the features you’ve requested (UnityEvents) and lots of bugs fixed. Should release it this week.

1 Like

Hi all,
here is a quick update on the upcoming version 1.2 of Binding System. The entire focus on this version was to fix known bugs and to introduce drawers based on UI Toolkit → Minimal UI. The UI Toolkit drawers are necessary for the next big update (Code-less bind fields), thus it was a long but necessary development.

Minimal UI

Here is a comparison between old (Verbose UI) and new (Minimal UI) for the same component:

The Minimal UI is optional and comes with some additional new features:

  • Drag and drop objects to change source and/or path:
    Drag and Drop on empty field

Drag and Drop and cancel the intent

Drag and Drop to replace source

  • Collapse or expand additional fields:
    Expand and collapse fields

  • Quick shortcuts, hold Ctrl (or Cmd on MacOS) and click:
    Convenient Shortcuts

  • Compact Modifiers:

  • Improved Tooltips:
    Improved Tooltips

  • Bind fields in groups. Groups are formed either by headers or by complex types:
    Bind groups of fields

New Bind Options

There are some changes to which types can be bound.
A Unity Event (both generic and specialized) can be bound and it will be automatically invoked on value change. When binding in Inspector, the system will automatically choose a backing field and bind it. This field can be left as fixed value to avoid any side effects.
Bind Unity Events

Every bind field can be bound to another bound value.

Powerful New Modifiers

Link to Bindable allows to link a bind field to another value, allowing for multiple bind controls for the same value:
Link to other bindable modifiers
Set Value allows to set values to bind sources directly in editor, without writing a line of code.
Fallback Value allows to use another value in case the source value is null or empty.

Other Important improvements

  • Bind Fields are now disabled if their context MonoBehaviours are disabled.
  • SmartDropdown has improved search layout and loading performance.
  • Improved Odin Inspector support.
  • Improved bind fields update logic → for those fields which are not triggered in code.

and other smaller improvements…

Let us know what you think about these new features.

Hi everyone,
I am pleased to announce that version 1.2.0 has been released, with fixes for known bugs and features listed above.

Looks great! I’m exited to try it out

Hey everyone,
For the past several months I’ve been working on Binding System version 2 and I would like to share some updates with you. Here are the biggest changes from version 1:

  • Code-less binding : bind potentially any field in inspector without writing scripts with Bind fields, which were mandatory in version 1. Now every object in inspector can have bindable fields.

  • Improved Performance : performance has been greatly improved, especially when getting values out of class fields. Version 1 required special auto-generated files to overcome these limitations, which in turn required multiple recompile stages. This was removed and the system works without requiring recompilation stages.

  • Moved to Packages : the asset has been moved to Packages, thus avoiding mixing up in the Assets folder.

  • Improved Smart dropdown : smart dropdown has been partially rewritten to allow progressive data loading, thus removing the long waiting times when loading objects with huge number of properties. Now only the first load will take longer, with all subsequent loads being near instantaneous even with huge amounts of properties.

  • Improved Preview logic : completely rewritten the preview logic. Now even non-serialized values can be previewed.

  • Added preview values in dropdown : there are cases where it is safe to preview property values directly in the dropdown menu, thus making it even easier to select the correct property.

  • Pinning System : a new pinning system has been added, which speeds up binding process when repeatedly binding from the same objects.

  • Added Async Update points : rewritten from scratch the way the async bindings were updated. Now there are multiple points in player pipeline where to update the bindings, and it can be selected for each binding.

  • Edit time binding update : now bindings can be updated even during edit time, opening up multiple possibilities for faster prototyping.

  • New Demo Scene : a new demo scene has been added, with more fun and binding examples.

Here below you may find promotional videos:

Main Features

How to easily bind anything

How to easily create a theming system

------------------------------------------------------------

Let me know your thoughts about it…

Wow, you have been busy! Looks really nice, @Geeorge. I like the fact that any field can be bound.

Will the Bind<> fields still be supported? I used it quite a lot and like accessing the ValueChanged event from code.

We’ve switched almost completely to the new UI Toolkit so I’m not sure the theme example could be adapted to that.

Hey @Colin_MacLeod, the Bind<T> is still pretty much part of the core of the asset, so it should work seamlessly. I’ve done tests on upgrading, but not on very big projects. If you encounter issues, just let me know and I will try to do my best to help you out.

1 Like