Skip to content

Commit 96a26ec

Browse files
author
Unity Technologies
committed
Unity 6000.0.49f1 C# reference source code
1 parent a20e820 commit 96a26ec

File tree

112 files changed

+1514
-1852
lines changed

Some content is hidden

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

112 files changed

+1514
-1852
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/BuildPipeline.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ public static string GetPlaybackEngineDirectory(BuildTargetGroup buildTargetGrou
703703
[FreeFunction(IsThreadSafe = true)]
704704
public static extern string GetPlaybackEngineDirectory(BuildTargetGroup buildTargetGroup, BuildTarget target, BuildOptions options, bool assertUnsupportedPlatforms);
705705

706+
[FreeFunction]
707+
internal static extern bool IsServerBuildPlatformSupported(BuildTarget target);
708+
706709
internal static string GetBuildToolsDirectory(BuildTarget target)
707710
{
708711
return Path.Combine(GetPlaybackEngineDirectory(target, BuildOptions.None, false), "Tools");

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -491,59 +491,16 @@ void OnGUI()
491491
{
492492
styles = new Styles();
493493
}
494-
495-
if (!UnityConnect.instance.canBuildWithUPID)
496-
{
497-
ShowAlert();
498-
}
499-
GUILayout.Space(5);
500-
GUILayout.BeginHorizontal();
501-
GUILayout.Space(10);
502-
GUILayout.BeginVertical();
503-
504-
string message = "";
505-
var buildSettingsLocked = !AssetDatabase.IsOpenForEdit(kEditorBuildSettingsPath, out message, StatusQueryOptions.UseCachedIfPossible);
506-
507-
using (new EditorGUI.DisabledScope(buildSettingsLocked))
508-
{
509-
ActiveScenesGUI();
510-
// Clear all and Add Current Scene
511-
GUILayout.BeginHorizontal();
512-
if (buildSettingsLocked)
513-
{
514-
GUI.enabled = true;
515-
if (GUILayout.Button(styles.checkOut))
516-
AssetDatabase.MakeEditable(kEditorBuildSettingsPath);
517-
GUILayout.Label(message);
518-
GUI.enabled = false;
519-
}
520-
GUILayout.FlexibleSpace();
521-
if (GUILayout.Button(styles.addOpenSource))
522-
AddOpenScenes();
523-
GUILayout.EndHorizontal();
524-
}
525-
526-
GUILayout.Space(10);
527-
528-
GUILayout.BeginHorizontal(GUILayout.Height(400));
529-
ActiveBuildTargetsGUI();
530-
GUILayout.Space(10);
531-
GUILayout.BeginVertical();
532-
ShowBuildTargetSettings();
533-
GUILayout.EndVertical();
534-
GUILayout.EndHorizontal();
535-
536-
GUILayout.Space(10);
537-
GUILayout.EndVertical();
538-
GUILayout.Space(10);
539-
GUILayout.EndHorizontal();
494+
// Override the 'old' build settings window in favor of the new build profile window.
495+
BuildPipeline.ShowBuildProfileWindow();
496+
Close();
540497
}
541498

542499
static bool IsAnyStandaloneModuleLoaded()
543500
{
544501
return ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneLinux64) ||
545-
ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneOSX) ||
546-
ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneWindows);
502+
ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneOSX) ||
503+
ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneWindows);
547504
}
548505

549506
static bool IsVirtualTexturingSettingsValid(BuildPlatform platform)

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ internal static BuildProfile activeProfile
6565
{
6666
get
6767
{
68-
// Active Build profile may be deleted from the project.
69-
var activeProfile = EditorUserBuildSettings.activeBuildProfile;
70-
if (activeProfile != null && activeProfile.CanBuildLocally())
71-
return activeProfile;
72-
73-
return null;
68+
return EditorUserBuildSettings.activeBuildProfile;
7469
}
7570

7671
set

Editor/Mono/BuildTargetDiscovery.bindings.cs

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -586,66 +586,17 @@ static void PreloadBuildPlatformInstalledData()
586586
}
587587

588588
bool isInstalled = false;
589-
if (platform.Value.HasFlag(PlatformAttributes.IsWindowsServerBuildTarget))
590-
{
591-
var serverVariations = new[]
592-
{
593-
"win32_server_development",
594-
"win32_server_nondevelopment",
595-
"win64_server_development",
596-
"win64_server_nondevelopment",
597-
"win_arm64_server_development",
598-
"win_arm64_server_nondevelopment",
599-
};
600-
isInstalled = VariationPresent(serverVariations, playbackEngineDirectory);
601-
}
602-
else if (platform.Value.HasFlag(PlatformAttributes.IsLinuxServerBuildTarget))
603-
{
604-
var serverVariations = new[]
605-
{
606-
"linux64_server_development",
607-
"linux64_server_nondevelopment",
608-
};
609-
isInstalled = VariationPresent(serverVariations, playbackEngineDirectory);
610-
}
611-
else if (platform.Value.HasFlag(PlatformAttributes.IsMacServerBuildTarget))
612-
{
613-
var serverVariations = new[]
614-
{
615-
"macos_x64_server_development",
616-
"macos_x64_server_nondevelopment",
617-
"macos_arm64_server_development",
618-
"macos_arm64_server_nondevelopment",
619-
"macos_x64arm64_server_development",
620-
"macos_x64arm64_server_nondevelopment",
621-
};
622-
isInstalled = VariationPresent(serverVariations, playbackEngineDirectory);
623-
}
589+
if (platform.Value.HasFlag(PlatformAttributes.IsWindowsServerBuildTarget) ||
590+
platform.Value.HasFlag(PlatformAttributes.IsLinuxServerBuildTarget) ||
591+
platform.Value.HasFlag(PlatformAttributes.IsMacServerBuildTarget))
592+
isInstalled = BuildPipeline.IsServerBuildPlatformSupported(platform.Value.buildTarget);
624593
else
625594
isInstalled = true;
626595

627596
k_PlatformInstalledData.Add(platform.Key, isInstalled);
628597
}
629598
}
630599

631-
static bool VariationPresent(string[] variations, string playbackEngineDirectory)
632-
{
633-
if (string.IsNullOrEmpty(playbackEngineDirectory))
634-
return false;
635-
636-
var scriptingBackends = new[] { "mono", "il2cpp", "coreclr" };
637-
foreach (var variation in variations)
638-
{
639-
foreach (var backend in scriptingBackends)
640-
{
641-
if (Directory.Exists(Paths.Combine(playbackEngineDirectory, "Variations", variation + "_" + backend)))
642-
return true;
643-
}
644-
}
645-
646-
return false;
647-
}
648-
649600
[System.Obsolete("BuildPlatformIsInstalled(BuildTarget) is obsolete. Use BuildPlatformIsInstalled(IBuildTarget) instead.", false)]
650601
public static bool BuildPlatformIsInstalled(BuildTarget platform) => BuildPlatformIsInstalled(GetGUIDFromBuildTarget(platform));
651602

Editor/Mono/ConsoleWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ const bool
739739
{
740740
SetActiveEntry(entry);
741741
m_LastActiveEntryIndex = entry.globalLineIndex;
742+
m_TextScroll = Vector2.zero;
742743
activeEntryChanged?.Invoke();
743744
}
744745

Editor/Mono/ContainerWindow.bindings.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ extern Rect Internal_Position
7070
[FreeFunction(k_ScriptingPrefix + "MoveBehindOf", HasExplicitThis = true)]
7171
public extern void MoveBehindOf(ContainerWindow other);
7272

73-
// Fit a container window to the screen.
74-
[FreeFunction(k_ScriptingPrefix + "FitWindowRectToScreen", HasExplicitThis = true)]
75-
public extern Rect FitWindowRectToScreen(Rect r, bool forceCompletelyVisible, bool useMouseScreen);
76-
7773
[FreeFunction(k_ScriptingPrefix + "SendCaptionEvent", HasExplicitThis = true)]
7874
public extern void SendCaptionEvent(bool mouseDown);
7975

@@ -108,7 +104,11 @@ extern Rect Internal_Position
108104
[FreeFunction(k_ScriptingPrefix + "GetOrderedWindowList")]
109105
internal static extern void GetOrderedWindowList();
110106

107+
[FreeFunction(k_ScriptingPrefix + "FitRectToMouseScreen")]
108+
internal static extern Rect FitRectToMouseScreen(Rect rect, bool forceCompletelyVisible, ContainerWindow windowForBorderCalculation);
109+
111110
[FreeFunction(k_ScriptingPrefix + "FitRectToScreen")]
112-
internal static extern Rect FitRectToScreen(Rect defaultRect, bool forceCompletelyVisible, bool useMouseScreen);
111+
internal static extern Rect FitRectToScreen(Rect rect, Vector2 uiPositionToFindScreen, bool forceCompletelyVisible, ContainerWindow windowForBorderCalculation);
112+
113113
}
114114
}

Editor/Mono/ContainerWindow.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ internal void ShowPopupWithMode(ShowMode mode, bool giveFocus)
149149
Internal_BringLiveAfterCreation(true, giveFocus, false);
150150

151151
// Fit window to screen - needs to be done after bringing the window live
152-
position = FitWindowRectToScreen(m_PixelRect, true, false);
152+
position = FitRectToScreen(m_PixelRect, m_PixelRect.center, true, this);
153153
rootView.position = new Rect(0, 0, GUIUtility.RoundToPixelGrid(m_PixelRect.width), GUIUtility.RoundToPixelGrid(m_PixelRect.height));
154154
rootView.Reflow();
155155
}
@@ -231,7 +231,11 @@ public void Show(ShowMode showMode, bool loadPosition, bool displayImmediately,
231231

232232
internal void FitWindowToScreen(bool useMousePos)
233233
{
234-
position = FitWindowRectToScreen(m_PixelRect, true, useMousePos);
234+
if (useMousePos)
235+
position = FitRectToMouseScreen(m_PixelRect, true, this);
236+
else
237+
position = FitRectToScreen(m_PixelRect, m_PixelRect.center, true, this);
238+
235239
if (rootView)
236240
rootView.position = new Rect(0, 0, GUIUtility.RoundToPixelGrid(m_PixelRect.width), GUIUtility.RoundToPixelGrid(m_PixelRect.height));
237241
}

Editor/Mono/EditorGUI.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,12 +2011,11 @@ public ScrollableAreaScope(int id, ref Rect position, string text, ref Vector2 s
20112011
this.style = style;
20122012
this.scrollPosition = scrollPosition;
20132013

2014+
position = IndentedRect(position);
20142015
float fullTextHeight = style.CalcHeight(GUIContent.Temp(text), position.width);
20152016
Rect viewRect = new Rect(0, 0, position.width, fullTextHeight);
20162017

20172018
oldScrollValue = style.contentOffset;
2018-
2019-
position = IndentedRect(position);
20202019
if (position.height < viewRect.height)
20212020
{
20222021
//Scroll bar position
@@ -2081,7 +2080,23 @@ internal static void ScrollableLabelAreaInternal(Rect position, string text, ref
20812080

20822081
RecycledTextEditor.s_AllowContextCutOrPaste = false;
20832082
if (sendEventToTextEditor)
2083+
{
2084+
bool isMouseDown = Event.current.rawType == EventType.MouseDown && Event.current.button == 0;
2085+
bool isEditingControl = s_RecycledEditor.IsEditingControl(id);
2086+
20842087
DoTextField(s_RecycledEditor, id, position, text, style, string.Empty, out _, false, true, false);
2088+
2089+
if (isMouseDown && Event.current.type == EventType.Used)
2090+
{
2091+
// We just took control over the Scrollable label
2092+
if (!isEditingControl && s_RecycledEditor.IsEditingControl(id))
2093+
{
2094+
// Properly set the scroll offset as it was set to 0 in the editor.BeginEditing
2095+
// Move the recycled Editor offset to match our scrollbar
2096+
s_RecycledEditor.scrollOffset = scrollPosition;
2097+
}
2098+
}
2099+
}
20852100
}
20862101

20872102
//Only update the out scrollPosition if the user has interacted with the TextArea (the current event was used)

Editor/Mono/EditorWindow.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ internal SerializableJsonDictionary viewDataDictionary
120120
}
121121
}
122122

123+
// This list contains all the editor windows that are already enabled/active/alive.
124+
// It is important to check if your window is contained in this list before doing anything,
125+
// such like UI build/rebuild.
123126
internal static List<EditorWindow> activeEditorWindows { get; } = new List<EditorWindow>();
124127

125128
internal void SaveViewData()
@@ -1258,7 +1261,7 @@ public Rect position
12581261
if (!da)
12591262
{
12601263
if(m_Parent.window.showMode == ShowMode.Tooltip || m_Parent.window.showMode == ShowMode.PopupMenu)
1261-
m_Parent.window.position = m_Parent.window.FitWindowRectToScreen(value, true, false);
1264+
m_Parent.window.position = ContainerWindow.FitRectToScreen(value, value.center, true, m_Parent.window);
12621265
else
12631266
m_Parent.window.position = value;
12641267
m_Parent.window.OnResize();

0 commit comments

Comments
 (0)