Home > database >  Finding out the value of a boolean in a custom class
Finding out the value of a boolean in a custom class

Time:09-24

enter image description hereI have a custom class script that is given below and I have attached an image of how it looks in the inspector. Suppose, I want to know if the 'has Bought' boolean of 'Apply some pressure' is true. How can I know it? Also, how do I set another bool equal to it? Code of the custom class script:

[System.Serializable]
public class Buyables
{
    public string name; // A string called as Name

    public int price; // An integer called as price

    public bool hasBought; // A bool called as has bought
}

CodePudding user response:

I want to know if the 'has Bought' boolean of 'Apply some pressure' is true

Get the reference of your Money Class.

Money money;

Check boolean value with:

money.buyables[1].hasBought == true

how do I set another bool equal to it?

anotherBoolVariable = money.buyables[1].hasBought;
  • Related