-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathLightsModuleUI.cs
More file actions
85 lines (75 loc) · 4.57 KB
/
LightsModuleUI.cs
File metadata and controls
85 lines (75 loc) · 4.57 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
// 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 LightsModuleUI : ModuleUI
{
class Texts
{
public GUIContent ratio = EditorGUIUtility.TrTextContent("Ratio", "Amount of particles that have a light source attached to them.");
public GUIContent randomDistribution = EditorGUIUtility.TrTextContent("Random Distribution", "Emit lights randomly, or at regular intervals.");
public GUIContent light = EditorGUIUtility.TrTextContent("Light", "Light prefab to be used for spawning particle lights.");
public GUIContent color = EditorGUIUtility.TrTextContent("Use Particle Color", "Check the option to multiply the particle color by the light color. Otherwise, only the color of the light is used.");
public GUIContent range = EditorGUIUtility.TrTextContent("Size Affects Range", "Multiply the range of the light with the size of the particle.");
public GUIContent intensity = EditorGUIUtility.TrTextContent("Alpha Affects Intensity", "Multiply the intensity of the light with the alpha of the particle.");
public GUIContent rangeCurve = EditorGUIUtility.TrTextContent("Range Multiplier", "Apply a custom multiplier to the range of the lights. If you use a curve to set this value, the Particle System applies the curve over the lifetime of each particle.");
public GUIContent intensityCurve = EditorGUIUtility.TrTextContent("Intensity Multiplier", "Apply a custom multiplier to the intensity of the lights. If you use a curve to set this value, the Particle System applies the curve over the lifetime of each particle.");
public GUIContent maxLights = EditorGUIUtility.TrTextContent("Maximum Lights", "Limit the amount of lights the system can create. This module makes it very easy to create lots of lights, which can hurt performance.");
}
static Texts s_Texts;
SerializedProperty m_Ratio;
SerializedProperty m_RandomDistribution;
SerializedProperty m_Light;
SerializedProperty m_UseParticleColor;
SerializedProperty m_SizeAffectsRange;
SerializedProperty m_AlphaAffectsIntensity;
SerializedMinMaxCurve m_Range;
SerializedMinMaxCurve m_Intensity;
SerializedProperty m_MaxLights;
public LightsModuleUI(ParticleSystemUI owner, SerializedObject o, string displayName)
: base(owner, o, "LightsModule", displayName)
{
m_ToolTip = "Controls light sources attached to particles.";
}
protected override void Init()
{
// Already initialized?
if (m_Ratio != null)
return;
if (s_Texts == null)
s_Texts = new Texts();
m_Ratio = GetProperty("ratio");
m_RandomDistribution = GetProperty("randomDistribution");
m_Light = GetProperty("light");
m_UseParticleColor = GetProperty("color");
m_SizeAffectsRange = GetProperty("range");
m_AlphaAffectsIntensity = GetProperty("intensity");
m_MaxLights = GetProperty("maxLights");
m_Range = new SerializedMinMaxCurve(this, s_Texts.rangeCurve, "rangeCurve");
m_Intensity = new SerializedMinMaxCurve(this, s_Texts.intensityCurve, "intensityCurve");
}
override public void OnInspectorGUI(InitialModuleUI initial)
{
GUIObject(s_Texts.light, m_Light);
GUIFloat(s_Texts.ratio, m_Ratio);
GUIToggle(s_Texts.randomDistribution, m_RandomDistribution);
GUIToggle(s_Texts.color, m_UseParticleColor);
GUIToggle(s_Texts.range, m_SizeAffectsRange);
GUIToggle(s_Texts.intensity, m_AlphaAffectsIntensity);
GUIMinMaxCurve(s_Texts.rangeCurve, m_Range);
GUIMinMaxCurve(s_Texts.intensityCurve, m_Intensity);
GUIInt(s_Texts.maxLights, m_MaxLights);
if (m_Light.objectReferenceValue)
{
Light light = (Light)m_Light.objectReferenceValue;
if (light.type != LightType.Point && light.type != LightType.Spot && light.type != LightType.Rectangle)
{
GUIContent warning = EditorGUIUtility.TrTextContent("Only point, spot, and rectangle area lights are supported on particles.");
EditorGUILayout.HelpBox(warning.text, MessageType.Warning, true);
}
}
}
}
} // namespace UnityEditor