Skip to content

Commit 5406f17

Browse files
author
Unity Technologies
committed
Unity 6000.0.10f1 C# reference source code
1 parent 1f8a545 commit 5406f17

34 files changed

+635
-206
lines changed

Editor/Mono/Audio/AudioContainerWindow.cs

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ namespace UnityEditor;
2020

2121
sealed class AudioContainerWindow : EditorWindow
2222
{
23+
/// <summary>
24+
/// The cached instance of the window, if it is open.
25+
/// </summary>
26+
internal static AudioContainerWindow Instance { get; private set; }
27+
2328
internal readonly AudioContainerWindowState State = new();
2429

2530
/// <summary>
@@ -116,6 +121,11 @@ static void OnCreateButtonClicked()
116121

117122
void OnEnable()
118123
{
124+
if (Instance == null)
125+
{
126+
Instance = this;
127+
}
128+
119129
m_DiceIconOff = EditorGUIUtility.IconContent("AudioRandomContainer On Icon").image as Texture2D;
120130
m_DiceIconOn = EditorGUIUtility.IconContent("AudioRandomContainer Icon").image as Texture2D;
121131
SetTitle();
@@ -130,6 +140,11 @@ void OnDisable()
130140
m_ContainerElementsInitialized = false;
131141
m_CachedElements.Clear();
132142
m_AddedElements.Clear();
143+
144+
if (Instance == this)
145+
{
146+
Instance = null;
147+
}
133148
}
134149

135150
void OnFocus()
@@ -1358,19 +1373,16 @@ class AudioContainerModificationProcessor : AssetModificationProcessor
13581373
/// </summary>
13591374
static string[] OnWillSaveAssets(string[] paths)
13601375
{
1361-
if (HasOpenInstances<AudioContainerWindow>())
1376+
// NOTE: this is a global callback that is triggered by changes to ANY project assets of ANY type,
1377+
// even when the window is closed, so no heavy calls should be done here unless
1378+
// the window is actually open. To avoid affecting editor performance we use the
1379+
// cached instance for an early out check rather than EditorWindow.HasOpenInstances.
1380+
if (Instance == null)
13621381
{
1363-
var window = focusedWindow as AudioContainerWindow;
1364-
1365-
if (window == null)
1366-
{
1367-
// The window is not focused, so make sure we don't focus when getting the reference here.
1368-
window = GetWindow<AudioContainerWindow>(false, null, false);
1369-
}
1370-
1371-
window.OnWillSaveAssets(paths);
1382+
return paths;
13721383
}
13731384

1385+
Instance.OnWillSaveAssets(paths);
13741386
return paths;
13751387
}
13761388
}
@@ -1384,25 +1396,23 @@ class AudioContainerPostProcessor : AssetPostprocessor
13841396
/// </summary>
13851397
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssets)
13861398
{
1387-
if (HasOpenInstances<AudioContainerWindow>())
1399+
// NOTE: this is a global callback that is triggered by changes to ANY project assets of ANY type,
1400+
// even when the window is closed, so no heavy calls should be done here unless
1401+
// the window is actually open. To avoid affecting editor performance we use the
1402+
// cached instance for an early out check rather than EditorWindow.HasOpenInstances.
1403+
if (Instance == null)
13881404
{
1389-
var window = focusedWindow as AudioContainerWindow;
1390-
1391-
if (window == null)
1392-
{
1393-
// The window is not focused, so make sure we don't focus when getting the reference here.
1394-
window = GetWindow<AudioContainerWindow>(false, null, false);
1395-
}
1405+
return;
1406+
}
13961407

1397-
if (movedFromAssets.Length > 0)
1398-
window.OnAssetsMoved(movedFromAssets);
1408+
if (movedFromAssets.Length > 0)
1409+
Instance.OnAssetsMoved(movedFromAssets);
13991410

1400-
if (importedAssets.Length > 0)
1401-
window.OnAssetsImported(importedAssets);
1411+
if (importedAssets.Length > 0)
1412+
Instance.OnAssetsImported(importedAssets);
14021413

1403-
if (deletedAssets.Length > 0)
1404-
window.OnAssetsDeleted(deletedAssets);
1405-
}
1414+
if (deletedAssets.Length > 0)
1415+
Instance.OnAssetsDeleted(deletedAssets);
14061416
}
14071417
}
14081418

Editor/Mono/GameView/GameView.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ private int XRTranslateMirrorViewBlitModeToRenderMode(int mirrorViewBlitMode)
731731
return 2;
732732
case XRMirrorViewBlitMode.SideBySideOcclusionMesh:
733733
return 3;
734+
case XRMirrorViewBlitMode.MotionVectors:
735+
return 4;
734736
}
735737
}
736738

@@ -746,6 +748,8 @@ private int XRTranslateRenderModeToMirrorViewBlitMode(int renderMode)
746748
return XRMirrorViewBlitMode.SideBySide;
747749
case 3:
748750
return XRMirrorViewBlitMode.SideBySideOcclusionMesh;
751+
case 4:
752+
return XRMirrorViewBlitMode.MotionVectors;
749753
}
750754
}
751755

@@ -765,6 +769,9 @@ private void SetXRRenderMode(int mode)
765769
case 3:
766770
UnityEngine.XR.XRSettings.gameViewRenderMode = UnityEngine.XR.GameViewRenderMode.OcclusionMesh;
767771
break;
772+
case 4:
773+
UnityEngine.XR.XRSettings.gameViewRenderMode = UnityEngine.XR.GameViewRenderMode.MotionVectors;
774+
break;
768775
}
769776

770777
if (mode != m_XRRenderMode)
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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.Diagnostics;
8+
using UnityEngine;
9+
using UnityEngine.Analytics;
10+
11+
namespace UnityEditor.Rendering.Analytics
12+
{
13+
// schema = com.unity3d.data.schemas.editor.analytics.uGraphicsToolLifetimeAnalytic_v2
14+
// taxonomy = editor.analytics.uGraphicsToolLifetimeAnalytic.v2
15+
public class GraphicsToolLifetimeAnalytic
16+
{
17+
static bool IsInternalAssembly(Type type)
18+
{
19+
var assemblyName = type.Assembly.FullName;
20+
if (assemblyName.StartsWith("UnityEditor.", StringComparison.InvariantCultureIgnoreCase) ||
21+
assemblyName.StartsWith("Unity.", StringComparison.InvariantCultureIgnoreCase))
22+
return true;
23+
return false;
24+
}
25+
26+
static List<string> GatherCurrentlyOpenWindowNames(Type editorWindowType)
27+
{
28+
var openWindows = Resources.FindObjectsOfTypeAll(typeof(EditorWindow));
29+
var openWindowNames = new List<string>(openWindows.Length);
30+
foreach (var w in openWindows)
31+
{
32+
var currentWindowType = w.GetType();
33+
if (IsInternalAssembly(currentWindowType) && currentWindowType != editorWindowType)
34+
{
35+
openWindowNames.Add((w as EditorWindow).titleContent.text);
36+
}
37+
}
38+
return openWindowNames;
39+
}
40+
41+
static string[] UnionWithoutLinq(List<string> a, List<string> b)
42+
{
43+
HashSet<string> aAndB = new HashSet<string>(a);
44+
aAndB.UnionWith(b);
45+
String[] aAndBArray = new String[aAndB.Count];
46+
aAndB.CopyTo(aAndBArray);
47+
return aAndBArray;
48+
}
49+
50+
[AnalyticInfo(eventName: "uGraphicsToolLifetimeAnalytic", vendorKey: "unity.graphics", version: 2, maxEventsPerHour: 100, maxNumberOfElements: 1000)]
51+
internal class Analytic : IAnalytic
52+
{
53+
public Analytic(WindowOpenedMetadata windowOpenedMetadata)
54+
{
55+
List<string> currentlyOpenEditorWindows = GatherCurrentlyOpenWindowNames(windowOpenedMetadata.editorWindowType);
56+
var elapsed = DateTime.Now - windowOpenedMetadata.openedTime;
57+
using (UnityEngine.Pool.GenericPool<Data>.Get(out var data))
58+
{
59+
data.window_id = windowOpenedMetadata.editorWindowType.Name;
60+
data.seconds_opened = elapsed.Seconds;
61+
data.other_open_windows = UnionWithoutLinq(currentlyOpenEditorWindows, windowOpenedMetadata.openEditorWindows);
62+
63+
m_Data = data;
64+
}
65+
}
66+
67+
[DebuggerDisplay("[{window_id}] Open time: {seconds_opened} - Other Windows Count: {other_open_windows.Length}")]
68+
[Serializable]
69+
class Data : IAnalytic.IData
70+
{
71+
// Naming convention for analytics data is lower case and and connecting with _
72+
public string window_id;
73+
public int seconds_opened;
74+
public string[] other_open_windows;
75+
}
76+
77+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
78+
{
79+
data = m_Data;
80+
error = null;
81+
return true;
82+
}
83+
84+
Data m_Data;
85+
}
86+
87+
internal struct WindowOpenedMetadata
88+
{
89+
public Type editorWindowType;
90+
public List<string> openEditorWindows;
91+
public DateTime openedTime;
92+
}
93+
94+
static Dictionary<Type, WindowOpenedMetadata> s_WindowOpenedMetadata = new Dictionary<Type, WindowOpenedMetadata>();
95+
96+
public static void WindowOpened<T>()
97+
where T : EditorWindow
98+
{
99+
if (!s_WindowOpenedMetadata.TryGetValue(typeof(T), out var metadata))
100+
{
101+
metadata = new WindowOpenedMetadata
102+
{
103+
editorWindowType = typeof(T),
104+
openEditorWindows = GatherCurrentlyOpenWindowNames(typeof(T)),
105+
openedTime = DateTime.Now
106+
};
107+
108+
s_WindowOpenedMetadata.Add(typeof(T), metadata);
109+
}
110+
}
111+
112+
public static void WindowClosed<T>()
113+
where T : EditorWindow
114+
{
115+
if (s_WindowOpenedMetadata.TryGetValue(typeof(T), out var metadata))
116+
{
117+
EditorAnalytics.SendAnalytic(new Analytic(metadata));
118+
s_WindowOpenedMetadata.Remove(typeof(T));
119+
}
120+
}
121+
}
122+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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.Diagnostics;
8+
using UnityEngine;
9+
using UnityEngine.Analytics;
10+
11+
namespace UnityEditor.Rendering.Analytics
12+
{
13+
// schema = com.unity3d.data.schemas.editor.analytics.uGraphicsToolUsageAnalytic_v1
14+
// taxonomy = editor.analytics.uGraphicsToolUsageAnalytic.v1
15+
public class GraphicsToolUsageAnalytic
16+
{
17+
[AnalyticInfo(eventName: "uGraphicsToolUsageAnalytic", vendorKey: "unity.graphics", version: 1, maxEventsPerHour: 100, maxNumberOfElements: 1000)]
18+
internal class Analytic<T> : IAnalytic
19+
{
20+
public Analytic(string action, string[] context)
21+
{
22+
using (UnityEngine.Pool.GenericPool<Data>.Get(out var data))
23+
{
24+
data.window_id = typeof(T).Name;
25+
data.action = action;
26+
data.context = context;
27+
28+
m_Data = data;
29+
}
30+
}
31+
32+
[DebuggerDisplay("[{window_id}] Action: {action} - Context: {context}")]
33+
[Serializable]
34+
class Data : IAnalytic.IData
35+
{
36+
// Naming convention for analytics data is lower case and and connecting with _
37+
public string window_id;
38+
public string action;
39+
public string[] context;
40+
}
41+
42+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
43+
{
44+
data = m_Data;
45+
error = null;
46+
return true;
47+
}
48+
49+
Data m_Data;
50+
}
51+
52+
public static void ActionPerformed<T>(string action, string[] context)
53+
where T : EditorWindow
54+
{
55+
if (string.IsNullOrEmpty(action))
56+
return;
57+
58+
EditorAnalytics.SendAnalytic(new Analytic<T>(action, context));
59+
}
60+
}
61+
}

Editor/Mono/Help.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using UnityEditorInternal;
1212
using UnityEngine.Networking;
1313
using System.Text.RegularExpressions;
14+
using UnityEditor.Presets;
1415

1516
namespace UnityEditor
1617
{
@@ -358,7 +359,12 @@ internal static string HelpFileNameForObject(Object obj)
358359

359360
if (obj is PrefabImporter)
360361
{
361-
return "-Prefab Asset";
362+
return "Prefabs";
363+
}
364+
365+
if (obj is Preset)
366+
{
367+
return "Presets";
362368
}
363369

364370
if (obj is DefaultAsset)

Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorUtility.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
using System.ComponentModel;
88
using System.Reflection;
99
using System.Text;
10-
using UnityEditor.Build;
11-
using UnityEditor.Build.Reporting;
1210
using UnityEditor.Rendering;
1311
using UnityEditor.Rendering.Settings;
1412
using UnityEditor.UIElements;
@@ -297,14 +295,6 @@ internal static Type GetRenderPipelineAssetTypeForSelectedTab(VisualElement root
297295
}
298296

299297
internal static void ReloadGraphicsSettingsEditorIfNeeded()
300-
{
301-
if (BuildPipeline.isBuildingPlayer)
302-
return;
303-
304-
ReloadGraphicsSettingsEditorIfOpened();
305-
}
306-
307-
private static void ReloadGraphicsSettingsEditorIfOpened()
308298
{
309299
if (!EditorWindow.HasOpenInstances<ProjectSettingsWindow>())
310300
return;

Editor/Mono/Inspector/LightingSettingsEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static class Styles
185185
};
186186

187187
public static readonly GUIContent lightmapperNotSupportedWarning = EditorGUIUtility.TrTextContent("This lightmapper is not supported by the current Render Pipeline. The Editor will use ");
188-
public static readonly GUIContent ARM64LightmapperWarning = EditorGUIUtility.TrTextContent("Progressive CPU Lightmapper is only available on Unity for x64 processors. Use Progressive GPU Lightmapper instead.");
188+
public static readonly GUIContent appleSiliconCPULightmapperWarning = EditorGUIUtility.TrTextContent("Progressive CPU Lightmapper is not available on Apple Silicon. Use Progressive GPU Lightmapper instead.");
189189
public static readonly GUIContent mixedModeNotSupportedWarning = EditorGUIUtility.TrTextContent("The Mixed mode is not supported by the current Render Pipeline. Fallback mode is ");
190190
public static readonly GUIContent directionalNotSupportedWarning = EditorGUIUtility.TrTextContent("Directional Mode is not supported. Fallback will be Non-Directional.");
191191
public static readonly GUIContent denoiserNotSupportedWarning = EditorGUIUtility.TrTextContent("The current hardware or system configuration does not support the selected denoiser. Select a different denoiser.");
@@ -938,7 +938,7 @@ void BakeBackendGUI()
938938

939939
if (!isOpenRLFunctionalForArchitecture && m_BakeBackend.intValue == (int)LightingSettings.Lightmapper.ProgressiveCPU)
940940
{
941-
EditorGUILayout.HelpBox(Styles.ARM64LightmapperWarning.text, MessageType.Warning);
941+
EditorGUILayout.HelpBox(Styles.appleSiliconCPULightmapperWarning.text, MessageType.Warning);
942942
}
943943
else if (!SupportedRenderingFeatures.IsLightmapperSupported(m_BakeBackend.intValue))
944944
{

0 commit comments

Comments
 (0)