Skip to content

Commit 7f267f1

Browse files
author
Unity Technologies
committed
Unity 2022.1.0a9 C# reference source code
1 parent 7aa6e4f commit 7f267f1

File tree

28 files changed

+331
-157
lines changed

28 files changed

+331
-157
lines changed

Editor/Mono/EditorUserSettings.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public static string GetConfigValue(string name)
7777

7878
public static extern int desiredImportWorkerCount { get; set; }
7979

80+
public static extern int standbyImportWorkerCount { get; set; }
81+
82+
public static extern int idleImportWorkerShutdownDelayMilliseconds { get; set; }
83+
8084
internal static extern void SoftReset();
8185
}
8286
}

Editor/Mono/Inspector/EditorSettingsInspector.cs

Lines changed: 89 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ class Content
2424
public static GUIContent joystickSource = EditorGUIUtility.TrTextContent("Joystick Source");
2525

2626
public static GUIContent mode = EditorGUIUtility.TrTextContent("Mode");
27-
public static GUIContent refresh = EditorGUIUtility.TrTextContent("Refresh");
28-
public static GUIContent refreshImportMode = EditorGUIUtility.TrTextContent("Import mode", "During an asset database refresh this mode determines if the imports are done: Entirely inside the editor process (In Process). In one or more worker processes potentially in parallel by importer queue index (Out of process by queue).");
29-
public static GUIContent desiredImportWorkerCount = EditorGUIUtility.TrTextContent("Desired worker count", "The desired number of import worker processes to keep around and ready for importing. The actual number of worker processes on the system can be both lower or higher that this, but the system will seek towards this number.");
27+
public static GUIContent parallelImport = EditorGUIUtility.TrTextContent("Parallel Import", "During an asset database refresh some asset imports can be performed in parallel in sub processes.");
28+
public static GUIContent parallelImportLearnMore = EditorGUIUtility.TrTextContent("Learn more...", "During an asset database refresh some asset imports can be performed in parallel in sub processes.");
29+
public static GUIContent desiredImportWorkerCountOverride = EditorGUIUtility.TrTextContent("Override Desired Worker Count", "Override the desired worker count specified in the preferences.");
30+
public static GUIContent desiredImportWorkerCount = EditorGUIUtility.TrTextContent("Desired Import Worker Count", "The desired number of import worker processes to use for importing. The actual number of worker processes on the system can be both lower or higher that this, but the system will seek towards this number when importing.");
31+
public static GUIContent standbyImportWorkerCount = EditorGUIUtility.TrTextContent("Standby Import Worker Count", "The number of import worker processes to keep around in standby and ready for importing. The actual number of worker processes on the system can be both lower or higher that this, but the system will seek towards this number when worker processes are idle.");
32+
public static GUIContent idleWorkerShutdownDelay = EditorGUIUtility.TrTextContent("Idle Import Worker Shutdown Delay", "When an importer worker has been idle for this amount of seconds in will be shutdown unless it would take the worker count below the standby worker count setting.");
3033

3134
public static GUIContent cacheServer = EditorGUIUtility.TrTextContent("Cache Server (project specific)");
32-
public static GUIContent assetPipeline = EditorGUIUtility.TrTextContent("Asset Pipeline (project specific)");
35+
public static GUIContent assetPipeline = EditorGUIUtility.TrTextContent("Asset Pipeline");
3336
public static GUIContent artifactGarbageCollection = EditorGUIUtility.TrTextContent("Remove unused Artifacts on Restart", "By default, when you start the Editor, Unity removes unused artifact files in the Library folder, and removes their entries in the asset database. This is a form of \"garbage collection\". This setting allows you to turn off the asset database garbage collection, so that previous artifact revisions which are no longer used are still preserved after restarting the Editor. This is useful if you need to debug unexpected import results.");
3437
public static GUIContent cacheServerIPLabel = EditorGUIUtility.TrTextContent("IP address");
3538
public static GUIContent cacheServerNamespacePrefixLabel = EditorGUIUtility.TrTextContent("Namespace prefix", "The namespace used for looking up and storing values on the cache server");
@@ -258,6 +261,8 @@ public PopupElement(string id, string content)
258261
bool m_IsGlobalSettings;
259262

260263
const string kRefreshImportModeKeyArgs = "-refreshImportMode";
264+
const string kStandbyWorkerCountKeyArgs = "-standbyWorkerCount";
265+
const string kIdleWorkerShutdownDelayKeyArgs = "-idleWorkerShutdownDelay";
261266
const string kDesiredImportWorkerCountKeyArgs = "-desiredWorkerCount";
262267

263268
enum CacheServerConnectionState { Unknown, Success, Failure }
@@ -443,8 +448,6 @@ public override void OnInspectorGUI()
443448

444449
DoCacheServerSettings();
445450

446-
DoRefreshModeSettings();
447-
448451
GUI.enabled = wasEnabled;
449452
}
450453

@@ -621,13 +624,93 @@ private bool DoTextureCompressorSettings()
621624

622625
private void DoAssetPipelineSettings()
623626
{
627+
GUILayout.Space(10);
628+
624629
GUILayout.Label(Content.assetPipeline, EditorStyles.boldLabel);
625630

626631
EditorGUI.BeginChangeCheck();
627632
bool enableArtifactGarbageCollection = EditorUserSettings.artifactGarbageCollection;
628633
enableArtifactGarbageCollection = EditorGUILayout.Toggle(Content.artifactGarbageCollection, enableArtifactGarbageCollection);
629634
if (EditorGUI.EndChangeCheck())
630635
EditorUserSettings.artifactGarbageCollection = enableArtifactGarbageCollection;
636+
637+
var overrideMode = GetCommandLineOverride(kRefreshImportModeKeyArgs);
638+
if (overrideMode != null)
639+
{
640+
EditorGUILayout.HelpBox($"Refresh Import mode forced to {overrideMode} via command line argument. To use the mode specified here please restart Unity without the -refreshImportMode command line argument.", MessageType.Info, true);
641+
}
642+
643+
using (new EditorGUI.DisabledScope(overrideMode != null))
644+
{
645+
GUILayout.BeginHorizontal();
646+
var refreshMode = EditorSettings.refreshImportMode;
647+
var parallelImportEnabledOld = refreshMode == AssetDatabase.RefreshImportMode.OutOfProcessPerQueue;
648+
var parallelImportEnabledNew = EditorGUILayout.Toggle(Content.parallelImport, parallelImportEnabledOld);
649+
650+
if (parallelImportEnabledOld != parallelImportEnabledNew)
651+
EditorSettings.refreshImportMode = parallelImportEnabledNew ? AssetDatabase.RefreshImportMode.OutOfProcessPerQueue : AssetDatabase.RefreshImportMode.InProcess;
652+
if (GUILayout.Button(Content.parallelImportLearnMore, EditorStyles.linkLabel))
653+
Application.OpenURL("https://docs.unity3d.com/Manual/ParallelImport.html");
654+
GUILayout.EndHorizontal();
655+
}
656+
657+
var overrideDesiredCount = GetCommandLineOverride(kDesiredImportWorkerCountKeyArgs);
658+
if (overrideDesiredCount != null)
659+
{
660+
EditorGUILayout.HelpBox($"Desired import worker count forced to {overrideDesiredCount} via command line argument. To use the worker count specified here please restart Unity without the -desiredWorkerCount command line argument.", MessageType.Info, true);
661+
}
662+
663+
// This min/max worker count is enforced here and in EditorUserSettings.cpp
664+
// Please keep them in sync.
665+
const int minWorkerCount = 1;
666+
const int maxWorkerCount = 128;
667+
668+
using (new EditorGUI.DisabledScope(overrideDesiredCount != null))
669+
{
670+
var oldCount = EditorUserSettings.desiredImportWorkerCount;
671+
int newCount = EditorGUILayout.IntField(Content.desiredImportWorkerCount, oldCount);
672+
newCount = Mathf.Clamp(newCount, minWorkerCount, maxWorkerCount);
673+
674+
if (oldCount != newCount)
675+
EditorUserSettings.desiredImportWorkerCount = newCount;
676+
}
677+
678+
var overrideStandbyCount = GetCommandLineOverride(kStandbyWorkerCountKeyArgs);
679+
if (overrideStandbyCount != null)
680+
{
681+
EditorGUILayout.HelpBox($"Standby import worker count forced to {overrideStandbyCount} via command line argument. To use the standby worker count specified here please restart Unity without the -standbyWorkerCount command line argument.", MessageType.Info, true);
682+
}
683+
684+
using (new EditorGUI.DisabledScope(overrideStandbyCount != null))
685+
{
686+
var oldCount = EditorUserSettings.standbyImportWorkerCount;
687+
var newCount = EditorGUILayout.IntField(Content.standbyImportWorkerCount, oldCount);
688+
int desiredWorkerCount = EditorUserSettings.desiredImportWorkerCount;
689+
newCount = Mathf.Clamp(newCount, 0, desiredWorkerCount);
690+
691+
if (oldCount != newCount)
692+
{
693+
EditorUserSettings.standbyImportWorkerCount = newCount;
694+
}
695+
}
696+
697+
var overridekIdleWorkerShutdownDelay = GetCommandLineOverride(kIdleWorkerShutdownDelayKeyArgs);
698+
if (overridekIdleWorkerShutdownDelay != null)
699+
{
700+
EditorGUILayout.HelpBox($"Idle import worker shutdown delay forced to {overrideStandbyCount} ms. via command line argument. To use the settings specified here please restart Unity without the -idleWorkerShutdownDelay command line argument.", MessageType.Info, true);
701+
}
702+
703+
using (new EditorGUI.DisabledScope(overridekIdleWorkerShutdownDelay != null))
704+
{
705+
var oldSeconds = EditorUserSettings.idleImportWorkerShutdownDelayMilliseconds / 1000.0f;
706+
var newSeconds = EditorGUILayout.FloatField(Content.idleWorkerShutdownDelay, oldSeconds);
707+
newSeconds = Mathf.Max(0, newSeconds);
708+
709+
if (oldSeconds != newSeconds)
710+
{
711+
EditorUserSettings.idleImportWorkerShutdownDelayMilliseconds = (int)(newSeconds * 1000.0f);
712+
}
713+
}
631714
}
632715

633716
private void DoCacheServerSettings()
@@ -770,42 +853,6 @@ private static string GetCommandLineOverride(string key)
770853
return address;
771854
}
772855

773-
private void DoRefreshModeSettings()
774-
{
775-
Assert.IsTrue(m_IsGlobalSettings);
776-
GUILayout.Space(10);
777-
778-
GUILayout.Label(Content.refresh, EditorStyles.boldLabel);
779-
780-
var overrideMode = GetCommandLineOverride(kRefreshImportModeKeyArgs);
781-
if (overrideMode != null)
782-
{
783-
EditorGUILayout.HelpBox($"Refresh Import mode to {overrideMode} via command line argument. To use the mode specified here please restart Unity without the -refreshImportMode command line argument.", MessageType.Info, true);
784-
}
785-
786-
int index = Mathf.Clamp((int)EditorSettings.refreshImportMode, 0, refreshImportModePopupList.Length - 1);
787-
CreatePopupMenu(serializedObject, Content.refreshImportMode, refreshImportModePopupList[index].content, refreshImportModePopupList, index, SetRefreshImportMode);
788-
789-
var overrideCount = GetCommandLineOverride(kDesiredImportWorkerCountKeyArgs);
790-
if (overrideCount != null)
791-
{
792-
EditorGUILayout.HelpBox($"Desired import worker count forced to {overrideCount} via command line argument. To use the worker count specified here please restart Unity without the -desiredWorkerCount command line argument.", MessageType.Info, true);
793-
}
794-
795-
var oldCount = EditorUserSettings.desiredImportWorkerCount;
796-
var newCount = EditorGUILayout.IntField(Content.desiredImportWorkerCount, oldCount);
797-
798-
// This max worker count is enforced here and in EditorUserSettings.cpp
799-
// Please keep them in sync.
800-
const int maxWorkerCount = 128;
801-
802-
newCount = Mathf.Clamp(newCount, 0, maxWorkerCount);
803-
if (oldCount != newCount)
804-
{
805-
EditorUserSettings.desiredImportWorkerCount = newCount;
806-
}
807-
}
808-
809856
private void DoLineEndingsSettings()
810857
{
811858
GUILayout.Space(10);

Editor/Mono/Inspector/MemorySettingsEditor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace UnityEditor
1616
{
1717
[CustomEditor(typeof(MemorySettings))]
18-
[ExcludeFromPreset]
1918
internal class MemorySettingsEditor : Editor
2019
{
2120
class Content

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class SettingsContent
144144
public static readonly GUIContent mTRendering = EditorGUIUtility.TrTextContent("Multithreaded Rendering*");
145145
public static readonly GUIContent staticBatching = EditorGUIUtility.TrTextContent("Static Batching");
146146
public static readonly GUIContent dynamicBatching = EditorGUIUtility.TrTextContent("Dynamic Batching");
147+
public static readonly GUIContent spriteBatchingVertexThreshold = EditorGUIUtility.TrTextContent("Sprite Batching Threshold", "Dynamic Batching is always enabled for Sprites and this controls max vertex threshold for batching. ");
147148
public static readonly GUIContent graphicsJobsNonExperimental = EditorGUIUtility.TrTextContent("Graphics Jobs");
148149
public static readonly GUIContent graphicsJobsExperimental = EditorGUIUtility.TrTextContent("Graphics Jobs (Experimental)");
149150
public static readonly GUIContent graphicsJobsMode = EditorGUIUtility.TrTextContent("Graphics Jobs Mode");
@@ -1777,6 +1778,12 @@ private void OtherSectionRenderingGUI(BuildPlatform platform, ISettingEditorExte
17771778
PlayerSettings.SetBatchingForPlatform(platform.defaultTarget, staticBatching, dynamicBatching);
17781779
}
17791780
}
1781+
1782+
int spriteVertexBatchingThreshold = PlayerSettings.spriteBatchVertexThreshold;
1783+
EditorGUI.BeginChangeCheck();
1784+
spriteVertexBatchingThreshold = EditorGUILayout.IntSlider(SettingsContent.spriteBatchingVertexThreshold, spriteVertexBatchingThreshold, 300, 8000);
1785+
if (EditorGUI.EndChangeCheck())
1786+
PlayerSettings.spriteBatchVertexThreshold = spriteVertexBatchingThreshold;
17801787
}
17811788

17821789
bool hdrDisplaySupported = false;

Editor/Mono/Inspector/PreviewRenderUtility.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class PreviewRenderUtility
9191
private SavedRenderTargetState m_SavedState;
9292
private bool m_PixelPerfect;
9393
private Material m_InvisibleMaterial;
94+
private bool m_previewOpened;
9495

9596
private string m_Type;
9697

@@ -144,6 +145,8 @@ public PreviewRenderUtility()
144145
}
145146
}
146147
}
148+
149+
m_previewOpened = false;
147150
}
148151

149152
~PreviewRenderUtility()
@@ -211,6 +214,12 @@ internal PreviewScene previewScene
211214

212215
public void Cleanup()
213216
{
217+
if (m_previewOpened)
218+
{
219+
Debug.LogError("Missing EndPreview() before cleanup of PreviewRenderUtility");
220+
EndPreview();
221+
}
222+
214223
if (m_RenderTexture)
215224
{
216225
Object.DestroyImmediate(m_RenderTexture);
@@ -229,6 +238,14 @@ public void Cleanup()
229238

230239
public void BeginPreview(Rect r, GUIStyle previewBackground)
231240
{
241+
if(m_previewOpened)
242+
{
243+
Debug.LogError("Previous PreviewRenderUtility.BeginPreview() was not closed with PreviewRenderUtility.EndPreview()");
244+
return;
245+
}
246+
247+
m_previewOpened = true;
248+
232249
Texture defaultEnvTexture = ReflectionProbe.defaultTexture;
233250

234251
if (Unsupported.SetOverrideLightingSettings(previewScene.scene))
@@ -360,6 +377,7 @@ public Texture EndPreview()
360377

361378
m_SavedState.Restore();
362379
FinishFrame();
380+
m_previewOpened = false;
363381
return m_RenderTexture;
364382
}
365383

Editor/Mono/PlayerSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ public static extern bool openGLRequireES32
626626
set;
627627
}
628628

629+
// Set Maximum Vertex Threshold for Sprite Batching.
630+
public static extern int spriteBatchVertexThreshold { get; set; }
631+
629632
// The image to display in the Resolution Dialog window.
630633
[Obsolete("resolutionDialogBanner has been removed.", false)]
631634
public static extern Texture2D resolutionDialogBanner { get; set; }

0 commit comments

Comments
 (0)