vendredi 10 mars 2023

Find all variables by their type [duplicate]

I have several values of type Upgradable in my C# script:

public class Player 
{
   public Upgradable speed;
   public Upgradable damage;
   public Upgradable reload;

   int someVar1; //etc., there are other variables
}

And I should create a method GetAllUpgrades() in each class to run trough upgrades and update each of them. Here I store an array of Upgradable values that I've added manually. But are there some ways to do it automatically?





Aucun commentaire:

Enregistrer un commentaire