reference to monobehaviour in static script,declaring a static class/script in a monobehaviour
Hello friends I have looked far and wide and I cannot locate anything on the internet to help me with this
Basically, I have two scripts: One is a monobehaviour and one is a static script my static script needs to get things from the monobehaviour. i know monobehaviours can reference other monobehaviours by getting the script component from an attached object but you cant attach static scripts to objects so i keep getting "object reference not set to an instance of an object" but i dont. know how to like declare a monobehaviour in a static script and i am losing my mind
heres a sample of the monobehavior
public class dexReader : MonoBehaviour
{
//misc variables not important
public int GetAttack(string characterName)
{
//code that returns an int attack value
}
and heres the static one
public class Character
{
//lotsof variables only showing relevant ones
protected int rarity;
protected string charName;
public int attack;
public GameObject dataHandler;
//this the obj script is attached to
private dexReader dexReader;
//this the script (normally declared at start like "dexReader = dataHandler.GetComponent<dexReader>();" but cannot do that because theres no!! start!! function in static!!
//init new char
public Character(int rar, string nam)
{
rarity = rar;
charName = nam;
attack = dexReader.GetAttack(nam);
}
}
annnnd heres the line thats making the null reference whatever stupid error (in another monobehaviour script)
Character testingguy = new Character(1, "Test Starter Character");
ANYWAYS any help would be appreciated I literally cannot figure out what to do and its driving me insane