I want to use the same vector in all instances of the script
Hi
So I have a bunch of vectors in my script like this:
public class MyScript : MonoBehaviour
{
private Vector2 bpA_p2X0Y = new Vector2(2, 0);
private Vector2 bpA_p2Xm4Y = new Vector2(2, -4);
private Vector2 bpA_p1X0Y = new Vector2(1, 0);
private Vector2 bpA_p1Xm4Y = new Vector2(1, -4);
private Vector2 bpA_0Xp1Y = new Vector2(0, 1);
private Vector2 bpA_0X0Y = new Vector2(0, 0);
private Vector2 bpA_0Xm1Y = new Vector2(0, -1);
private Vector2 bpA_0Xm2Y = new Vector2(0, -2);
private Vector2 bpA_0Xm3Y = new Vector2(0, -3);
private Vector2 bpA_0Xm4Y = new Vector2(0, -4);
private Vector2 bpA_0Xm5Y = new Vector2(0, -5);
private Vector2 bpA_m1X0Y = new Vector2(-1, 0);
private Vector2 bpA_m1Xm4Y = new Vector2(-1, -4);
private Vector2 bpA_m2X0Y = new Vector2(-2, 0);
private Vector2 bpA_m2Xm4Y = new Vector2(-2, -4);
}
This vectors are not going to change, they are constants.
But I have them stored in MyScrip, so this vectors are going to be created every time i place this script in some object, meaning that this vectors despite being constants are going to be created and stored in memory multiple times, because every instance of the script has it's own set of vectors.
I don't want that to hapen, I wan't to create and store them only one time, and then have every instance of MyScript use the same instance of the Vector set;
Your answer
Follow this Question
Related Questions
Raycast shotgun help! 2 Answers
Unexpected Symbol 'break' 2 Answers
Code to avoid or consider when exporting to WebGL? 0 Answers
Buttons not hiding 0 Answers
Debugging trouble; C# 0 Answers