[Solved] How can I access a variable from another script in Unity?


Try this:

public class Particle : MonoBehaviour
{
    public static Particle instance;
    public float particleSize;
    public Transform particle;

    void Awake()
    {
      instance = this;
    }
    void Start()
    {
        particle.localScale *= particleSize;
    }
}


public class Magnetic : MonoBehaviour
{
    
    public Transform magnetic;

    void Start()
    {
        magnetic.localscale *= Particle.instance.particleSize;
    }
}

2

solved How can I access a variable from another script in Unity?