-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathRotationModuleUI.cs
More file actions
101 lines (86 loc) · 3.77 KB
/
RotationModuleUI.cs
File metadata and controls
101 lines (86 loc) · 3.77 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
// 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 RotationModuleUI : ModuleUI
{
SerializedMinMaxCurve m_X;
SerializedMinMaxCurve m_Y;
SerializedMinMaxCurve m_Z;
SerializedProperty m_SeparateAxes;
class Texts
{
public GUIContent rotation = EditorGUIUtility.TrTextContent("Angular Velocity", "Controls the angular velocity of each particle during its lifetime.");
public GUIContent separateAxes = EditorGUIUtility.TrTextContent("Separate Axes", "If enabled, you can control the angular velocity limit separately for each axis.");
public GUIContent x = EditorGUIUtility.TextContent("X");
public GUIContent y = EditorGUIUtility.TextContent("Y");
public GUIContent z = EditorGUIUtility.TextContent("Z");
}
static Texts s_Texts;
public RotationModuleUI(ParticleSystemUI owner, SerializedObject o, string displayName)
: base(owner, o, "RotationModule", displayName)
{
m_ToolTip = "Controls the angular velocity of each particle during its lifetime.";
}
protected override void Init()
{
// Already initialized?
if (m_Z != null)
return;
if (s_Texts == null)
s_Texts = new Texts();
m_SeparateAxes = GetProperty("separateAxes");
m_X = new SerializedMinMaxCurve(this, s_Texts.x, "x", kUseSignedRange, false, m_SeparateAxes.boolValue);
m_Y = new SerializedMinMaxCurve(this, s_Texts.y, "y", kUseSignedRange, false, m_SeparateAxes.boolValue);
m_Z = new SerializedMinMaxCurve(this, s_Texts.z, "curve", kUseSignedRange);
m_X.m_RemapValue = Mathf.Rad2Deg;
m_Y.m_RemapValue = Mathf.Rad2Deg;
m_Z.m_RemapValue = Mathf.Rad2Deg;
}
public override 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_X.RemoveCurveFromEditor();
m_Y.RemoveCurveFromEditor();
}
}
// Keep states in sync
if (!m_Z.stateHasMultipleDifferentValues)
{
m_X.SetMinMaxState(m_Z.state, separateAxes);
m_Y.SetMinMaxState(m_Z.state, separateAxes);
}
if (separateAxes)
{
m_Z.m_DisplayName = s_Texts.z;
GUITripleMinMaxCurve(GUIContent.none, s_Texts.x, m_X, s_Texts.y, m_Y, s_Texts.z, m_Z, null);
}
else
{
m_Z.m_DisplayName = s_Texts.rotation;
GUIMinMaxCurve(s_Texts.rotation, m_Z);
}
}
override public void UpdateCullingSupportedString(ref string text)
{
Init();
string failureReason = string.Empty;
if (!m_X.SupportsProcedural(ref failureReason))
text += "\nRotation over Lifetime module curve X: " + failureReason;
failureReason = string.Empty;
if (!m_Y.SupportsProcedural(ref failureReason))
text += "\nRotation over Lifetime module curve Y: " + failureReason;
failureReason = string.Empty;
if (!m_Z.SupportsProcedural(ref failureReason))
text += "\nRotation over Lifetime module curve Z: " + failureReason;
}
}
} // namespace UnityEditor