标签:unity
在之前的文章《Unity 编辑器下控制播放粒子》讲到在Unity编辑器的Scene视图进行控制播放粒子ParticleSystem,但是当这个粒子是挂载在人物身体部位的时候,会有可能出现不跟随位移的情况。查找原因,发现是 Resimulate 被勾选中了,这个选项是指当粒子参数改变时,立即更新粒子效果。要让粒子也能跟随移动,必须将这个选项取消掉。
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 EditorParticleSystemHelper { 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.ParticleSystemEditorUtils"); property_editorResimulation = realType.GetProperty("editorResimulation", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); } } /// <summary> /// 必须禁止粒子的Resimulation,这样才能让粒子跟随位移 /// </summary> public static bool editorResimulation { set { InitType(); property_editorResimulation.SetValue(null, value, null); } } } |
|
EditorParticleSystemHelper.editorResimulation = false;
|
标签:unity
原文地址:http://blog.csdn.net/akof1314/article/details/46239281