Skip to content

Commit 82e03c8

Browse files
authored
Updating to Unity 5.6.0f3 by merging ntratcliff/master
2 parents 084900c + b0bf01a commit 82e03c8

1,183 files changed

Lines changed: 53927 additions & 17146 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
This was made by decompiling UnityEditor.dll and UnityEngine.dll using [ILSpy](http://ilspy.net)
55

6-
Current version: *5.5.2f1* - other versions can be found in the [tags](https://github.com/MattRix/UnityDecompiled/tags)
6+
Current version: *5.6.0f3* - other versions can be found in the [tags](https://github.com/MattRix/UnityDecompiled/tags)
77

88
Feel free to either browse the code directly or [download it](https://github.com/MattRix/UnityDecompiled/archive/master.zip)
99

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
using System;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
internal abstract class BaseExposedPropertyDrawer : PropertyDrawer
6+
{
7+
protected enum ExposedPropertyMode
8+
{
9+
DefaultValue,
10+
Named,
11+
NamedGUID
12+
}
13+
14+
protected enum OverrideState
15+
{
16+
DefaultValue,
17+
MissingOverride,
18+
Overridden
19+
}
20+
21+
private static float kDriveWidgetWidth = 18f;
22+
23+
private static GUIStyle kDropDownStyle = null;
24+
25+
private static Color kMissingOverrideColor = new Color(1f, 0.11f, 0.11f, 1f);
26+
27+
protected readonly GUIContent ExposePropertyContent = EditorGUIUtility.TextContent("Expose Property");
28+
29+
protected readonly GUIContent UnexposePropertyContent = EditorGUIUtility.TextContent("Unexpose Property");
30+
31+
protected readonly GUIContent NotFoundOn = EditorGUIUtility.TextContent("not found on");
32+
33+
protected readonly GUIContent OverridenByContent = EditorGUIUtility.TextContent("Overriden by ");
34+
35+
private GUIContent m_ModifiedLabel = new GUIContent();
36+
37+
public BaseExposedPropertyDrawer()
38+
{
39+
if (BaseExposedPropertyDrawer.kDropDownStyle == null)
40+
{
41+
BaseExposedPropertyDrawer.kDropDownStyle = new GUIStyle("ShurikenDropdown");
42+
}
43+
}
44+
45+
private static BaseExposedPropertyDrawer.ExposedPropertyMode GetExposedPropertyMode(string propertyName)
46+
{
47+
BaseExposedPropertyDrawer.ExposedPropertyMode result;
48+
GUID gUID;
49+
if (string.IsNullOrEmpty(propertyName))
50+
{
51+
result = BaseExposedPropertyDrawer.ExposedPropertyMode.DefaultValue;
52+
}
53+
else if (GUID.TryParse(propertyName, out gUID))
54+
{
55+
result = BaseExposedPropertyDrawer.ExposedPropertyMode.NamedGUID;
56+
}
57+
else
58+
{
59+
result = BaseExposedPropertyDrawer.ExposedPropertyMode.Named;
60+
}
61+
return result;
62+
}
63+
64+
protected IExposedPropertyTable GetExposedPropertyTable(SerializedProperty property)
65+
{
66+
UnityEngine.Object context = property.serializedObject.context;
67+
return context as IExposedPropertyTable;
68+
}
69+
70+
protected abstract void OnRenderProperty(Rect position, PropertyName exposedPropertyNameString, UnityEngine.Object currentReferenceValue, SerializedProperty exposedPropertyDefault, SerializedProperty exposedPropertyName, BaseExposedPropertyDrawer.ExposedPropertyMode mode, IExposedPropertyTable exposedProperties);
71+
72+
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
73+
{
74+
SerializedProperty serializedProperty = prop.FindPropertyRelative("defaultValue");
75+
SerializedProperty serializedProperty2 = prop.FindPropertyRelative("exposedName");
76+
string text = serializedProperty2.stringValue;
77+
BaseExposedPropertyDrawer.ExposedPropertyMode exposedPropertyMode = BaseExposedPropertyDrawer.GetExposedPropertyMode(text);
78+
Rect rect = position;
79+
rect.xMax -= BaseExposedPropertyDrawer.kDriveWidgetWidth;
80+
Rect position2 = position;
81+
position2.x = rect.xMax;
82+
position2.width = BaseExposedPropertyDrawer.kDriveWidgetWidth;
83+
IExposedPropertyTable exposedPropertyTable = this.GetExposedPropertyTable(prop);
84+
bool flag = exposedPropertyTable != null;
85+
PropertyName propertyName = new PropertyName(text);
86+
BaseExposedPropertyDrawer.OverrideState overrideState = BaseExposedPropertyDrawer.OverrideState.DefaultValue;
87+
UnityEngine.Object currentReferenceValue = this.Resolve(propertyName, exposedPropertyTable, serializedProperty.objectReferenceValue, out overrideState);
88+
Color color = GUI.color;
89+
bool boldDefaultFont = EditorGUIUtility.GetBoldDefaultFont();
90+
Rect position3 = this.DrawLabel(flag, overrideState, label, position, exposedPropertyTable, text, serializedProperty2, serializedProperty);
91+
EditorGUI.BeginChangeCheck();
92+
if (exposedPropertyMode == BaseExposedPropertyDrawer.ExposedPropertyMode.DefaultValue || exposedPropertyMode == BaseExposedPropertyDrawer.ExposedPropertyMode.NamedGUID)
93+
{
94+
this.OnRenderProperty(position3, propertyName, currentReferenceValue, serializedProperty, serializedProperty2, exposedPropertyMode, exposedPropertyTable);
95+
}
96+
else
97+
{
98+
position3.width /= 2f;
99+
EditorGUI.BeginChangeCheck();
100+
text = EditorGUI.TextField(position3, text);
101+
if (EditorGUI.EndChangeCheck())
102+
{
103+
serializedProperty2.stringValue = text;
104+
}
105+
position3.x += position3.width;
106+
this.OnRenderProperty(position3, new PropertyName(text), currentReferenceValue, serializedProperty, serializedProperty2, exposedPropertyMode, exposedPropertyTable);
107+
}
108+
EditorGUI.EndDisabledGroup();
109+
GUI.color = color;
110+
EditorGUIUtility.SetBoldDefaultFont(boldDefaultFont);
111+
if (flag && GUI.Button(position2, GUIContent.none, BaseExposedPropertyDrawer.kDropDownStyle))
112+
{
113+
GenericMenu genericMenu = new GenericMenu();
114+
this.PopulateContextMenu(genericMenu, overrideState, exposedPropertyTable, serializedProperty2, serializedProperty);
115+
genericMenu.ShowAsContext();
116+
Event.current.Use();
117+
}
118+
}
119+
120+
private Rect DrawLabel(bool showContextMenu, BaseExposedPropertyDrawer.OverrideState currentOverrideState, GUIContent label, Rect position, IExposedPropertyTable exposedPropertyTable, string exposedNameStr, SerializedProperty exposedName, SerializedProperty defaultValue)
121+
{
122+
if (showContextMenu)
123+
{
124+
position.xMax -= BaseExposedPropertyDrawer.kDriveWidgetWidth;
125+
}
126+
EditorGUIUtility.SetBoldDefaultFont(currentOverrideState != BaseExposedPropertyDrawer.OverrideState.DefaultValue);
127+
this.m_ModifiedLabel.text = label.text;
128+
this.m_ModifiedLabel.tooltip = label.tooltip;
129+
this.m_ModifiedLabel.image = label.image;
130+
if (!string.IsNullOrEmpty(this.m_ModifiedLabel.tooltip))
131+
{
132+
GUIContent expr_78 = this.m_ModifiedLabel;
133+
expr_78.tooltip += "\n";
134+
}
135+
if (currentOverrideState == BaseExposedPropertyDrawer.OverrideState.MissingOverride)
136+
{
137+
GUI.color = BaseExposedPropertyDrawer.kMissingOverrideColor;
138+
GUIContent expr_A6 = this.m_ModifiedLabel;
139+
string tooltip = expr_A6.tooltip;
140+
expr_A6.tooltip = string.Concat(new string[]
141+
{
142+
tooltip,
143+
label.text,
144+
" ",
145+
this.NotFoundOn.text,
146+
" ",
147+
exposedPropertyTable.ToString(),
148+
"."
149+
});
150+
}
151+
else if (currentOverrideState == BaseExposedPropertyDrawer.OverrideState.Overridden && exposedPropertyTable != null)
152+
{
153+
GUIContent expr_115 = this.m_ModifiedLabel;
154+
expr_115.tooltip = expr_115.tooltip + this.OverridenByContent.text + exposedPropertyTable.ToString() + ".";
155+
}
156+
Rect result = EditorGUI.PrefixLabel(position, this.m_ModifiedLabel);
157+
if (exposedPropertyTable != null && Event.current.type == EventType.ContextClick)
158+
{
159+
if (position.Contains(Event.current.mousePosition))
160+
{
161+
GenericMenu genericMenu = new GenericMenu();
162+
this.PopulateContextMenu(genericMenu, (!string.IsNullOrEmpty(exposedNameStr)) ? BaseExposedPropertyDrawer.OverrideState.Overridden : BaseExposedPropertyDrawer.OverrideState.DefaultValue, exposedPropertyTable, exposedName, defaultValue);
163+
genericMenu.ShowAsContext();
164+
}
165+
}
166+
return result;
167+
}
168+
169+
protected UnityEngine.Object Resolve(PropertyName exposedPropertyName, IExposedPropertyTable exposedPropertyTable, UnityEngine.Object defaultValue, out BaseExposedPropertyDrawer.OverrideState currentOverrideState)
170+
{
171+
UnityEngine.Object @object = null;
172+
bool flag = false;
173+
bool flag2 = !PropertyName.IsNullOrEmpty(exposedPropertyName);
174+
currentOverrideState = BaseExposedPropertyDrawer.OverrideState.DefaultValue;
175+
if (exposedPropertyTable != null)
176+
{
177+
@object = exposedPropertyTable.GetReferenceValue(exposedPropertyName, out flag);
178+
if (flag)
179+
{
180+
currentOverrideState = BaseExposedPropertyDrawer.OverrideState.Overridden;
181+
}
182+
else if (flag2)
183+
{
184+
currentOverrideState = BaseExposedPropertyDrawer.OverrideState.MissingOverride;
185+
}
186+
}
187+
return (currentOverrideState != BaseExposedPropertyDrawer.OverrideState.Overridden) ? defaultValue : @object;
188+
}
189+
190+
protected abstract void PopulateContextMenu(GenericMenu menu, BaseExposedPropertyDrawer.OverrideState overrideState, IExposedPropertyTable exposedPropertyTable, SerializedProperty exposedName, SerializedProperty defaultValue);
191+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
[CustomPropertyDrawer(typeof(ExposedReference<>))]
6+
internal class ExposedReferencePropertyDrawer : BaseExposedPropertyDrawer
7+
{
8+
protected override void OnRenderProperty(Rect position, PropertyName exposedPropertyNameString, UnityEngine.Object currentReferenceValue, SerializedProperty exposedPropertyDefault, SerializedProperty exposedPropertyName, BaseExposedPropertyDrawer.ExposedPropertyMode mode, IExposedPropertyTable exposedPropertyTable)
9+
{
10+
Type objType = base.fieldInfo.FieldType.GetGenericArguments()[0];
11+
EditorGUI.BeginChangeCheck();
12+
UnityEngine.Object @object = EditorGUI.ObjectField(position, currentReferenceValue, objType, exposedPropertyTable != null);
13+
if (EditorGUI.EndChangeCheck())
14+
{
15+
if (mode == BaseExposedPropertyDrawer.ExposedPropertyMode.DefaultValue)
16+
{
17+
if (!EditorUtility.IsPersistent(exposedPropertyDefault.serializedObject.targetObject) || @object == null || EditorUtility.IsPersistent(@object))
18+
{
19+
if (!EditorGUI.CheckForCrossSceneReferencing(exposedPropertyDefault.serializedObject.targetObject, @object))
20+
{
21+
exposedPropertyDefault.objectReferenceValue = @object;
22+
}
23+
}
24+
else
25+
{
26+
string text = GUID.Generate().ToString();
27+
exposedPropertyNameString = new PropertyName(text);
28+
exposedPropertyName.stringValue = text;
29+
Undo.RecordObject(exposedPropertyTable as UnityEngine.Object, "Set Exposed Property");
30+
exposedPropertyTable.SetReferenceValue(exposedPropertyNameString, @object);
31+
}
32+
}
33+
else
34+
{
35+
Undo.RecordObject(exposedPropertyTable as UnityEngine.Object, "Set Exposed Property");
36+
exposedPropertyTable.SetReferenceValue(exposedPropertyNameString, @object);
37+
}
38+
}
39+
}
40+
41+
protected override void PopulateContextMenu(GenericMenu menu, BaseExposedPropertyDrawer.OverrideState overrideState, IExposedPropertyTable exposedPropertyTable, SerializedProperty exposedName, SerializedProperty defaultValue)
42+
{
43+
PropertyName propertyName = new PropertyName(exposedName.stringValue);
44+
BaseExposedPropertyDrawer.OverrideState overrideState2;
45+
UnityEngine.Object currentValue = base.Resolve(new PropertyName(exposedName.stringValue), exposedPropertyTable, defaultValue.objectReferenceValue, out overrideState2);
46+
if (overrideState == BaseExposedPropertyDrawer.OverrideState.DefaultValue)
47+
{
48+
menu.AddItem(new GUIContent(this.ExposePropertyContent.text), false, delegate(object userData)
49+
{
50+
GUID gUID = GUID.Generate();
51+
exposedName.stringValue = gUID.ToString();
52+
exposedName.serializedObject.ApplyModifiedProperties();
53+
PropertyName id = new PropertyName(exposedName.stringValue);
54+
Undo.RecordObject(exposedPropertyTable as UnityEngine.Object, "Set Exposed Property");
55+
exposedPropertyTable.SetReferenceValue(id, currentValue);
56+
}, null);
57+
}
58+
else
59+
{
60+
menu.AddItem(this.UnexposePropertyContent, false, delegate(object userData)
61+
{
62+
exposedName.stringValue = "";
63+
exposedName.serializedObject.ApplyModifiedProperties();
64+
Undo.RecordObject(exposedPropertyTable as UnityEngine.Object, "Clear Exposed Property");
65+
exposedPropertyTable.ClearReferenceValue(propertyName);
66+
}, null);
67+
}
68+
}
69+
}

UnityEditor/ParticleSystemCurveEditor.cs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,11 @@ private void SetTopMostCurve(DoubleCurve doubleCurve)
508508
{
509509
if (curveData.m_MaxId > 0)
510510
{
511-
this.SetCurve(this.m_CurveEditor.GetCurveFromID(curveData.m_MaxId), doubleCurve.maxCurve);
511+
this.SetCurve(this.m_CurveEditor.GetCurveWrapperFromID(curveData.m_MaxId), doubleCurve.maxCurve);
512512
}
513513
if (curveData.m_MinId > 0)
514514
{
515-
this.SetCurve(this.m_CurveEditor.GetCurveFromID(curveData.m_MinId), doubleCurve.minCurve);
515+
this.SetCurve(this.m_CurveEditor.GetCurveWrapperFromID(curveData.m_MinId), doubleCurve.minCurve);
516516
}
517517
}
518518
else
@@ -556,7 +556,7 @@ private DoubleCurve CreateDoubleCurveFromTopMostCurve()
556556

557557
private void PresetDropDown(Rect rect)
558558
{
559-
if (EditorGUI.ButtonMouseDown(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText))
559+
if (EditorGUI.DropdownButton(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText))
560560
{
561561
DoubleCurve doubleCurve = this.CreateDoubleCurveFromTopMostCurve();
562562
if (doubleCurve != null)
@@ -793,25 +793,36 @@ private CurveWrapper[] CreateCurveWrapperArray()
793793
{
794794
List<CurveWrapper> list = new List<CurveWrapper>();
795795
int num = 0;
796-
for (int i = 0; i < this.m_AddedCurves.Count; i++)
796+
int i = 0;
797+
while (i < this.m_AddedCurves.Count)
797798
{
798799
ParticleSystemCurveEditor.CurveData curveData = this.m_AddedCurves[i];
799800
if (curveData.m_Visible)
800801
{
801-
int regionId = -1;
802-
if (curveData.IsRegion())
803-
{
804-
num = (regionId = num + 1);
805-
}
806-
if (curveData.m_Max != null)
802+
if (curveData.m_Max == null || !curveData.m_Max.hasMultipleDifferentValues)
807803
{
808-
list.Add(this.CreateCurveWrapper(curveData.m_Max, curveData.m_MaxId, regionId, curveData.m_Color, curveData.m_SignedRange, curveData.m_GetAxisScalarsCallback, curveData.m_SetAxisScalarsCallback));
809-
}
810-
if (curveData.m_Min != null)
811-
{
812-
list.Add(this.CreateCurveWrapper(curveData.m_Min, curveData.m_MinId, regionId, curveData.m_Color, curveData.m_SignedRange, curveData.m_GetAxisScalarsCallback, curveData.m_SetAxisScalarsCallback));
804+
if (curveData.m_Min == null || !curveData.m_Min.hasMultipleDifferentValues)
805+
{
806+
int regionId = -1;
807+
if (curveData.IsRegion())
808+
{
809+
num = (regionId = num + 1);
810+
}
811+
if (curveData.m_Max != null)
812+
{
813+
list.Add(this.CreateCurveWrapper(curveData.m_Max, curveData.m_MaxId, regionId, curveData.m_Color, curveData.m_SignedRange, curveData.m_GetAxisScalarsCallback, curveData.m_SetAxisScalarsCallback));
814+
}
815+
if (curveData.m_Min != null)
816+
{
817+
list.Add(this.CreateCurveWrapper(curveData.m_Min, curveData.m_MinId, regionId, curveData.m_Color, curveData.m_SignedRange, curveData.m_GetAxisScalarsCallback, curveData.m_SetAxisScalarsCallback));
818+
}
819+
}
813820
}
814821
}
822+
IL_FF:
823+
i++;
824+
continue;
825+
goto IL_FF;
815826
}
816827
return list.ToArray();
817828
}

UnityEditor/PreviewGUI.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,15 @@ public static Vector2 EndScrollView()
4848
{
4949
if (type != EventType.Used)
5050
{
51-
bool flag = false;
52-
bool flag2 = false;
53-
if (flag2 || rect3.width > rect.width)
54-
{
55-
flag2 = true;
56-
}
57-
if (flag || rect3.height > rect.height)
58-
{
59-
flag = true;
60-
}
51+
bool flag = (int)rect3.width > (int)rect.width;
52+
bool flag2 = (int)rect3.height > (int)rect.height;
6153
int controlID = GUIUtility.GetControlID(PreviewGUI.sliderHash, FocusType.Passive);
6254
if (flag2)
6355
{
6456
GUIStyle gUIStyle = "PreHorizontalScrollbar";
65-
GUIStyle thumbStyle = "PreHorizontalScrollbarThumb";
57+
GUIStyle thumb = "PreHorizontalScrollbarThumb";
6658
float num = (rect3.width - rect.width) * 0.5f;
67-
result.x = GUI.Slider(new Rect(rect2.x, rect2.yMax - gUIStyle.fixedHeight, rect.width - ((!flag) ? 0f : gUIStyle.fixedHeight), gUIStyle.fixedHeight), result.x, rect.width + num, -num, rect3.width, gUIStyle, thumbStyle, true, controlID);
59+
result.x = GUI.Slider(new Rect(rect2.x, rect2.yMax - gUIStyle.fixedHeight, rect.width - ((!flag) ? 0f : gUIStyle.fixedHeight), gUIStyle.fixedHeight), result.x, rect.width + num, -num, rect3.width, gUIStyle, thumb, true, controlID);
6860
}
6961
else
7062
{
@@ -74,9 +66,9 @@ public static Vector2 EndScrollView()
7466
if (flag)
7567
{
7668
GUIStyle gUIStyle2 = "PreVerticalScrollbar";
77-
GUIStyle thumbStyle2 = "PreVerticalScrollbarThumb";
69+
GUIStyle thumb2 = "PreVerticalScrollbarThumb";
7870
float num2 = (rect3.height - rect.height) * 0.5f;
79-
result.y = GUI.Slider(new Rect(rect.xMax - gUIStyle2.fixedWidth, rect.y, gUIStyle2.fixedWidth, rect.height), result.y, rect.height + num2, -num2, rect3.height, gUIStyle2, thumbStyle2, false, controlID);
71+
result.y = GUI.Slider(new Rect(rect.xMax - gUIStyle2.fixedWidth, rect.y, gUIStyle2.fixedWidth, rect.height), result.y, rect.height + num2, -num2, rect3.height, gUIStyle2, thumb2, false, controlID);
8072
}
8173
else
8274
{

0 commit comments

Comments
 (0)