protected override void InitialiseIfNeeded() { base.InitialiseIfNeeded(); if (_particleCustomData == null) { for (int i = 0; i < _materials.Length; i++) { _animationTexture.SetMaterialProperties(_materials[i]); } _mesh = AnimationTexture.AddExtraMeshData(_mesh, 4); _particleCurrentFrame = new float[_particles.Length]; _particleCustomData = new List <Vector4>(_particles.Length); ParticleSystem.CustomDataModule customData = _particleSystem.customData; customData.SetMode(_customDataChannel, ParticleSystemCustomDataMode.Vector); customData.SetVector(_customDataChannel, 0, new ParticleSystem.MinMaxCurve(kDefaultData.x)); customData.SetVector(_customDataChannel, 1, new ParticleSystem.MinMaxCurve(kDefaultData.y)); customData.SetVector(_customDataChannel, 2, new ParticleSystem.MinMaxCurve(kDefaultData.z)); customData.SetVector(_customDataChannel, 3, new ParticleSystem.MinMaxCurve(kDefaultData.w)); } }
public override object WriteTo(object obj) { obj = base.WriteTo(obj); if (obj == null) { return(null); } ParticleSystem.CustomDataModule o = (ParticleSystem.CustomDataModule)obj; o.SetMode(ParticleSystemCustomData.Custom1, m_mode1); o.SetMode(ParticleSystemCustomData.Custom1, m_mode2); if (m_mode1 == ParticleSystemCustomDataMode.Color) { o.SetColor(ParticleSystemCustomData.Custom1, m_color1); } else if (m_mode1 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom1, m_vectorComponentCount1); for (int i = 0; i < m_vectorComponentCount1; ++i) { o.SetVector(ParticleSystemCustomData.Custom1, i, m_vectors1[i]); } } if (m_mode2 == ParticleSystemCustomDataMode.Color) { o.SetColor(ParticleSystemCustomData.Custom2, m_color2); } else if (m_mode2 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom2, m_vectorComponentCount2); for (int i = 0; i < m_vectorComponentCount2; ++i) { o.SetVector(ParticleSystemCustomData.Custom2, i, m_vectors2[i]); } } return(obj); }
private void MapCustomDataParameters(ParticleSystem pSystem, int i) { ParticleSystem.CustomDataModule customDataModule = pSystem.customData; try { customDataModule.enabled = GetBoolParam(i, "customData_enabled"); } catch (NullReferenceException) { customDataModule.enabled = false; return; } customDataModule.SetMode(ParticleSystemCustomData.Custom1, ParticleSystemCustomDataMode.Vector); customDataModule.SetMode(ParticleSystemCustomData.Custom2, ParticleSystemCustomDataMode.Vector); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 0)); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 1)); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 2)); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 3)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 0)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 1)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 2)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 3)); }
public override object WriteTo(object obj) { obj = base.WriteTo(obj); if (obj == null) { return(null); } ParticleSystem.CustomDataModule o = (ParticleSystem.CustomDataModule)obj; o.SetMode(ParticleSystemCustomData.Custom1, m_mode1); o.SetMode(ParticleSystemCustomData.Custom1, m_mode2); if (m_mode1 == ParticleSystemCustomDataMode.Color) { if (m_color1 != null) { ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(); m_color1.WriteTo(grad); o.SetColor(ParticleSystemCustomData.Custom1, grad); } } else if (m_mode1 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom1, m_vectorComponentCount1); if (m_vectors1 != null) { for (int i = 0; i < m_vectorComponentCount1; ++i) { if (m_vectors1[i] != null) { ParticleSystem.MinMaxCurve v = new ParticleSystem.MinMaxCurve(); m_vectors1[i].WriteTo(v); o.SetVector(ParticleSystemCustomData.Custom1, i, v); } } } } if (m_mode2 == ParticleSystemCustomDataMode.Color) { if (m_color2 != null) { ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(); m_color2.WriteTo(grad); o.SetColor(ParticleSystemCustomData.Custom2, grad); } } else if (m_mode2 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom2, m_vectorComponentCount2); if (m_vectors2 != null) { for (int i = 0; i < m_vectorComponentCount2; ++i) { if (m_vectors2[i] != null) { ParticleSystem.MinMaxCurve v = new ParticleSystem.MinMaxCurve(); m_vectors2[i].WriteTo(v); o.SetVector(ParticleSystemCustomData.Custom2, i, v); } } } } return(obj); }