Hello! I need to use the AttributeBinding on the Item to bind the Attribute in the CharacterAttributeManager.
Because the Items in my game project will be dynamically loaded and deleted and use the object pool, when to register and unregister the binding of Attribute is a key point.
I found that only m_BoundGameObject and m_StateObject can be obtained on AttributeBinding, and these two variables will only be refreshed when the Unity game object is instantiated in some places. Therefore, it seems not a good way to get the CharacterAttributeManager component through m_BoundGameObject or m_StateObject.
So I thought I could write a linker component on the Item game object to store a reference to the CharacterAttributeManager.
When the "OnInventoryAddItem" and "OnInventoryDestroyItem" events are executed, the CharacterAttributeManager obtains the linker component on the Item game object and updates the reference, so that the CharacterAttributeManager can be correctly refreshed when adding and deleting Items and correctly register and unregister the binding of the Attribute.
Is the above approach okay, please let me know if there is a better way, thank you!
Because the Items in my game project will be dynamically loaded and deleted and use the object pool, when to register and unregister the binding of Attribute is a key point.
I found that only m_BoundGameObject and m_StateObject can be obtained on AttributeBinding, and these two variables will only be refreshed when the Unity game object is instantiated in some places. Therefore, it seems not a good way to get the CharacterAttributeManager component through m_BoundGameObject or m_StateObject.
So I thought I could write a linker component on the Item game object to store a reference to the CharacterAttributeManager.
When the "OnInventoryAddItem" and "OnInventoryDestroyItem" events are executed, the CharacterAttributeManager obtains the linker component on the Item game object and updates the reference, so that the CharacterAttributeManager can be correctly refreshed when adding and deleting Items and correctly register and unregister the binding of the Attribute.
Is the above approach okay, please let me know if there is a better way, thank you!