forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternalForcesModuleUI.cs
More file actions
113 lines (97 loc) · 4.65 KB
/
Copy pathExternalForcesModuleUI.cs
File metadata and controls
113 lines (97 loc) · 4.65 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
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using UnityEditorInternal;
using UnityEngine;
namespace UnityEditor
{
class ExternalForcesModuleUI : ModuleUI
{
SerializedMinMaxCurve m_Multiplier;
SerializedProperty m_InfluenceFilter;
SerializedProperty m_InfluenceMask;
SerializedProperty m_InfluenceList;
ReorderableList m_InfluenceListView;
class Texts
{
public GUIContent multiplier = EditorGUIUtility.TrTextContent("Multiplier", "Used to scale the force applied to this particle system.");
public GUIContent influenceFilter = EditorGUIUtility.TrTextContent("Influence Filter", "Use either a LayerMask or a List, to decide which Force Fields affect this Particle System.");
public GUIContent influenceMask = EditorGUIUtility.TrTextContent("Influence Mask", "Select a global mask of which GameObjects can affect this Particle System.");
public GUIContent[] influenceFilters = new GUIContent[]
{
EditorGUIUtility.TrTextContent("Layer Mask"),
EditorGUIUtility.TrTextContent("List"),
EditorGUIUtility.TrTextContent("Layer Mask and List")
};
}
static Texts s_Texts;
public ExternalForcesModuleUI(ParticleSystemUI owner, SerializedObject o, string displayName)
: base(owner, o, "ExternalForcesModule", displayName)
{
m_ToolTip = "Controls the wind zones that each particle is affected by.";
}
protected override void Init()
{
// Already initialized?
if (m_Multiplier != null)
return;
if (s_Texts == null)
s_Texts = new Texts();
m_Multiplier = new SerializedMinMaxCurve(this, s_Texts.multiplier, "multiplierCurve");
m_InfluenceFilter = GetProperty("influenceFilter");
m_InfluenceMask = GetProperty("influenceMask");
m_InfluenceList = GetProperty("influenceList");
m_InfluenceListView = new ReorderableList(serializedObject, m_InfluenceList, true, true, true, true);
m_InfluenceListView.elementHeight = kReorderableListElementHeight;
m_InfluenceListView.headerHeight = 0;
m_InfluenceListView.drawElementCallback = DrawInfluenceListElementCallback;
}
override public void OnInspectorGUI(InitialModuleUI initial)
{
GUIMinMaxCurve(s_Texts.multiplier, m_Multiplier);
ParticleSystemGameObjectFilter filter = (ParticleSystemGameObjectFilter)GUIPopup(s_Texts.influenceFilter, m_InfluenceFilter, s_Texts.influenceFilters);
if (m_InfluenceFilter.hasMultipleDifferentValues)
{
EditorGUILayout.HelpBox("Influence List editing is only available when all selected systems have the same filter type", MessageType.Info, true);
}
else
{
if (filter != ParticleSystemGameObjectFilter.List)
GUILayerMask(s_Texts.influenceMask, m_InfluenceMask);
if (filter != ParticleSystemGameObjectFilter.LayerMask)
m_InfluenceListView.DoLayoutList();
}
}
override public void OnSceneViewGUI()
{
using (new Handles.DrawingScope(Handles.matrix))
{
ParticleSystemForceField[] forceFields = ParticleSystemForceField.FindAll();
foreach (ParticleSystemForceField ff in forceFields)
{
bool valid = false;
foreach (ParticleSystem ps in m_ParticleSystemUI.m_ParticleSystems)
{
if (ps.externalForces.IsAffectedBy(ff))
{
valid = true;
break;
}
}
if (!valid)
continue;
ParticleSystemForceFieldInspector.DrawHandle(ff);
}
}
}
override public void UpdateCullingSupportedString(ref string text)
{
text += "\nExternal Forces module is enabled.";
}
private void DrawInfluenceListElementCallback(Rect rect, int index, bool isActive, bool isFocused)
{
SerializedProperty forceField = m_InfluenceList.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(rect, forceField, null, GUIContent.none, ParticleSystemStyles.Get().objectField);
}
} // namespace UnityEditor
}