Skip to content

Commit eb55e2f

Browse files
author
Unity Technologies
committed
Unity 6000.1.0b4 C# reference source code
1 parent 0a1cdae commit eb55e2f

30 files changed

+784
-108
lines changed

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ private enum EnabledState
5656
const float k_WindowWidth = 270;
5757
const float k_ScrollBarWidth = 14;
5858
const float k_ListElementHeight = 18;
59-
const float k_JustClosedPeriod = 200;
6059
const float k_FrameWidth = 1f;
6160
float iconSize = 16;
6261
float gizmoRightAlign;
@@ -66,6 +65,8 @@ private enum EnabledState
6665

6766
static AnnotationWindow s_AnnotationWindow = null;
6867
static long s_LastClosedTime;
68+
const long k_JustClosedPeriod = 400;
69+
6970
static Styles m_Styles;
7071
List<GizmoInfo> m_RecentAnnotations;
7172
List<GizmoInfo> m_BuiltinAnnotations;

Editor/Mono/Annotation/LayerVisibilityWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public Styles()
3939
const float k_FrameWidth = 1f;
4040
const float k_ToggleSize = 17;
4141
const float k_SeparatorHeight = 6;
42-
const float k_JustClosedPeriod = 200;
4342
const string k_LayerVisible = "Show/Hide Layer";
4443
const string k_LayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View.";
4544

4645
private static LayerVisibilityWindow s_LayerVisibilityWindow;
4746
private static long s_LastClosedTime;
48-
private static Styles s_Styles;
47+
const long k_JustClosedPeriod = 400;
4948

49+
private static Styles s_Styles;
5050
private List<string> s_LayerNames;
5151
private List<int> s_LayerMasks;
5252
private int m_AllLayersMask;

Editor/Mono/GUI/ColorPicker.cs

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace UnityEditor
1212
internal class ColorPicker : EditorWindow
1313
{
1414
private const string k_HeightPrefKey = "CPickerHeight";
15+
private const string k_ShowDefaultsPrefKey = "CPDefaultsShow";
1516
private const string k_ShowPresetsPrefKey = "CPPresetsShow";
1617
// HDR and LDR have different slider mode pref keys because they have different defaults for the sake of discoverability
1718
private const string k_SliderModePrefKey = "CPSliderMode";
@@ -40,6 +41,8 @@ internal class ColorPicker : EditorWindow
4041
Texture2D m_ColorBox;
4142
static int s_Slider2Dhash = "Slider2D".GetHashCode();
4243
[SerializeField]
44+
bool m_ShowDefaults = true;
45+
[SerializeField]
4346
bool m_ShowPresets = true;
4447

4548
[SerializeField]
@@ -482,6 +485,7 @@ static class Styles
482485
public static readonly GUIContent exposureValue = EditorGUIUtility.TrTextContent("Intensity", "Number of stops to over- or under-expose the color. The intensity calculates each time based on the predefined max color component of 191 (0.749) when Color Picker opens.");
483486
public static readonly GUIContent hexLabel = EditorGUIUtility.TrTextContent("Hexadecimal");
484487
public static readonly GUIContent presetsToggle = EditorGUIUtility.TrTextContent("Swatches");
488+
public static readonly GUIContent defaultsToggle = EditorGUIUtility.TrTextContent("Defaults");
485489

486490
public static readonly ScalableGUIContent originalColorSwatchFill =
487491
new ScalableGUIContent(string.Empty, "The original color. Click this swatch to reset the color picker to this value.", "ColorPicker-OriginalColor");
@@ -877,6 +881,218 @@ void DoExposureSwatches()
877881
GUI.contentColor = contentColor;
878882
}
879883

884+
// used in TestColorPicker.OpeningColorPicker_InitialisesCorrectDefaultColors
885+
internal static (Color, string)[] TESTdefaultColors => instance?.m_DefaultColors;
886+
readonly (Color, string)[] m_DefaultColors = new (Color, string)[]
887+
{
888+
(Color.red, nameof(Color.red)),
889+
(Color.green, nameof(Color.green)),
890+
(Color.blue, nameof(Color.blue)),
891+
(Color.yellow, nameof(Color.yellow)),
892+
(Color.cyan, nameof(Color.cyan)),
893+
(Color.magenta, nameof(Color.magenta)),
894+
(Color.gray1, nameof(Color.gray1)),
895+
(Color.gray2, nameof(Color.gray2)),
896+
(Color.gray3, nameof(Color.gray3)),
897+
(Color.gray4, nameof(Color.gray4)),
898+
(Color.gray5, nameof(Color.gray5)),
899+
(Color.gray6, nameof(Color.gray6)),
900+
(Color.gray7, nameof(Color.gray7)),
901+
(Color.gray8, nameof(Color.gray8)),
902+
(Color.gray9, nameof(Color.gray9)),
903+
(Color.white, nameof(Color.white)),
904+
(Color.whiteSmoke, nameof(Color.whiteSmoke)),
905+
(Color.gainsboro, nameof(Color.gainsboro)),
906+
(Color.lightGray, nameof(Color.lightGray)),
907+
(Color.silver, nameof(Color.silver)),
908+
(Color.darkGray, nameof(Color.darkGray)),
909+
(Color.dimGray, nameof(Color.dimGray)),
910+
(Color.black, nameof(Color.black)),
911+
(Color.darkRed, nameof(Color.darkRed)),
912+
(Color.brown, nameof(Color.brown)),
913+
(Color.firebrick, nameof(Color.firebrick)),
914+
(Color.crimson, nameof(Color.crimson)),
915+
(Color.softRed, nameof(Color.softRed)),
916+
(Color.indianRed, nameof(Color.indianRed)),
917+
(Color.violetRed, nameof(Color.violetRed)),
918+
(Color.mediumVioletRed, nameof(Color.mediumVioletRed)),
919+
(Color.deepPink, nameof(Color.deepPink)),
920+
(Color.hotPink, nameof(Color.hotPink)),
921+
(Color.lightPink, nameof(Color.lightPink)),
922+
(Color.pink, nameof(Color.pink)),
923+
(Color.paleVioletRed, nameof(Color.paleVioletRed)),
924+
(Color.maroon, nameof(Color.maroon)),
925+
(Color.rosyBrown, nameof(Color.rosyBrown)),
926+
(Color.lightCoral, nameof(Color.lightCoral)),
927+
(Color.salmon, nameof(Color.salmon)),
928+
(Color.tomato, nameof(Color.tomato)),
929+
(Color.darkSalmon, nameof(Color.darkSalmon)),
930+
(Color.coral, nameof(Color.coral)),
931+
(Color.orangeRed, nameof(Color.orangeRed)),
932+
(Color.lightSalmon, nameof(Color.lightSalmon)),
933+
(Color.sienna, nameof(Color.sienna)),
934+
(Color.saddleBrown, nameof(Color.saddleBrown)),
935+
(Color.chocolate, nameof(Color.chocolate)),
936+
(Color.sandyBrown, nameof(Color.sandyBrown)),
937+
(Color.peru, nameof(Color.peru)),
938+
(Color.darkOrange, nameof(Color.darkOrange)),
939+
(Color.burlywood, nameof(Color.burlywood)),
940+
(Color.tan, nameof(Color.tan)),
941+
(Color.moccasin, nameof(Color.moccasin)),
942+
(Color.peachPuff, nameof(Color.peachPuff)),
943+
(Color.bisque, nameof(Color.bisque)),
944+
(Color.navajoWhite, nameof(Color.navajoWhite)),
945+
(Color.wheat, nameof(Color.wheat)),
946+
(Color.orange, nameof(Color.orange)),
947+
(Color.darkGoldenRod, nameof(Color.darkGoldenRod)),
948+
(Color.goldenRod, nameof(Color.goldenRod)),
949+
(Color.lightGoldenRod, nameof(Color.lightGoldenRod)),
950+
(Color.gold, nameof(Color.gold)),
951+
(Color.softYellow, nameof(Color.softYellow)),
952+
(Color.lightGoldenRodYellow, nameof(Color.lightGoldenRodYellow)),
953+
(Color.beige, nameof(Color.beige)),
954+
(Color.lemonChiffon, nameof(Color.lemonChiffon)),
955+
(Color.lightYellow, nameof(Color.lightYellow)),
956+
(Color.yellowNice, nameof(Color.yellowNice)),
957+
(Color.khaki, nameof(Color.khaki)),
958+
(Color.paleGoldenRod, nameof(Color.paleGoldenRod)),
959+
(Color.darkKhaki, nameof(Color.darkKhaki)),
960+
(Color.olive, nameof(Color.olive)),
961+
(Color.oliveDrab, nameof(Color.oliveDrab)),
962+
(Color.yellowGreen, nameof(Color.yellowGreen)),
963+
(Color.darkOliveGreen, nameof(Color.darkOliveGreen)),
964+
(Color.softGreen, nameof(Color.softGreen)),
965+
(Color.greenYellow, nameof(Color.greenYellow)),
966+
(Color.chartreuse, nameof(Color.chartreuse)),
967+
(Color.lawnGreen, nameof(Color.lawnGreen)),
968+
(Color.darkGreen, nameof(Color.darkGreen)),
969+
(Color.forestGreen, nameof(Color.forestGreen)),
970+
(Color.limeGreen, nameof(Color.limeGreen)),
971+
(Color.darkSeaGreen, nameof(Color.darkSeaGreen)),
972+
(Color.lightGreen, nameof(Color.lightGreen)),
973+
(Color.paleGreen, nameof(Color.paleGreen)),
974+
(Color.seaGreen, nameof(Color.seaGreen)),
975+
(Color.mediumSeaGreen, nameof(Color.mediumSeaGreen)),
976+
(Color.springGreen, nameof(Color.springGreen)),
977+
(Color.mediumSpringGreen, nameof(Color.mediumSpringGreen)),
978+
(Color.aquamarine, nameof(Color.aquamarine)),
979+
(Color.mediumAquamarine, nameof(Color.mediumAquamarine)),
980+
(Color.turquoise, nameof(Color.turquoise)),
981+
(Color.mediumTurquoise, nameof(Color.mediumTurquoise)),
982+
(Color.lightSeaGreen, nameof(Color.lightSeaGreen)),
983+
(Color.lightSlateGray, nameof(Color.lightSlateGray)),
984+
(Color.slateGray, nameof(Color.slateGray)),
985+
(Color.darkSlateGray, nameof(Color.darkSlateGray)),
986+
(Color.teal, nameof(Color.teal)),
987+
(Color.darkCyan, nameof(Color.darkCyan)),
988+
(Color.lightCyan, nameof(Color.lightCyan)),
989+
(Color.mintCream, nameof(Color.mintCream)),
990+
(Color.honeydew, nameof(Color.honeydew)),
991+
(Color.azure, nameof(Color.azure)),
992+
(Color.paleTurquoise, nameof(Color.paleTurquoise)),
993+
(Color.darkTurquoise, nameof(Color.darkTurquoise)),
994+
(Color.cadetBlue, nameof(Color.cadetBlue)),
995+
(Color.powderBlue, nameof(Color.powderBlue)),
996+
(Color.softBlue, nameof(Color.softBlue)),
997+
(Color.lightBlue, nameof(Color.lightBlue)),
998+
(Color.deepSkyBlue, nameof(Color.deepSkyBlue)),
999+
(Color.skyBlue, nameof(Color.skyBlue)),
1000+
(Color.lightSkyBlue, nameof(Color.lightSkyBlue)),
1001+
(Color.steelBlue, nameof(Color.steelBlue)),
1002+
(Color.dodgerBlue, nameof(Color.dodgerBlue)),
1003+
(Color.lightSteelBlue, nameof(Color.lightSteelBlue)),
1004+
(Color.ghostWhite, nameof(Color.ghostWhite)),
1005+
(Color.aliceBlue, nameof(Color.aliceBlue)),
1006+
(Color.lavender, nameof(Color.lavender)),
1007+
(Color.cornflowerBlue, nameof(Color.cornflowerBlue)),
1008+
(Color.royalBlue, nameof(Color.royalBlue)),
1009+
(Color.navyBlue, nameof(Color.navyBlue)),
1010+
(Color.midnightBlue, nameof(Color.midnightBlue)),
1011+
(Color.darkBlue, nameof(Color.darkBlue)),
1012+
(Color.mediumBlue, nameof(Color.mediumBlue)),
1013+
(Color.slateBlue, nameof(Color.slateBlue)),
1014+
(Color.lightSlateBlue, nameof(Color.lightSlateBlue)),
1015+
(Color.mediumSlateBlue, nameof(Color.mediumSlateBlue)),
1016+
(Color.darkSlateBlue, nameof(Color.darkSlateBlue)),
1017+
(Color.mediumPurple, nameof(Color.mediumPurple)),
1018+
(Color.rebeccaPurple, nameof(Color.rebeccaPurple)),
1019+
(Color.blueViolet, nameof(Color.blueViolet)),
1020+
(Color.indigo, nameof(Color.indigo)),
1021+
(Color.purple, nameof(Color.purple)),
1022+
(Color.darkOrchid, nameof(Color.darkOrchid)),
1023+
(Color.darkViolet, nameof(Color.darkViolet)),
1024+
(Color.mediumOrchid, nameof(Color.mediumOrchid)),
1025+
(Color.darkMagenta, nameof(Color.darkMagenta)),
1026+
(Color.violet, nameof(Color.violet)),
1027+
(Color.plum, nameof(Color.plum)),
1028+
(Color.thistle, nameof(Color.thistle)),
1029+
(Color.orchid, nameof(Color.orchid)),
1030+
(Color.lavenderBlush, nameof(Color.lavenderBlush)),
1031+
(Color.seashell, nameof(Color.seashell)),
1032+
(Color.blanchedAlmond, nameof(Color.blanchedAlmond)),
1033+
(Color.papayaWhip, nameof(Color.papayaWhip)),
1034+
(Color.cornsilk, nameof(Color.cornsilk)),
1035+
(Color.ivory, nameof(Color.ivory)),
1036+
(Color.linen, nameof(Color.linen)),
1037+
(Color.floralWhite, nameof(Color.floralWhite)),
1038+
(Color.antiqueWhite, nameof(Color.antiqueWhite)),
1039+
(Color.oldLace, nameof(Color.oldLace)),
1040+
(Color.mistyRose, nameof(Color.mistyRose)),
1041+
(Color.snow, nameof(Color.snow)),
1042+
};
1043+
1044+
Texture2D m_SwatchTex;
1045+
void DoDefaultsGUI()
1046+
{
1047+
if (m_SwatchTex == null) m_SwatchTex = ColorPresetLibrary.CreateColorSwatchWithBorder(14, 14, false);
1048+
1049+
m_ShowDefaults = EditorGUILayout.Foldout(m_ShowDefaults, Styles.defaultsToggle, true);
1050+
1051+
if (m_ShowDefaults)
1052+
{
1053+
using (new EditorGUILayout.VerticalScope())
1054+
{
1055+
EditorGUILayout.BeginHorizontal();
1056+
for (int i = 0; i < m_DefaultColors.Length; ++i)
1057+
{
1058+
var (color, name) = m_DefaultColors[i];
1059+
if (i != 0 && i % 15 == 0)
1060+
{
1061+
GUILayout.FlexibleSpace();
1062+
EditorGUILayout.EndHorizontal();
1063+
EditorGUILayout.BeginHorizontal();
1064+
}
1065+
1066+
using (new GUI.ColorScope(color))
1067+
{
1068+
string tooltip;
1069+
if (m_SliderMode == SliderMode.HSV)
1070+
{
1071+
Color.RGBToHSV(color, out var h, out var s, out var v);
1072+
tooltip = $"{name} HSVA({Mathf.RoundToInt(h * 360)}, {Mathf.RoundToInt(s * 100)}, {Mathf.RoundToInt(v * 100)}, {Mathf.RoundToInt(color.a * 100)})";
1073+
}
1074+
else if (m_SliderMode == SliderMode.RGB)
1075+
{
1076+
tooltip = $"{name} {(Color32)color}";;
1077+
}
1078+
else
1079+
tooltip = $"{name} {color}";
1080+
1081+
var clicked = GUILayout.Button(
1082+
new GUIContent(m_SwatchTex, tooltip),
1083+
GUIStyle.none,
1084+
new GUILayoutOption(GUILayoutOption.Type.fixedWidth, 14f));
1085+
1086+
if (clicked)
1087+
SetColor(color);
1088+
}
1089+
}
1090+
GUILayout.FlexibleSpace();
1091+
EditorGUILayout.EndHorizontal();
1092+
}
1093+
}
1094+
}
1095+
8801096
void DoPresetsGUI()
8811097
{
8821098
var foldoutRect = GUILayoutUtility.GetRect(Styles.presetsToggle, EditorStyles.foldout);
@@ -953,6 +1169,8 @@ void OnGUI()
9531169
GUILayout.Space(Styles.extraVerticalSpacing);
9541170
}
9551171

1172+
DoDefaultsGUI();
1173+
9561174
DoPresetsGUI();
9571175

9581176
// Call last to ensure we only use the copy paste events if no
@@ -1177,11 +1395,13 @@ void OnEnable()
11771395

11781396
m_SliderMode = (SliderMode)EditorPrefs.GetInt(k_SliderModePrefKey, (int)SliderMode.RGB);
11791397
m_ShowPresets = EditorPrefs.GetInt(k_ShowPresetsPrefKey, 1) != 0;
1398+
m_ShowDefaults = EditorPrefs.GetInt(k_ShowDefaultsPrefKey, 1) != 0;
11801399
}
11811400

11821401
void OnDisable()
11831402
{
11841403
EditorPrefs.SetInt(m_HDR ? k_SliderModeHDRPrefKey : k_SliderModePrefKey, (int)m_SliderMode);
1404+
EditorPrefs.SetInt(k_ShowDefaultsPrefKey, m_ShowDefaults ? 1 : 0);
11851405
EditorPrefs.SetInt(k_ShowPresetsPrefKey, m_ShowPresets ? 1 : 0);
11861406
EditorPrefs.SetInt(k_HeightPrefKey, (int)position.height);
11871407
}
@@ -1208,6 +1428,8 @@ public void OnDestroy()
12081428
DestroyImmediate(m_ValTexture);
12091429
if (m_AlphaTexture)
12101430
DestroyImmediate(m_AlphaTexture);
1431+
if (m_SwatchTex)
1432+
DestroyImmediate(m_SwatchTex);
12111433
s_Instance = null;
12121434

12131435
if (m_ColorLibraryEditorState != null)

Editor/Mono/PresetLibraries/ColorPresetLibrary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void CreateDebugColors()
161161
m_Presets.Add(new ColorPreset(new Color(Random.Range(0.2f, 1f), Random.Range(0.2f, 1f), Random.Range(0.2f, 1f), 1f), "Preset Color " + i));
162162
}
163163

164-
private static Texture2D CreateColorSwatchWithBorder(int width, int height, bool triangular)
164+
internal static Texture2D CreateColorSwatchWithBorder(int width, int height, bool triangular)
165165
{
166166
Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, false);
167167
texture.hideFlags = HideFlags.HideAndDontSave;

Editor/Mono/SceneModeWindows/DefaultLightingExplorerExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ protected virtual LightingExplorerTableColumn[] GetEmissivesColumns()
471471
if (EditorGUI.EndChangeCheck())
472472
{
473473
Material material = (Material)prop.serializedObject.targetObject;
474+
Undo.RecordObject(material, $"Modify Emission Flags of {material.name}");
474475
material.globalIlluminationFlags = giFlags;
476+
EditorUtility.SetDirty(material);
475477

476478
prop.serializedObject.Update();
477479
}
@@ -495,7 +497,9 @@ protected virtual LightingExplorerTableColumn[] GetEmissivesColumns()
495497

496498
if (EditorGUI.EndChangeCheck())
497499
{
500+
Undo.RecordObject(material, $"Modify Emission Flags of {material.name}");
498501
material.SetColor("_EmissionColor", newValue);
502+
EditorUtility.SetDirty(material);
499503
}
500504
EditorGUI.EndProperty();
501505
}
@@ -511,7 +515,9 @@ protected virtual LightingExplorerTableColumn[] GetEmissivesColumns()
511515
Color color = sourceMaterial.GetColor("_EmissionColor");
512516

513517
Material targetMaterial = (Material)target.serializedObject.targetObject;
518+
Undo.RecordObject(targetMaterial, $"Modify Emission Flags of {targetMaterial.name}");
514519
targetMaterial.SetColor("_EmissionColor", color);
520+
EditorUtility.SetDirty(targetMaterial);
515521
}) // 3: Color
516522
};
517523
}

Modules/BuildReportingEditor/Managed/BuildFile.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77

88
namespace UnityEditor.Build.Reporting
99
{
10+
///<summary>Contains information about a single file produced by the build process.</summary>
1011
[NativeType(Header = "Modules/BuildReportingEditor/Public/BuildReport.h")]
1112
public struct BuildFile
1213
{
14+
///<summary>The unique indentifier of the build file.</summary>
1315
public uint id { get; }
16+
///<summary>The absolute path of the file produced by the build process.</summary>
1417
public string path { get; }
18+
///<summary>The role the file plays in the build output.</summary>
19+
///<remarks>Use this field to understand what purpose a file serves within the built player. Common roles for files are captured by the members of the <see cref="CommonRoles" /> class.</remarks>
1520
public string role { get; }
1621

22+
///<summary>The total size of the file, in bytes.</summary>
1723
[NativeName("totalSize")]
1824
public ulong size { get; }
1925

0 commit comments

Comments
 (0)