void ComponentParticleSystem::OnLoad(Config* config) { init.max_particles = config->GetUInt("Max particles", 100); init.loop = config->GetBool("Loop", false); init.duration = config->GetFloat("Duration", 0.0f); init.life.Load("Life", *config); init.speed.Load("Speed", *config); init.size.Load("Size", *config); init.rotation.Load("Rotation", *config); init.gravity.Load("Gravity", *config); init.color = config->GetFloat4("Color", float4::one); init.whole_speed = config->GetFloat("Whole speed", 1.0f); emitter.particles_per_second = config->GetUInt("Particles per second", 0); emitter.particles_per_distance = config->GetUInt("Particles per distance", 0); shape.type = (ShapeType)config->GetUInt("Shape type", (uint)Circle); if(shape.type == Circle) { shape.radius = config->GetFloat("Circle radius", 1.0f); } else if(shape.type == Cone) { shape.radius = config->GetFloat("Cone radius", 1.0f); shape.angle = config->GetFloat("Cone angle", 0.0f); } speed_over_time.init = config->GetFloat3("Speed init", float3::zero); speed_over_time.end = config->GetFloat3("Speed end", float3::zero); speed_over_time.bezier = config->GetFloat4("Speed bezier", float4(0.0f, 1.0f, 0.0f, 1.0f)); size_over_time.init = config->GetFloat("Size init", 1.0f); size_over_time.end = config->GetFloat("Size end", 1.0f); size_over_time.bezier = config->GetFloat4("Size bezier", float4(0.0f, 1.0f, 0.0f, 1.0f)); color_over_time.gradient.clearMarks(); uint count = config->GetArrayCount("Color over time"); for(uint i=0; i< count; ++i) { Config mark = config->GetArray("Color over time", i); bool alpha = mark.GetBool("alpha", false); float position = mark.GetFloat("position", 0.0f); if(alpha) { float color = mark.GetFloat("color", 1.0f); color_over_time.gradient.addAlphaMark(position, color); } else { float4 color = mark.GetFloat4("color", float4::one); color_over_time.gradient.addMark(position, ImColor(color.x, color.y, color.z, 1.0f)); } } if(color_over_time.gradient.getMarks().empty()) { color_over_time.gradient.addMark(0.0f, ImColor(1.0f, 1.0f, 1.0f, 1.0f)); } SetTexture(config->GetUID("Texture", 0)); texture_info.x_tiles = config->GetInt("Sheet x", 1); texture_info.y_tiles = config->GetInt("Sheet y", 1); texture_info.random = config->GetBool("Sheet random", false); texture_info.frame_over_time.init = config->GetFloat("Sheet init", 0.0f); texture_info.frame_over_time.end = config->GetFloat("Sheet end", 0.0f); texture_info.frame_over_time.bezier = config->GetFloat4("Sheet bezier", float4(0.0f, 1.0f, 0.0f, 1.0f)); blend_mode = (RenderBlendMode)config->GetInt("Blend mode", (int)AdditiveBlend); layer = config->GetFloat("Layer", 0.0f); }