Skip to content

Commit d76ca0c

Browse files
author
Unity Technologies
committed
Unity 2022.2.0a13 C# reference source code
1 parent 4dfc797 commit d76ca0c

117 files changed

Lines changed: 3420 additions & 2293 deletions

File tree

Some content is hidden

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

Editor/Mono/2D/SpriteAtlas/SpriteAtlasImporterInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ public override void OnPreviewSettings()
917917
if (t == null)
918918
return;
919919

920-
if (TextureUtil.HasAlphaTextureFormat(t.format) || (m_PreviewAlphaTextures != null && m_PreviewAlphaTextures.Length > 0))
920+
if (GraphicsFormatUtility.HasAlphaChannel(t.format) || (m_PreviewAlphaTextures != null && m_PreviewAlphaTextures.Length > 0))
921921
m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? styles.alphaIcon : styles.RGBIcon, styles.previewButton);
922922

923923
int mipCount = Mathf.Max(1, TextureUtil.GetMipmapCount(t));

Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ public override void OnPreviewSettings()
804804

805805
Texture2D t = m_PreviewTextures[m_PreviewPage];
806806

807-
if (TextureUtil.HasAlphaTextureFormat(t.format) || (m_PreviewAlphaTextures != null && m_PreviewAlphaTextures.Length > 0))
807+
if (GraphicsFormatUtility.HasAlphaChannel(t.format) || (m_PreviewAlphaTextures != null && m_PreviewAlphaTextures.Length > 0))
808808
m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? styles.alphaIcon : styles.RGBIcon, styles.previewButton);
809809

810810
int mipCount = Mathf.Max(1, TextureUtil.GetMipmapCount(t));

Editor/Mono/AssetPipeline/TextureUtil.bindings.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,9 @@ namespace UnityEditor
1313
[NativeHeader("Runtime/Graphics/Format.h")]
1414
internal static class TextureUtil
1515
{
16-
[Obsolete("GetStorageMemorySize has been deprecated since it is limited to 2GB. Please use GetStorageMemorySizeLong() instead.")]
17-
public static int GetStorageMemorySize(Texture t)
18-
{
19-
return (int)GetStorageMemorySizeLong(t);
20-
}
21-
2216
[FreeFunction]
2317
public static extern long GetStorageMemorySizeLong([NotNull("NullExceptionObject")] Texture t);
2418

25-
[Obsolete("GetRuntimeMemorySize has been deprecated since it is limited to 2GB. Please use GetRuntimeMemorySizeLong() instead.")]
26-
public static int GetRuntimeMemorySize(Texture t)
27-
{
28-
return (int)GetRuntimeMemorySizeLong(t);
29-
}
30-
3119
[FreeFunction]
3220
public static extern long GetRuntimeMemorySizeLong([NotNull("NullExceptionObject")] Texture t);
3321

@@ -55,33 +43,41 @@ public static int GetRuntimeMemorySize(Texture t)
5543
[FreeFunction]
5644
public static extern bool IsValidTextureFormat(TextureFormat format);
5745

46+
[Obsolete("IsCompressedTextureFormat has been moved to GraphicsFormatUtility.IsCompressedFormat(TextureFormat)")]
5847
[FreeFunction("IsAnyCompressedTextureFormat")]
5948
public static extern bool IsCompressedTextureFormat(TextureFormat format);
6049

50+
[Obsolete("IsCompressedCrunchTextureFormat has been moved to GraphicsFormatUtility.IsCrunchFormat(TextureFormat)")]
6151
[FreeFunction("IsCompressedCrunchTextureFormat")]
6252
public static extern bool IsCompressedCrunchTextureFormat(TextureFormat format);
6353

6454
[FreeFunction]
6555
public static extern TextureFormat GetTextureFormat([NotNull("NullExceptionObject")] Texture texture);
6656

57+
[Obsolete("IsAlphaOnlyTextureFormat has been moved to GraphicsFormatUtility.IsAlphaOnlyFormat(TextureFormat)")]
6758
[FreeFunction]
6859
public static extern bool IsAlphaOnlyTextureFormat(TextureFormat format);
6960

61+
[Obsolete("IsHDRFormat has been moved to GraphicsFormatUtility.IsHDRFormat(TextureFormat)")]
7062
[FreeFunction]
7163
public static extern bool IsHDRFormat(TextureFormat format);
7264

65+
[Obsolete("IsHDRGraphicsFormat has been moved to GraphicsFormatUtility.IsHDRFormat(GraphicsFormat)")]
7366
[FreeFunction("IsHDRFormat")]
7467
public static extern bool IsHDRGraphicsFormat(GraphicsFormat format);
7568

69+
[Obsolete("HasAlphaTextureFormat has been moved to GraphicsFormatUtility.HasAlphaChannel(TextureFormat)")]
7670
[FreeFunction]
7771
public static extern bool HasAlphaTextureFormat(TextureFormat format);
7872

73+
[Obsolete("GetTextureFormatString has been moved to GraphicsFormatUtility.GetFormatString(TextureFormat)")]
7974
[FreeFunction]
8075
public static extern string GetTextureFormatString(TextureFormat format);
8176

8277
[FreeFunction]
8378
public static extern string GetTextureColorSpaceString([NotNull("NullExceptionObject")] Texture texture);
8479

80+
[Obsolete("ConvertToAlphaTextureFormat has been moved to GraphicsFormatUtility.ConvertToAlphaFormat(TextureFormat)")]
8581
[FreeFunction]
8682
public static extern TextureFormat ConvertToAlphaTextureFormat(TextureFormat format);
8783

Editor/Mono/AssetPostprocessor.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,25 @@ static void PostprocessAllAssets(string[] importedAssets, string[] addedAssets,
299299

300300
foreach (OnPostprocessAllAssetsCallbackCollection.MethodInfoCallback assetPostProcessor in s_OnPostprocessAllAssetsCallbacks.sortedCallbacks)
301301
{
302-
if (assetPostProcessor.MethodDomainReload)
302+
try
303303
{
304-
using (new EditorPerformanceMarker($"{assetPostProcessor.classType.Name}.OnPostprocessAllAssets", assetPostProcessor.classType).Auto())
305-
InvokeMethod(assetPostProcessor.Method, argsWithDidDomainReload);
304+
if (assetPostProcessor.MethodDomainReload)
305+
{
306+
using (new EditorPerformanceMarker($"{assetPostProcessor.classType.Name}.OnPostprocessAllAssets", assetPostProcessor.classType).Auto())
307+
InvokeMethod(assetPostProcessor.Method, argsWithDidDomainReload);
308+
}
309+
else
310+
{
311+
if (containsNoAssets)
312+
continue;
313+
314+
using (new EditorPerformanceMarker($"{assetPostProcessor.classType.Name}.OnPostprocessAllAssets", assetPostProcessor.classType).Auto())
315+
InvokeMethod(assetPostProcessor.Method, args);
316+
}
306317
}
307-
else
318+
catch (Exception e)
308319
{
309-
if (containsNoAssets)
310-
continue;
311-
312-
using (new EditorPerformanceMarker($"{assetPostProcessor.classType.Name}.OnPostprocessAllAssets", assetPostProcessor.classType).Auto())
313-
InvokeMethod(assetPostProcessor.Method, args);
320+
Debug.LogException(e);
314321
}
315322
}
316323

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using UnityEditor.Build.Reporting;
6+
using UnityEngine;
7+
8+
namespace UnityEditor.Build.Rendering
9+
{
10+
class EnsureSinglePipelineOnBuild : IPreprocessBuildWithReport
11+
{
12+
public int callbackOrder => int.MinValue; // We want it to be the first preprocessor to be executed
13+
14+
public void OnPreprocessBuild(BuildReport report)
15+
{
16+
var buildTargetGroupName = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget).ToString();
17+
if (!QualitySettings.SamePipelineAssetsForPlatform(buildTargetGroupName))
18+
throw new BuildFailedException($"The current build target has assets in its associated Quality levels and Graphics Settings that belong to different render pipelines. Please check your settings.");
19+
}
20+
}
21+
}

Editor/Mono/BuildPipeline/OSArchitecture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace UnityEditor.Build
66
{
7-
internal enum OSArchitecture
7+
public enum OSArchitecture
88
{
99
x64,
1010
ARM64,

Editor/Mono/EditorGUI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Linq;
2525
using System.Reflection;
2626
using Unity.Profiling;
27+
using UnityEngine.Experimental.Rendering;
2728

2829
namespace UnityEditor
2930
{
@@ -7140,7 +7141,7 @@ internal static Material GetMaterialForSpecialTexture(Texture t, Material defaul
71407141
normalMat.SetFloat("_ManualTex2Linear", manualTex2Linear ? 1.0f : 0.0f);
71417142
return normalMat;
71427143
}
7143-
else if (TextureUtil.IsAlphaOnlyTextureFormat(format))
7144+
else if (GraphicsFormatUtility.IsAlphaOnlyFormat(format))
71447145
{
71457146
var alphaOnlyMat = useVT ? alphaVTMaterial : alphaMaterial;
71467147
alphaOnlyMat.SetFloat("_ManualTex2Linear", manualTex2Linear ? 1.0f : 0.0f);

Editor/Mono/EditorHandles/RotationHandle.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ internal static Quaternion DoRotationHandle(RotationHandleIds ids, Quaternion ro
147147

148148
var isHot = ids.Has(GUIUtility.hotControl);
149149

150+
VertexSnapping.HandleMouseMove(ids.xyz);
151+
150152
// Draw free rotation first to give it the lowest priority
151153
if (!isDisabled
152154
&& param.ShouldShow(RotationHandleParam.Handle.XYZ)

Editor/Mono/EditorHandles/ScaleHandle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ internal static Vector3 DoScaleHandle(ScaleHandleIds ids, Vector3 scale, Vector3
164164
}
165165

166166
var isCenterIsHot = ids.xyz == GUIUtility.hotControl;
167+
VertexSnapping.HandleMouseMove(ids.xyz);
167168

168169
switch (Event.current.type)
169170
{

Editor/Mono/EditorSceneManager.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ internal static void RemapAssetReferencesInScene(UnityEngine.SceneManagement.Sce
145145
[NativeMethod("IsPreviewSceneObject")]
146146
public extern static bool IsPreviewSceneObject(UnityEngine.Object obj);
147147

148+
[StaticAccessor("EditorSceneManagerBindings", StaticAccessorType.DoubleColon)]
149+
[NativeMethod("IsAuthoringScene")]
150+
internal extern static bool IsAuthoringScene(Scene scene);
151+
148152
[NativeThrows]
149153
[StaticAccessor("EditorSceneManagerBindings", StaticAccessorType.DoubleColon)]
150154
[NativeMethod("ReloadScene")]

0 commit comments

Comments
 (0)