Control the following position of the particle play in the Unity editor.
In the previous article "control playing particles in Unity Editor", we talked about controlling playing particles in the Scene view of the Unity editor. However, when this particle is mounted to the body of a character, there may be situations where the displacement is not followed. Find the cause and find thatResimulateChecked. This option is used to update the particle effect immediately when the particle parameter changes. To make the particle move as well, you must remove this option.
You can simply cancel this option in the editor, as shown below:
However, if other people do not know the reason, the manual setting is not smart enough and requires further active control in the code. To manipulate this option, you need to obtain the editor class through reflection, as shown below:
C # Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Using System; Using System. Reflection; Using UnityEditor;
Public static class editorparticipant lesystemhelper { Private static Type realType; Private static PropertyInfo property_editorResimulation;
Public static void InitType () { If (realType = null) { Var assembly = Assembly. GetAssembly (typeof (Editor )); RealType = assembly. GetType ("UnityEditor. Participant systemeditorutils ");
Property_editorResimulation = realType. GetProperty ("editorResimulation", BindingFlags. Static | BindingFlags. NonPublic | BindingFlags. Public ); } }
/// <Summary> /// The Resimulation of the particle must be disabled so that the particle can follow the displacement. /// </Summary> Public static bool editorResimulation { Set { InitType (); Property_editorResimulation.SetValue (null, value, null ); } } }
|
Use the following Code as needed: C # Code
1 |
|
Editorparticipant systemhelper. editorResimulation = false; |