Skip to content

Commit ddda763

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a17 C# reference source code
1 parent 5cdad00 commit ddda763

File tree

240 files changed

+6752
-1636
lines changed

Some content is hidden

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

240 files changed

+6752
-1636
lines changed

Editor/Mono/ActiveEditorTracker.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public static ActiveEditorTracker sharedTracker
207207
[FreeFunction("Internal_SetupSharedTracker")]
208208
static extern void SetupSharedTracker(ActiveEditorTracker sharedTracker);
209209

210+
[RequiredByNativeCode]
210211
static void Internal_OnTrackerRebuild()
211212
{
212213
if (editorTrackerRebuilt != null)

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ private void DrawSeparator(ref Rect rect)
230230
//Opens render debugger window located at \newSRP\unity\Packages\com.unity.render-pipelines.core\Editor\Debugging\DebugWindow.cs
231231
private void DrawRenderingDebuggerShortCut(Rect rect)
232232
{
233-
GUIContent label = new GUIContent("Open Rendering Debugger...");
233+
GUIContent label = new GUIContent("Rendering Debugger...");
234234
var labelRect = rect;
235235
labelRect.y += (kHeaderVerticalPadding * 2f);
236-
labelRect.x += kHeaderHorizontalPadding;
237-
labelRect.width = EditorStyles.miniLabel.CalcSize(label).x;
238-
labelRect.height = EditorStyles.miniLabel.CalcSize(label).y;
236+
labelRect.x += kHeaderHorizontalPadding + 15f;
237+
labelRect.width = EditorStyles.foldout.CalcSize(label).x;
238+
labelRect.height = EditorStyles.foldout.CalcSize(label).y;
239239

240-
if (GUI.Button(labelRect, label, EditorStyles.miniLabel))
240+
if (GUI.Button(labelRect, label, EditorStyles.label))
241241
{
242242
EditorApplication.ExecuteMenuItem("Window/Analysis/Rendering Debugger");
243243
editorWindow.Close();

Editor/Mono/AssemblyValidation.cs

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ public static Error[] ValidateAssemblies(string[] assemblyPaths, bool enableLogg
132132
}
133133

134134
var errors = ValidateAssemblyDefinitions(assemblyPaths,
135-
assemblyDefinitions,
136-
PluginCompatibleWithEditor);
135+
assemblyDefinitions);
137136

138137
return errors;
139138
}
@@ -212,19 +211,6 @@ public static Error[] ValidateAssemblyDefinitionFiles()
212211
return errors.ToArray();
213212
}
214213

215-
public static bool PluginCompatibleWithEditor(string path)
216-
{
217-
var pluginImporter = AssetImporter.GetAtPath(path) as PluginImporter;
218-
219-
if (pluginImporter == null)
220-
return true;
221-
222-
if (pluginImporter.GetCompatibleWithAnyPlatform())
223-
return true;
224-
225-
return pluginImporter.GetCompatibleWithEditor();
226-
}
227-
228214
public static bool ShouldValidateReferences(string path,
229215
Dictionary<string, PrecompiledAssembly> allPrecompiledAssemblies)
230216
{
@@ -251,23 +237,20 @@ public static void PrintAssemblyDefinitions(AssemblyDefinition[] assemblyDefinit
251237
}
252238

253239
public static Error[] ValidateAssembliesInternal(string[] assemblyPaths,
254-
string[] searchPaths,
255-
Func<string, bool> compatibleWithEditor)
240+
string[] searchPaths)
256241
{
257242
var assemblyDefinitions = LoadAssemblyDefinitions(assemblyPaths, searchPaths);
258-
return ValidateAssemblyDefinitions(assemblyPaths, assemblyDefinitions, compatibleWithEditor);
243+
return ValidateAssemblyDefinitions(assemblyPaths, assemblyDefinitions);
259244
}
260245

261246
public static Error[] ValidateAssemblyDefinitions(string[] assemblyPaths,
262-
AssemblyDefinition[] assemblyDefinitions,
263-
Func<string, bool> compatibleWithEditor)
247+
AssemblyDefinition[] assemblyDefinitions)
264248
{
265249
var errors = new Error[assemblyPaths.Length];
266250

267251
CheckAssemblyReferences(assemblyPaths,
268252
errors,
269-
assemblyDefinitions,
270-
compatibleWithEditor);
253+
assemblyDefinitions);
271254

272255
return errors;
273256
}
@@ -301,11 +284,8 @@ public static AssemblyDefinition[] LoadAssemblyDefinitions(string[] assemblyPath
301284

302285
public static void CheckAssemblyReferences(string[] assemblyPaths,
303286
Error[] errors,
304-
AssemblyDefinition[] assemblyDefinitions,
305-
Func<string, bool> compatibleWithEditor)
287+
AssemblyDefinition[] assemblyDefinitions)
306288
{
307-
SetupEditorCompatibility(assemblyPaths, errors, compatibleWithEditor);
308-
309289
var assemblyDefinitionNameToIndex = new Dictionary<string, int>();
310290
var assembliesAndReferencesArray = new AssemblyAndReferences[assemblyPaths.Length];
311291

@@ -382,22 +362,6 @@ public static void CheckAssemblyReferences(string[] assemblyPaths,
382362
while (referenceErrorCount > 0);
383363
}
384364

385-
public static void SetupEditorCompatibility(string[] assemblyPaths,
386-
Error[] errors,
387-
Func<string, bool> compatibleWithEditor)
388-
{
389-
for (int i = 0; i < assemblyPaths.Length; ++i)
390-
{
391-
var assemblyPath = assemblyPaths[i];
392-
393-
if (!compatibleWithEditor(assemblyPath))
394-
{
395-
errors[i].Add(ErrorFlags.IncompatibleWithEditor,
396-
"Assembly is incompatible with the editor");
397-
}
398-
}
399-
}
400-
401365
public static void ResolveAndSetupReferences(int index,
402366
Error[] errors,
403367
AssemblyDefinition[] assemblyDefinitions,

Editor/Mono/AssetModificationProcessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ internal static void OnWillCreateAsset(string path)
116116
}
117117

118118
// ReSharper disable once UnusedMember.Local - invoked from native code
119+
[RequiredByNativeCode]
119120
static void FileModeChanged(string[] assets, FileMode mode)
120121
{
121122
AssetModificationHook.FileModeChanged(assets, mode);
@@ -196,6 +197,7 @@ static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSav
196197
}
197198
}
198199

200+
[RequiredByNativeCode]
199201
static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths)
200202
{
201203
AssetMoveResult finalResult = AssetMoveResult.DidNotMove;
@@ -219,6 +221,7 @@ static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[]
219221
return finalResult;
220222
}
221223

224+
[RequiredByNativeCode]
222225
static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
223226
{
224227
AssetDeleteResult finalResult = AssetDeleteResult.DidNotDelete;
@@ -246,6 +249,7 @@ static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions
246249
return finalResult;
247250
}
248251

252+
[RequiredByNativeCode]
249253
static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathDeletionResults, RemoveAssetOptions options)
250254
{
251255
for (int i = 0; i < outPathDeletionResults.Length; i++)
@@ -542,6 +546,7 @@ static List<string> GetQueryList(string[] paths, List<string> outNotEditablePath
542546
return result;
543547
}
544548

549+
[RequiredByNativeCode]
545550
internal static void OnStatusUpdated()
546551
{
547552
WindowPending.OnStatusUpdated();

Editor/Mono/AssetPostprocessor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,14 @@ static void PostprocessMeshHierarchy(GameObject root)
697697
CallPostProcessMethods("OnPostprocessMeshHierarchy", args);
698698
}
699699

700+
[RequiredByNativeCode]
700701
static void PostprocessMesh(GameObject gameObject)
701702
{
702703
object[] args = { gameObject };
703704
CallPostProcessMethods("OnPostprocessModel", args);
704705
}
705706

707+
[RequiredByNativeCode]
706708
static void PostprocessSpeedTree(GameObject gameObject)
707709
{
708710
object[] args = { gameObject };

Editor/Mono/AssetPreviewUpdater.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using UnityEngine;
6+
using UnityEngine.Scripting;
67
using UnityEngine.Rendering;
78

89
namespace UnityEditor
910
{
1011
internal static class AssetPreviewUpdater
1112
{
13+
[RequiredByNativeCode]
1214
public static Texture2D CreatePreviewForAsset(Object obj, Object[] subAssets, string assetPath)
1315
{
1416
return CreatePreview(obj, subAssets, assetPath, 128, 128);

Editor/Mono/BuildPipeline.bindings.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,6 @@ public class BuildPipeline
278278
[FreeFunction]
279279
public static extern void PopAssetDependencies();
280280

281-
private static string[] InvokeCalculateBuildTags(BuildTarget target, BuildTargetGroup group)
282-
{
283-
// TODO: This is a temporary function until the new Package Manager comes online. (cases 849472)
284-
// When that happens, we will walk the list of installed packages, see which ones are active for the current build settings
285-
// and if they are unity official packages with metadata for analytics, we will append those tags to the returned vector.
286-
287-
return new string[0];
288-
}
289-
290281
private static void LogBuildExceptionAndExit(string buildFunctionName, System.Exception exception)
291282
{
292283
Debug.LogErrorFormat("Internal Error in {0}:", buildFunctionName);

Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,17 @@ static public void Postprocess(BuildTargetGroup targetGroup, BuildTarget target,
253253
throw new Exception(installPath + " must not be an empty string");
254254

255255
IBuildPostprocessor postprocessor = ModuleManager.GetBuildPostProcessor(targetGroup, target);
256-
if (postprocessor != null)
256+
if (postprocessor == null)
257+
// If postprocessor is not provided, build target is not supported
258+
throw new UnityException($"Build target '{target}' not supported");
259+
260+
try
257261
{
262+
AddIconsArgs iconArgs;
263+
iconArgs.stagingArea = stagingArea;
264+
if (!postprocessor.AddIconsToBuild(iconArgs))
265+
throw new BuildFailedException("Failed to add player icon");
266+
258267
BuildPostProcessArgs args;
259268
args.target = target;
260269
args.subtarget = subtarget;
@@ -271,29 +280,24 @@ static public void Postprocess(BuildTargetGroup targetGroup, BuildTarget target,
271280
args.report = report;
272281

273282
BuildProperties props;
274-
try
275-
{
276-
postprocessor.PostProcess(args, out props);
277-
}
278-
catch (BuildFailedException)
279-
{
280-
throw;
281-
}
282-
catch (Exception e)
283-
{
284-
// Rethrow exceptions during build postprocessing as BuildFailedException, so we don't pretend the build was fine.
285-
throw new BuildFailedException(e);
286-
}
283+
postprocessor.PostProcess(args, out props);
284+
287285
if (props != null)
288286
{
289287
report.AddAppendix(props);
290288
}
291289

292290
return;
293291
}
294-
295-
// If postprocessor is not provided, build target is not supported
296-
throw new UnityException(string.Format("Build target '{0}' not supported", target));
292+
catch (BuildFailedException)
293+
{
294+
throw;
295+
}
296+
catch (Exception e)
297+
{
298+
// Rethrow exceptions during build postprocessing as BuildFailedException, so we don't pretend the build was fine.
299+
throw new BuildFailedException(e);
300+
}
297301
}
298302

299303
public static void PostProcessCompletedBuild(BuildPostProcessArgs args)

Editor/Mono/BuildPipeline/RenderPipeline/RenderPipelineGlobalSettingsStripper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void OnPreprocessBuild(BuildReport report)
2424
if (renderPipelineAssets.Count > 0 && renderPipelineAssets[0] != null)
2525
{
2626
// Top level stripping, even if there are multiple pipelines registered into the project, as we are building we are making sure the only one that is being transferred into the player is the current one.
27-
GraphicsSettings.currentRenderPipelineGlobalSettings = EditorGraphicsSettings.GetSettingsForRenderPipeline(renderPipelineAssets[0].renderPipelineType);
27+
GraphicsSettings.currentRenderPipelineGlobalSettings = EditorGraphicsSettings.GetSettingsForRenderPipeline(renderPipelineAssets[0].pipelineType);
2828
}
2929

3030
ListPool<RenderPipelineAsset>.Release(renderPipelineAssets);

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static Styles()
148148

149149
static bool isEditorinstalledWithHub = IsEditorInstalledWithHub();
150150

151-
[UsedImplicitly]
151+
[UsedImplicitly, RequiredByNativeCode]
152152
public static void ShowBuildPlayerWindow()
153153
{
154154
EditorUserBuildSettings.selectedBuildTargetGroup = EditorUserBuildSettings.activeBuildTargetGroup;
@@ -175,7 +175,7 @@ static bool BuildPlayerAndRunEnabled()
175175

176176
// This overload is used by the Build & Run menu item & hot key - prompt for location only if the configured
177177
// output location is not valid.
178-
[UsedImplicitly]
178+
[UsedImplicitly, RequiredByNativeCode]
179179
static void BuildPlayerAndRun()
180180
{
181181
var buildTarget = EditorUserBuildSettingsUtils.CalculateSelectedBuildTarget();
@@ -189,11 +189,11 @@ static void BuildPlayerAndRun()
189189
EditorUserBuildSettings.SetBuildLocation(buildTarget, newBuildLocation);
190190
}
191191

192-
BuildPlayerAndRun(!buildLocationIsValid);
192+
BuildPlayerAndRunInternal(!buildLocationIsValid);
193193
}
194194

195195
// This overload is used by the default player window, to always prompt for build location
196-
static void BuildPlayerAndRun(bool askForBuildLocation)
196+
static void BuildPlayerAndRunInternal(bool askForBuildLocation)
197197
{
198198
CallBuildMethods(askForBuildLocation, BuildOptions.AutoRunPlayer | BuildOptions.StrictMode);
199199
}
@@ -1110,7 +1110,7 @@ private static void GUIBuildButtons(IBuildWindowExtension buildWindowExtension,
11101110
GUI.enabled = enableBuildAndRunButton && selectedTargetIsActive;
11111111
if (GUILayout.Button(buildAndRunButton, GUILayout.Width(Styles.kButtonWidth)))
11121112
{
1113-
BuildPlayerAndRun(askForBuildLocation);
1113+
BuildPlayerAndRunInternal(askForBuildLocation);
11141114
GUIUtility.ExitGUI();
11151115
}
11161116

0 commit comments

Comments
 (0)