Skip to content

Commit 7e6dcf5

Browse files
author
Unity Technologies
committed
Unity 2021.2.0a17 C# reference source code
1 parent 3b27cb2 commit 7e6dcf5

File tree

239 files changed

+10910
-4159
lines changed

Some content is hidden

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

239 files changed

+10910
-4159
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class LinkerConfig
6060
public class Il2CppConfig
6161
{
6262
public bool EnableDeepProfilingSupport;
63+
public bool EnableFullGenericSharing;
6364
public string Profile;
6465

6566
public string ConfigurationName;

Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public void DependsOnSourceAsset(GUID guid)
8282
[NativeName("DependsOnSourceAsset")]
8383
private extern void DependsOnSourceAssetInternalGUID(GUID guid);
8484

85+
[NativeName("GetFolderEntries")]
86+
internal extern GUID[] GetFolderEntries(GUID folder);
87+
8588
internal void DependsOnImportedAsset(string path)
8689
{
8790
if (string.IsNullOrEmpty(path))
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 System;
6+
using System.Collections.Generic;
7+
using System.Runtime.InteropServices;
8+
using UnityEngine;
9+
using UnityEngine.Bindings;
10+
using UnityEngine.Scripting;
11+
12+
namespace UnityEditor.AssetImporters
13+
{
14+
[RequiredByNativeCode]
15+
[NativeHeader("Editor/Src/AssetPipeline/ModelImporting/CameraDescription.h")]
16+
public class CameraDescription : IDisposable
17+
{
18+
internal IntPtr m_Ptr;
19+
20+
public CameraDescription()
21+
{
22+
m_Ptr = Internal_Create();
23+
}
24+
25+
~CameraDescription()
26+
{
27+
Destroy();
28+
}
29+
30+
public void Dispose()
31+
{
32+
Destroy();
33+
GC.SuppressFinalize(this);
34+
}
35+
36+
void Destroy()
37+
{
38+
if (m_Ptr != IntPtr.Zero)
39+
{
40+
Internal_Destroy(m_Ptr);
41+
m_Ptr = IntPtr.Zero;
42+
}
43+
}
44+
45+
public bool TryGetProperty(string propertyName, out float value) => TryGetFloatProperty(propertyName, out value);
46+
public bool TryGetProperty(string propertyName, out Vector4 value) => TryGetVector4Property(propertyName, out value);
47+
public bool TryGetProperty(string propertyName, out string value) => TryGetStringProperty(propertyName, out value);
48+
public bool TryGetProperty(string propertyName, out int value) => TryGetIntProperty(propertyName, out value);
49+
50+
public extern void GetVector4PropertyNames(List<string> names);
51+
public extern void GetFloatPropertyNames(List<string> names);
52+
public extern void GetStringPropertyNames(List<string> names);
53+
public extern void GetIntPropertyNames(List<string> names);
54+
55+
extern bool TryGetVector4Property(string propertyName, out Vector4 value);
56+
extern bool TryGetFloatProperty(string propertyName, out float value);
57+
extern bool TryGetStringProperty(string propertyName, out string value);
58+
extern bool TryGetIntProperty(string propertyName, out int value);
59+
60+
public bool TryGetAnimationCurve(string clipName, string propertyName, out AnimationCurve value)
61+
{
62+
value = TryGetAnimationCurve(clipName, propertyName);
63+
return value != null;
64+
}
65+
66+
public extern bool HasAnimationCurveInClip(string clipName, string propertyName);
67+
public extern bool HasAnimationCurve(string propertyName);
68+
extern AnimationCurve TryGetAnimationCurve(string clipName, string propertyName);
69+
70+
static extern IntPtr Internal_Create();
71+
static extern void Internal_Destroy(IntPtr ptr);
72+
}
73+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 System;
6+
using System.Collections.Generic;
7+
using System.Runtime.InteropServices;
8+
using UnityEngine;
9+
using UnityEngine.Bindings;
10+
using UnityEngine.Scripting;
11+
12+
namespace UnityEditor.AssetImporters
13+
{
14+
[RequiredByNativeCode]
15+
[NativeHeader("Editor/Src/AssetPipeline/ModelImporting/LightDescription.h")]
16+
public class LightDescription : IDisposable
17+
{
18+
internal IntPtr m_Ptr;
19+
20+
public LightDescription()
21+
{
22+
m_Ptr = Internal_Create();
23+
}
24+
25+
~LightDescription()
26+
{
27+
Destroy();
28+
}
29+
30+
public void Dispose()
31+
{
32+
Destroy();
33+
GC.SuppressFinalize(this);
34+
}
35+
36+
void Destroy()
37+
{
38+
if (m_Ptr != IntPtr.Zero)
39+
{
40+
Internal_Destroy(m_Ptr);
41+
m_Ptr = IntPtr.Zero;
42+
}
43+
}
44+
45+
public bool TryGetProperty(string propertyName, out float value) => TryGetFloatProperty(propertyName, out value);
46+
public bool TryGetProperty(string propertyName, out Vector4 value) => TryGetVector4Property(propertyName, out value);
47+
public bool TryGetProperty(string propertyName, out string value) => TryGetStringProperty(propertyName, out value);
48+
public bool TryGetProperty(string propertyName, out int value) => TryGetIntProperty(propertyName, out value);
49+
50+
public extern void GetVector4PropertyNames(List<string> names);
51+
public extern void GetFloatPropertyNames(List<string> names);
52+
public extern void GetStringPropertyNames(List<string> names);
53+
public extern void GetIntPropertyNames(List<string> names);
54+
55+
extern bool TryGetVector4Property(string propertyName, out Vector4 value);
56+
extern bool TryGetFloatProperty(string propertyName, out float value);
57+
extern bool TryGetStringProperty(string propertyName, out string value);
58+
extern bool TryGetIntProperty(string propertyName, out int value);
59+
60+
public bool TryGetAnimationCurve(string clipName, string propertyName, out AnimationCurve value)
61+
{
62+
value = TryGetAnimationCurve(clipName, propertyName);
63+
return value != null;
64+
}
65+
66+
public extern bool HasAnimationCurveInClip(string clipName, string propertyName);
67+
public extern bool HasAnimationCurve(string propertyName);
68+
extern AnimationCurve TryGetAnimationCurve(string clipName, string propertyName);
69+
70+
static extern IntPtr Internal_Create();
71+
static extern void Internal_Destroy(IntPtr ptr);
72+
}
73+
}

Editor/Mono/AssetPipeline/MaterialDescription.bindings.cs

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

55
using System;
66
using System.Collections.Generic;
7-
using System.Runtime.InteropServices;
87
using UnityEngine;
98
using UnityEngine.Bindings;
109
using UnityEngine.Scripting;

Editor/Mono/AssetPipeline/TextureImporterEnums.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ internal enum TextureUsageMode
2727
// Baked lightmap without any encoding
2828
BakedLightmapFullHDR = 8,
2929
RealtimeLightmapRGBM = 9,
30+
NormalmapASTCnm = 10,
31+
SingleChannelRed = 11,
32+
SingleChannelAlpha = 12,
3033
}
3134

3235
// Imported texture format for [[TextureImporter]].

Editor/Mono/AssetPostprocessor.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ internal class PostprocessStack
146146
internal ArrayList m_ImportProcessors = null;
147147
}
148148

149+
const string kCameraPostprocessorDependencyName = "postprocessor/camera";
150+
const string kLightPostprocessorDependencyName = "postprocessor/light";
151+
149152
static ArrayList m_PostprocessStack = null;
150153
static ArrayList m_ImportProcessors = null;
151154
static Type[] m_PostprocessorClasses = null;
@@ -154,6 +157,8 @@ internal class PostprocessStack
154157
static string m_AudioProcessorsHashString = null;
155158
static string m_SpeedTreeProcessorsHashString = null;
156159
static string m_PrefabProcessorsHashString = null;
160+
static string m_CameraProcessorsHashString = null;
161+
static string m_LightProcessorsHashString = null;
157162

158163
static Type[] GetCachedAssetPostprocessorClasses()
159164
{
@@ -368,6 +373,22 @@ static void PostprocessMaterial(Material material)
368373
CallPostProcessMethods("OnPostprocessMaterial", args);
369374
}
370375

376+
[RequiredByNativeCode]
377+
static void PreprocessCameraDescription(AssetImportContext assetImportContext, CameraDescription description, Camera camera, AnimationClip[] animations)
378+
{
379+
assetImportContext.DependsOnCustomDependency(kCameraPostprocessorDependencyName);
380+
object[] args = { description, camera, animations };
381+
CallPostProcessMethods("OnPreprocessCameraDescription", args);
382+
}
383+
384+
[RequiredByNativeCode]
385+
static void PreprocessLightDescription(AssetImportContext assetImportContext, LightDescription description, Light light, AnimationClip[] animations)
386+
{
387+
assetImportContext.DependsOnCustomDependency(kLightPostprocessorDependencyName);
388+
object[] args = { description, light, animations };
389+
CallPostProcessMethods("OnPreprocessLightDescription", args);
390+
}
391+
371392
[RequiredByNativeCode]
372393
static void PreprocessMaterialDescription(MaterialDescription description, Material material, AnimationClip[] animations)
373394
{
@@ -611,6 +632,58 @@ static string GetSpeedTreeProcessorsHashString()
611632
return m_SpeedTreeProcessorsHashString;
612633
}
613634

635+
[InitializeOnLoadMethod]
636+
static void RefreshCustomDependencies()
637+
{
638+
AssetDatabase.RegisterCustomDependency(kCameraPostprocessorDependencyName, Hash128.Compute(GetCameraProcessorsHashString()));
639+
AssetDatabase.RegisterCustomDependency(kLightPostprocessorDependencyName, Hash128.Compute(GetLightProcessorsHashString()));
640+
}
641+
642+
static void GetProcessorHashString(string methodName, ref string hashString)
643+
{
644+
if (hashString != null)
645+
return;
646+
647+
var versionsByType = new SortedList<string, uint>();
648+
649+
foreach (var assetPostprocessorClass in GetCachedAssetPostprocessorClasses())
650+
{
651+
try
652+
{
653+
if (assetPostprocessorClass.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null)
654+
{
655+
var inst = Activator.CreateInstance(assetPostprocessorClass) as AssetPostprocessor;
656+
uint version = inst.GetVersion();
657+
versionsByType.Add(assetPostprocessorClass.FullName, version);
658+
}
659+
}
660+
catch (MissingMethodException)
661+
{
662+
LogPostProcessorMissingDefaultConstructor(assetPostprocessorClass);
663+
}
664+
catch (Exception e)
665+
{
666+
Debug.LogException(e);
667+
}
668+
}
669+
670+
hashString = BuildHashString(versionsByType);
671+
}
672+
673+
[RequiredByNativeCode]
674+
static string GetCameraProcessorsHashString()
675+
{
676+
GetProcessorHashString("OnPreprocessCameraDescription", ref m_CameraProcessorsHashString);
677+
return m_CameraProcessorsHashString;
678+
}
679+
680+
[RequiredByNativeCode]
681+
static string GetLightProcessorsHashString()
682+
{
683+
GetProcessorHashString("OnPreprocessLightDescription", ref m_LightProcessorsHashString);
684+
return m_LightProcessorsHashString;
685+
}
686+
614687
static bool IsAssetPostprocessorAnalyticsEnabled()
615688
{
616689
return EditorAnalytics.enabled;

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,12 @@ private static void RunAssemblyStripper(UnityLinkerRunInformation runInformation
249249
}
250250

251251
if (runInformation.performEngineStripping)
252-
UpdateBuildReport(ReadLinkerToEditorData(tempStripPath), runInformation);
252+
{
253+
var strippingInfo = runInformation.BuildReportData;
254+
255+
if (strippingInfo != null)
256+
UpdateBuildReport(ReadLinkerToEditorData(tempStripPath), strippingInfo);
257+
}
253258

254259
// keep unstripped files for debugging purposes
255260
var tempUnstrippedPath = GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempUnstripped"));
@@ -371,13 +376,8 @@ private static string WriteSerializedTypesBlacklist(string managedAssemblyDirect
371376
return path;
372377
}
373378

374-
private static void UpdateBuildReport(LinkerToEditorData dataFromLinker, UnityLinkerRunInformation runInformation)
379+
internal static void UpdateBuildReport(LinkerToEditorData dataFromLinker, StrippingInfo strippingInfo)
375380
{
376-
var strippingInfo = runInformation.BuildReportData;
377-
378-
if (strippingInfo == null)
379-
return;
380-
381381
foreach (var moduleInfo in dataFromLinker.report.modules)
382382
{
383383
strippingInfo.AddModule(moduleInfo.name);

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,15 @@ protected string GetVariationName(BuildPostProcessArgs args)
561561

562562
protected virtual string GetVariationName(BuildPostProcessArgs args, string platformString)
563563
{
564-
var configurationString = GetDevelopment(args) ? "development" : "nondevelopment";
565-
566564
var scriptingBackend = "mono";
567565
if (UseIl2Cpp && !IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildTargetGroup.Standalone))
568566
scriptingBackend = "il2cpp";
569567

570-
return $"{platformString}_{configurationString}_{scriptingBackend}";
568+
return string.Format("{0}_{1}_{2}_{3}",
569+
platformString,
570+
IsServerBuild(args) ? "server" : "player",
571+
GetDevelopment(args) ? "development" : "nondevelopment",
572+
scriptingBackend);
571573
}
572574

573575
protected static string GetPathSafeProductName(BuildPostProcessArgs args)

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ private void ConvertPlayerDlltoCpp(Il2CppBuildPipelineData data)
710710
if (m_BuildForMonoRuntime)
711711
arguments.Add("--mono-runtime");
712712

713+
if (EditorUserBuildSettings.il2CppCodeGeneration == Il2CppCodeGeneration.OptimizeSize)
714+
arguments.Add("--generics-option=EnableFullSharing");
715+
713716
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
714717
var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
715718
arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(apiCompatibilityLevel)));

0 commit comments

Comments
 (0)