Skip to content

Commit

Permalink
Unity 6000.0.0f1 C# reference source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Technologies committed Apr 29, 2024
1 parent e336592 commit 9778aae
Show file tree
Hide file tree
Showing 321 changed files with 8,878 additions and 2,431 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
5 changes: 4 additions & 1 deletion Editor/Mono/Animation/AnimationWindow/CurveBindingUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static object GetCurrentValue(AnimationWindowState state, EditorCurveBind
// Otherwise, evaluate AnimationWindowCurve at current time.
public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
{
if (state.previewing && curve.rootGameObject != null)
// UUM-66112 - state.linkedWithSequencer - Padding for issue in Timeline where muscle
// values are not updated in the editor when previewing in the Animation Window.
// Fallback to curve values.
if (state.previewing && curve.rootGameObject != null && !state.linkedWithSequencer)
{
return GetCurrentValue(state, curve.binding);
}
Expand Down
8 changes: 4 additions & 4 deletions 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 All @@ -163,7 +163,7 @@ private float windowHeight
modes = Styles.sBuiltinCameraModes.Count(mode => m_SceneView.IsCameraDrawModeSupported(mode) && mode.show) +
SceneView.userDefinedModes.Count(mode => m_SceneView.IsCameraDrawModeSupported(mode) && mode.show);

return UpdatedHeight(headers, modes, GraphicsSettings.renderPipelineAsset != null);
return UpdatedHeight(headers, modes, GraphicsSettings.isScriptableRenderPipelineEnabled);
}
}

Expand Down Expand Up @@ -295,7 +295,7 @@ private void Draw(float listElementWidth)
}
}

if (GraphicsSettings.renderPipelineAsset != null)
if (GraphicsSettings.isScriptableRenderPipelineEnabled)
{
DrawSeparator(ref drawPos);
DrawRenderingDebuggerShortCut(drawPos);
Expand Down Expand Up @@ -339,7 +339,7 @@ private float RecalculateWindowHeight()
}
}

return UpdatedHeight(headers, modes, GraphicsSettings.renderPipelineAsset != null);
return UpdatedHeight(headers, modes, GraphicsSettings.isScriptableRenderPipelineEnabled);
}

private float UpdatedHeight(int headers, int modes, bool isSRP)
Expand Down
3 changes: 3 additions & 0 deletions Editor/Mono/AssemblyInfo/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
[assembly: InternalsVisibleTo("Unity.Muse.Common.Bridge")]
[assembly: InternalsVisibleTo("Unity.Muse.Chat.Bridge")]

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

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

// This should move with the AnimationWindow to a module at some point
Expand Down
9 changes: 7 additions & 2 deletions Editor/Mono/AssetPipeline/TextureGenerator.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,16 @@ public static unsafe class TextureGenerator
{
public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, NativeArray<Color32> colorBuffer)
{
return GenerateTextureImpl(settings, colorBuffer.GetUnsafeReadOnlyPtr(), colorBuffer.Length * UnsafeUtility.SizeOf<Color32>());
return GenerateTextureImpl(settings, colorBuffer.GetUnsafeReadOnlyPtr(), colorBuffer.Length * UnsafeUtility.SizeOf<Color32>(), 4);
}

public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, NativeArray<Color> colorBuffer)
{
return GenerateTextureImpl(settings, colorBuffer.GetUnsafeReadOnlyPtr(), colorBuffer.Length * UnsafeUtility.SizeOf<Color>(), 16);
}

[NativeThrows]
[NativeMethod("GenerateTextureScripting")]
extern static unsafe TextureGenerationOutput GenerateTextureImpl(TextureGenerationSettings settings, void* colorBuffer, int colorBufferLength);
extern static unsafe TextureGenerationOutput GenerateTextureImpl(TextureGenerationSettings settings, void* colorBuffer, int colorBufferLength, int bytesPerPixel);
}
}
15 changes: 15 additions & 0 deletions Editor/Mono/Audio/AudioContainerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ void OnDisable()
m_AddedElements.Clear();
}

private void OnFocus()
{
if (State.AudioContainer != null)
{
UpdateTransportButtonStates();
}
}

void Update()
{
if (!m_IsVisible)
Expand Down Expand Up @@ -232,6 +240,7 @@ void CreateGUI()

m_Day0RootVisualElement.style.display = DisplayStyle.None;
m_ContainerRootVisualElement.style.display = DisplayStyle.Flex;
m_CachedElements = State.AudioContainer.elements.ToList();
m_ClipsListView.Rebuild(); // Force a list rebuild when the list has changed or it will not always render correctly due to a UI toolkit bug.
}
}
Expand Down Expand Up @@ -519,12 +528,14 @@ void OnVolumeRandomizationEnabledChanged(SerializedProperty property)
m_VolumeRandomizationButtonImage.style.backgroundImage = new StyleBackground(m_DiceIconOn);
m_VolumeRandomizationRangeSlider.SetEnabled(true);
m_VolumeRandomizationRangeField.SetEnabled(true);
m_VolumeRandomRangeTracker.SetEnabled(true);
}
else
{
m_VolumeRandomizationButtonImage.style.backgroundImage = new StyleBackground(m_DiceIconOff);
m_VolumeRandomizationRangeSlider.SetEnabled(false);
m_VolumeRandomizationRangeField.SetEnabled(false);
m_VolumeRandomRangeTracker.SetEnabled(false);
}
}

Expand Down Expand Up @@ -624,12 +635,14 @@ void OnPitchRandomizationEnabledChanged(SerializedProperty property)
m_PitchRandomizationButtonImage.style.backgroundImage = new StyleBackground(m_DiceIconOn);
m_PitchRandomizationRangeSlider.SetEnabled(true);
m_PitchRandomizationRangeField.SetEnabled(true);
m_PitchRandomRangeTracker.SetEnabled(true);
}
else
{
m_PitchRandomizationButtonImage.style.backgroundImage = new StyleBackground(m_DiceIconOff);
m_PitchRandomizationRangeSlider.SetEnabled(false);
m_PitchRandomizationRangeField.SetEnabled(false);
m_PitchRandomRangeTracker.SetEnabled(false);
}
}

Expand Down Expand Up @@ -1190,12 +1203,14 @@ void OnTimeRandomizationEnabledChanged(SerializedProperty property)
m_TimeRandomizationButtonImage.style.backgroundImage = new StyleBackground(m_DiceIconOn);
m_TimeRandomizationRangeSlider.SetEnabled(true);
m_TimeRandomizationRangeField.SetEnabled(true);
m_TimeRandomRangeTracker.SetEnabled(true);
}
else
{
m_TimeRandomizationButtonImage.style.backgroundImage = new StyleBackground(m_DiceIconOff);
m_TimeRandomizationRangeSlider.SetEnabled(false);
m_TimeRandomizationRangeField.SetEnabled(false);
m_TimeRandomRangeTracker.SetEnabled(false);
}
}

Expand Down
23 changes: 18 additions & 5 deletions Editor/Mono/Audio/UIElements/AudioRandomRangeSliderTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;
using System.Transactions;
using UnityEngine;
using UnityEngine.UIElements;

Expand All @@ -16,11 +17,12 @@ class AudioRandomRangeSliderTracker : VisualElement
public override object CreateInstance() => new AudioRandomRangeSliderTracker();
}

static readonly CustomStyleProperty<Color> s_TrackerColorProperty = new("--tracker-color");
static readonly CustomStyleProperty<Color> s_TrackerEnabledColorProperty = new("--tracker-color");

Slider m_ParentSlider;
Vector2 m_Range = Vector2.zero;
Color m_TrackerColor;
Color m_TrackerEnabledColor;
Color m_TrackerDisabledColor = Color.gray;

static void CustomStylesResolved(CustomStyleResolvedEvent evt)
{
Expand All @@ -31,9 +33,9 @@ static void CustomStylesResolved(CustomStyleResolvedEvent evt)

void UpdateCustomStyles()
{
if (customStyle.TryGetValue(s_TrackerColorProperty, out var trackerColor))
if (customStyle.TryGetValue(s_TrackerEnabledColorProperty, out var trackerColor))
{
m_TrackerColor = trackerColor;
m_TrackerEnabledColor = trackerColor;
}
}

Expand All @@ -54,6 +56,7 @@ internal static AudioRandomRangeSliderTracker Create(Slider parentSlider, Vector
rangeTracker.generateVisualContent += GenerateVisualContent;
rangeTracker.RegisterCallback<CustomStyleResolvedEvent>(CustomStylesResolved);
rangeTracker.m_ParentSlider.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
rangeTracker.RegisterCallback<PropertyChangedEvent>(OnPropertyChanged);

return rangeTracker;
}
Expand All @@ -72,6 +75,16 @@ static void OnGeometryChanged(GeometryChangedEvent evt)
sliderTracker.SetRange(sliderTracker.m_Range);
}

static void OnPropertyChanged(PropertyChangedEvent evt)
{
var sliderTracker = evt.elementTarget;

if (evt.property == "enabledSelf")
{
sliderTracker.MarkDirtyRepaint();
}
}

// Maps 'x' from the range '[x_min; x_max]' to the range '[y_min; y_max]'.
static float Map(float x, float x_min, float x_max, float y_min, float y_max)
{
Expand Down Expand Up @@ -102,7 +115,7 @@ static void GenerateVisualContent(MeshGenerationContext context)
right = Mathf.Clamp(right, contentRect.xMin, contentRect.xMax);

// Draw the tracker.
painter2D.fillColor = sliderTracker.m_TrackerColor;
painter2D.fillColor = sliderTracker.enabledSelf ? sliderTracker.m_TrackerEnabledColor : sliderTracker.m_TrackerDisabledColor;
painter2D.BeginPath();
painter2D.MoveTo(new Vector2(left, contentRect.yMin));
painter2D.LineTo(new Vector2(right, contentRect.yMin));
Expand Down
2 changes: 2 additions & 0 deletions Editor/Mono/BaseBuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal abstract class BaseBuildTarget : IBuildTarget

public abstract RuntimePlatform RuntimePlatform { get; }
public abstract string TargetName { get; }
public abstract GUID Guid { get; }

public abstract int GetLegacyId { get; }

public virtual IBuildPlatformProperties BuildPlatformProperties => Properties as IBuildPlatformProperties;
Expand Down
31 changes: 31 additions & 0 deletions Editor/Mono/BuildPipeline.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using UnityEditor.Scripting.ScriptCompilation;
using System.Runtime.InteropServices;
using UnityEditor.Build;
using UnityEditor.Build.Profile;
using UnityEngine.Scripting;

namespace UnityEditor
Expand Down Expand Up @@ -223,6 +224,14 @@ public struct BuildPlayerOptions
public string[] extraScriptingDefines { get; set; }
}

public struct BuildPlayerWithProfileOptions
{
public BuildProfile buildProfile { get; set; }
public string locationPathName { get; set; }
public string assetBundleManifestPath { get; set; }
public BuildOptions options { get; set; }
}

internal struct BuildPlayerDataOptions
{
public string[] scenes { get; set; }
Expand Down Expand Up @@ -276,6 +285,10 @@ public class BuildPipeline
[FreeFunction(IsThreadSafe = true)]
internal static extern string GetEditorTargetName();

[NativeHeader("Editor/Src/BuildPipeline/BuildPlayerHelpers.h")]
[FreeFunction]
internal static extern void ShowBuildProfileWindow();

[Obsolete("PushAssetDependencies has been made obsolete. Please use the new AssetBundle build system introduced in 5.0 and check BuildAssetBundles documentation for details.", true)]
[FreeFunction]
public static extern void PushAssetDependencies();
Expand All @@ -302,6 +315,24 @@ internal static BuildPlayerContext PreparePlayerBuild(BuildPlayerOptions buildPl
return buildPlayerContext;
}

/// <summary>
/// Builds a player.
/// </summary>
/// <param name="buildPlayerWithProfileOptions">The BuildPlayerWithProfileOptions to be built with.</param>
/// <returns>A BuildReport giving build process information.</returns>
/// <exception cref="ArgumentException">Throws if build profile is null.</exception>
public static BuildReport BuildPlayer(BuildPlayerWithProfileOptions buildPlayerWithProfileOptions)
{
var buildProfile = buildPlayerWithProfileOptions.buildProfile;
if (buildProfile == null)
throw new ArgumentException("Build profile is invalid.");

BuildProfileContext.instance.activeProfile = buildProfile;
var buildPlayerOptions = BuildProfileModuleUtil.GetBuildPlayerOptionsFromActiveProfile(
buildPlayerWithProfileOptions.locationPathName, buildPlayerWithProfileOptions.assetBundleManifestPath, buildPlayerWithProfileOptions.options);
return BuildPlayer(buildPlayerOptions);
}

public static BuildReport BuildPlayer(EditorBuildSettingsScene[] levels, string locationPathName, BuildTarget target, BuildOptions options)
{
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
Expand Down
43 changes: 18 additions & 25 deletions Editor/Mono/BuildPipeline/BuildPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using System;
using System.Collections.Generic;
using DiscoveredTargetInfo = UnityEditor.BuildTargetDiscovery.DiscoveredTargetInfo;
using TargetAttributes = UnityEditor.BuildTargetDiscovery.TargetAttributes;

namespace UnityEditor.Build
{
// All settings for a build platform.
internal class BuildPlatform
internal class BuildPlatform : ICloneable
{
// short name used for texture settings, etc.
public string name;
Expand Down Expand Up @@ -38,13 +39,24 @@ public BuildPlatform(string locTitle, string tooltip, string iconId, NamedBuildT
{
this.namedBuildTarget = namedBuildTarget;
name = namedBuildTarget.TargetName;
m_Title = new ScalableGUIContent(locTitle, null, iconId);

// Workaround for some platforms which have | in their name which is also used as separator for tooltips
if (locTitle.Contains("|"))
m_Title = new ScalableGUIContent(locTitle.Replace("|", " "), null, iconId);
else
m_Title = new ScalableGUIContent(locTitle, null, iconId);

m_SmallTitle = new ScalableGUIContent(null, null, iconId + ".Small");
this.tooltip = tooltip;
this.hideInUi = hideInUi;
this.defaultTarget = defaultTarget;
this.installed = installed;
}

public object Clone()
{
return MemberwiseClone();
}
}

internal class BuildPlatformWithSubtarget : BuildPlatform
Expand Down Expand Up @@ -132,29 +144,10 @@ public string GetBuildTargetDisplayName(NamedBuildTarget namedBuildTarget, Build
}

var suffix = namedBuildTarget == NamedBuildTarget.Server ? " Server" : "";

switch (target)
{
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
return $"Windows{suffix}";
case BuildTarget.StandaloneOSX:
// Deprecated
#pragma warning disable 612, 618
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
#pragma warning restore 612, 618
return $"macOS{suffix}";
// Deprecated
#pragma warning disable 612, 618
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneLinuxUniversal:
#pragma warning restore 612, 618
case BuildTarget.StandaloneLinux64:
return $"Linux{suffix}";
}

return "Unsupported Target";
#pragma warning disable CS0618 // Member is obsolete
string targetName = BuildTargetDiscovery.BuildPlatformDisplayName(target) + suffix;
#pragma warning restore CS0618
return targetName.Length == 0 ? "Unsupported Target" : targetName;
}

public string GetModuleDisplayName(NamedBuildTarget namedBuildTarget, BuildTarget buildTarget)
Expand Down
Loading

0 comments on commit 9778aae

Please sign in to comment.