Skip to content

Commit 7699e50

Browse files
author
Unity Technologies
committed
Unity 2021.2.0a19 C# reference source code
1 parent 7e6dcf5 commit 7699e50

File tree

577 files changed

+40445
-8574
lines changed

Some content is hidden

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

577 files changed

+40445
-8574
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class PlayerBuildConfig
3535
public bool GenerateIdeProject;
3636
public bool Development;
3737
public Services Services;
38+
public StreamingAssetsFile[] StreamingAssetsFiles;
3839
}
3940

4041
public class BuiltFilesOutput
@@ -81,4 +82,10 @@ public class Services
8182
public bool EnableAnalytics;
8283
public bool EnableCrashReporting;
8384
}
85+
86+
public class StreamingAssetsFile
87+
{
88+
public string File;
89+
public string RelativePath;
90+
}
8491
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Styles
6464
public readonly GUIContent copyMasterButton = EditorGUIUtility.TrTextContent("Copy Master's Settings", "Copy all master's settings into this variant.");
6565

6666
public readonly GUIContent disabledPackLabel = EditorGUIUtility.TrTextContent("Sprite Atlas packing is disabled. Enable it in Edit > Project Settings > Editor.", null, EditorGUIUtility.GetHelpIcon(MessageType.Info));
67-
public readonly GUIContent packableListLabel = EditorGUIUtility.TrTextContent("Objects for Packing", "Only accepts Sprite Sheet (Texture) and Sprite.");
67+
public readonly GUIContent packableListLabel = EditorGUIUtility.TrTextContent("Objects for Packing", "Only accepts Folders, Sprite Sheet (Texture) and Sprite.");
6868

6969
public readonly GUIContent notPowerOfTwoWarning = EditorGUIUtility.TrTextContent("This scale will produce a Variant Sprite Atlas with a packed Texture that is NPOT (non - power of two). This may cause visual artifacts in certain compression/Texture formats.");
7070
public readonly GUIContent secondaryTextureNameLabel = EditorGUIUtility.TrTextContent("Secondary Texture Name", "The name of the Secondary Texture to apply the following settings to.");
@@ -167,7 +167,7 @@ private enum AtlasType { Undefined = -1, Master = 0, Variant = 1 }
167167

168168
static bool IsPackable(Object o)
169169
{
170-
return o != null && (o.GetType() == typeof(Sprite) || o.GetType() == typeof(Texture2D));
170+
return o != null && (o.GetType() == typeof(Sprite) || o.GetType() == typeof(Texture2D) || (o.GetType() == typeof(DefaultAsset) && ProjectWindowUtil.IsFolder(o.GetInstanceID())));
171171
}
172172

173173
static Object ValidateObjectForPackableFieldAssignment(Object[] references, System.Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options)
@@ -337,7 +337,7 @@ void RenameSecondaryPlatformSettings(string oldName, string newName)
337337
void AddPackable(ReorderableList list)
338338
{
339339
ObjectSelector.get.Show(null, typeof(Object), null, false);
340-
ObjectSelector.get.searchFilter = "t:sprite t:texture2d";
340+
ObjectSelector.get.searchFilter = "t:sprite t:texture2d t:folder";
341341
ObjectSelector.get.objectSelectorID = styles.packableSelectorHash;
342342
}
343343

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private enum EnabledState
7373
Vector2 m_ScrollPosition;
7474
bool m_SyncWithState;
7575
string m_LastScriptThatHasShownTheIconSelector;
76+
7677
List<MonoScript> m_MonoScriptIconsChanged;
7778

7879
const int maxShowRecent = 5;
@@ -144,7 +145,7 @@ void OnDisable()
144145
AssemblyReloadEvents.beforeAssemblyReload -= Close;
145146
// When window closes we copy all changes to monoimporters (reimport monoScripts)
146147
foreach (MonoScript monoScript in m_MonoScriptIconsChanged)
147-
MonoImporter.CopyMonoScriptIconToImporters(monoScript);
148+
IconSelector.CopyIconToImporter(monoScript);
148149

149150
s_LastClosedTime = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
150151
s_AnnotationWindow = null;

Editor/Mono/AssemblyHelper.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Collections.Generic;
1010
using System.Diagnostics;
1111
using Mono.Cecil;
12+
using UnityEditor.Build;
1213
using UnityEditor.Modules;
1314
using UnityEditorInternal;
1415
using UnityEngine;
@@ -25,6 +26,7 @@ internal partial class AssemblyHelper
2526
static BuildPlayerDataExtractor m_BuildPlayerDataExtractor = new BuildPlayerDataExtractor();
2627

2728
// Check if assmebly internal name doesn't match file name, and show the warning.
29+
[RequiredByNativeCode]
2830
static public void CheckForAssemblyFileNameMismatch(string assemblyPath)
2931
{
3032
string fileName = Path.GetFileNameWithoutExtension(assemblyPath);
@@ -99,7 +101,7 @@ static private bool IgnoreAssembly(string assemblyPath, BuildTarget target)
99101
}
100102
else if (target == BuildTarget.XboxOne)
101103
{
102-
var profile = PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.XboxOne);
104+
var profile = PlayerSettings.GetApiCompatibilityLevel(NamedBuildTarget.XboxOne);
103105
if (profile == ApiCompatibilityLevel.NET_4_6 || profile == ApiCompatibilityLevel.NET_Standard_2_0)
104106
{
105107
if (CouldBelongToDotNetOrWindowsRuntime(assemblyPath))
@@ -192,6 +194,7 @@ static string FindAssemblyName(string fullName, string name, string[] allAssembl
192194
return "";
193195
}
194196

197+
[RequiredByNativeCode]
195198
static public string[] FindAssembliesReferencedBy(string[] paths, string[] foldersToSearch, BuildTarget target)
196199
{
197200
List<string> unique = new List<string>();
@@ -207,13 +210,6 @@ static public string[] FindAssembliesReferencedBy(string[] paths, string[] folde
207210
return unique.ToArray();
208211
}
209212

210-
static public string[] FindAssembliesReferencedBy(string path, string[] foldersToSearch, BuildTarget target)
211-
{
212-
string[] tmp = new string[1];
213-
tmp[0] = path;
214-
return FindAssembliesReferencedBy(tmp, foldersToSearch, target);
215-
}
216-
217213
static public bool IsUnityEngineModule(AssemblyDefinition assembly)
218214
{
219215
return assembly.CustomAttributes.Any(a => a.AttributeType.FullName == typeof(UnityEngineModuleAssembly).FullName);

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
[assembly: InternalsVisibleTo("Unity.WebGL.Extensions")]
4646
[assembly: InternalsVisibleTo("UnityEditor.LinuxStandalone.Extensions")]
4747
[assembly: InternalsVisibleTo("UnityEditor.CloudRendering.Extensions")]
48+
[assembly: InternalsVisibleTo("UnityEditor.EmbeddedLinux.Extensions")]
4849
[assembly: InternalsVisibleTo("UnityEditor.WindowsStandalone.Extensions")]
4950
[assembly: InternalsVisibleTo("UnityEditor.OSXStandalone.Extensions")]
5051
[assembly: InternalsVisibleTo("UnityEditor.Lumin.Extensions")]

Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Linq;
77
using System.Collections.Generic;
8+
using UnityEditor.Utils;
89
using UnityEngine;
910
using Object = UnityEngine.Object;
1011

@@ -66,11 +67,12 @@ private static IEnumerator<T> FindInFolders<T>(SearchFilter searchFilter, Func<H
6667

6768
foreach (var folderPath in folders)
6869
{
69-
var folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath);
70+
var sanitizedFolderPath = folderPath.ConvertSeparatorsToUnity().TrimTrailingSlashes();
71+
var folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(sanitizedFolderPath);
7072
var rootPath = "Assets";
7173

7274
// Find the right rootPath if folderPath is part of a package
73-
var packageInfo = PackageManager.PackageInfo.FindForAssetPath(folderPath);
75+
var packageInfo = PackageManager.PackageInfo.FindForAssetPath(sanitizedFolderPath);
7476
if (packageInfo != null)
7577
{
7678
rootPath = packageInfo.assetPath;
@@ -94,7 +96,7 @@ private static IEnumerator<T> FindInFolders<T>(SearchFilter searchFilter, Func<H
9496
}
9597
else
9698
{
97-
Debug.LogWarning("AssetDatabase.FindAssets: Folder not found: '" + folderPath + "'");
99+
Debug.LogWarning("AssetDatabase.FindAssets: Folder not found: '" + sanitizedFolderPath + "'");
98100
}
99101
}
100102
}

Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class AssetImportContext
3232
AssetImportContext() {}
3333

3434
public extern string assetPath { get; internal set; }
35+
36+
[Obsolete("GetResultPath has been deprecated. Use GetOutputArtifactFilePath(string) instead (UnityUpgradable) -> GetOutputArtifactFilePath(*)")]
37+
[NativeName("GetOutputArtifactFilePath")]
3538
public extern string GetResultPath(string extension);
3639

3740
public extern BuildTarget selectedBuildTarget { get; }
@@ -95,6 +98,23 @@ internal void DependsOnImportedAsset(string path)
9598
DependsOnImportedAssetInternal(path);
9699
}
97100

101+
[NativeName("GetArtifactFilePath")]
102+
private extern string GetArtifactFilePath_Internal(string path, string fileName);
103+
104+
public string GetArtifactFilePath(string path, string fileName)
105+
{
106+
return GetArtifactFilePath_Internal(path, fileName);
107+
}
108+
109+
public string GetArtifactFilePath(GUID guid, string fileName)
110+
{
111+
return GetArtifactFilePath(new ArtifactKey(guid), fileName);
112+
}
113+
114+
public extern string GetArtifactFilePath(ArtifactKey key, string fileName);
115+
116+
public extern string GetOutputArtifactFilePath(string fileName);
117+
98118
[NativeName("DependsOnImportedAsset")]
99119
private extern void DependsOnImportedAssetInternal(string path);
100120

Editor/Mono/AssetPipeline/TextureGenerator.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public struct TextureGenerationOutput
5252
private Sprite[] m_Sprites;
5353

5454
public Texture2D texture { get { return m_Texture as Texture2D; } }
55+
public Texture output { get { return m_Texture; } }
5556
public string importInspectorWarnings { get { return m_ImportInspectorWarnings; } }
5657
public string[] importWarnings { get { return m_ImportWarnings; } }
5758
public Texture2D thumbNail { get { return m_ThumbNail; } }

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_VTOnly;
6769
[SerializeField]
6870
int m_IgnoreMasterTextureLimit;
6971

@@ -302,6 +304,11 @@ public int streamingMipmapsPriority
302304
set { m_StreamingMipmapsPriority = value; }
303305
}
304306

307+
public bool vtOnly
308+
{
309+
get { return m_VTOnly != 0; }
310+
set { m_VTOnly = value ? 1 : 0; }
311+
}
305312
internal bool ignoreMasterTextureLimit
306313
{
307314
get { return m_IgnoreMasterTextureLimit != 0; }

Editor/Mono/Audio/Mixer/Bindings/AudioMixerController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ public void RemoveEffect(AudioMixerEffectController effect, AudioMixerGroupContr
443443

444444
public void OnSubAssetChanged()
445445
{
446+
AssetDatabase.SaveAssets();
446447
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(this));
447448
}
448449

0 commit comments

Comments
 (0)