Skip to content

Commit 3e4f048

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a14 C# reference source code
1 parent dcd45f4 commit 3e4f048

File tree

120 files changed

+12160
-1647
lines changed

Some content is hidden

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

120 files changed

+12160
-1647
lines changed

Editor/Mono/Annotation/SceneViewCameraWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public override void OnGUI(Rect rect)
8686
if (m_SceneView == null || m_SceneView.sceneViewState == null)
8787
return;
8888

89-
Draw(rect);
89+
Draw();
9090

9191
// Escape closes the window
9292
if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
@@ -96,7 +96,7 @@ public override void OnGUI(Rect rect)
9696
}
9797
}
9898

99-
void Draw(Rect rect)
99+
void Draw()
100100
{
101101
Styles.Init();
102102

@@ -172,7 +172,7 @@ void Draw(Rect rect)
172172
if (Event.current.type == EventType.Repaint)
173173
m_WindowSize.y = Math.Min(GUILayoutUtility.GetLastRect().yMax + kContentPadding, kWindowHeight * 3);
174174

175-
GUILayout.BeginVertical(Styles.settingsArea);
175+
GUILayout.EndVertical();
176176
GUILayout.EndScrollView();
177177
}
178178

Editor/Mono/EditorApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static void DirtyHierarchyWindowSorting()
179179

180180
public static event Action quitting;
181181

182-
public static CallbackFunction delayCall;
182+
public static event Action delayCall;
183183

184184
// Each time an object is (or a group of objects are) created, renamed, parented, unparented or destroyed this callback is raised.
185185
public static event Action hierarchyChanged;
@@ -319,7 +319,7 @@ static void Internal_CallUpdateFunctions()
319319

320320
static void Internal_CallDelayFunctions()
321321
{
322-
CallbackFunction delay = delayCall;
322+
var delay = delayCall;
323323
delayCall = null;
324324

325325
if (delay != null)

Editor/Mono/EditorConnectionInternal.bindings.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,18 @@ public static bool TrySendMessage(string messageId, byte[] data, int playerId)
125125

126126
[NativeConditional("ENABLE_PLAYERCONNECTION && UNITY_EDITOR")]
127127
public extern static void DisconnectAll();
128+
129+
[NativeConditional("ENABLE_PLAYERCONNECTION")]
130+
public extern static UInt32 GetLocalGuid();
131+
132+
[NativeConditional("ENABLE_PLAYERCONNECTION && UNITY_EDITOR")]
133+
extern public static string GetMulticastAddress();
134+
135+
[NativeConditional("ENABLE_PLAYERCONNECTION && UNITY_EDITOR")]
136+
extern public static UInt32 GetMulticastPort();
137+
138+
[NativeConditional("ENABLE_PLAYERCONNECTION && UNITY_EDITOR")]
139+
[NativeName("BuildServerIDString")]
140+
extern public static string BuildServerIdentificationFormat(string localIP, UInt32 listenPort, int flags, UInt32 localGuid, UInt32 editorGuid, string idString, bool allowDebugging, string packageString, string projectName);
128141
}
129142
}

Editor/Mono/EditorGUI.cs

Lines changed: 90 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,86 +2470,96 @@ internal static GenericMenu FillPropertyContextMenu(SerializedProperty property,
24702470
if (!property.serializedObject.targetObjects[icount])
24712471
return null;
24722472
}
2473+
24732474
// Since the menu items are invoked with delay, we can't assume a SerializedObject we don't own
24742475
// will still be around at that time. Hence create our own copy. (case 1051734)
24752476
SerializedObject serializedObjectCopy = new SerializedObject(property.serializedObject.targetObjects);
24762477
SerializedProperty propertyWithPath = serializedObjectCopy.FindProperty(property.propertyPath);
2477-
ScriptAttributeUtility.GetHandler(property).AddMenuItems(property, pm);
24782478

2479-
SerializedProperty linkedPropertyWithPath = null;
2480-
if (linkedProperty != null)
2479+
// FillPropertyContextMenu is now always called when a right click is done on a property.
2480+
// However we don't want those menu to be added when the property is disabled.
2481+
if (GUI.enabled)
24812482
{
2482-
linkedPropertyWithPath = serializedObjectCopy.FindProperty(linkedProperty.propertyPath);
2483-
ScriptAttributeUtility.GetHandler(linkedProperty).AddMenuItems(linkedProperty, pm);
2484-
}
2483+
ScriptAttributeUtility.GetHandler(property).AddMenuItems(property, pm);
24852484

2486-
// Would be nice to allow to set to value of a specific target for properties with children too,
2487-
// but it's not currently supported.
2488-
if (property.hasMultipleDifferentValues && !property.hasVisibleChildren)
2489-
{
2490-
TargetChoiceHandler.AddSetToValueOfTargetMenuItems(pm, propertyWithPath, TargetChoiceHandler.SetToValueOfTarget);
2491-
}
2485+
SerializedProperty linkedPropertyWithPath = null;
2486+
if (linkedProperty != null)
2487+
{
2488+
linkedPropertyWithPath = serializedObjectCopy.FindProperty(linkedProperty.propertyPath);
2489+
ScriptAttributeUtility.GetHandler(linkedProperty).AddMenuItems(linkedProperty, pm);
2490+
}
24922491

2493-
if (property.serializedObject.targetObjectsCount == 1 && property.isInstantiatedPrefab && property.prefabOverride)
2494-
{
2495-
Object targetObject = property.serializedObject.targetObject;
2492+
// Would be nice to allow to set to value of a specific target for properties with children too,
2493+
// but it's not currently supported.
2494+
if (property.hasMultipleDifferentValues && !property.hasVisibleChildren)
2495+
{
2496+
TargetChoiceHandler.AddSetToValueOfTargetMenuItems(pm, propertyWithPath, TargetChoiceHandler.SetToValueOfTarget);
2497+
}
24962498

2497-
SerializedProperty[] properties;
2498-
if (linkedProperty == null)
2499-
properties = new SerializedProperty[] { propertyWithPath };
2500-
else
2501-
properties = new SerializedProperty[] { propertyWithPath, linkedPropertyWithPath };
2499+
if (property.serializedObject.targetObjectsCount == 1 && property.isInstantiatedPrefab && property.prefabOverride)
2500+
{
2501+
Object targetObject = property.serializedObject.targetObject;
25022502

2503-
PrefabUtility.HandleApplyRevertMenuItems(
2504-
null,
2505-
targetObject,
2506-
(menuItemContent, sourceObject) =>
2507-
{
2508-
// Add apply menu item for this apply target.
2509-
TargetChoiceHandler.PropertyAndSourcePathInfo info = new TargetChoiceHandler.PropertyAndSourcePathInfo();
2510-
info.properties = properties;
2511-
info.assetPath = AssetDatabase.GetAssetPath(sourceObject);
2512-
GameObject rootObject = PrefabUtility.GetRootGameObject(sourceObject);
2513-
if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(targetObject))
2514-
pm.AddDisabledItem(menuItemContent);
2515-
else
2516-
pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabPropertyOverride, info);
2517-
},
2518-
(menuItemContent) =>
2519-
{
2520-
// Add revert menu item.
2521-
pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabPropertyOverride, properties);
2522-
},
2523-
false
2524-
);
2525-
}
2503+
SerializedProperty[] properties;
2504+
if (linkedProperty == null)
2505+
properties = new SerializedProperty[] { propertyWithPath };
2506+
else
2507+
properties = new SerializedProperty[] { propertyWithPath, linkedPropertyWithPath };
25262508

2527-
// If property is an element in an array, show duplicate and delete menu options
2528-
if (property.propertyPath.LastIndexOf(']') == property.propertyPath.Length - 1)
2529-
{
2530-
var parentArrayPropertyPath = property.propertyPath.Substring(0, property.propertyPath.LastIndexOf(".Array.data[", StringComparison.Ordinal));
2531-
var parentArrayProperty = property.serializedObject.FindProperty(parentArrayPropertyPath);
2509+
PrefabUtility.HandleApplyRevertMenuItems(
2510+
null,
2511+
targetObject,
2512+
(menuItemContent, sourceObject) =>
2513+
{
2514+
// Add apply menu item for this apply target.
2515+
TargetChoiceHandler.PropertyAndSourcePathInfo info = new TargetChoiceHandler.PropertyAndSourcePathInfo();
2516+
info.properties = properties;
2517+
info.assetPath = AssetDatabase.GetAssetPath(sourceObject);
2518+
GameObject rootObject = PrefabUtility.GetRootGameObject(sourceObject);
2519+
if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(targetObject))
2520+
pm.AddDisabledItem(menuItemContent);
2521+
else
2522+
pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabPropertyOverride, info);
2523+
},
2524+
(menuItemContent) =>
2525+
{
2526+
// Add revert menu item.
2527+
pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabPropertyOverride, properties);
2528+
},
2529+
false
2530+
);
2531+
}
25322532

2533-
if (!parentArrayProperty.isFixedBuffer)
2533+
// If property is an element in an array, show duplicate and delete menu options
2534+
if (property.propertyPath.LastIndexOf(']') == property.propertyPath.Length - 1)
25342535
{
2535-
if (pm.GetItemCount() > 0)
2536+
var parentArrayPropertyPath = property.propertyPath.Substring(0, property.propertyPath.LastIndexOf(".Array.data[", StringComparison.Ordinal));
2537+
var parentArrayProperty = property.serializedObject.FindProperty(parentArrayPropertyPath);
2538+
2539+
if (!parentArrayProperty.isFixedBuffer)
25362540
{
2537-
pm.AddSeparator("");
2541+
if (pm.GetItemCount() > 0)
2542+
{
2543+
pm.AddSeparator("");
2544+
}
2545+
2546+
pm.AddItem(EditorGUIUtility.TrTextContent("Duplicate Array Element"), false, (a) =>
2547+
{
2548+
TargetChoiceHandler.DuplicateArrayElement(a);
2549+
EditorGUIUtility.editingTextField = false;
2550+
}, propertyWithPath);
2551+
pm.AddItem(EditorGUIUtility.TrTextContent("Delete Array Element"), false, (a) =>
2552+
{
2553+
TargetChoiceHandler.DeleteArrayElement(a);
2554+
EditorGUIUtility.editingTextField = false;
2555+
}, propertyWithPath);
25382556
}
2539-
pm.AddItem(EditorGUIUtility.TrTextContent("Duplicate Array Element"), false, (a) =>
2540-
{
2541-
TargetChoiceHandler.DuplicateArrayElement(a);
2542-
EditorGUIUtility.editingTextField = false;
2543-
}, propertyWithPath);
2544-
pm.AddItem(EditorGUIUtility.TrTextContent("Delete Array Element"), false, (a) =>
2545-
{
2546-
TargetChoiceHandler.DeleteArrayElement(a);
2547-
EditorGUIUtility.editingTextField = false;
2548-
}, propertyWithPath);
25492557
}
25502558
}
25512559

25522560
// If shift is held down, show debug menu options
2561+
// This menu is not excluded when the field is disabled
2562+
// because it is nice to get information about the property even when it's disabled.
25532563
if (Event.current.shift)
25542564
{
25552565
if (pm.GetItemCount() > 0)
@@ -2558,6 +2568,8 @@ internal static GenericMenu FillPropertyContextMenu(SerializedProperty property,
25582568
}
25592569

25602570
// If property is a reference and we're using VCS, add item to check it out
2571+
// This menu is not excluded when the field is disabled
2572+
// because it is nice to get information about the property even when it's disabled.
25612573
if (propertyWithPath.propertyType == SerializedPropertyType.ObjectReference && Provider.isActive)
25622574
{
25632575
var obj = propertyWithPath.objectReferenceValue;
@@ -2573,13 +2585,20 @@ internal static GenericMenu FillPropertyContextMenu(SerializedProperty property,
25732585
}
25742586
}
25752587

2576-
if (EditorApplication.contextualPropertyMenu != null)
2588+
// FillPropertyContextMenu is now always called when a right click is done on a property.
2589+
// However we don't want those menu to be added when the property is disabled.
2590+
if (GUI.enabled)
25772591
{
2578-
if (pm.GetItemCount() > 0)
2579-
pm.AddSeparator("");
2580-
EditorApplication.contextualPropertyMenu(pm, property);
2592+
if (EditorApplication.contextualPropertyMenu != null)
2593+
{
2594+
if (pm.GetItemCount() > 0)
2595+
pm.AddSeparator("");
2596+
EditorApplication.contextualPropertyMenu(pm, property);
2597+
}
25812598
}
25822599

2600+
EditorGUIUtility.ContextualPropertyMenuCallback(pm, property);
2601+
25832602
return pm;
25842603
}
25852604

@@ -5768,6 +5787,8 @@ internal static GUIContent BeginPropertyInternal(Rect totalPosition, GUIContent
57685787

57695788
s_PropertyStack.Push(new PropertyGUIData(property, totalPosition, wasBoldDefaultFont, GUI.enabled, GUI.backgroundColor));
57705789

5790+
EditorGUIUtility.BeginPropertyCallback(totalPosition, property);
5791+
57715792
if (GUIDebugger.active && Event.current.type != EventType.Layout)
57725793
{
57735794
var targetObjectTypeName = property.serializedObject.targetObject != null ?
@@ -5830,13 +5851,17 @@ public static void EndProperty()
58305851
// Handle context menu in EndProperty instead of BeginProperty. This ensures that child properties
58315852
// get the event rather than parent properties when clicking inside the child property rects, but the menu can
58325853
// still be invoked for the parent property by clicking inside the parent rect but outside the child rects.
5854+
var oldEnable = GUI.enabled;
5855+
GUI.enabled = true; // Event.current.type will never return ContextClick if the GUI is disabled.
58335856
if (Event.current.type == EventType.ContextClick && data.totalPosition.Contains(Event.current.mousePosition))
58345857
{
5858+
GUI.enabled = oldEnable;
58355859
if (linkedProperties)
58365860
DoPropertyContextMenu(data.property, parentData.property);
58375861
else
58385862
DoPropertyContextMenu(data.property);
58395863
}
5864+
GUI.enabled = oldEnable;
58405865

58415866
EditorGUIUtility.SetBoldDefaultFont(data.wasBoldDefaultFont);
58425867
GUI.enabled = data.wasEnabled;

Editor/Mono/EditorGUIUtility.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ static EditorGUIUtility()
103103
s_HasCurrentWindowKeyFocusFunc = HasCurrentWindowKeyFocus;
104104
}
105105

106+
// this method gets called on right clicking a property regardless of GUI.enable value.
107+
internal static event Action<GenericMenu, SerializedProperty> contextualPropertyMenu;
108+
internal static event Action<Rect, SerializedProperty> beginProperty;
109+
110+
internal static void BeginPropertyCallback(Rect totalRect, SerializedProperty property)
111+
{
112+
beginProperty?.Invoke(totalRect, property);
113+
}
114+
115+
internal static void ContextualPropertyMenuCallback(GenericMenu gm, SerializedProperty prop)
116+
{
117+
if (contextualPropertyMenu != null)
118+
{
119+
if (gm.GetItemCount() > 0)
120+
gm.AddSeparator("");
121+
contextualPropertyMenu(gm, prop);
122+
}
123+
}
124+
106125
// returns position and size of the main Unity Editor window
107126
public static Rect GetMainWindowPosition()
108127
{

Editor/Mono/EditorSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ internal static extern string Internal_ProjectGenerationUserExtensions
251251
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
252252
public static extern EnterPlayModeOptions enterPlayModeOptions { get; set; }
253253

254+
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
255+
public static extern bool serializeInlineMappingsOnOneLine { get; set; }
256+
254257
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
255258
public static extern AssetPipelineMode assetPipelineMode { get; set; }
256259

Editor/Mono/EditorUserBuildSettings.bindings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,15 @@ public static extern bool switchRedirectWritesToHostMount
679679
set;
680680
}
681681

682+
// Enable using the HTC devkit connection for script debugging
683+
public static extern bool switchHTCSScriptDebugging
684+
{
685+
[NativeMethod("GetHTCSScriptDebuggingForSwitch")]
686+
get;
687+
[NativeMethod("SetHTCSScriptDebuggingForSwitch")]
688+
set;
689+
}
690+
682691
internal static extern SwitchShaderCompilerConfig switchShaderCompilerConfig
683692
{
684693
[NativeMethod("GetSwitchShaderCompilerConfig")]

Editor/Mono/GI/LightingSettings.bindings.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ public enum DenoiserType
7474
Optix = 1,
7575

7676
// The Intel Open Image AI denoiser is applied.
77-
OpenImage = 2
77+
OpenImage = 2,
78+
79+
// The AMD Radeon Pro Image Processing denoiser is applied.
80+
RadeonPro = 3
7881
}
7982

8083
// Which path tracer filter is used.
@@ -259,5 +262,9 @@ public bool autoGenerate
259262
// How many reference points to generate when using MIS
260263
[NativeName("PVREnvironmentReferencePointCount")]
261264
internal extern int environmentReferencePointCount { get; set; }
265+
266+
// How many samples to use for light probes relative to lightmap texels
267+
[NativeName("LightProbeSampleCountMultiplier")]
268+
public extern float lightProbeSampleCountMultiplier { get; set; }
262269
}
263270
}

0 commit comments

Comments
 (0)