In the previous article, controlling play particles under the Unity editor, the scene view of the Unity editor controls the playback of particle particlesystem, but when the particle is attached to the body of the character, there is a possibility of not following the displacement. Find the cause and find it is
resimulateChecked, this option refers to updating the particle effect as soon as the particle parameter changes. To allow particles to follow the move, you must cancel this option.
You can simply cancel this option under the editor, as follows:
However, for other people who may not be aware of this, manual provisioning is not smart enough and needs to be further actively controlled in the code. To manipulate this option, you need to get the editor class, via reflection, as follows:
C # Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21st 22 23 24 25 26 27 28 29 30 31 32 33 |
|
usingSystem; usingSystem.Reflection; usingUnityeditor;
PublicStaticclassEditorparticlesystemhelper { PrivateStaticType RealType; PrivateStaticPropertyInfo property_editorresimulation;
PublicStaticvoidInittype () { if(RealType = =NULL) { var assembly = assembly.getassembly (typeof(Editor)); RealType = assembly. GetType ("Unityeditor.particlesystemeditorutils");
Property_editorresimulation = Realtype.getproperty ("Editorresimulation", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); } }
// <summary> /// must prohibit the resimulation of particles so that particles can follow the displacement // </summary> PublicStaticBOOLEditorresimulation { Set { Inittype (); Property_editorresimulation.setvalue (NULL, Value,NULL); } } }
|
So as long as the code in the appropriate place, use the following: C # code
1 |
|
Editorparticlesystemhelper.editorresimulation = false; |
Controlling particle playback following displacements under the Unity editor