Skip to content

Commit 6a26bc1

Browse files
author
Unity Technologies
committed
Unity 6000.0.0b12 C# reference source code
1 parent 6c8a95f commit 6a26bc1

File tree

226 files changed

+3222
-1424
lines changed

Some content is hidden

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

226 files changed

+3222
-1424
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public class Il2CppConfig
9393
public string[] AdditionalArgs = new string[0];
9494
public string CompilerFlags;
9595
public string LinkerFlags;
96+
public string LinkerFlagsFile;
9697
public string ExtraTypes;
9798
public bool CreateSymbolFiles;
9899
public bool AllowDebugging;

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
[assembly: InternalsVisibleTo("UnityEditor.PS5.Extensions")]
5555
[assembly: InternalsVisibleTo("UnityEditor.Switch.Extensions")]
5656
[assembly: InternalsVisibleTo("UnityEditor.WebGL.Extensions")]
57+
[assembly: InternalsVisibleTo("Unity.Automation.Players.WebGL")]
5758
[assembly: InternalsVisibleTo("Unity.WebGL.Extensions")]
5859
[assembly: InternalsVisibleTo("UnityEditor.LinuxStandalone.Extensions")]
5960
[assembly: InternalsVisibleTo("UnityEditor.CloudRendering.Extensions")]
@@ -149,6 +150,9 @@
149150

150151
[assembly: InternalsVisibleTo("Unity.Entities.Build")]
151152

153+
[assembly: InternalsVisibleTo("Unity.Muse.Common.Bridge")]
154+
[assembly: InternalsVisibleTo("Unity.Muse.Chat.Bridge")]
155+
152156
[assembly: InternalsVisibleTo("Unity.Scenes")]
153157

154158
// This should move with the AnimationWindow to a module at some point

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ public STMeshGeometry(int vertexCount, int UVCount, int indexLod)
115115
/// </remarks>
116116
public delegate void OnCustomEditorSettings(ref SerializedProperty diffusionProfileAsset, ref SerializedProperty diffusionProfileHash);
117117

118+
[SerializeField]
119+
internal SpeedTreeImporterOutputData m_OutputImporterData;
120+
118121
// Cache main objects, created during import process.
119122
private AssetImportContext m_Context;
120123
private SpeedTree9Reader m_Tree;
121-
private SpeedTreeImporterOutputData m_OutputImporterData;
122124
private Shader m_Shader;
123125
private SpeedTreeWindAsset m_WindAsset;
124126
private STRenderPipeline m_RenderPipeline;
@@ -214,6 +216,8 @@ public override void OnImportAsset(AssetImportContext ctx)
214216
ctx.AddObjectToAsset(m_OutputImporterData.name, m_OutputImporterData);
215217
ctx.DependsOnCustomDependency(ImporterSettings.kMaterialSettingsDependencyname);
216218

219+
AddDependencyOnExtractedMaterials();
220+
217221
TriggerAllCabback();
218222
}
219223

@@ -621,7 +625,7 @@ private void CreateMaterialsForCurrentLOD(STMaterial stMaterial, int lodIndex, b
621625
// Explicity regenerate materials, should happen when bumping the material version for example.
622626
if (regenerateMaterials)
623627
{
624-
extractedMat = CreateMaterial(stMaterial, lodIndex, stMatName, m_PathFromDirectory);
628+
extractedMat = CreateMaterial(stMaterial, lodIndex, extractedMat.name, m_PathFromDirectory);
625629

626630
SetMaterialTextureAndColorProperties(stMaterial, extractedMat, lodIndex, m_PathFromDirectory);
627631
}
@@ -630,10 +634,10 @@ private void CreateMaterialsForCurrentLOD(STMaterial stMaterial, int lodIndex, b
630634
RetrieveMaterialSpecialProperties(extractedMat);
631635
}
632636

633-
var existedMatIndex = m_OutputImporterData.lodMaterials.materials.FindIndex(m => m.material.name == stMatName);
637+
var existedMatIndex = m_OutputImporterData.lodMaterials.materials.FindIndex(m => m.defaultName == stMatName);
634638
if (existedMatIndex == -1)
635639
{
636-
m_OutputImporterData.lodMaterials.materials.Add(new MaterialInfo { material = extractedMat, exported = true });
640+
m_OutputImporterData.lodMaterials.materials.Add(new MaterialInfo { material = extractedMat, defaultName = stMatName, exported = true });
637641
m_OutputImporterData.lodMaterials.matNameToIndex[stMatName] = m_OutputImporterData.lodMaterials.materials.Count - 1;
638642
}
639643
else
@@ -646,7 +650,7 @@ private void CreateMaterialsForCurrentLOD(STMaterial stMaterial, int lodIndex, b
646650
{
647651
Material newMat = CreateMaterial(stMaterial, lodIndex, stMatName, m_PathFromDirectory);
648652

649-
m_OutputImporterData.lodMaterials.materials.Add(new MaterialInfo { material = newMat, exported = false });
653+
m_OutputImporterData.lodMaterials.materials.Add(new MaterialInfo { material = newMat, defaultName = stMatName, exported = false });
650654
m_OutputImporterData.lodMaterials.matNameToIndex.Add(stMatName, m_OutputImporterData.lodMaterials.materials.Count - 1);
651655
}
652656

@@ -675,7 +679,7 @@ private void CreateAssetIdentifiersAndAddMaterialsToContext()
675679
}
676680
}
677681

678-
m_OutputImporterData.materialsIdentifiers.Add(new AssetIdentifier(matInfo.material.GetType(), matInfo.material.name));
682+
m_OutputImporterData.materialsIdentifiers.Add(new AssetIdentifier(matInfo.material.GetType(), matInfo.defaultName));
679683
}
680684
}
681685

@@ -738,7 +742,7 @@ private void RegenerateAndPopulateExternalMaterials(string assetPath)
738742
m_OutputImporterData.materialsIdentifiers.Add(new AssetIdentifier(matInfo.material.GetType(), matInfo.material.name));
739743

740744
// Remap the new material to the importer 'ExternalObjectMap'.
741-
if (TryGetExternalMaterial(matInfo.material.name, out var extractedMat))
745+
if (TryGetExternalMaterial(matInfo.defaultName, out var extractedMat))
742746
{
743747
string newMatPath = AssetDatabase.GetAssetPath(extractedMat);
744748

@@ -750,7 +754,7 @@ private void RegenerateAndPopulateExternalMaterials(string assetPath)
750754
AssetDatabase.CreateAsset(matInfo.material, newMatPath);
751755
}
752756

753-
if (TryGetSourceAssetIdentifierFromName(matInfo.material.name, out var assetIdentifier))
757+
if (TryGetSourceAssetIdentifierFromName(matInfo.defaultName, out var assetIdentifier))
754758
{
755759
AddRemap(assetIdentifier, matInfo.material);
756760
}
@@ -816,17 +820,17 @@ private bool SetMaterialTexture(Material mat, STMaterial stMaterial, int indexMa
816820
{
817821
MaterialMap stMatMap = stMaterial.Maps[indexMap];
818822
string mapPath = stMatMap.Path;
819-
if (stMatMap.Used && !string.IsNullOrEmpty(mapPath))
820-
{
821-
string finalTexturePath = path + mapPath;
822823

823-
Texture2D tex = (m_Context != null)
824-
? m_Context.GetReferenceToAssetMainObject(finalTexturePath) as Texture2D
825-
: AssetDatabase.LoadAssetAtPath(finalTexturePath, typeof(Texture2D)) as Texture2D;
824+
if (!stMatMap.Used)
825+
return false;
826+
827+
if (!string.IsNullOrEmpty(mapPath))
828+
{
829+
Texture2D texture = LoadTexture(mapPath, path);
826830

827-
if (tex != null)
831+
if (texture != null)
828832
{
829-
mat.SetTexture(property, tex);
833+
mat.SetTexture(property, texture);
830834
return true;
831835
}
832836
}
@@ -835,6 +839,35 @@ private bool SetMaterialTexture(Material mat, STMaterial stMaterial, int indexMa
835839
return false;
836840
}
837841

842+
private Texture2D LoadTexture(string mapPath, string path)
843+
{
844+
string texturePath = path + mapPath;
845+
846+
Texture2D texture = (m_Context != null)
847+
? m_Context.GetReferenceToAssetMainObject(texturePath) as Texture2D
848+
: AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
849+
850+
if (texture != null)
851+
return texture;
852+
853+
// Textures are not located near the asset, let's check if they were moved somewhere else.
854+
string mapPathWithoutExtension = Path.GetFileNameWithoutExtension(mapPath);
855+
string[] textureAssets = AssetDatabase.FindAssets(mapPathWithoutExtension);
856+
857+
if (textureAssets != null && textureAssets.Length > 0)
858+
{
859+
string assetPathFromGUID = AssetDatabase.GUIDToAssetPath(textureAssets[0]);
860+
861+
texture = (m_Context != null)
862+
? m_Context.GetReferenceToAssetMainObject(assetPathFromGUID) as Texture2D
863+
: AssetDatabase.LoadAssetAtPath(assetPathFromGUID, typeof(Texture2D)) as Texture2D;
864+
865+
return texture;
866+
}
867+
868+
return null;
869+
}
870+
838871
private bool TryGetInstanceIDFromMaterialProperty(Material material, int propertyName, out int id)
839872
{
840873
if (!material.HasProperty(propertyName))
@@ -1094,6 +1127,25 @@ internal void SetMaterialsVersionToCurrent()
10941127
m_MaterialVersion = SPEEDTREE_9_MATERIAL_VERSION;
10951128
MarkDirty();
10961129
}
1130+
1131+
private void AddDependencyOnExtractedMaterials()
1132+
{
1133+
Dictionary<SourceAssetIdentifier, UnityEngine.Object> extMap = GetExternalObjectMap();
1134+
1135+
foreach (var entry in extMap)
1136+
{
1137+
if (entry.Value != null)
1138+
{
1139+
string matPath = AssetDatabase.GetAssetPath(entry.Value);
1140+
1141+
m_Context.DependsOnImportedAsset(matPath);
1142+
1143+
// Necessary to avoid the warning "Import of asset setup artifact dependency to but dependency isn't used
1144+
// and therefore not registered in the asset database".
1145+
AssetDatabase.LoadAssetAtPath(matPath, typeof(Material));
1146+
}
1147+
}
1148+
}
10971149
#endregion
10981150

10991151
#region Wind

Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ internal class PerLODSettings
8585
internal class MaterialInfo
8686
{
8787
public Material material = null;
88+
public string defaultName = null;
8889
public bool exported = false;
8990
}
9091

Editor/Mono/Audio/AudioContainerWindow.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,19 @@ static void OnCreateButtonClicked()
122122
void OnEnable()
123123
{
124124
Instance = this;
125-
126125
m_DiceIconOff = EditorGUIUtility.IconContent("AudioRandomContainer On Icon").image as Texture2D;
127126
m_DiceIconOn = EditorGUIUtility.IconContent("AudioRandomContainer Icon").image as Texture2D;
128-
129127
SetTitle();
130-
131-
m_IsInitializing = false;
132-
m_Day0ElementsInitialized = false;
133-
m_ContainerElementsInitialized = false;
134128
}
135129

136130
void OnDisable()
137131
{
138132
Instance = null;
139133
State.OnDestroy();
134+
UnsubscribeFromGUICallbacksAndEvents();
135+
m_IsInitializing = false;
136+
m_Day0ElementsInitialized = false;
137+
m_ContainerElementsInitialized = false;
140138
m_CachedElements.Clear();
141139
m_AddedElements.Clear();
142140
}
@@ -272,6 +270,11 @@ void InitializeContainerElements()
272270

273271
void SubscribeToGUICallbacksAndEvents()
274272
{
273+
if (!m_ContainerElementsInitialized || m_IsSubscribedToGUICallbacksAndEvents)
274+
{
275+
return;
276+
}
277+
275278
SubscribeToPreviewCallbacksAndEvents();
276279
SubscribeToVolumeCallbacksAndEvents();
277280
SubscribeToPitchCallbacksAndEvents();
@@ -283,6 +286,11 @@ void SubscribeToGUICallbacksAndEvents()
283286

284287
void UnsubscribeFromGUICallbacksAndEvents()
285288
{
289+
if (!m_ContainerElementsInitialized || !m_IsSubscribedToGUICallbacksAndEvents)
290+
{
291+
return;
292+
}
293+
286294
UnsubscribeFromPreviewCallbacksAndEvents();
287295
UnsubscribeFromVolumeCallbacksAndEvents();
288296
UnsubscribeFromPitchCallbacksAndEvents();

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public abstract class Sysroot
3535
public abstract string GetToolchainPath();
3636
public abstract string GetIl2CppCompilerFlags();
3737
public abstract string GetIl2CppLinkerFlags();
38+
// The sysroot package does not currently contain an implemenation for this method, adding a default implementation to avoid breaking stuff
39+
public virtual string GetIl2CppLinkerFlagsFile() => null;
3840
}
3941
}
4042

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public GUIContent GetDownloadErrorForTarget(BuildTarget target)
7070
public GUIContent autoconnectProfiler = EditorGUIUtility.TrTextContent("Autoconnect Profiler", "When the build is started, an open Profiler Window will automatically connect to the Player and start profiling. The \"Build And Run\" option will also automatically open the Profiler Window.");
7171
public GUIContent autoconnectProfilerDisabled = EditorGUIUtility.TrTextContent("Autoconnect Profiler", "Profiling is only enabled in a Development Player.");
7272
public GUIContent buildWithDeepProfiler = EditorGUIUtility.TrTextContent("Deep Profiling Support", "Build Player with Deep Profiling Support. This might affect Player performance.");
73-
public GUIContent buildWithDeepProfilerDisabled = EditorGUIUtility.TrTextContent("Deep Profiling", "Profiling is only enabled in a Development Player.");
73+
public GUIContent buildWithDeepProfilerDisabled = EditorGUIUtility.TrTextContent("Deep Profiling Support", "Profiling is only enabled in a Development Player.");
7474
public GUIContent allowDebugging = EditorGUIUtility.TrTextContent("Script Debugging", "Enable this setting to allow your script code to be debugged.");
7575
public GUIContent waitForManagedDebugger = EditorGUIUtility.TrTextContent("Wait For Managed Debugger", "Show a dialog where you can attach a managed debugger before any script execution. Can also use volume Up or Down button to confirm on Android.");
7676
public GUIContent managedDebuggerFixedPort = EditorGUIUtility.TrTextContent("Managed Debugger Fixed Port", "Use the specified port to attach to the managed debugger. If 0, the port will be automatically selected.");

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,61 @@
1111
namespace UnityEditor.Build.Profile
1212
{
1313
/// <summary>
14-
/// TODO EPIC: https://jira.unity3d.com/browse/PLAT-5745
14+
/// Provides a set of configuration settings you can use to build your application on a particular platform.
1515
/// </summary>
1616
[RequiredByNativeCode(GenerateProxy = true)]
1717
[StructLayout(LayoutKind.Sequential)]
18-
[VisibleToOtherModules]
19-
internal sealed partial class BuildProfile : ScriptableObject
18+
[ExcludeFromObjectFactory]
19+
[ExcludeFromPreset]
20+
public sealed partial class BuildProfile : ScriptableObject
2021
{
2122
/// <summary>
2223
/// Build Target used to fetch module and build profile extension.
2324
/// </summary>
2425
[SerializeField] BuildTarget m_BuildTarget = BuildTarget.NoTarget;
25-
public BuildTarget buildTarget
26+
[VisibleToOtherModules]
27+
internal BuildTarget buildTarget
2628
{
2729
get => m_BuildTarget;
28-
internal set => m_BuildTarget = value;
30+
set => m_BuildTarget = value;
2931
}
3032

3133
/// <summary>
3234
/// Subtarget, Default for all non-Standalone platforms.
3335
/// </summary>
3436
[SerializeField] StandaloneBuildSubtarget m_Subtarget;
35-
public StandaloneBuildSubtarget subtarget
37+
[VisibleToOtherModules]
38+
internal StandaloneBuildSubtarget subtarget
3639
{
3740
get => m_Subtarget;
38-
internal set => m_Subtarget = value;
41+
set => m_Subtarget = value;
3942
}
4043

4144
/// <summary>
4245
/// Module name used to fetch build profiles.
4346
/// </summary>
4447
[SerializeField] string m_ModuleName;
45-
public string moduleName
48+
[VisibleToOtherModules]
49+
internal string moduleName
4650
{
4751
get => m_ModuleName;
48-
internal set => m_ModuleName = value;
52+
set => m_ModuleName = value;
4953
}
5054

5155
/// <summary>
5256
/// Platform module specific build settings; e.g. AndroidBuildSettings.
5357
/// </summary>
5458
[SerializeReference] BuildProfilePlatformSettingsBase m_PlatformBuildProfile;
55-
public BuildProfilePlatformSettingsBase platformBuildProfile
59+
[VisibleToOtherModules]
60+
internal BuildProfilePlatformSettingsBase platformBuildProfile
5661
{
5762
get => m_PlatformBuildProfile;
58-
internal set => m_PlatformBuildProfile = value;
63+
set => m_PlatformBuildProfile = value;
5964
}
6065

6166
[SerializeField] private EditorBuildSettingsScene[] m_Scenes = Array.Empty<EditorBuildSettingsScene>();
62-
public EditorBuildSettingsScene[] scenes
67+
[VisibleToOtherModules]
68+
internal EditorBuildSettingsScene[] scenes
6369
{
6470
get
6571
{
@@ -101,6 +107,14 @@ internal bool IsActiveBuildProfileOrPlatform()
101107
return profileModuleName == activeModuleName && subtarget == EditorUserBuildSettings.standaloneBuildSubtarget;
102108
}
103109

110+
[VisibleToOtherModules]
111+
internal bool CanBuildLocally()
112+
{
113+
// Note: A platform build profile may have a non-null value even if its module is not installed.
114+
// This scenario is true for server platform profiles, which are the same type as the standalone one.
115+
return platformBuildProfile != null && BuildProfileModuleUtil.IsModuleInstalled(moduleName, subtarget);
116+
}
117+
104118
void OnEnable()
105119
{
106120
// Check if the platform support module has been installed,
@@ -144,7 +158,7 @@ void CheckSceneListConsistency()
144158
RemoveAt(i);
145159
continue;
146160
}
147-
161+
148162
if (!isGuidValid)
149163
scene.guid = AssetDatabase.GUIDFromAssetPath(scene.path);
150164

0 commit comments

Comments
 (0)