分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
在Unity编辑器的Scene视图进行控制播放粒子ParticleSystem,可以借助方法Simulate,具体可以参照以下例子:
创建一个空对象ParticleAll,在这个对象下添加一个粒子(要添加多个粒子的话,添加到这个粒子之下),此时选中粒子, 可以看到 Scene视图预览播放粒子效果。附上新脚本
EditParticleSystem ,此为空脚本,如下:
C# Code
1
2 3 4 5 6 |
using UnityEngine;
public class EditParticleSystem : MonoBehaviour { } |
创建一个这个脚本的编辑器类
EditParticleSystemInspector,代码如下:
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
using UnityEditor;
using UnityEngine; [CustomEditor( typeof(EditParticleSystem))] public class EditParticleSystemInspector : Editor { /// <summary> /// 滑动杆的当前时间 /// </summary> private float m_CurTime; /// <summary> /// 当前是否是预览播放状态 /// </summary> private bool m_Playing; /// <summary> /// 当前运行时间 /// </summary> private float m_RunningTime; /// <summary> /// 上一次系统时间 /// </summary> private double m_PreviousTime; /// <summary> /// 滑动杆总长度 /// </summary> private const float kDuration = 30f; private ParticleSystem m_ParticleSystem; private EditParticleSystem editAnimator { get { return target as EditParticleSystem; } } private ParticleSystem particleSystem { get { return m_ParticleSystem ?? (m_ParticleSystem = editAnimator.GetComponentInChildren<ParticleSystem>()); } } void OnEnable() { m_PreviousTime = EditorApplication.timeSinceStartup; EditorApplication.update += inspectorUpdate; } void OnDisable() { EditorApplication.update -= inspectorUpdate; } public override void OnInspectorGUI() { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button( "Play")) { play(); } if (GUILayout.Button( "Stop")) { |