Skip to content

Commit 3b27cb2

Browse files
author
Unity Technologies
committed
Unity 2021.2.0a16 C# reference source code
1 parent ac78b93 commit 3b27cb2

File tree

129 files changed

+4053
-972
lines changed

Some content is hidden

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

129 files changed

+4053
-972
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public class Plugin
88
{
99
public string AssetPath;
1010
public string DestinationPath;
11-
11+
public string Architecture;
1212
public override string ToString()
1313
{
14-
return $"'{AssetPath} -> '{DestinationPath}'";
14+
return $"'{AssetPath} -> '{DestinationPath}' ({Architecture})";
1515
}
1616
}
1717

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public static class SpriteAtlasExtensions
9797
extern public static void SetIsVariant([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, bool value);
9898
extern public static void SetMasterAtlas([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, SpriteAtlas value);
9999
extern public static void SetVariantScale([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas, float value);
100+
extern public static bool IsIncludeInBuild([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
101+
extern public static SpriteAtlas GetMasterAtlas([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
100102
extern internal static void CopyMasterAtlasSettings([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
101103
extern internal static string GetHash([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);
102104
extern internal static Texture2D[] GetPreviewTextures([NotNull("NullExceptionObject")] this SpriteAtlas spriteAtlas);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class SpriteAtlasAsset : UnityEngine.Object
2626
extern public void SetIsVariant(bool value);
2727
extern public void SetMasterAtlas(SpriteAtlas atlas);
2828
extern public void SetIncludeInBuild(bool value);
29+
extern public bool IsIncludeInBuild();
30+
extern public SpriteAtlas GetMasterAtlas();
2931
extern public void SetVariantScale(float value);
3032
extern public void SetPlatformSettings(TextureImporterPlatformSettings src);
3133
extern public TextureImporterPlatformSettings GetPlatformSettings(string buildTarget);

Editor/Mono/AssemblyReloadEvents.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,33 @@ namespace UnityEditor
99
public static class AssemblyReloadEvents
1010
{
1111
public delegate void AssemblyReloadCallback();
12-
public static event AssemblyReloadCallback beforeAssemblyReload;
13-
public static event AssemblyReloadCallback afterAssemblyReload;
12+
public static event AssemblyReloadCallback beforeAssemblyReload
13+
{
14+
add => m_BeforeAssemblyReloadEvent.Add(value);
15+
remove => m_BeforeAssemblyReloadEvent.Remove(value);
16+
}
17+
private static EventWithPerformanceTracker<AssemblyReloadCallback> m_BeforeAssemblyReloadEvent =
18+
new EventWithPerformanceTracker<AssemblyReloadCallback>($"{nameof(AssemblyReloadEvents)}.{nameof(beforeAssemblyReload)}");
19+
public static event AssemblyReloadCallback afterAssemblyReload
20+
{
21+
add => m_AfterAssemblyReloadEvent.Add(value);
22+
remove => m_AfterAssemblyReloadEvent.Remove(value);
23+
}
24+
private static EventWithPerformanceTracker<AssemblyReloadCallback> m_AfterAssemblyReloadEvent =
25+
new EventWithPerformanceTracker<AssemblyReloadCallback>($"{nameof(AssemblyReloadEvents)}.{nameof(afterAssemblyReload)}");
1426

1527
[RequiredByNativeCode]
1628
static void OnBeforeAssemblyReload()
1729
{
18-
if (beforeAssemblyReload != null)
19-
beforeAssemblyReload();
30+
foreach (var evt in m_BeforeAssemblyReloadEvent)
31+
evt();
2032
}
2133

2234
[RequiredByNativeCode]
2335
static void OnAfterAssemblyReload()
2436
{
25-
if (afterAssemblyReload != null)
26-
afterAssemblyReload();
37+
foreach (var evt in m_AfterAssemblyReloadEvent)
38+
evt();
2739
}
2840
}
2941
}

Editor/Mono/AssetPipeline/TextureGenerator.bindings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public struct SpriteImportData
4141
public struct TextureGenerationOutput
4242
{
4343
[NativeName("texture")]
44-
private Texture2D m_Texture;
44+
private Texture m_Texture;
4545
[NativeName("importInspectorWarnings")]
4646
private string m_ImportInspectorWarnings;
4747
[NativeName("importWarnings")]
@@ -51,7 +51,7 @@ public struct TextureGenerationOutput
5151
[NativeName("sprites")]
5252
private Sprite[] m_Sprites;
5353

54-
public Texture2D texture { get { return m_Texture; } }
54+
public Texture2D texture { get { return m_Texture as Texture2D; } }
5555
public string importInspectorWarnings { get { return m_ImportInspectorWarnings; } }
5656
public string[] importWarnings { get { return m_ImportWarnings; } }
5757
public Texture2D thumbNail { get { return m_ThumbNail; } }

Editor/Mono/AssetPipeline/TextureImporter.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ public static bool IsDefaultPlatformTextureFormatValid(TextureImporterType textu
251251
[NativeProperty("VTOnly")]
252252
public extern bool vtOnly { get; set; }
253253

254+
internal extern bool ignoreMasterTextureLimit { get; set; }
255+
254256
// Generate mip maps for the texture?
255257
public extern bool mipmapEnabled { get; set; }
256258
// Keep texture borders the same when generating mipmaps?

Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public sealed partial class TextureImporterSettings
6464
[SerializeField]
6565
int m_StreamingMipmapsPriority;
6666

67+
[SerializeField]
68+
int m_IgnoreMasterTextureLimit;
6769

6870
[SerializeField]
6971
int m_NPOTScale;
@@ -300,6 +302,11 @@ public int streamingMipmapsPriority
300302
set { m_StreamingMipmapsPriority = value; }
301303
}
302304

305+
internal bool ignoreMasterTextureLimit
306+
{
307+
get { return m_IgnoreMasterTextureLimit != 0; }
308+
set { m_IgnoreMasterTextureLimit = value ? 1 : 0; }
309+
}
303310

304311
public TextureImporterNPOTScale npotScale
305312
{

Editor/Mono/AssetPostprocessor.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,17 @@ static void InitPostprocessors(AssetImportContext context, string pathName)
167167
{
168168
m_ImportProcessors = new ArrayList();
169169
var analyticsEvent = new AssetPostProcessorAnalyticsData();
170-
analyticsEvent.importActionId = ((int)Math.Floor(AssetImporter.GetAtPath(pathName).GetImportStartTime() * 1000)).ToString();
170+
171+
// This may happen if the processors are initialized outside a proper importer context. This is currently
172+
// used by the TextureGenerator to be able to invoke the postprocessors on the generated texture.
173+
if (AssetImporter.GetAtPath(pathName) != null)
174+
{
175+
analyticsEvent.importActionId = ((int)Math.Floor(AssetImporter.GetAtPath(pathName).GetImportStartTime() * 1000)).ToString();
176+
}
177+
else
178+
{
179+
analyticsEvent.importActionId = "None";
180+
}
171181
s_AnalyticsEventsStack.Push(analyticsEvent);
172182

173183
// @TODO: This is just a temporary workaround for the import settings.
@@ -396,7 +406,9 @@ static string GetTextureProcessorsHashString()
396406
var type = inst.GetType();
397407
bool hasPreProcessMethod = type.GetMethod("OnPreprocessTexture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null;
398408
bool hasPostProcessMethod = (type.GetMethod("OnPostprocessTexture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null) ||
399-
(type.GetMethod("OnPostprocessCubemap", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null);
409+
(type.GetMethod("OnPostprocessCubemap", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null) ||
410+
(type.GetMethod("OnPostprocessTexture3D", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null) ||
411+
(type.GetMethod("OnPostprocessTexture2DArray", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null);
400412
uint version = inst.GetVersion();
401413
if (hasPreProcessMethod || hasPostProcessMethod)
402414
{
@@ -437,6 +449,20 @@ static void PostprocessCubemap(Cubemap tex, string pathName)
437449
CallPostProcessMethods("OnPostprocessCubemap", args);
438450
}
439451

452+
[RequiredByNativeCode]
453+
static void PostprocessTexture3D(Texture3D tex, string pathName)
454+
{
455+
object[] args = { tex };
456+
CallPostProcessMethods("OnPostprocessTexture3D", args);
457+
}
458+
459+
[RequiredByNativeCode]
460+
static void PostprocessTexture2DArray(Texture2DArray tex, string pathName)
461+
{
462+
object[] args = { tex };
463+
CallPostProcessMethods("OnPostprocessTexture2DArray", args);
464+
}
465+
440466
[RequiredByNativeCode]
441467
static void PostprocessSprites(Texture2D tex, string pathName, Sprite[] sprites)
442468
{
@@ -617,6 +643,11 @@ static void CallPostProcessMethodsUntilReturnedObjectIsValid<T>(string methodNam
617643

618644
static void CallPostProcessMethods(string methodName, object[] args)
619645
{
646+
if (m_ImportProcessors == null)
647+
{
648+
throw new Exception("m_ImportProcessors is null, InitPostProcessors should be called before any of the post process methods are called.");
649+
}
650+
620651
if (IsAssetPostprocessorAnalyticsEnabled())
621652
{
622653
int invocationCount = 0;

Editor/Mono/AssetStore/AssetStoreWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void OnEnable()
5050
var lightStyleSheet = EditorGUIUtility.Load(EditorUIService.instance.GetUIToolkitDefaultCommonLightStyleSheetPath()) as StyleSheet;
5151
var assetStoreStyleSheet = EditorGUIUtility.Load("StyleSheets/AssetStore/AssetStoreWindow.uss") as StyleSheet;
5252
var styleSheet = CreateInstance<StyleSheet>();
53-
styleSheet.isUnityStyleSheet = true;
53+
styleSheet.isDefaultStyleSheet = true;
5454

5555
var resolver = new StyleSheets.StyleSheetResolver();
5656
resolver.AddStyleSheets(lightStyleSheet, assetStoreStyleSheet);

0 commit comments

Comments
 (0)