Add Custom Attribute look like AmmoData

Hi,
I copy and modified all script contain "AmmoData",
In "UltimateCharacterControllerIntegration.cs",
I add "SetAttributeItemBinding(itemDefinition, characterItem);" after "SetShootableWeaponBinding(itemDefinition, characterItem);",
But when I call "GetItemAttributeOfType<AttributeData>(itemDefinition);",
It's return NULL :unsure:

I try force add, but when play the attribute disapear...
Any suggestion?
 
Hi, I don't understand what you are trying to do.

UltimateCharacterControllerIntegration is an Editor script. It does nothing at runtime.

It simply helps adding the components when you build new items in the Editor. But if you are making custom components you could simply add the components you want on the Item prefab directly after it was built.

Could you elaborate on what you want to do and why?
 
In Character Items, I try add setup for "AttributeData" based on "AmmoData" for sync AttributeManager of chracter item to UIS look like "Durability" or "Battery", but when I call "GetItemAttributeOfType<AttributeData>(itemDefinition);" that's "return null",
I forced set attribute but when I try dirty for save the "AttributeData" on item that's don't work, when play or compile it's disapear...
 
I'm still confused as to what you are doing.

You wish to add a new Attribute value when creating an Item in the editor automatically?
Or are you simply trying to bind an existing Attribute to an existing property on the Item gameobject?

GetItemAttributeOfType will only return null if the attribute you are looking for does not exist or if the attribute value is null.

If the attribute does not exist you need to add it on one of the parent categories of the ItemDefinition. You could do so through the ItemCategoryEditorUtility.

If you are trying to set the value in the editor manually, but it's not saving then you might have the same issue as the mentioned on this post:
 
That's doesn't work..
So where is AmmoData added to the character item?
I followed the same procedure as AmmoData, and it does not work, I do not understand.
 
AmmoData is an Attribute. If you followed the video tutorial you'll see that the attribute is part of a Category called "Item With Ammo". That category has that Attribute pre-added.
So any ItemDefinition that inherits from this category will have the AmmoData attribute.

In the Character Item Editor if you have selected an Item prefab with a "Shootable Weapon" component it will try to find that existing attribute. If it does find the AmmoData Attribute on the UIS item, it will give you to option to add the components that bind the ammo attribute to the ammo on the "Shootable Weapon".
The Editor simply helps you add the components, such that it's easier for new users, but you could simply add the "ShootableWeaponAmmoBinding " component manually and it would result in the same thing.

In your case, from what I understand you wish to make a custom type and you want to bind the item attribute value to a component on the Item prefab.

So you simply need to follow these steps
1) Create your custom type (I believe you called it AttributeData)
2) Add your type as an attribute on an Item Category that your Items will inherit from, if your custom attribute type does not show up, make sure to add it in the Unit Options. If you don't know what that is refer to this page: https://opsive.com/support/documentation/ultimate-inventory-system/attributes/
3) Create a component similar to the ShootableWeaponAmmoBinding component.
4) Add your components on your Item prefab

That's all you'll need. There is no need to do anything Editor related.

Don't forget that if you have a simply type you can use the ItemBinding component directly: https://opsive.com/support/documentation/ultimate-inventory-system/item-objects/item-binding/

I hope this clears things up
 
Yes I almost understood everything, I successful to add "AttributeData" in the item editor ?
Sorry, I have a little trouble with English!
By speaking of language, I know how to add the localized text class now, verry thanks ?
 
Top