I'm trying to have some toolbox with each tool in that toolbox being something quite different in functionality. So every tool would require its own config to be created and passed at the start, or when you need to change params, while the base class would be just the general outline of what all the tools have in common, but I'm getting an error when trying to access a public member of some config from a generic method. I have something like this:
public abstract class Tool
{
public abstract void Setup<T>(T setupParams);
}
public class SomeTool : Tool
{
public class SomeConfig
{
public int counter;
public float size;
public SomeConfig(int _counter, float _size)
{
counter = _counter;
size = _size;
}
}
int m_counter;
int m_size;
public override void Setup<SomeConfig>(SomeConfig setupParams)
{
m_counter = setupParams.counter;
//'SomeConfig' does not contain a definition for 'counter' and no accessible extension
// method 'counter' accepting a first argument of type 'SomeConfig' could be found
// (are you missing a using directive or an assembly reference?)
}
}
Having a constructor, or non generic setup function works, but why am I getting an error with what I am doing here?