Skip to content

Commit

Permalink
Unity 6000.0.1f1 C# reference source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Technologies committed May 8, 2024
1 parent 22a9cc4 commit b1c78d1
Show file tree
Hide file tree
Showing 180 changed files with 5,513 additions and 2,133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class ConfigurationData
public string UnityVersion;
public Version UnityVersionNumeric;
public string UnitySourceCodePath;
public bool AdvancedLicense;
public bool Batchmode;
public bool EmitDataForBeeWhy;
public string NamedPipeOrUnixSocket;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/Annotation/SceneRenderModeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static class Styles
new SceneView.CameraMode(DrawCameraMode.AlphaChannel, "Alpha Channel", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.Overdraw, "Overdraw", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.Mipmaps, "Mipmaps", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.TextureStreaming, "Texture Streaming", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.TextureStreaming, "Texture Mipmap Streaming", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.SpriteMask, "Sprite Mask", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.ValidateAlbedo, "Validate Albedo", kMiscellaneous),
new SceneView.CameraMode(DrawCameraMode.ValidateMetalSpecular, "Validate Metal Specular", kMiscellaneous),
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/AssemblyInfo/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
[assembly: InternalsVisibleTo("Unity.Muse.Chat.Bridge")]

[assembly: InternalsVisibleTo("Unity.Multiplayer.Playmode.Editor.Bridge")]
[assembly: InternalsVisibleTo("Unity.DedicatedServer.Editor.Bridge")]

[assembly: InternalsVisibleTo("Unity.Scenes")]

Expand Down
7 changes: 5 additions & 2 deletions Editor/Mono/Audio/UIElements/AudioRandomRangeSliderTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ static void GenerateVisualContent(MeshGenerationContext context)
range.x += parentSlider.value;
range.y += parentSlider.value;

// Measured from a screenshot of the slider. The value is in pixels.
var sliderHeadWidth = 10.0f;

// Map the range from the slider value range (e.g. dB) to the horizontal span of the content-rect (px).
var left = Map(range.y, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin, contentRect.xMax);
var right = Map(range.x, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin, contentRect.xMax);
var left = Map(range.y, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin + sliderHeadWidth / 2.0f, contentRect.xMax - sliderHeadWidth / 2.0f);
var right = Map(range.x, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin + sliderHeadWidth / 2.0f, contentRect.xMax - sliderHeadWidth / 2.0f);

// Clamp the mapped range so that it lies within the boundaries of the content-rect.
left = Mathf.Clamp(left, contentRect.xMin, contentRect.xMax);
Expand Down
3 changes: 1 addition & 2 deletions Editor/Mono/BuildPipeline/BuildPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ public string GetBuildTargetDisplayName(NamedBuildTarget namedBuildTarget, Build
return cur.title.text;
}

var suffix = namedBuildTarget == NamedBuildTarget.Server ? " Server" : "";
#pragma warning disable CS0618 // Member is obsolete
string targetName = BuildTargetDiscovery.BuildPlatformDisplayName(target) + suffix;
string targetName = BuildTargetDiscovery.BuildPlatformDisplayName(namedBuildTarget, target);
#pragma warning restore CS0618
return targetName.Length == 0 ? "Unsupported Target" : targetName;
}
Expand Down
20 changes: 15 additions & 5 deletions Editor/Mono/BuildPlayerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using RequiredByNativeCodeAttribute = UnityEngine.Scripting.RequiredByNativeCodeAttribute;
using UnityEditor.Connect;
using UnityEditor.Utils;
using UnityEditor.Build.Profile;

namespace UnityEditor
{
Expand Down Expand Up @@ -151,7 +152,7 @@ static Styles()

static bool isEditorinstalledWithHub = IsEditorInstalledWithHub();

internal static event Action<NamedBuildTarget> drawingMultiplayerBuildOptions;
internal static event Action<BuildProfile> drawingMultiplayerBuildOptions;

[UsedImplicitly, RequiredByNativeCode]
public static void ShowBuildPlayerWindow()
Expand All @@ -162,9 +163,9 @@ public static void ShowBuildPlayerWindow()

internal static bool WillDrawMultiplayerBuildOptions() => drawingMultiplayerBuildOptions != null;

internal static void DrawMultiplayerBuildOption(NamedBuildTarget namedBuildTarget)
internal static void DrawMultiplayerBuildOption(BuildProfile buildProfile)
{
drawingMultiplayerBuildOptions?.Invoke(namedBuildTarget);
drawingMultiplayerBuildOptions?.Invoke(buildProfile);
}

static bool BuildLocationIsValid(string path)
Expand Down Expand Up @@ -941,7 +942,13 @@ void ShowBuildTargetSettings()
GUILayout.EndHorizontal();
}

drawingMultiplayerBuildOptions?.Invoke(namedBuildTarget);
var subtarget = StandaloneBuildSubtarget.Default;
if (namedBuildTarget == NamedBuildTarget.Standalone)
subtarget = StandaloneBuildSubtarget.Player;
else if (namedBuildTarget == NamedBuildTarget.Server)
subtarget = StandaloneBuildSubtarget.Server;

drawingMultiplayerBuildOptions?.Invoke(BuildProfileContext.instance.GetForClassicPlatform(buildTarget, subtarget));

GUILayout.EndScrollView();

Expand All @@ -958,7 +965,10 @@ internal static void ShowNoModuleLabel(
GUIContent installModuleWithHub,
string editorWillNeedToBeReloaded)
{
GUILayout.Label(EditorGUIUtility.TextContent(string.Format(noModuleLoaded, BuildPlatforms.instance.GetModuleDisplayName(namedBuildTarget, buildTarget))));
#pragma warning disable CS0618 // Member is obsolete
var displayName = BuildTargetDiscovery.BuildPlatformDisplayName(namedBuildTarget, buildTarget);
#pragma warning restore CS0618
GUILayout.Label(EditorGUIUtility.TextContent(string.Format(noModuleLoaded, displayName)));
string url = "";
#pragma warning disable CS0618 // Member is obsolete
if (!isEditorinstalledWithHub || !BuildTargetDiscovery.BuildPlatformCanBeInstalledWithHub(buildTarget))
Expand Down
17 changes: 17 additions & 0 deletions Editor/Mono/BuildProfile/BuildProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ void OnDisable()
AssetDatabase.SaveAssetIfDirty(this);
}

[MenuItem("CONTEXT/BuildProfile/Reset", false)]
static void ContextMenuReset(MenuCommand menuCommand)
{
var targetBuildProfile = (BuildProfile) menuCommand.context;
if (targetBuildProfile == null)
return;

targetBuildProfile.platformBuildProfile = null;
targetBuildProfile.TryCreatePlatformSettings();
targetBuildProfile.scenes = Array.Empty<EditorBuildSettingsScene>();
targetBuildProfile.scriptingDefines = Array.Empty<string>();

BuildProfileModuleUtil.RemovePlayerSettings(targetBuildProfile);

AssetDatabase.SaveAssetIfDirty(targetBuildProfile);
}

void ValidateDataConsistency()
{
// TODO: Remove migration code (https://jira.unity3d.com/browse/PLAT-8909)
Expand Down
117 changes: 22 additions & 95 deletions Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,23 @@ internal class BuildProfileModuleUtil
{
const string k_BuyProUrl = "https://store.unity.com/products/unity-pro";
const string k_ConsoleModuleUrl = "https://unity3d.com/platform-installation";
const string k_BuildSettingsPlatformIconFormat = "BuildSettings.{0}";
const string k_LastRunnableBuildPathSeparator = "_";
static readonly string k_NoModuleLoaded = L10n.Tr("No {0} module loaded.");
static readonly string k_EditorWillNeedToBeReloaded = L10n.Tr("Note: Editor will need to be restarted to load any newly installed modules");
static readonly string k_BuildProfileRecompileReason = L10n.Tr("Active build profile scripting defines changes.");
static readonly GUIContent k_OpenDownloadPage = EditorGUIUtility.TrTextContent("Open Download Page");
static readonly GUIContent k_InstallModuleWithHub = EditorGUIUtility.TrTextContent("Install with Unity Hub");
static Dictionary<string, BuildTargetDiscovery.DiscoveredTargetInfo> s_DiscoveredTargetInfos = InitializeDiscoveredTargetDict();
static HashSet<string> s_BuildProfileIconModules = new()
{
"Switch",
"QNX",
};

/// <summary>
/// Classic platform display name for a given build profile. Matching
/// value in the old BuildSettings window.
/// Classic platform display name for a given build profile.
/// </summary>
/// <see cref="BuildPlayerWindow"/>
public static string GetClassicPlatformDisplayName(string platformId)
{
var (buildTarget, subtarget) = GetBuildTargetAndSubtarget(platformId);
var moduleName = GetModuleName(buildTarget);

return (moduleName, subtarget) switch
{
("OSXStandalone", StandaloneBuildSubtarget.Server) => "Mac Server",
("WindowsStandalone", StandaloneBuildSubtarget.Server) => "Windows Server",
("LinuxStandalone", StandaloneBuildSubtarget.Server) => "Linux Server",
("OSXStandalone", _) => "Mac",
("WindowsStandalone", _) => "Windows",
("LinuxStandalone", _) => "Linux",
_ => GetModuleDisplayName(moduleName),
};
}
public static string GetClassicPlatformDisplayName(string platformId) =>
GetModuleDisplayName(platformId);

/// <summary>
/// Fetch default editor platform icon texture.
Expand Down Expand Up @@ -102,25 +84,10 @@ public static Texture2D GetWarningIcon()
/// </summary>
public static bool IsModuleInstalled(string platformId)
{
var (buildTarget, subtarget) = GetBuildTargetAndSubtarget(platformId);
var (buildTarget, _) = GetBuildTargetAndSubtarget(platformId);
var moduleName = GetModuleName(buildTarget);

// NamedBuildTarget will be deprecated. This code is extracted from
// NamedBuildTarget.FromActiveSettings. Except instead of taking a dependency
// on Editor User Build Settings, we use the passed subtarget.
NamedBuildTarget namedTarget;
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);
if (buildTargetGroup == BuildTargetGroup.Standalone
&& subtarget == StandaloneBuildSubtarget.Server)
{
namedTarget = NamedBuildTarget.Server;
}
else
{
namedTarget = NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup);
}

bool installed = BuildPlatforms.instance.BuildPlatformFromNamedBuildTarget(namedTarget).installed;
bool installed = BuildTargetDiscovery.BuildPlatformIsInstalled(new GUID(platformId));
return installed
&& BuildPipeline.LicenseCheck(buildTarget)
&& !string.IsNullOrEmpty(moduleName)
Expand Down Expand Up @@ -168,9 +135,7 @@ public static VisualElement CreateLicenseNotFoundElement(string platformId)
if (BuildPipeline.LicenseCheck(buildTarget))
return null;

var targetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);
var namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(targetGroup);
string niceName = BuildPipeline.GetBuildTargetGroupDisplayName(namedBuildTarget.ToBuildTargetGroup());
string displayName = GetModuleDisplayName(platformId);
string licenseMsg = L10n.Tr("Your license does not cover {0} Publishing.");
string buttonMsg = L10n.Tr("Go to Our Online Store");
string url = k_BuyProUrl;
Expand All @@ -184,7 +149,7 @@ public static VisualElement CreateLicenseNotFoundElement(string platformId)

var root = new VisualElement();
root.style.flexDirection = FlexDirection.Column;
var label = new Label(string.Format(licenseMsg, niceName));
var label = new Label(string.Format(licenseMsg, displayName));
label.style.whiteSpace = WhiteSpace.Normal;
root.Add(label);
if (!BuildTargetDiscovery.PlatformHasFlag(buildTarget, TargetAttributes.IsStandalonePlatform))
Expand Down Expand Up @@ -341,36 +306,23 @@ public static IBuildProfileExtension GetBuildProfileExtension(string moduleName)
/// </summary>
public static List<string> FindAllViewablePlatforms()
{
var result = new List<string>()
var result = new List<string>();

foreach (var platformGuid in BuildTargetDiscovery.GetAllPlatforms())
{
GetPlatformId(BuildTarget.StandaloneWindows64, StandaloneBuildSubtarget.Player),
GetPlatformId(BuildTarget.StandaloneOSX, StandaloneBuildSubtarget.Player),
GetPlatformId(BuildTarget.StandaloneLinux64, StandaloneBuildSubtarget.Player),
GetPlatformId(BuildTarget.StandaloneWindows64, StandaloneBuildSubtarget.Server),
GetPlatformId(BuildTarget.StandaloneOSX, StandaloneBuildSubtarget.Server),
GetPlatformId(BuildTarget.StandaloneLinux64, StandaloneBuildSubtarget.Server)
};
var installed = BuildTargetDiscovery.BuildPlatformIsInstalled(platformGuid);
if (!installed && BuildTargetDiscovery.BuildPlatformIsHiddenInUI(platformGuid))
continue;

result.Add(platformGuid.ToString());
}

// Swap current editor standalone platform to the top.
if (Application.platform == RuntimePlatform.OSXEditor)
result.Reverse(0, 2);
if (Application.platform == RuntimePlatform.LinuxEditor)
result.Reverse(0, 3);

foreach (var buildTargetInfo in BuildTargetDiscovery.GetBuildTargetInfoList())
{
if (buildTargetInfo.HasFlag(TargetAttributes.IsStandalonePlatform))
continue;

// installed platform check from BuildPlatforms
bool installed = BuildPipeline.GetPlaybackEngineDirectory(buildTargetInfo.buildTargetPlatformVal, BuildOptions.None, false) != string.Empty;
if (!installed && buildTargetInfo.HasFlag(TargetAttributes.HideInUI))
continue;

var platformId = GetPlatformId(buildTargetInfo.buildTargetPlatformVal, StandaloneBuildSubtarget.Default);
result.Add(platformId);
}

return result;
}

Expand Down Expand Up @@ -542,17 +494,6 @@ internal static void SetBuildProfileLastRunnableBuildPathKey(string key, string
EditorPrefs.SetString(key, value);
}

static Dictionary<string, BuildTargetDiscovery.DiscoveredTargetInfo> InitializeDiscoveredTargetDict()
{
var result = new Dictionary<string, BuildTargetDiscovery.DiscoveredTargetInfo>();
foreach (var kvp in BuildTargetDiscovery.GetBuildTargetInfoList())
{
var targetString = GetModuleName(kvp.buildTargetPlatformVal);
result.TryAdd(targetString, kvp);
}
return result;
}

static bool LoadBuildProfileIcon(string platformId, out Texture2D icon)
{
var moduleName = GetModuleName(platformId);
Expand All @@ -568,31 +509,17 @@ static bool LoadBuildProfileIcon(string platformId, out Texture2D icon)

static string GetPlatformIconId(string platformId)
{
var (buildTarget, subtarget) = GetBuildTargetAndSubtarget(platformId);
var moduleName = GetModuleName(buildTarget);

if (subtarget == StandaloneBuildSubtarget.Server)
{
return string.Format(k_BuildSettingsPlatformIconFormat, "DedicatedServer");
}
var iconName = BuildTargetDiscovery.BuildPlatformIconName(new GUID(platformId));

if (s_DiscoveredTargetInfos.TryGetValue(moduleName, out var targetInfo))
{
return targetInfo.iconName;
}
if (string.IsNullOrEmpty(iconName))
return "BuildSettings.Editor";

return "BuildSettings.Editor";
return iconName;
}

/// <summary>
/// Module display name as defined on native side in "BuildTargetGroupName.h"
/// </summary>
static string GetModuleDisplayName(string moduleName)
static string GetModuleDisplayName(string platformId)
{
if (!s_DiscoveredTargetInfos.TryGetValue(moduleName, out var gt))
return moduleName;

return BuildPipeline.GetBuildTargetGroupDisplayName(BuildPipeline.GetBuildTargetGroup(gt.buildTargetPlatformVal));
return BuildTargetDiscovery.BuildPlatformDisplayName(new GUID(platformId));
}

/// <summary>
Expand Down
Loading

0 comments on commit b1c78d1

Please sign in to comment.