I want to reproduce the behaviour of the Particle System where one can change the time of the ParticleSystem and see it at particular playback positions.
This can be done with the “Playback Time” but I need to do it by script.
I only need this to work in editor mode and not in playmode.
I tried using ParticleSystem.Simulate and ParticleSystem.time to no avail.
How can I set the Playback Time value of that popup window by script?
// my failed attempts
if (Ps != null)
{
// Ps.Simulate(adjustedTime, true, false);
Ps.Pause(true);
Ps.time = adjustedTime;
}
Ah yes, the restart parameter I had forgotten about that.
I thought the script would allow to preview properly but something’s amiss.
An issue I found was due to the particles having a different seed @ every simulation. But there still are deeper problems and I really hope you can take a look at this: I provided a package of the example I show in the video.
Here’s a video of the difference between clicking on the Particle System’s Restart button and the ParticleSystem.Simulate by script.
As you can see the 1st particle isn’t disappearing and the blue one can’t even be seen going up.
When I’m moving the playback time when the particle system is paused, it works perfectly.
It means that the Editor is calling something that allows to preview without bugs, I just need to call the same thing then.
What is the editor calling when modifying this value?
Or how can I set that value to something I want through script?
I only need this to work in the editor and not in playmode.
Obviously, internal methods may also change without warning in future versions of Unity.
Sorry I don’t have a good answer for this. I’ll try find time to look at that bug again in the near future… it’s literally the oldest open Particle System bug… we haven’t managed to find a fix for it (yet).
Thanks a lot for answering all this Richard, it’s much appreciated!
I will have to use the reflection temporarily until you find out how to fix that bug because my vfx artist needs that previewer asap. However, I haven’t used reflection yet so do you know why it’s not finding the PsUtils in the SetPlaybackTime() method here?
Are there any plans to fix the long standing simulate bug in the unity 2019 cycle? My project is totally dependent on this working, been waiting a while, it’d be nice to know if I should just scrap it and move on.
Also an annoyance for us. It ate quite a few hours and I was beginning to suspect I was going insane for a bit.
I used a pile of hacks to get it somewhat working, but would appreciate a lot if it was officially fixed.
@dpizzle@SugoiDev can you confirm whether this statement from the original post is also true for you?
I ask because, looking at the repro project for the bug we have (https://issuetracker.unity3d.com/issues/particle-system-simulate-issues) the steps demonstrate the issue in a playmode scenario. (and thus any fix would only be guaranteed to fix the playmode issue in that project, and might miss an editmode isuse, if there is one)
If you have an editmode scenario, please report it as a separate bug and reply here with the case number so I can track it.
I only need play mode bug fixed. I do not need editor mode fixed. Sorry, I posted on this thread because it seemed most active and relevant. Many thanks for looking into it.
We are currently testing a fix for this issue which aims to resolve it in Play Mode (and players).
To reiterate about Edit Mode: the bug report doesn’t show an Edit Mode problem and we don’t know of any problem with this in Edit Mode, so, if you’re reading this and thinking “Hey, I get this bug in Edit Mode!”, then please report a bug for us and we’ll investigate it
There’s always been something that seemed more important (and arguably there still is!) but you’re right that it’s been a long time (too long, probably!) and we want to be able to help you out, so we’ve diverted a bit of time towards trying to figure this one out. Hopefully it’s a good fix and will pass testing.
First, thanks Richard for looking deeper into this issue.
I never managed to use the trick with UnityEditor.ParticleSystemEditorUtils you had once mentioned.
Could it be that the play and editor mode bugs are one and the same?
There shouldn’t be a doubt as to whether there is a bug in the editor mode with what I showed in the video above by the way. I could make a project with the scripts and post them as a bug if they are indeed different bugs.
I don’t think so, because the fix I’ve applied should (in theory) only affect playmode.
Ah, good point! I had forgotten about that. I’ve just loaded it up and yes you’re right, it reproduces what I think is a different issue. I’m currently on a version of 2019.1 one so i can’t say right now if the other fix would fix this too (thougth I’m still speculating that it won’t)
I think what you have in your video is probably different to what’s currently logged, but I’ll check for sure next week, before asking you to do anything. I can log it myself, to be honest, as it’s so simple, it just depends if you want to benefit from the bug notifications by logging it yourself.
Hard to say… it has quite a few votes on the issue tracker. It might make the cut.
Hey, another update - the editmode repro did indeed still fail. I now have a fix for that too, and we are beginning testing of the changes. After that, assuming all goes well, we will look at what versions we can get this into.