Hi
I’m still very very new. I don’t even have the terms down yet, so help me like I’m 5 
I just learned about animationcurves, and got it to work in my project. But then I decided I wanted to put the two animationcurves I’m using in a separate script, and call them from 6 other scripts, each using the animationcurves to affect a value. (the size of an image)
However, since I can’t make the “public animationcurves” static, i don’t really know how to reference them. The code I’m currently using to attempt to extract the value, is this, in Update::
sizeChange = SpellCurve.selectedSpellcurve.Evaluate(curveTimer);
it says: “an object reference is required for the non-static field”
So how do I reference it, so it acts “static” ? cause I can’t create a “static public AnimationCurve”
Well, you could make them static, that just doesn’t leave a way for you to change them in the inspector.
But what you can do is make a reference to your object itself static. This is called the ‘singleton pattern’. Here’s a very simple implementation:
public class SpellCurve : MonoBehaviour {
public static SpellCurve Instance;
void Awake() {
Instance = this;
}
public AnimationCurve selectedSpellCurve;
}
//elsewhere
sizeChange = SpellCurve.Instance.selectedSpellCurve.Evaluate(curveTimer);
Just put one SpellCurve in your scene, and you can set your curve there and access it anywhere.
2 Likes
Hey thanks man, that actually worked like a charm. 
Now I just need to juggle some timers and if statements… But I think I will save that for tomorrow.
You can create a static class with static animation curves and all, and assign the values from another component that is not static and you can edit in the inspector, said component can be destroyed after assignment(at game start) to not take runtime resources.
1 Like
You can also do it with non-static curves, just have them in a script attached to an empty GameObject. Then get a reference to that script in any script that needs access, just like you would access variables etc. This does allow multiple instances of the curves, but if you don’t need that, just use one GameObject (or one per curve, however you want to do it).