Skip to content

Commit 789400a

Browse files
author
Unity Technologies
committed
Unity 6000.1.3f1 C# reference source code
1 parent 365d236 commit 789400a

File tree

66 files changed

+1367
-1934
lines changed

Some content is hidden

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

66 files changed

+1367
-1934
lines changed

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ public enum NormalizationMode
3030
}
3131

3232
//const int kToolbarHeight = 17;
33-
const int kPresetsHeight = 46;
33+
const int kPresetsHeight = 50;
3434

3535
static CurveEditorWindow s_SharedCurveEditor;
3636

3737
internal CurveEditor m_CurveEditor;
3838

39+
Vector2 m_PresetScrollPosition;
3940
AnimationCurve m_Curve;
4041
Color m_Color;
4142

@@ -469,20 +470,38 @@ void OnGUI()
469470
m_CurveEditor.OnGUI();
470471

471472
// Preset swatch area
472-
GUI.Box(new Rect(0, position.height - kPresetsHeight, position.width, kPresetsHeight), "", ms_Styles.curveSwatchArea);
473+
var presetRect = new Rect(0, position.height - kPresetsHeight, position.width, kPresetsHeight);
474+
GUI.Box(presetRect, "", ms_Styles.curveSwatchArea);
475+
473476
Color curveColor = m_Color;
474477
curveColor.a *= 0.6f;
475-
const float margin = 45f;
476478
const float width = 40f;
477479
const float height = 25f;
478-
float yPos = position.height - kPresetsHeight + (kPresetsHeight - height) * 0.5f;
480+
const float spaceBetweenSwatches = 5f;
481+
const float presetDropdownSize = 16f;
482+
const float horizontalScrollbarHeight = 15f;
483+
const float presetDropdownCenteringOffset = 2f;
484+
float yPos = (kPresetsHeight - height) * 0.5f;
479485
InitCurvePresets();
480486
CurvePresetLibrary curveLibrary = m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib();
481487
if (curveLibrary != null)
482488
{
483-
for (int i = 0; i < curveLibrary.Count(); i++)
489+
var numPresets = curveLibrary.Count();
490+
var presetDropDownRect = new Rect(spaceBetweenSwatches, yPos + presetDropdownCenteringOffset, presetDropdownSize, presetDropdownSize);
491+
Rect contentRect = new Rect(0, 0, numPresets * (width + spaceBetweenSwatches) + presetDropDownRect.xMax, presetRect.height - horizontalScrollbarHeight);
492+
m_PresetScrollPosition = GUI.BeginScrollView(
493+
presetRect, // Rectangle of the visible area
494+
m_PresetScrollPosition, // Current scroll position
495+
contentRect, // Rectangle containing all content
496+
false, // Always show horizontal scrollbar
497+
false // Always show vertical scrollbar
498+
);
499+
500+
PresetDropDown(presetDropDownRect);
501+
502+
Rect swatchRect = new Rect(presetDropDownRect.xMax + spaceBetweenSwatches, yPos, width, height);
503+
for (int i = 0; i < numPresets; i++)
484504
{
485-
Rect swatchRect = new Rect(margin + (width + 5f) * i, yPos, width, height);
486505
m_GUIContent.tooltip = curveLibrary.GetName(i);
487506
if (GUI.Button(swatchRect, m_GUIContent, ms_Styles.curveSwatch))
488507
{
@@ -496,14 +515,11 @@ void OnGUI()
496515
if (Event.current.type == EventType.Repaint)
497516
curveLibrary.Draw(swatchRect, i);
498517

499-
if (swatchRect.xMax > position.width - 2 * margin)
500-
break;
518+
swatchRect.x += width + spaceBetweenSwatches;
501519
}
520+
GUI.EndScrollView();
502521
}
503522

504-
Rect presetDropDownButtonRect = new Rect(margin - 20f, yPos + 5f, 20, 20);
505-
PresetDropDown(presetDropDownButtonRect);
506-
507523
// For adding default preset curves
508524
//if (EditorGUI.DropdownButton(new Rect (position.width -26, yPos, 20, 20), GUIContent.none, FocusType.Passive, "OL Plus"))
509525
// AddDefaultPresetsToCurrentLib ();

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ void ValidateDataConsistency()
403403
}
404404

405405
CheckSceneListConsistency();
406+
407+
// On disk changes to active profile may change platform guid.
408+
// Specifically copying the entire YAML of a valid build profile.
409+
if (this == BuildProfileContext.activeProfile && platformGuid != EditorUserBuildSettings.activePlatformGuid)
410+
{
411+
EditorUserBuildSettings.SwitchActiveBuildTargetGuid(this);
412+
}
406413
}
407414

408415
/// <summary>

Editor/Mono/BuildTargetDiscovery.bindings.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public PlatformInfo() {}
256256

257257
static GUID EmptyGuid = new GUID("");
258258

259-
static Dictionary<BuildTarget, GUID> s_PlatformGUIDDataQuickLookup = new Dictionary<BuildTarget, GUID>();
259+
static Dictionary<BuildTarget, GUID> s_BuildTargetToPlatformGUID = new Dictionary<BuildTarget, GUID>();
260260

261261
// This list should not be exposed ouside of BuildTargetDiscovery to avoid NDA spillage, provide a access function for data here instead.
262262
// Changes here should be synced with the usage of
@@ -660,10 +660,7 @@ public static GUID GetGUIDFromBuildTarget(NamedBuildTarget namedBuildTarget, Bui
660660
/// <returns>The platform GUID. Derived platform GUID when the active platform is a derived platform. Base platform GUID otherwise.</returns>
661661
public static GUID GetGUIDFromBuildTarget(BuildTarget buildTarget)
662662
{
663-
if (buildTarget == BuildTarget.StandaloneWindows) //workaround for win64 and win having the same guid in new Build Target system
664-
buildTarget = BuildTarget.StandaloneWindows64;
665-
666-
if (s_PlatformGUIDDataQuickLookup.TryGetValue(buildTarget, out GUID value))
663+
if (s_BuildTargetToPlatformGUID.TryGetValue(buildTarget, out GUID value))
667664
{
668665
var module = ModuleManager.FindPlatformSupportModule(value);
669666
if (module != null && module is IDerivedBuildTargetProvider)
@@ -702,7 +699,7 @@ internal static GUID GetBasePlatformGUIDFromBuildTarget(NamedBuildTarget namedBu
702699
if (TryGetServerGUIDFromBuildTarget(namedBuildTarget, buildTarget, out var value))
703700
return value;
704701

705-
if (s_PlatformGUIDDataQuickLookup.TryGetValue(buildTarget, out GUID guid))
702+
if (s_BuildTargetToPlatformGUID.TryGetValue(buildTarget, out GUID guid))
706703
return guid;
707704

708705
return EmptyGuid;
@@ -721,7 +718,7 @@ internal static GUID GetBasePlatformGUID(GUID platformGuid)
721718
if (!platformInfo.HasFlag(PlatformAttributes.IsDerivedBuildTarget))
722719
return platformGuid;
723720

724-
if (s_PlatformGUIDDataQuickLookup.TryGetValue(platformInfo.buildTarget, out GUID basePlatformGuid))
721+
if (s_BuildTargetToPlatformGUID.TryGetValue(platformInfo.buildTarget, out GUID basePlatformGuid))
725722
return basePlatformGuid;
726723

727724
return EmptyGuid;
@@ -739,12 +736,15 @@ static void PreloadBuildPlatformInstalledData()
739736
{
740737
foreach (var platform in allPlatforms)
741738
{
739+
// Capture BuildTarget to GUID mapping for all platforms.
740+
// Considers that StandaloneWindows and StandaloneWindows64 are the same platform.
742741
if (platform.Value.buildTarget != BuildTarget.StandaloneWindows
743742
&& platform.Value.subtarget != StandaloneBuildSubtarget.Server
744-
&& !platform.Value.HasFlag(PlatformAttributes.IsDerivedBuildTarget)
745-
) //workaround for win64 and win having the same guid in new Build Target system and for derived build targets
743+
&& !platform.Value.HasFlag(PlatformAttributes.IsDerivedBuildTarget))
746744
{
747-
s_PlatformGUIDDataQuickLookup.Add(platform.Value.buildTarget, platform.Key);
745+
s_BuildTargetToPlatformGUID.Add(platform.Value.buildTarget, platform.Key);
746+
if (platform.Value.buildTarget == BuildTarget.StandaloneWindows64)
747+
s_BuildTargetToPlatformGUID.Add(BuildTarget.StandaloneWindows, platform.Key);
748748
}
749749

750750
var playbackEngineDirectory = BuildPipeline.GetPlaybackEngineDirectory(platform.Value.buildTarget, BuildOptions.None, false);

Editor/Mono/GI/Lightmapping.bindings.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,24 @@ internal static FilterMode filterMode
241241

242242
// Starts an asynchronous bake job.
243243
[FreeFunction]
244-
public static extern bool BakeAsync();
244+
internal static extern bool BakeAsyncImpl();
245245

246-
// Stars a synchronous bake job.
246+
// Starts a synchronous bake job.
247247
[FreeFunction]
248-
public static extern bool Bake();
248+
internal static extern bool BakeImpl();
249+
250+
public static bool BakeAsync()
251+
{
252+
RenderPipelineManager.TryPrepareRenderPipeline(GraphicsSettings.currentRenderPipeline);
253+
return BakeAsyncImpl();
254+
}
249255

256+
public static bool Bake()
257+
{
258+
RenderPipelineManager.TryPrepareRenderPipeline(GraphicsSettings.currentRenderPipeline);
259+
return BakeImpl();
260+
}
261+
250262
// Cancels the currently running asynchronous bake job.
251263
[FreeFunction("CancelLightmapping")]
252264
public static extern void Cancel();
@@ -716,6 +728,7 @@ public static bool extractAmbientOcclusion
716728

717729
public static bool BakeAsync(Scene targetScene)
718730
{
731+
RenderPipelineManager.TryPrepareRenderPipeline(GraphicsSettings.currentRenderPipeline);
719732
return BakeSceneAsync(targetScene);
720733
}
721734

@@ -726,6 +739,7 @@ public static bool BakeAsync(Scene targetScene)
726739

727740
public static bool Bake(Scene targetScene)
728741
{
742+
RenderPipelineManager.TryPrepareRenderPipeline(GraphicsSettings.currentRenderPipeline);
729743
return BakeScene(targetScene);
730744
}
731745

Editor/Mono/GUI/Toolbars/EditorToolbarUtility.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
using System.Collections.Generic;
66
using System.Linq;
7+
using UnityEditor.Overlays;
8+
using UnityEngine;
79
using UnityEngine.UIElements;
810

911
namespace UnityEditor.Toolbars
@@ -73,5 +75,67 @@ internal static VisualTreeAsset LoadUxml(string name)
7375
{
7476
return EditorGUIUtility.Load($"{k_UxmlPath}{name}.uxml") as VisualTreeAsset;
7577
}
78+
79+
internal static void UpdateIconContent(
80+
string text,
81+
string textIcon,
82+
Texture2D icon,
83+
TextElement textElement,
84+
TextElement textIconElement,
85+
Image iconElement)
86+
{
87+
if (text == string.Empty)
88+
{
89+
textElement.style.display = DisplayStyle.None;
90+
textIconElement.style.display = DisplayStyle.None;
91+
}
92+
else
93+
textElement.style.display = StyleKeyword.Null;
94+
95+
// First priority: image icon, if available
96+
if (icon != null)
97+
{
98+
if (iconElement != null)
99+
{
100+
iconElement.style.display = DisplayStyle.Flex;
101+
iconElement.image = icon;
102+
}
103+
if (textIconElement != null)
104+
textIconElement.style.display = DisplayStyle.None;
105+
}
106+
else if (iconElement != null && iconElement.resolvedStyle.backgroundImage != null)
107+
{
108+
if (textIconElement != null)
109+
textIconElement.style.display = DisplayStyle.None;
110+
iconElement.style.display = DisplayStyle.Flex;
111+
}
112+
// Second priority: text icon, if available
113+
else if (!string.IsNullOrEmpty(textIcon))
114+
{
115+
if (textIconElement != null)
116+
{
117+
textIconElement.style.display = DisplayStyle.Flex;
118+
textIconElement.text = OverlayUtilities.GetSignificantLettersForIcon(textIcon);
119+
}
120+
if (iconElement != null)
121+
iconElement.style.display = DisplayStyle.None;
122+
}
123+
// Fall back: abbreviation of text.
124+
else if (!string.IsNullOrEmpty(text))
125+
{
126+
if (textIconElement != null)
127+
{
128+
textIconElement.style.display = StyleKeyword.Null;
129+
textIconElement.text = OverlayUtilities.GetSignificantLettersForIcon(text);
130+
}
131+
if (iconElement != null)
132+
iconElement.style.display = DisplayStyle.None;
133+
}
134+
else
135+
{
136+
if (iconElement != null)
137+
iconElement.style.display = DisplayStyle.Flex;
138+
}
139+
}
76140
}
77141
}

Editor/Mono/Inspector/Core/ScriptAttributeGUI/Implementations/ExposedReferenceDrawer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using UnityEditor;
7+
using UnityEditor.UIElements;
78
using UnityEngine;
89
using UnityEngine.UIElements;
910
using ObjectField = UnityEditor.UIElements.ObjectField;
@@ -156,16 +157,23 @@ public override VisualElement CreatePropertyGUI(SerializedProperty prop)
156157

157158
obj.RegisterValueChangedCallback(SetReference);
158159
obj.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
160+
obj.AddToClassList(ObjectField.alignedFieldUssClassName);
159161

162+
// Track for Undo/Redo changes which can come from exposedPropertyTable
160163
Undo.UndoRedoCallback undoRedoCallback = () =>
161164
{
162165
m_Item.UpdateValue();
163166
obj.SetValueWithoutNotify(m_Item.currentReferenceValue);
164167
};
165168

169+
// Track the property for external changed including Undo/Redo
170+
obj.TrackPropertyValue(prop, _ => undoRedoCallback());
166171
obj.RegisterCallback<AttachToPanelEvent>(evt => Undo.undoRedoPerformed += undoRedoCallback);
167172
obj.RegisterCallback<DetachFromPanelEvent>(evt => Undo.undoRedoPerformed -= undoRedoCallback);
168173

174+
// Set the serialized property so we can support drag and drop
175+
obj.SetProperty(ObjectField.serializedPropertyKey, m_Item.exposedPropertyDefault);
176+
169177
return obj;
170178
}
171179

External/NiceIO/NiceIO.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
using File = NiceIO.Do_Not_Use_File_Directly_Use_FileSystem_Active_Instead;
1717
using Directory = NiceIO.Do_Not_Use_Directory_Directly_Use_FileSystem_Active_Instead;
1818

19+
#nullable disable
20+
1921
namespace NiceIO
2022
{
2123
/// <summary>

0 commit comments

Comments
 (0)