How to control Particle System size in Unity through coding?

Hi, I’m doing a group project where we have to use Photon particle to control the unity world. I’m having problem using the data from the Accelerometer to control the size of the Particle System in Unity. Is there any reference code that can help me started? Thanks!

Depending on whether you want to control the start size of the currently emitted particles or size after the particle has been emitted. For the former, it’s simply feeding your accelerometer data to the start size (1 constant)/start size 3D/start size multiplier (2 constants/curves) of the particle system. You need to define the module the function you’re gonna use. In this case, “start size” or similar functions are under the “main module”, so this is the basic script (added to the same object of the particle system) for accessing particle start size:

using System.Collections;
using UnityEngine;
public class yourScript : MonoBehaviour {
	ParticleSystem ps;
	ParticleSystem.MainModule psmain;

	void Start() {
		ps = GetComponent<ParticleSystem>();
		psmain = ps.main;
	}

	void Update() {
		psmain.startSize = accelerometer;
	}
}

Obviously this code is terribly incomplete without defining the var “accelerometer”, but you get the idea.