Controlling particle playback following displacements under the Unity editor

Source: Internet
Author: User

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

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.