Control the following position of the particle play in the Unity editor.

Source: Internet
Author: User

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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.