What would you expect to happen? For the trail points to be removed when it is disabled?
I guess what is happening, is that the trail enters a kind of āpausedā state while it is disabled.
I doubt we will want to change this, given that you can easily use Clear ⦠there is a risk of breaking other usersā content.
Yes the points should be removed when itās disabled, this is what happens in a particle system with trails gets disabled for example.
Itās not exactly behaving like a pause because if you set a short Lifetime: say 3s, make it draw then quicky disable it:
If you reactivate the trail after more than 3 seconds, you wonāt have any points drawn.
If you reactivate the trail before 3 seconds have passed, then you will have points drawn.
I saw this bug when using a pooling system on fx with trails.
Yes, I expected this, not a problem
Itās as simple as adding this script to fix the issue anyway:
using UnityEngine;
[RequireComponent(typeof(TrailRenderer))]
public class TrailRenderer_ClearOnDisable : MonoBehaviour
{
void OnDisable()
{
var trail = GetComponent<TrailRenderer>();
trail.Clear();
}
}
To be clear: I donāt need anything changed, the question below is just me being curious.
Is there really no way to make new default behaviours for future versions without breaking user content?
There are ways to change behaviour for new content, but it can get weird and messy (imagine having a mix of upgraded vs new assetsā¦)
If particles get cleared out when disabling the component, Im more inclined to agree with you about it being a bug⦠still scared to change it tho
I guess when itās unpaused any points that would have died due to too much time passing will be all removed instantly when enabled. That seems like a more clear cut bug. If disabling doesnāt clear out the points then time shouldnāt pass for the trail while disabled either.
including a āclearOnā operation in the component with a āonDisableā or āonActivationā could allow users options; without causing existing content to have it enabled.
typically in pooling logic I have had to ask engineers to instantiate + move, then next update tic to activate⦠otherwise behavior can cause long streaks across game content, including the inherintVelocity on shuriken making particles wiz across the screen on the frame they awaken
Iām seeing a similar issue but slightly different. When moving the PS, some of the particles jump to the new location, then back and continue their remaining journey, creating a streak. It only happens in world simulation mode, and it doesnāt matter how the trail is set (World checked or unchecked).