Hello people!
I noticed this one:
I was in need of something that remembers if a light was on or off. Of course, this one worked like a charm even though I don't know the first thing about scripting (seeing that I had a step by step tutorial on how to write it).
Now I am in need of something that checks if a standart shuriken particle system is turned on, or off via the "Particle Switch" script (provided with AC).
Did someone already write this script or does someone need to write it anyways?
I'd be grateful if someone could help me out with that, seeing that I have no idea where even to start with it.
Comments
RememberParticle.cs(13,72): error CS1061: Type `UnityEngine.Particle' does not contain a definition for `enableEmission' and no extension method `enableEmission' of type `UnityEngine.Particle' could be found (are you missing a using directive or an assembly reference?)
In the SaveData function, set "isOn" to match the value of the ParticleSystem's isAlive property. Then in LoadData, use the "isOn" to either call Play or Stop.
using System.Collections.Generic;
using UnityEngine;
namespace AC
{
[RequireComponent (typeof (ParticleSystem))]
public class RememberParticle : Remember
{
public override string SaveData ()
{
ParticleData particleData = new ParticleData ();
particleData.isOn = GetComponent ().isPlaying;
particleData.objectID = constantID;
return Serializer.SaveScriptData (particleData);
}
public override void LoadData (string stringData)
{
ParticleData data = Serializer.LoadScriptData (stringData);
if (data == null) return;
if(data.isOn) GetComponent ().Play();
}
[System.Serializable]
public class ParticleData : RememberData
{
public bool isOn;
public ParticleData () { }
}
}
}