Skip to content

Commit 51ea2cc

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a5 C# reference source code
1 parent 8a74505 commit 51ea2cc

File tree

646 files changed

+14315
-8514
lines changed

Some content is hidden

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

646 files changed

+14315
-8514
lines changed

Editor/Mono/2D/SpriteAtlas/EditorSpriteAtlas.bindings.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,34 @@ public struct SpriteAtlasPackingSettings
9696
[NativeHeader("Runtime/2D/SpriteAtlas/SpriteAtlas.h")]
9797
public static class SpriteAtlasExtensions
9898
{
99-
extern public static void Add([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, UnityEngine.Object[] objects);
100-
extern public static void Remove([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, UnityEngine.Object[] objects);
101-
extern internal static void RemoveAt([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, int index);
102-
extern public static UnityEngine.Object[] GetPackables([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
103-
extern public static SpriteAtlasTextureSettings GetTextureSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
104-
extern public static void SetTextureSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, SpriteAtlasTextureSettings src);
105-
extern public static SpriteAtlasPackingSettings GetPackingSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
106-
extern public static void SetPackingSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, SpriteAtlasPackingSettings src);
107-
extern public static TextureImporterPlatformSettings GetPlatformSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, string buildTarget);
108-
extern public static void SetPlatformSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src);
109-
extern public static void SetIncludeInBuild([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, bool value);
110-
extern public static void SetIsVariant([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, bool value);
111-
extern public static void SetMasterAtlas([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, SpriteAtlas value);
112-
extern public static void SetVariantScale([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, float value);
113-
extern public static bool IsIncludeInBuild([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
114-
extern public static SpriteAtlas GetMasterAtlas([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
115-
extern internal static void CopyMasterAtlasSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
116-
extern internal static string GetHash([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
117-
extern internal static Texture2D[] GetPreviewTextures([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
118-
extern internal static Texture2D[] GetPreviewAlphaTextures([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
119-
extern internal static TextureFormat GetTextureFormat([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, BuildTarget target);
120-
extern internal static Sprite[] GetPackedSprites([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
121-
extern internal static Hash128 GetStoredHash([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
122-
extern internal static TextureImporterPlatformSettings GetSecondaryPlatformSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, string buildTarget, string secondaryTextureName);
123-
extern internal static void SetSecondaryPlatformSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src, string secondaryTextureName);
124-
extern internal static bool GetSecondaryColorSpace([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, string secondaryTextureName);
125-
extern internal static void SetSecondaryColorSpace([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, string secondaryTextureName, bool srGB);
126-
extern internal static void DeleteSecondaryPlatformSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, string secondaryTextureName);
99+
extern public static void Add([NotNull] this SpriteAtlas spriteAtlas, UnityEngine.Object[] objects);
100+
extern public static void Remove([NotNull] this SpriteAtlas spriteAtlas, UnityEngine.Object[] objects);
101+
extern internal static void RemoveAt([NotNull] this SpriteAtlas spriteAtlas, int index);
102+
extern public static UnityEngine.Object[] GetPackables([NotNull] this SpriteAtlas spriteAtlas);
103+
extern public static SpriteAtlasTextureSettings GetTextureSettings([NotNull] this SpriteAtlas spriteAtlas);
104+
extern public static void SetTextureSettings([NotNull] this SpriteAtlas spriteAtlas, SpriteAtlasTextureSettings src);
105+
extern public static SpriteAtlasPackingSettings GetPackingSettings([NotNull] this SpriteAtlas spriteAtlas);
106+
extern public static void SetPackingSettings([NotNull] this SpriteAtlas spriteAtlas, SpriteAtlasPackingSettings src);
107+
extern public static TextureImporterPlatformSettings GetPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, string buildTarget);
108+
extern public static void SetPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src);
109+
extern public static void SetIncludeInBuild([NotNull] this SpriteAtlas spriteAtlas, bool value);
110+
extern public static void SetIsVariant([NotNull] this SpriteAtlas spriteAtlas, bool value);
111+
extern public static void SetMasterAtlas([NotNull] this SpriteAtlas spriteAtlas, SpriteAtlas value);
112+
extern public static void SetVariantScale([NotNull] this SpriteAtlas spriteAtlas, float value);
113+
extern public static bool IsIncludeInBuild([NotNull] this SpriteAtlas spriteAtlas);
114+
extern public static SpriteAtlas GetMasterAtlas([NotNull] this SpriteAtlas spriteAtlas);
115+
extern internal static void CopyMasterAtlasSettings([NotNull] this SpriteAtlas spriteAtlas);
116+
extern internal static string GetHash([NotNull] this SpriteAtlas spriteAtlas);
117+
extern internal static Texture2D[] GetPreviewTextures([NotNull] this SpriteAtlas spriteAtlas);
118+
extern internal static Texture2D[] GetPreviewAlphaTextures([NotNull] this SpriteAtlas spriteAtlas);
119+
extern internal static TextureFormat GetTextureFormat([NotNull] this SpriteAtlas spriteAtlas, BuildTarget target);
120+
extern internal static Sprite[] GetPackedSprites([NotNull] this SpriteAtlas spriteAtlas);
121+
extern internal static Hash128 GetStoredHash([NotNull] this SpriteAtlas spriteAtlas);
122+
extern internal static TextureImporterPlatformSettings GetSecondaryPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, string buildTarget, string secondaryTextureName);
123+
extern internal static void SetSecondaryPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src, string secondaryTextureName);
124+
extern internal static bool GetSecondaryColorSpace([NotNull] this SpriteAtlas spriteAtlas, string secondaryTextureName);
125+
extern internal static void SetSecondaryColorSpace([NotNull] this SpriteAtlas spriteAtlas, string secondaryTextureName, bool srGB);
126+
extern internal static void DeleteSecondaryPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, string secondaryTextureName);
127127
extern internal static string GetSecondaryTextureNameInAtlas(string atlasTextureName);
128128
extern internal static string GetPageNumberInAtlas(string atlasTextureName);
129129
}

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public static AnimationEvent[] GetAnimationEvents(AnimationClip clip)
394394
blittableEvent.Dispose();
395395
return animationEvents;
396396
}
397+
[return:Unmarshalled]
397398
extern internal static AnimationEventBlittable[] GetAnimationEventsInternal([NotNull] AnimationClip clip);
398399
public static void SetAnimationEvents(AnimationClip clip, AnimationEvent[] events)
399400
{

Editor/Mono/AnimatorController.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static public StateMachineBehaviourContext[] FindStateMachineBehaviourContext(St
8787
extern internal MonoScript GetBehaviourMonoScript(AnimatorState state, int layerIndex, int behaviourIndex);
8888

8989
[FreeFunction]
90-
extern private static ScriptableObject ScriptingAddStateMachineBehaviourWithType(Type stateMachineBehaviourType, [NotNull("NullExceptionObject")] AnimatorController controller, [NotNull("NullExceptionObject")] AnimatorState state, int layerIndex);
90+
extern private static ScriptableObject ScriptingAddStateMachineBehaviourWithType(Type stateMachineBehaviourType, [NotNull] AnimatorController controller, [NotNull] AnimatorState state, int layerIndex);
9191

9292

9393
[TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,18 @@ private enum EnabledState
7878

7979
const int maxShowRecent = 5;
8080
readonly string textGizmoVisible = L10n.Tr("Show/Hide Gizmo");
81+
GUIContent generalContent = EditorGUIUtility.TrTextContent("General");
8182
GUIContent iconToggleContent = EditorGUIUtility.TrTextContent("", "Show/Hide Icon");
8283
GUIContent iconSelectContent = EditorGUIUtility.TrTextContent("", "Select Icon");
8384
GUIContent icon3dGizmoContent = EditorGUIUtility.TrTextContent("3D Icons");
8485
GUIContent terrainDebugWarnings = EditorGUIUtility.TrTextContent("Terrain Debug Warnings");
8586
GUIContent showOutlineContent = EditorGUIUtility.TrTextContent("Selection Outline");
8687
GUIContent showWireframeContent = EditorGUIUtility.TrTextContent("Selection Wire");
8788
GUIContent fadeGizmosContent = EditorGUIUtility.TrTextContent("Fade Gizmos", "Fade out and stop rendering gizmos that are small on screen");
89+
GUIContent lightProbeVisualizationContent = EditorGUIUtility.TrTextContent("Light Probe Visualization");
90+
GUIContent displayWeightsContent = EditorGUIUtility.TrTextContent("Display Weights");
91+
GUIContent displayOcclusionContent = EditorGUIUtility.TrTextContent("Display Occlusion");
92+
GUIContent highlightInvalidCellsContent = EditorGUIUtility.TrTextContent("Highlight Invalid Cells", "Highlight the invalid cells that cannot be used for probe interpolation.");
8893
private bool m_IsGameView;
8994

9095
string m_SearchFilter = string.Empty;
@@ -130,7 +135,18 @@ static public void IconChanged()
130135

131136
float GetTopSectionHeight()
132137
{
133-
const int numberOfControls = 5;
138+
const int numberOfGeneralControls = 6;
139+
140+
int numberOfLightProbeVisualizationControls = 0;
141+
if (!UnityEngine.Rendering.SupportedRenderingFeatures.active.overridesLightProbeSystem)
142+
{
143+
if (LightProbeVisualization.lightProbeVisualizationMode == LightProbeVisualization.LightProbeVisualizationMode.None)
144+
numberOfLightProbeVisualizationControls = 3;
145+
else
146+
numberOfLightProbeVisualizationControls = 5;
147+
}
148+
149+
int numberOfControls = numberOfGeneralControls + numberOfLightProbeVisualizationControls;
134150
return EditorGUI.kSingleLineHeight * numberOfControls + EditorGUI.kControlVerticalSpacing * (numberOfControls - 1) + EditorStyles.inspectorBig.padding.bottom;
135151
}
136152

@@ -307,8 +323,13 @@ void DrawTopSection(float topSectionHeight)
307323
float labelWidth = m_Styles.listHeaderStyle.CalcSize(terrainDebugWarnings).x + GUI.skin.toggle.CalcSize(GUIContent.none).x + 1;
308324
float rowHeight = 18;
309325

310-
// 3D icons toggle & slider
326+
// General section
311327
Rect toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
328+
GUI.Label(toggleRect, generalContent, EditorStyles.boldLabel);
329+
curY += rowHeight;
330+
331+
// 3D icons toggle & slider
332+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
312333
AnnotationUtility.use3dGizmos = GUI.Toggle(toggleRect, AnnotationUtility.use3dGizmos, icon3dGizmoContent);
313334
using (new EditorGUI.DisabledScope(!AnnotationUtility.use3dGizmos))
314335
{
@@ -347,17 +368,47 @@ void DrawTopSection(float topSectionHeight)
347368
// Selection outline/wire
348369
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
349370
AnnotationUtility.showSelectionOutline = GUI.Toggle(toggleRect, AnnotationUtility.showSelectionOutline, showOutlineContent);
371+
curY += rowHeight;
350372

351-
toggleRect.y += rowHeight;
373+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
352374
AnnotationUtility.showSelectionWire = GUI.Toggle(toggleRect, AnnotationUtility.showSelectionWire, showWireframeContent);
375+
curY += rowHeight;
353376

354377
// TODO: Change to Debug Errors & Debug Warnings
355-
toggleRect.y += rowHeight;
378+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
356379
EditorGUI.BeginChangeCheck();
357380
s_ShowTerrainDebugWarnings.value = GUI.Toggle(toggleRect, s_ShowTerrainDebugWarnings.value, terrainDebugWarnings);
358381
if (EditorGUI.EndChangeCheck())
359382
SceneView.RepaintAll();
360383
}
384+
curY += rowHeight;
385+
386+
// Light probe section
387+
if (!UnityEngine.Rendering.SupportedRenderingFeatures.active.overridesLightProbeSystem)
388+
{
389+
curY += rowHeight;
390+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
391+
GUI.Label(toggleRect, lightProbeVisualizationContent, EditorStyles.boldLabel);
392+
curY += rowHeight;
393+
394+
toggleRect = new Rect(margin, curY, position.width - margin * 2, rowHeight);
395+
LightProbeVisualization.lightProbeVisualizationMode = (LightProbeVisualization.LightProbeVisualizationMode)EditorGUI.EnumPopup(toggleRect, LightProbeVisualization.lightProbeVisualizationMode);
396+
curY += rowHeight;
397+
398+
if (LightProbeVisualization.lightProbeVisualizationMode != LightProbeVisualization.LightProbeVisualizationMode.None)
399+
{
400+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
401+
LightProbeVisualization.showInterpolationWeights = GUI.Toggle(toggleRect, LightProbeVisualization.showInterpolationWeights, displayWeightsContent);
402+
curY += rowHeight;
403+
404+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
405+
LightProbeVisualization.showOcclusions = GUI.Toggle(toggleRect, LightProbeVisualization.showOcclusions, displayOcclusionContent);
406+
curY += rowHeight;
407+
408+
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
409+
LightProbeVisualization.highlightInvalidCells = GUI.Toggle(toggleRect, LightProbeVisualization.highlightInvalidCells, highlightInvalidCellsContent);
410+
}
411+
}
361412
}
362413

363414
// ------------------------------------

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ static class Styles
9696
private static readonly string kBakedGI = "Baked Global Illumination";
9797
private static readonly string kMaterialValidation = "Material Validation";
9898

99-
public static readonly GUIContent sResolutionToggle =
100-
EditorGUIUtility.TrTextContent("Show Lightmap Resolution");
101-
10299
// Map all builtin DrawCameraMode entries
103100
// This defines the order in which the entries appear in the dropdown menu!
104101
public static readonly SceneView.CameraMode[] sBuiltinCameraModes =
@@ -161,18 +158,14 @@ private float windowHeight
161158
modes = Styles.sBuiltinCameraModes.Count(mode => m_SceneView.IsCameraDrawModeSupported(mode)) + SceneView.userDefinedModes.Count(mode => m_SceneView.IsCameraDrawModeSupported(mode));
162159

163160
int separators = headers - 1;
164-
return ((headers + modes) * EditorGUI.kSingleLineHeight) + (kSeparatorHeight * separators) + kShowLightmapResolutionHeight;
161+
return ((headers + modes) * EditorGUI.kSingleLineHeight) + (kSeparatorHeight * separators);
165162
}
166163
}
167164

168165
const float windowWidth = 205;
169166
const float kSeparatorHeight = 3;
170-
const float kFrameWidth = 1f;
171167
const float kHeaderHorizontalPadding = 5f;
172168
const float kHeaderVerticalPadding = 3f;
173-
const float kTogglePadding = 7f;
174-
175-
static readonly float kShowLightmapResolutionHeight = EditorGUI.kSingleLineHeight + kSeparatorHeight * 2;
176169

177170
readonly SceneView m_SceneView;
178171

@@ -262,34 +255,13 @@ private void Draw(float listElementWidth)
262255

263256
bool disabled = (m_SceneView.cameraMode.drawMode < DrawCameraMode.RealtimeCharting) ||
264257
!IsModeEnabled(m_SceneView.cameraMode.drawMode);
265-
DoResolutionToggle(drawPos, disabled);
266258
}
267259

268260
bool IsModeEnabled(DrawCameraMode mode)
269261
{
270262
return m_SceneView.IsCameraDrawModeEnabled(GetBuiltinCameraMode(mode));
271263
}
272264

273-
void DoResolutionToggle(Rect rect, bool disabled)
274-
{
275-
// Bg
276-
GUI.Label(new Rect(kFrameWidth, rect.y, windowWidth - kFrameWidth * 2, kShowLightmapResolutionHeight), "", EditorStyles.inspectorBig);
277-
278-
rect.y += kSeparatorHeight;
279-
rect.x += kTogglePadding;
280-
281-
using (new EditorGUI.DisabledScope(disabled))
282-
{
283-
EditorGUI.BeginChangeCheck();
284-
bool showResolution = GUI.Toggle(rect, LightmapVisualization.showResolution, Styles.sResolutionToggle);
285-
if (EditorGUI.EndChangeCheck())
286-
{
287-
LightmapVisualization.showResolution = showResolution;
288-
SceneView.RepaintAll();
289-
}
290-
}
291-
}
292-
293265
void DoBuiltinMode(ref Rect rect, SceneView.CameraMode mode)
294266
{
295267
using (new EditorGUI.DisabledScope(!m_SceneView.CheckDrawModeForRenderingPath(mode.drawMode)))

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
[assembly: InternalsVisibleTo("Unity.IntegrationTests")]
2727
[assembly: InternalsVisibleTo("Unity.DeploymentTests.Services")]
2828
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")]
29+
[assembly: InternalsVisibleTo("Unity.PerformanceIntegrationTests")]
2930
[assembly: InternalsVisibleTo("Unity.Timeline.Editor")]
3031
[assembly: InternalsVisibleTo("Unity.PackageManagerUI.Develop.Editor")]
3132
[assembly: InternalsVisibleTo("Unity.DeviceSimulator.Editor")]
@@ -50,7 +51,6 @@
5051
[assembly: InternalsVisibleTo("UnityEditor.WindowsStandalone.Extensions")]
5152
[assembly: InternalsVisibleTo("UnityEditor.OSXStandalone.Extensions")]
5253
[assembly: InternalsVisibleTo("UnityEditor.Lumin.Extensions")]
53-
[assembly: InternalsVisibleTo("UnityEditor.Stadia.Extensions")]
5454
[assembly: InternalsVisibleTo("UnityEditor.GameCoreScarlett.Extensions")]
5555
[assembly: InternalsVisibleTo("UnityEditor.GameCoreXboxOne.Extensions")]
5656
[assembly: InternalsVisibleTo("UnityEditor.GameCoreCommon.Extensions")]

Editor/Mono/AssetModificationProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static Editability GetPathEditability(string assetPath)
390390
{
391391
// read-only asset locations (e.g. shared packages) are considered not editable
392392
bool rootFolder, readOnly;
393-
bool validPath = AssetDatabase.GetAssetFolderInfo(assetPath, out rootFolder, out readOnly);
393+
bool validPath = AssetDatabase.TryGetAssetFolderInfo(assetPath, out rootFolder, out readOnly);
394394
if (validPath && readOnly)
395395
return Editability.Never;
396396

Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,9 @@ internal void LogImportWarning(string msg, string file, int line, UnityEngine.Ob
202202
AddImportLog(msg, file, line, ImportLogFlags.Warning, obj);
203203
}
204204

205+
internal static class BindingsMarshaller
206+
{
207+
public static IntPtr ConvertToNative(AssetImportContext ctx) => ctx.m_Self;
208+
}
205209
}
206210
}

Editor/Mono/AssetPipeline/BumpMapSettings.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class BumpMapSettings
1313
{
1414
public static extern bool silentMode { get; set; }
1515

16-
public static extern void PerformBumpMapCheck([NotNull("NullExceptionObject")] Material material);
16+
public static extern void PerformBumpMapCheck([NotNull] Material material);
1717
}
1818

1919
public static class MaterialEditorExtensions

0 commit comments

Comments
 (0)