-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathClampVelocityModuleUI.cs
More file actions
120 lines (106 loc) · 5.31 KB
/
ClampVelocityModuleUI.cs
File metadata and controls
120 lines (106 loc) · 5.31 KB
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
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using UnityEngine;
namespace UnityEditor
{
class ClampVelocityModuleUI : ModuleUI
{
SerializedMinMaxCurve m_X;
SerializedMinMaxCurve m_Y;
SerializedMinMaxCurve m_Z;
SerializedMinMaxCurve m_Magnitude;
SerializedProperty m_SeparateAxes;
SerializedProperty m_InWorldSpace;
SerializedProperty m_Dampen;
SerializedMinMaxCurve m_Drag;
SerializedProperty m_MultiplyDragByParticleSize;
SerializedProperty m_MultiplyDragByParticleVelocity;
class Texts
{
public GUIContent x = EditorGUIUtility.TextContent("X");
public GUIContent y = EditorGUIUtility.TextContent("Y");
public GUIContent z = EditorGUIUtility.TextContent("Z");
public GUIContent dampen = EditorGUIUtility.TrTextContent("Dampen", "Controls how much the velocity that exceeds the velocity limit should be dampened. A value of 0.5 will dampen the exceeding velocity by 50%.");
public GUIContent magnitude = EditorGUIUtility.TrTextContent("Speed", "The speed limit of particles over the particle lifetime.");
public GUIContent separateAxes = EditorGUIUtility.TrTextContent("Separate Axes", "If enabled, you can control the velocity limit separately for each axis.");
public GUIContent space = EditorGUIUtility.TrTextContent("Space", "Specifies if the velocity values are in local space (rotated with the transform) or world space.");
public string[] spaces = { "Local", "World" };
public GUIContent drag = EditorGUIUtility.TrTextContent("Drag", "Control the amount of drag applied to each particle during its lifetime.");
public GUIContent multiplyDragByParticleSize = EditorGUIUtility.TrTextContent("Multiply by Size", "Adjust the drag based on the size of the particles.");
public GUIContent multiplyDragByParticleVelocity = EditorGUIUtility.TrTextContent("Multiply by Velocity", "Adjust the drag based on the velocity of the particles.");
}
static Texts s_Texts;
public ClampVelocityModuleUI(ParticleSystemUI owner, SerializedObject o, string displayName)
: base(owner, o, "ClampVelocityModule", displayName)
{
m_ToolTip = "Controls the velocity limit and damping of each particle during its lifetime.";
}
protected override void Init()
{
// Already initialized?
if (m_X != null)
return;
if (s_Texts == null)
s_Texts = new Texts();
m_X = new SerializedMinMaxCurve(this, s_Texts.x, "x");
m_Y = new SerializedMinMaxCurve(this, s_Texts.y, "y");
m_Z = new SerializedMinMaxCurve(this, s_Texts.z, "z");
m_Magnitude = new SerializedMinMaxCurve(this, s_Texts.magnitude, "magnitude");
m_SeparateAxes = GetProperty("separateAxis");
m_InWorldSpace = GetProperty("inWorldSpace");
m_Dampen = GetProperty("dampen");
m_Drag = new SerializedMinMaxCurve(this, s_Texts.drag, "drag");
m_MultiplyDragByParticleSize = GetProperty("multiplyDragByParticleSize");
m_MultiplyDragByParticleVelocity = GetProperty("multiplyDragByParticleVelocity");
}
override public void OnInspectorGUI(InitialModuleUI initial)
{
EditorGUI.BeginChangeCheck();
bool separateAxes = GUIToggle(s_Texts.separateAxes, m_SeparateAxes);
if (EditorGUI.EndChangeCheck())
{
// Remove old curves from curve editor
if (separateAxes)
{
m_Magnitude.RemoveCurveFromEditor();
}
else
{
m_X.RemoveCurveFromEditor();
m_Y.RemoveCurveFromEditor();
m_Z.RemoveCurveFromEditor();
}
}
// Keep states in sync
if (!m_X.stateHasMultipleDifferentValues)
{
m_Y.SetMinMaxState(m_X.state, separateAxes);
m_Z.SetMinMaxState(m_X.state, separateAxes);
}
if (separateAxes)
{
GUITripleMinMaxCurve(GUIContent.none, s_Texts.x, m_X, s_Texts.y, m_Y, s_Texts.z, m_Z, null);
EditorGUI.indentLevel++;
GUIBoolAsPopup(s_Texts.space, m_InWorldSpace, s_Texts.spaces);
EditorGUI.indentLevel--;
}
else
{
GUIMinMaxCurve(s_Texts.magnitude, m_Magnitude);
}
EditorGUI.indentLevel++;
GUIFloat(s_Texts.dampen, m_Dampen);
EditorGUI.indentLevel--;
GUIMinMaxCurve(s_Texts.drag, m_Drag);
EditorGUI.indentLevel++;
GUIToggle(s_Texts.multiplyDragByParticleSize, m_MultiplyDragByParticleSize);
GUIToggle(s_Texts.multiplyDragByParticleVelocity, m_MultiplyDragByParticleVelocity);
EditorGUI.indentLevel--;
}
override public void UpdateCullingSupportedString(ref string text)
{
text += "\nLimit Velocity over Lifetime module is enabled.";
}
}
} // namespace UnityEditor