Dynamic reference to Class reference.

What I want to achieve.
I have 4 classes containing weapon stats (around 10 values).
I have them all referenced in the script I want to use them in.
I get the values by

RifleStats.damge //etc..

Or different setup


What I can’t figure out is how do I store a specific selected weapon (one of the 4) in a variable.
So that my other script can simply call:


You can do this using inheritance or interfaces.

With inheritance you declare a base weapon class and your different weapons inherit from that base class, so you would define your selected weapon as your base class and you can assign any class derived from your base class to the reference. Your inherited class will contain all the variables and methods of the base class.

With an interface you declare an interface class that would have all the methods you want to share, your weapon classes would all implement your interface.

For your purposes I think an abstract base class is the way to go.