Adding Custom Effect โ
While Elin includes a list of prebuilt effects that can be used with PlayEffect
or Effect.Get
, you can also easily add your own.
Spritesheet Setup โ
Your custom effect spritesheet must meet the following requirements:
- Format: The image must be a horizontal spritesheet containing all frames of the animation laid out in a single row.
- Frame Dimensions: Each frame within the spritesheet must be a perfect square (e.g., 32x32, 64x64, 128x128 etc.).
- Location: Place the spritesheet directly inside the Texture folder.
- Effect ID: The filename (without the extension) will be used as the unique ID for your effect.
For example, to create an effect called magic_burst
, you would create a file named magic_burst.png
and place it in the Texture
folder. You could then play it in-game by calling PlayEffect("magic_burst")
or customize it with Effect.Get("magic_burst")
.
Hot Reload Testing โ
While the game is running, you can modify effect files and use the console command cwl.data.clear_effect_cache
to clear the effect cache for hot reloading and applying any new changes.
Modifying Effect Templates โ
In your code, you can modify your custom effect templates so that all subsequently generated instances of that effect will apply the changes:
using Cwl.Helper.Unity;
var myEffectTemplate = EffectHelper.GetEffectTemplate("magic_burst");
using UnityEngine;
var manager = Effect.manager;
if (manager.effects.map is null) {
var rod = Effect.Get("rod");
Object.Destroy(rod);
}
var myEffectTemplate = manager.effects.map.GetValueOrDefault(id);