How to set up resources?

Note

Multiple resources types support added in 1.8.0 version. Previous versions have one resource type - money, with no specific setup.

To setup a new resources, you need to create ResourceData asset in the Project Manager window

../../_images/create-resource-data.png

In this data you can setup text Id and Icon.

Warning

Currently, these fields not used by asset, but you can use it from your own code for UI and other purposes. Next asset versions will introduce more feature-packed Multi-resources system.

After this, you need to add new resource to the Game Settings:

../../_images/add-resource-data-to-storage.png

Now you can use your resources data in the different asset settings by simple linking in fields your created ResourceData asset:

../../_images/resource-data-usage-example.png

How to use Resource system from code

Note

More info about this will be added to the Scripting API and Programming partitions soon.

Player class contains these methods to work with resources:

// to get resource id, use method resourceData.GetResourceId()

public void SetResource(int id, int value)
public void GetResourceAmount(int id, int value)
public void AddResource(string id, int amount)
public void SpendResource(string id, int amount)

// etc.