forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformSupportModule.cs
More file actions
434 lines (331 loc) · 17 KB
/
Copy pathPlatformSupportModule.cs
File metadata and controls
434 lines (331 loc) · 17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections.Generic;
using UnityEditor.DeploymentTargets;
using UnityEngine;
using Mono.Cecil;
using UnityEditor.Scripting.ScriptCompilation;
namespace UnityEditor.Modules
{
internal interface IPlatformSupportModule
{
/// Returns name identifying a target, for ex., Metro, note this name should match prefix
/// for extension module UnityEditor.Metro.Extensions.dll, UnityEditor.Metro.Extensions.Native.dll
string TargetName { get; }
/// Returns the filename of jam which should be executed when you're recompiling extensions
/// from Editor using CTRL + L shortcut, for ex., WP8EditorExtensions, MetroEditorExtensions, etc
string JamTarget { get; }
/// Returns an array of native libraries that are required by the extension and must be loaded
/// by the editor.
///
/// NOTE: If two different platform extensions return a native library with a same file name
/// (regardless of the path), then only first one will be loaded. This is due to the fact that
/// some platforms may require same native library, but we must ship a copy with both platforms,
/// since our modularization and platform installers don't support shared stuff.
string[] NativeLibraries { get; }
/// Returns an array of assemblies that should be referenced by user's scripts. These will be
/// referenced by editor scripts, and game scripts running in editor. Used to export additional
/// platform specific editor API.
string[] AssemblyReferencesForUserScripts { get; }
// Returns an array of assemblies that should be included into C# project as references.
// This is different from AssemblyReferencesForUserScripts by that most assembly references
// are internal and not added to the C# project. On the other hand, certain assemblies
// contain public API, and thus should be added to C# project.
string[] AssemblyReferencesForEditorCsharpProject { get; }
/// A human friendly version (eg. an incrementing number on each release) of the platform extension. Null/Empty if none available
string ExtensionVersion { get; }
// Names of displays to show in GameView and Camera inspector if the platform supports multiple displays. Return null if default names should be used.
GUIContent[] GetDisplayNames();
IBuildPostprocessor CreateBuildPostprocessor();
// Returns an instance of IDeploymentTargetsExtension or null if not supported
IDeploymentTargetsExtension CreateDeploymentTargetsExtension();
// Returns an instance of IScriptingImplementations or null if only one scripting backend is supported
IScriptingImplementations CreateScriptingImplementations();
// Return an instance of ISettingEditorExtension or null if not used
// See DefaultPlayerSettingsEditorExtension.cs for abstract implementation
ISettingEditorExtension CreateSettingsEditorExtension();
// Return an instance of IPreferenceWindowExtension or null if not used
IPreferenceWindowExtension CreatePreferenceWindowExtension();
// Return an instance of IBuildWindowExtension or null if not used
IBuildWindowExtension CreateBuildWindowExtension();
ICompilationExtension CreateCompilationExtension();
// Rather than null above, this returns a default extension if not used
ITextureImportSettingsExtension CreateTextureImportSettingsExtension();
IPluginImporterExtension CreatePluginImporterExtension();
IBuildAnalyzer CreateBuildAnalyzer();
// Return an instance of IUserAssembliesValidator or null if not used
IUserAssembliesValidator CreateUserAssembliesValidatorExtension();
// Register platform specific Unity extensions
// For ex., Metro specifc UnityEngine.Networking.dll which is different from the generic UnityEngine.Networking.dll
void RegisterAdditionalUnityExtensions();
// return valid object for this device. This ensures that API for certain operations is
// still available even if device was removed, for example stopping remote support.
IDevice CreateDevice(string id);
// Called when build target supplied by this module is activated in the editor.
//
// NOTE: Keep in mind that due domain reloads and the way unity builds, calls on OnActive
// and OnDeactivate will be forced even if current build target isn't being changed.
//
// PERFORMANCE: This method will be called each time user starts the game, so use this
// only for lightweight code, like registering to events, etc.
//
// Currently (de)activation happens when:
// * User switches build target.
// * User runs build for current target.
// * Build is run through scripting API.
// * Scripts are recompiled and reloaded (due user's change, forced reimport, etc).
// * User clicks play in editor.
// * ... and possibly more I'm not aware of.
void OnActivate();
// Called when build target supplied by this module is deactivated in the editor.
//
// NOTE: Keep in mind that due domain reloads and the way unity builds, calls on OnActive
// and OnDeactivate will be forced even if current build target isn't being changed.
//
// PERFORMANCE: This method will be called each time user starts the game, so use this
// only for lightweight code, like unregistering from events, etc.
//
// For more info see OnActivate().
void OnDeactivate();
// Called when extension is loaded, on editor start or domain reload.
//
// PERFORMANCE: This will be called for all available platform extensions during each
// domain reload, including each time user starts the game, so use this only for
// lightweight code.
void OnLoad();
// Called when extension is unloaded, when editor is exited or before domain reload.
//
// PERFORMANCE: This will be called for all available platform extensions during each
// domain reload, including each time user starts the game, so use this only for
// lightweight code.
void OnUnload();
}
internal interface IBuildPostprocessor
{
void LaunchPlayer(BuildLaunchPlayerArgs args);
void PostProcess(BuildPostProcessArgs args, out BuildProperties outProperties);
bool SupportsInstallInBuildFolder();
bool SupportsLz4Compression();
bool SupportsScriptsOnlyBuild();
// This is the place to make sure platform has everything it needs for the build.
// Use EditorUtility.Display(Cancelable)ProgressBar when running long tasks (e.g. downloading SDK from internet).
// Return non-empty string indicating error message to stop the build.
string PrepareForBuild(BuildOptions options, BuildTarget target);
void UpdateBootConfig(BuildTarget target, BootConfigData config, BuildOptions options);
// Return string.Empty if targeting a folder.
string GetExtension(BuildTarget target, BuildOptions options);
}
internal interface IScriptingImplementations
{
// All supported scripting implementations. First is the default one.
ScriptingImplementation[] Supported();
// Scripting implementations exposed to the user.
ScriptingImplementation[] Enabled();
bool AllowIL2CPPCompilerConfigurationSelection();
}
internal class DefaultScriptingImplementations : IScriptingImplementations
{
public virtual ScriptingImplementation[] Supported()
{
return new[] { ScriptingImplementation.Mono2x, ScriptingImplementation.IL2CPP };
}
public virtual ScriptingImplementation[] Enabled()
{
return new[] { ScriptingImplementation.Mono2x, ScriptingImplementation.IL2CPP };
}
public virtual bool AllowIL2CPPCompilerConfigurationSelection()
{
return true;
}
}
// Extension point to add/alter the SettingsEditorWindow class
// If you are creating a new extension you should probably inherit from DefaultPlayerSettingsEditorExtension
internal interface ISettingEditorExtension
{
void OnEnable(PlayerSettingsEditor settingsEditor);
bool HasPublishSection();
// Leave blank if no contribution
void PublishSectionGUI(float h, float midWidth, float maxWidth);
bool HasIdentificationGUI();
// Leave blank if no contribution
void IdentificationSectionGUI();
// Leave blank if no contribution
void ConfigurationSectionGUI();
bool SupportsOrientation();
bool SupportsStaticBatching();
bool SupportsDynamicBatching();
bool SupportsHighDynamicRangeDisplays();
bool SupportsGfxJobModes();
bool CanShowUnitySplashScreen();
void SplashSectionGUI();
bool UsesStandardIcons();
void IconSectionGUI();
bool HasResolutionSection();
void ResolutionSectionGUI(float h, float midWidth, float maxWidth);
bool HasBundleIdentifier();
bool SupportsMultithreadedRendering();
void MultithreadedRenderingGUI(BuildTargetGroup targetGroup);
bool SupportsCustomLightmapEncoding();
bool ShouldShowVulkanSettings();
bool SupportsFrameTimingStatistics();
}
// Extension point to add preferences to the PreferenceWindow class
internal interface IPreferenceWindowExtension
{
// Called from PreferenceWindow whenever preferences should be read
void ReadPreferences();
// Called from PreferenceWindow whenever preferences should be written
void WritePreferences();
// True is this extension contributes an external application/tool preference(s)
bool HasExternalApplications();
// Called from OnGui - this function should draw any contributing UI components
void ShowExternalApplications();
}
// NOTE: You probably want to inherit from DefaultBuildWindowExtension class
internal interface IBuildWindowExtension
{
void ShowPlatformBuildOptions();
void ShowPlatformBuildWarnings();
// Use this for "developer" Unity builds
void ShowInternalPlatformBuildOptions();
bool EnabledBuildButton();
bool EnabledBuildAndRunButton();
void GetBuildButtonTitles(out GUIContent buildButtonTitle, out GUIContent buildAndRunButtonTitle);
// Show path location dialog during Build or Build & Run click
bool AskForBuildLocation();
bool ShouldDrawScriptDebuggingCheckbox();
bool ShouldDrawProfilerCheckbox();
bool ShouldDrawDevelopmentPlayerCheckbox();
bool ShouldDrawExplicitNullCheckbox();
bool ShouldDrawExplicitDivideByZeroCheckbox();
bool ShouldDrawExplicitArrayBoundsCheckbox();
// Force full optimisations for script complilation in Development builds.
// Useful for forcing optimized compiler for IL2CPP when profiling.
bool ShouldDrawForceOptimizeScriptsCheckbox();
// Enables a dialog "Wait For Managed debugger", which halts program execution until managed debugger is connected
bool ShouldDrawWaitForManagedDebugger();
// Grays out managed debugger options
bool ShouldDisableManagedDebuggerCheckboxes();
// UI rendering functions for general options
// Todo: move all of them from BuildPlayerWindow
void DoScriptsOnlyGUI();
}
internal interface IBuildAnalyzer
{
void OnAddedExecutable(Build.Reporting.BuildReport report, int fileIndex);
}
// Extension point to add platform-specific texture import settings.
// You probably want to inherit from DefaultTextureImportSettingsExtension
internal interface ITextureImportSettingsExtension
{
void ShowImportSettings(Editor baseEditor, TextureImportPlatformSettings platformSettings);
}
// Interface for target device related operations
internal interface IDevice
{
// Start remote support for this device
RemoteAddress StartRemoteSupport();
// Stop remote support for this device
void StopRemoteSupport();
// Start player connection support for this device. This only sets up ability to connect,
// like setting up TCP tunneling over USB, getting remote device's IP, but it doesn't
// actually make the connection. Only available if SupportsPlayerConnection is true.
// Otherwise throws NotSupportedException.
RemoteAddress StartPlayerConnectionSupport();
// Stop player connection support for this device. Only available if SupportsPlayerConnection
// is true. Otherwise throws NotSupportedException.
void StopPlayerConnectionSupport();
}
internal struct RemoteAddress
{
public string ip;
public int port;
public RemoteAddress(string ip, int port)
{
this.ip = ip;
this.port = port;
}
}
internal interface IPluginImporterExtension
{
// Functions use by PluginImporterInspector
void ResetValues(PluginImporterInspector inspector);
bool HasModified(PluginImporterInspector inspector);
void Apply(PluginImporterInspector inspector);
void OnEnable(PluginImporterInspector inspector);
void OnDisable(PluginImporterInspector inspector);
void OnPlatformSettingsGUI(PluginImporterInspector inspector);
// Called before building the player, checks if plugins don't overwrite each other
string CalculateFinalPluginPath(string buildTargetName, PluginImporter imp);
bool CheckFileCollisions(string buildTargetName);
}
internal struct BuildLaunchPlayerArgs
{
public BuildTarget target;
public string playerPackage;
public string installPath;
public string productName;
public BuildOptions options;
public Build.Reporting.BuildReport report;
}
internal struct BuildPostProcessArgs
{
public BuildTarget target;
public string stagingArea;
public string stagingAreaData;
public string stagingAreaDataManaged;
public string playerPackage;
public string installPath;
public string companyName;
public string productName;
public Guid productGUID;
public BuildOptions options;
public Build.Reporting.BuildReport report;
internal RuntimeClassRegistry usedClassRegistry;
}
// An 'IUserAssembliesValidator' is responsible of validating the assemblies
// generated after a successful recompilation of the scripts.
// For performance reason, and to keep the Editor responsive, the validation is
// allowed to run in background.
internal interface IUserAssembliesValidator
{
// If true, it allow the Editor to run the validation in a background Thread
bool canRunInBackground { get; }
// Invoked by the Editor after the user assemblies have been rebuilt, to allow the
// validator to validate the generated assemblies.
//
// This method is invoked only in case rebuilding the scripts was successful.
// The method might be run in a separate thread in case canRunInBackground was true.
void Validate(string[] userAssemblies);
// Invoked by the Editor in case the validation has just been killed, usually due to
// script rebuilds being triggered when the Validate method has not been terminated yet.
void Cleanup();
}
internal enum CSharpCompiler
{
Mono,
Microsoft,
}
internal interface ICompilationExtension
{
string[] GetCompilerExtraAssemblyPaths(bool isEditor, string assemblyPathName);
IAssemblyResolver GetAssemblyResolver(bool buildingForEditor, string assemblyPath, string[] searchDirectories);
// Returns an array of windows metadata files (.winmd) that should be referenced when compiling scripts.
// Only WinRT based platforms need these references.
IEnumerable<string> GetWindowsMetadataReferences();
// Returns an array of managed assemblies that should be referenced when compiling scripts
// Currently, only .NET scripting backend uses it to include WinRTLegacy.dll into compilation
IEnumerable<string> GetAdditionalAssemblyReferences();
// Returns an array of defines that should be used when compiling scripts
IEnumerable<string> GetAdditionalDefines();
// Returns an array of C# source files that should be included into the assembly when compiling scripts
IEnumerable<string> GetAdditionalSourceFiles();
}
internal class CSharpProject
{
public string Path { get; set; }
public Guid Guid { get; set; }
}
}