Upgradable Item - flexible component for things that can be upgraded. It saves item upgrade level.
Button Buy - Button Buy component link.
Use Price Text - if enabled, sets the text on the buy button.
Button Text After Max Upgrade - text which will be shown after last upgrade.
Use Progress Bar - allows to use progress bar.
Progress Bar - component link.
Id - it can be a random number, but all items must have a different id.
Max Upgrade Level - number of times you can buy an upgrade. Note that the Progress Bar with Items must have the same maximum value.
Price - item price.
Payment Resource - resource to which the purchase will be paid.
Increase Price After Upgrade - increase item price after every upgrade.
Increase Type - increase method (multiply price by value or add value to price).
Increase Value - value by which the price increases or multiplies.
On Upgrade Item(int) - event which invokes when the item upgrades
UpgradableItemData.cs - a script that contains data about an item state.
[Serializable]
public class UpgradableItemData
{
public int Id;
public int UpgradeLevel;
}
QUESTIONS:
How to use the component?
Add the component to any object you want and set the settings: set id, max upgrade level and price and turn on use price text if you need.
Add link to a button buy component and turn on and add link to a progress bar if you want.
After that, the component is fully configured. Now you just need to realize for yourself what should happen when it upgrades. You can create a script, subscribe to events and continue to do what you want.
2. How to subscribe event?
[SerializeField] private UpgradableItem _upgradableItem;
private void Start()
{
_upgradableItem.OnUpgradeItem.AddListener(OnUpgradeItem);
}
private void OnUpgradeItem(int upgradeLevel)
{
Debug.Log($"Upgrade level is {upgradeLevel}");
}