Skip to content

Commit c4aff6a

Browse files
author
Unity Technologies
committed
Unity 6000.2.0a8 C# reference source code
1 parent b1cf2a8 commit c4aff6a

File tree

511 files changed

+18355
-7647
lines changed

Some content is hidden

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

511 files changed

+18355
-7647
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public class Services
114114
public bool EnablePerformanceReporting;
115115
public bool EnableAnalytics;
116116
public bool EnableCrashReporting;
117+
public bool EnableInsights;
117118
}
118119

119120
public class StreamingAssetsFile

Editor/IncrementalBuildPipeline/ScriptCompilationBuildProgram.Data/Data.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class AssemblyData
5656
public class ScriptCompilationData_Out
5757
{
5858
public AssemblyData_Out[] Assemblies;
59+
public bool LocalizeCompilerMessages;
5960
}
6061

6162
public class AssemblyData_Out

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@
183183

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

186-
// This should move with the AnimationWindow to a module at some point
187-
[assembly: InternalsVisibleTo("UnityEditor.Modules.Animation.tests.AnimationWindow")]
188-
189-
[assembly: InternalsVisibleTo("UnityEditor.Modules.Physics.Tests")]
190186

191187
[assembly: InternalsVisibleTo("UnityEditor.Switch.Tests")]
192188

@@ -201,3 +197,9 @@
201197

202198
[assembly: InternalsVisibleTo("Unity.GraphToolsAuthoringFramework.InternalEditorBridge")]
203199

200+
// Module test assemblies
201+
[assembly: InternalsVisibleTo("Unity.Modules.Licensing.Tests.Editor")]
202+
// This should move with the AnimationWindow to a module at some point
203+
[assembly: InternalsVisibleTo("Unity.Modules.Animation.AnimationWindow.Tests.Editor")]
204+
[assembly: InternalsVisibleTo("Unity.Modules.Physics.Tests.Editor")]
205+

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ static ulong ComputeDefaultShaderHash()
317317

318318
static void DirtyCustomDependencies()
319319
{
320-
DateTime now = DateTime.Now;
321-
if (Application.isPlaying || now - s_LastCheck < k_CheckDependencyFrequency)
320+
DateTime now = DateTime.UtcNow;
321+
if (Application.isPlaying || ((now - s_LastCheck) < k_CheckDependencyFrequency))
322322
{
323323
return;
324324
}

Editor/Mono/BaseBuildTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ internal abstract class BaseBuildTarget : IBuildTarget
2929
public virtual IUIPlatformProperties UIPlatformProperties => Properties as IUIPlatformProperties;
3030
public virtual IAudioPlatformProperties AudioPlatformProperties => Properties as IAudioPlatformProperties;
3131
public virtual IVRPlatformProperties VRPlatformProperties => Properties as IVRPlatformProperties;
32+
public virtual ISubtargetPlatformProperties TextureSubtargetPlatformProperties => Properties as ISubtargetPlatformProperties;
3233

3334
protected virtual IPlatformProperties Properties => null;
3435

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,29 @@ public static string WriteEditorData(BuildPostProcessArgs args, NPath linkerInpu
300300
return items;
301301
}
302302

303+
private class AssemblyStripperModuleAdder : IPreStrippingModuleAdder
304+
{
305+
private List<string> m_ForceIncludes;
306+
307+
public AssemblyStripperModuleAdder(List<string> forceIncludes)
308+
{
309+
m_ForceIncludes = forceIncludes;
310+
}
311+
312+
public void AddModule(string moduleName)
313+
{
314+
if (IsModuleIncluded(moduleName))
315+
return;
316+
317+
m_ForceIncludes.Add(moduleName);
318+
}
319+
320+
public bool IsModuleIncluded(string moduleName)
321+
=> m_ForceIncludes.Any(i => string.Equals(i, moduleName));
322+
}
323+
324+
public static event Action<IPreStrippingModuleAdder> onCollectIncludedModules;
325+
303326
static void CollectIncludedAndExcludedModules(out List<string> forceInclude, out List<string> forceExclude)
304327
{
305328
forceInclude = new List<string>();
@@ -313,6 +336,9 @@ static void CollectIncludedAndExcludedModules(out List<string> forceInclude, out
313336
else if (includeSetting == ModuleIncludeSetting.ForceExclude)
314337
forceExclude.Add(module);
315338
}
339+
340+
var adder = new AssemblyStripperModuleAdder(forceInclude);
341+
onCollectIncludedModules?.Invoke(adder);
316342
}
317343

318344
private static NPath WriteMethodsToPreserveBlackList(RuntimeClassRegistry rcr, NPath linkerInputDirectory)

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,20 @@ static void UpdateActiveProfilePlayerSettingsObjectFromYAML()
808808
activeProfile?.UpdatePlayerSettingsObjectFromYAML();
809809
}
810810

811+
[RequiredByNativeCode]
812+
static void SerializeActiveProfilePlayerSettings()
813+
{
814+
var profile = EditorUserBuildSettings.activeBuildProfile;
815+
if (profile == null)
816+
return;
817+
818+
if (!EditorUtility.IsDirty(profile.playerSettings))
819+
return;
820+
821+
profile.SerializePlayerSettings();
822+
}
823+
824+
811825
static bool ShouldReturnActiveProfile(GUID platformGuid, string sharedSetting = null)
812826
{
813827
if (!string.IsNullOrEmpty(sharedSetting))

Editor/Mono/BuildProfile/BuildProfileGraphicsSettingsEditor.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using UnityEngine.Bindings;
88
using UnityEngine.UIElements;
99
using UnityEngine.Rendering;
10+
using UnityEngine;
1011

1112
namespace UnityEditor.Build.Profile
1213
{
@@ -33,6 +34,8 @@ public override VisualElement CreateInspectorGUI()
3334
BindEnumFieldWithFadeGroup(root, "Lightmap", CalculateLightmapStrippingFromCurrentScene);
3435
BindEnumFieldWithFadeGroup(root, "Fog", CalculateFogStrippingFromCurrentScene);
3536

37+
BindShaderPreload(root);
38+
3639
// Align fields as in the inspector
3740
var type = typeof(BaseField<>);
3841
root.Query<BindableElement>()
@@ -59,6 +62,57 @@ void BindEnumFieldWithFadeGroup(VisualElement content, string id, Action buttonC
5962
content.MandatoryQ<Button>($"Import{id}FromCurrentScene").clicked += buttonCallback;
6063
}
6164

65+
void BindShaderPreload(VisualElement root)
66+
{
67+
var shaderPreloadProperty = serializedObject.FindProperty("m_PreloadedShaders");
68+
shaderPreloadProperty.isExpanded = false;
69+
70+
var delayedShaderTimeLimitProperty = serializedObject.FindProperty("m_PreloadShadersBatchTimeLimit");
71+
var shaderPreloadToggle = root.MandatoryQ<Toggle>("ShaderPreloadToggle");
72+
var delayedShaderTimeLimitGroup = root.MandatoryQ<VisualElement>("DelayedShaderTimeLimitGroup");
73+
var delayedShaderTimeLimit = root.MandatoryQ<IntegerField>("DelayedShaderTimeLimit");
74+
shaderPreloadToggle.RegisterValueChangedCallback(evt => {
75+
delayedShaderTimeLimitGroup.style.display = evt.newValue ? DisplayStyle.Flex : DisplayStyle.None;
76+
var newVal = evt.newValue ? delayedShaderTimeLimit.value : -1;
77+
if (delayedShaderTimeLimitProperty.intValue != newVal)
78+
{
79+
delayedShaderTimeLimitProperty.intValue = newVal;
80+
delayedShaderTimeLimitProperty.serializedObject.ApplyModifiedProperties();
81+
}
82+
});
83+
delayedShaderTimeLimit.RegisterValueChangedCallback(evt =>
84+
{
85+
if (delayedShaderTimeLimitProperty.intValue != evt.newValue)
86+
{
87+
delayedShaderTimeLimitProperty.intValue = evt.newValue;
88+
delayedShaderTimeLimitProperty.serializedObject.ApplyModifiedProperties();
89+
}
90+
});
91+
shaderPreloadToggle.SetValueWithoutNotify(delayedShaderTimeLimitProperty.intValue >= 0);
92+
delayedShaderTimeLimit.SetValueWithoutNotify(Mathf.Max(0, delayedShaderTimeLimitProperty.intValue));
93+
delayedShaderTimeLimitGroup.style.display = delayedShaderTimeLimitProperty.intValue >= 0 ? DisplayStyle.Flex : DisplayStyle.None;
94+
95+
var shaderTracking = root.MandatoryQ<HelpBox>("ShaderTrackingInfoBox");
96+
shaderTracking.schedule.Execute(() =>
97+
shaderTracking.text =
98+
$"Currently tracked: {ShaderUtil.GetCurrentShaderVariantCollectionShaderCount()} shaders {ShaderUtil.GetCurrentShaderVariantCollectionVariantCount()} total variants").Every(500);
99+
100+
var saveButton = root.MandatoryQ<Button>("SaveShaderVariants");
101+
saveButton.clickable = new Clickable(() =>
102+
{
103+
var assetPath = EditorUtility.SaveFilePanelInProject(
104+
L10n.Tr("Save Shader Variant Collection"),
105+
"NewShaderVariants",
106+
"shadervariants",
107+
L10n.Tr("Save shader variant collection"),
108+
ProjectWindowUtil.GetActiveFolderPath());
109+
if (!string.IsNullOrEmpty(assetPath))
110+
ShaderUtil.SaveCurrentShaderVariantCollection(assetPath);
111+
});
112+
var clearButton = root.MandatoryQ<Button>("ClearCurrentShaderVariants");
113+
clearButton.clickable = new Clickable(ShaderUtil.ClearCurrentShaderVariantCollection);
114+
}
115+
62116
void CalculateLightmapStrippingFromCurrentScene()
63117
{
64118
bool lightmapKeepPlain, lightmapKeepDirCombined, lightmapKeepDynamicPlain, lightmapKeepDynamicDirCombined, lightmapKeepShadowMask, lightmapKeepSubtractive;

Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using UnityEngine.UIElements;
1414
using TargetAttributes = UnityEditor.BuildTargetDiscovery.TargetAttributes;
1515
using UnityEditor.Profiling;
16+
using InternalEditorUtility = UnityEditorInternal.InternalEditorUtility;
1617

1718
namespace UnityEditor.Build.Profile
1819
{
@@ -33,6 +34,7 @@ internal class BuildProfileModuleUtil
3334
public const int k_MaxAssetFileNameLengthWithoutExtension = k_MaxAssetFileNameLength - 6;
3435
static readonly string k_NoModuleLoaded = L10n.Tr("No {0} module loaded.");
3536
static readonly string k_DerivedPlatformInactive = L10n.Tr("{0} is currently disabled.");
37+
static readonly string k_DerivedPlatformDisabled = L10n.Tr("{0} was disabled via command-line arguments.");
3638
static readonly string k_EditorWillNeedToBeReloaded = L10n.Tr("Note: Editor will need to be restarted to load any newly installed modules");
3739
static readonly string k_BuildProfileRecompileReason = L10n.Tr("Active build profile scripting defines changes.");
3840
static readonly GUIContent k_OpenDownloadPage = EditorGUIUtility.TrTextContent("Open Download Page");
@@ -187,11 +189,29 @@ public static VisualElement CreateModuleNotInstalledElement(GUID platformId)
187189
});
188190
}
189191

192+
if (IsBuildProfileDisabledViaArguments(platformId))
193+
return new IMGUIContainer(() =>
194+
{
195+
GUILayout.Label(EditorGUIUtility.TextContent(string.Format(k_DerivedPlatformDisabled, BuildTargetDiscovery.BuildPlatformDisplayName(platformId))));
196+
});
197+
190198
return new IMGUIContainer(
191199
() => BuildPlayerWindow.ShowNoModuleLabel(platformId,
192200
k_NoModuleLoaded, k_OpenDownloadPage, k_InstallModuleWithHub, k_EditorWillNeedToBeReloaded));
193201
}
194202

203+
static bool IsBuildProfileDisabledViaArguments(GUID platformId)
204+
{
205+
var (buildTarget, _) = BuildTargetDiscovery.GetBuildTargetAndSubtargetFromGUID(platformId);
206+
var buildTargetInfoList = BuildTargetDiscovery.GetBuildTargetInfoList();
207+
208+
foreach (var info in buildTargetInfoList)
209+
if (info.buildTargetPlatformVal.Equals(buildTarget))
210+
return InternalEditorUtility.IsPlaybackEngineDisabled(info.dirName);
211+
212+
return false;
213+
}
214+
195215
/// <summary>
196216
/// Exported from <see cref="BuildPlayerWindow"/>, UI code specifically for when current license does not cover
197217
/// BuildTarget.
@@ -247,7 +267,7 @@ public static string GetModuleName(GUID platformId)
247267
/// </summary>
248268
public static void SwitchLegacyActiveFromBuildProfile(BuildProfile profile)
249269
{
250-
EditorUserBuildSettings.SwitchActiveBuildTargetGuid(profile.platformGuid);
270+
EditorUserBuildSettings.SwitchActiveBuildTargetGuid(profile);
251271
}
252272

253273
public static void SwitchLegacySelectedBuildTargets(BuildProfile profile)

Editor/Mono/BuildProfile/BuildProfilePlatformSettingsBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ internal protected virtual bool installInBuildFolder
117117
set => m_InstallInBuildFolder = value;
118118
}
119119

120+
120121
/// <summary>
121122
/// Set platform setting based on strings for name and value. Native
122123
/// calls this to keep build profiles and EditorUserBuildSettings

Editor/Mono/BuildProfile/BuildProfilePlayerSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,16 @@ internal void DeserializePlayerSettings()
198198
if (!HasSerializedPlayerSettings())
199199
return;
200200

201+
var isDirtyBeforeDeserialize = EditorUtility.IsDirty(m_PlayerSettings);
201202
if (m_PlayerSettings == null)
202203
m_PlayerSettings = PlayerSettings.DeserializeFromYAMLString(m_PlayerSettingsYaml.GetYamlString());
203204
else
204205
UpdatePlayerSettingsObjectFromYAML();
205206
s_LoadedPlayerSettings.Add(m_PlayerSettings);
206207

208+
if (!isDirtyBeforeDeserialize)
209+
EditorUtility.ClearDirty(m_PlayerSettings);
210+
207211
PlayerSettings.EnsureUnityConnectSettingsEqual(m_PlayerSettings, s_GlobalPlayerSettings);
208212
UpdateGlobalManagerPlayerSettings();
209213
}

Editor/Mono/ConsoleWindow.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,16 +789,13 @@ const bool
789789
if (rowDoubleClicked != -1)
790790
LogEntries.RowGotDoubleClicked(rowDoubleClicked);
791791

792-
793792
// Display active text (We want word wrapped text with a vertical scrollbar)
794-
m_TextScroll = GUILayout.BeginScrollView(m_TextScroll, Constants.Box);
795-
796793
string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText, m_CallstackTextStart, s_StripLoggingCallstack, m_ActiveMode);
797794
float height = Constants.MessageStyle.CalcHeight(GUIContent.Temp(stackWithHyperlinks), position.width);
798-
EditorGUILayout.SelectableLabel(stackWithHyperlinks, Constants.MessageStyle,
799-
GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height + 10));
800795

801-
GUILayout.EndScrollView();
796+
var rect = EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height + 10));
797+
EditorGUI.ScrollableLabelAreaInternal(rect, stackWithHyperlinks, ref m_TextScroll, Constants.MessageStyle);
798+
EditorGUILayout.EndHorizontal();
802799

803800
SplitterGUILayout.EndVerticalSplit();
804801
}

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/DeploymentTargets/DeploymentTargetManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class DeploymentTargetManager
1616
readonly IDeploymentTargetsMainThreadContext m_Context;
1717

1818
public IDeploymentTargetsMainThreadContext Context { get { return m_Context; }}
19+
public IDeploymentTargetsExtension Extension { get { return m_Extension; } }
1920

2021
public static DeploymentTargetManager CreateInstance(BuildTarget buildTarget, bool setup = true)
2122
{

Editor/Mono/DeploymentTargets/IDeploymentTargetsExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public DeploymentOperationFailedException(string title, string message, DefaultD
151151
{
152152
this.title = title;
153153
this.launchResult = result;
154-
if (result != null && !result.Success)
154+
if (result != null && result.Success)
155155
Debug.LogWarning($"Creating DeploymentOperationFailedException('{title}') , but launch result says it's succeeded?");
156156
}
157157
}

Editor/Mono/EditorApplication.bindings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace UnityEditor
2121
[NativeHeader("Runtime/Input/TimeManager.h")]
2222
[NativeHeader("Editor/Src/ProjectVersion.h")]
2323
[NativeHeader("Runtime/Misc/BuildSettings.h")]
24+
[NativeHeader("Runtime/Interfaces/ILicensing.h")]
2425
[StaticAccessor("EditorApplicationBindings", StaticAccessorType.DoubleColon)]
2526
public sealed partial class EditorApplication
2627
{
@@ -146,7 +147,7 @@ public static ScriptingRuntimeVersion scriptingRuntimeVersion
146147
get { return ScriptingRuntimeVersion.Latest; }
147148
}
148149

149-
[StaticAccessor("GetApplication()", StaticAccessorType.Dot)]
150+
[StaticAccessor("GetILicensing()", StaticAccessorType.Arrow)]
150151
internal static extern string GetLicenseType();
151152

152153
// Prevents loading of assemblies when it is inconvenient.

0 commit comments

Comments
 (0)