/// <summary> /// Populates a <see cref="Galaxia.ParticlesPrefab"/> with ready set Presets. /// </summary> /// <param name="prefab">The Prefab to populate</param> /// <param name="Preset"> The preset to use</param> public void PopulatePreset(ParticlesPrefab prefab, ParticlesPrefab.Preset Preset) { switch (Preset) { case ParticlesPrefab.Preset.SmallStars: prefab.Size = 0.4f; prefab.MaxScreenSize = 0.04f; prefab.Texture = DefaultResources.StarTexture; prefab.ColorDistributor.Variation = 0.6f; break; case ParticlesPrefab.Preset.BigStars: prefab.Size = 1; prefab.MaxScreenSize = 0.1f; prefab.ColorDistributor.Variation = 0.4f; prefab.Texture = DefaultResources.StarTexture; break; case ParticlesPrefab.Preset.Dust: prefab.Size = 3; prefab.MaxScreenSize = 0.25f; prefab.AlphaDistributor.Multiplayer = 0.02f; prefab.ColorDistributor.Variation = 0.1f; prefab.Texture = DefaultResources.DustTexture; break; } prefab.Seed = Random.Next(int.MinValue, int.MaxValue); prefab.OriginalPreset = Preset; }
/// <summary> /// Creates and adds a <see cref="Galaxia.ParticlesPrefab"/> from a given preset /// </summary> /// <param name="name">Name of the new Particles Prefab</param> /// <param name="Preset"></param> /// <returns>The created and populated Particles Prefab</returns> public ParticlesPrefab Create(string name, ParticlesPrefab.Preset Preset) { ParticlesPrefab prefab = CreateInstance <ParticlesPrefab>(); prefab.name = name; PopulatePreset(prefab, Preset); Add(prefab); #if HIDE_SUB_ASSETS prefab.hideFlags = HideFlags.HideInHierarchy; #endif return(prefab); }