Hello,
I am trying to build a simple example of integration of SO and UITK. It ‘feels’ as if it should be so simple that it is possible. So…
- Has anyone done it (I’m sure someone has)
- Is there an example which is available
- Are there any ‘gotchas’ that one needs to be aware of before trying to do this.
I have followed these
and others (Ryan H) which are very helpful but don’t use UITK.
I have changes to SO values being shown in the inspector, but seem to be struggling to display the changes in a specific UI (TK) Element.
Comments welcome…
Hi @GameDev273 , it would help to have more details on what you are trying to do and perhaps have some example code as well.
Thanks.
I ended up using a custom Observable type in the ScripableObject to store the value, so that it could emit an event when the value is changed, and that event assigns the new value to the UITK element.
If you are just wanting it to update when it’s changed in the inspector, you can put something in the OnValidate() ScriptableObject callback to emit an event, or if your SO has reference to the element, you can just have it change the value directly in there.
Thanks for the replies. I am trying to implement an architecture shown (roughly) in the attached picture below.
I think that the problem is binding the SO values to elements in the toolkit (Newb limitations), but will have alook at ‘custom Observable type’ as suggested by MostHated. Also MH, could you elaborate on 'or if your SO has reference to the element,'.
I have a reference to the SO in the UI Manager script but I’m currenly getting a null ref error and the message below when I try to print the debug log in the UI manager with ref to the SO. Where playerData is the SO.
Debug.Log(" Player Data SO Time = " + playerData.Time);
The error message below suggets the SO value is null…doesn’t it?
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at :0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at :0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at :0)
UnityEngine.UIElements.Panel.UpdateBindings () (at :0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at :0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at :0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <68ddc6fd093848298397957a5969af5e>:0
