Is there any reason that Ability can't inherit from BoundStateObject so that ability properties can bind to item attributes?

airoll

Member
Hi I noticed the new introduction of a BoundStateObject class which is the base class for action modules and the like. This is super useful for binding item attributes to properties in those modules. I'm wondering: What if Ability also inherited from BoundStateObject? Would that break abilities in any way? It would be super nice so that I could avoid hacky binding code to bind item attributes to ability properties.
 
The BoundStateObject state object class was added later in the v3 development cycle and I never got the chance to switch it and properly test. It shouldn't cause any issues but let me know how well it works and I will do the same.
 
Hi Justin, I tried to change Ability to derive from BoundStateObject and AbilityControlType to derive from BoundStateObjectControlType, but I got the following error in the Editor when I have the UltimateCharacterLocomotion component open in the inspector:

Code:
[Exception] NullReferenceException: Object reference not set to an instance of an object
BoundStateObjectControlType.GetControl() at /Opsive/UltimateCharacterController/Editor/Controls/Types/BoundStateObjectControl.cs:43

TypeControlBase.GetTypeControl() at <f3132f0252d1485082ec6036aa56ed1f>:0

FieldInspectorView.AddTypeControl() at <f3132f0252d1485082ec6036aa56ed1f>:0

FieldInspectorView.AddFields() at <f3132f0252d1485082ec6036aa56ed1f>:0

FieldInspectorView.AddFields() at <f3132f0252d1485082ec6036aa56ed1f>:0

UltimateCharacterLocomotionInspector.ShowAbility() at /Opsive/UltimateCharacterController/Editor/Inspectors/Character/UltimateCharacterLocomotionInspector.cs:621

UltimateCharacterLocomotionInspector+<>c__DisplayClass38_0.<AddAbilityList>b__3() at /Opsive/UltimateCharacterController/Editor/Inspectors/Character/UltimateCharacterLocomotionInspector.cs:504

ReorderableList.SelectItem() at <f3132f0252d1485082ec6036aa56ed1f>:0

ReorderableList.set_SelectedIndex() at <f3132f0252d1485082ec6036aa56ed1f>:0

UltimateCharacterLocomotionInspector.AddAbilityList() at /Opsive/UltimateCharacterController/Editor/Inspectors/Character/UltimateCharacterLocomotionInspector.cs:560

UltimateCharacterLocomotionInspector.ShowFooterElements() at /Opsive/UltimateCharacterController/Editor/Inspectors/Character/UltimateCharacterLocomotionInspector.cs:387

UIElementsInspector.DrawElements() at <f3132f0252d1485082ec6036aa56ed1f>:0

UIElementsInspector.CreateInspectorGUI() at <f3132f0252d1485082ec6036aa56ed1f>:0

InspectorElement.CreateInspectorElementFromEditor() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

InspectorElement.Reset() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

InspectorElement.ExecuteDefaultActionAtTarget() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

CallbackEventHandler.HandleEvent() at <8759e14def7c40b68c657c638e8a0434>:0

CallbackEventHandler.HandleEventAtTargetPhase() at <8759e14def7c40b68c657c638e8a0434>:0

SerializedObjectBindingContext.SendBindingEvent[TEventType]() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

SerializedObjectBindingContext.BindTree() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

SerializedObjectBindingContext.ContinueBinding() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

SerializedObjectBindingContext.Bind() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

DefaultSerializedObjectBindingImplementation.Bind() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

BindingExtensions.Bind() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

UnityEditor.UIElements.InspectorElement..ctor() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

EditorElement.Init() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

UnityEditor.UIElements.EditorElement..ctor() at <b0f293012f4f4a13b3c5a7dc37df7ba8>:0

EditorUIServiceImpl.CreateEditorElement() at <a670b6bef51a40afbed82ef31a9f41e1>:0

PropertyEditor.DrawEditors() at <11d97693183d4a6bb35c29ae7882c66b>:0

PropertyEditor.RebuildContentsContainers() at <11d97693183d4a6bb35c29ae7882c66b>:0

InspectorWindow.RedrawFromNative() at <11d97693183d4a6bb35c29ae7882c66b>:0

Am I missing something?
 
It doesn't look like this setup will work without some changes. I have it on my list to take a look at.
 
Hey @Justin, how's it looking for this? Do you have any ETA or sense of when Ability can inherit from BoundStateObject? Thanks so much!
 
I do not currently have an ETA for this. Right now I am still in bug fixing mode rather than adding new features.
 
Top