Skip to content

Commit 73925b1

Browse files
author
Unity Technologies
committed
Unity 2020.1.0b12 C# reference source code
1 parent 172dbfe commit 73925b1

43 files changed

Lines changed: 556 additions & 228 deletions

Some content is hidden

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

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public override bool StartPreview()
420420
CreateCandidateClip();
421421

422422
IAnimationWindowPreview[] previewComponents = FetchPostProcessComponents();
423-
m_UsesPostProcessComponents = previewComponents != null;
423+
m_UsesPostProcessComponents = previewComponents != null && previewComponents.Length > 0;
424424
if (previewComponents != null)
425425
{
426426
foreach (var component in previewComponents)

Editor/Mono/EditorGUIUtility.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,17 +669,31 @@ internal static Texture2D LoadIcon(string name)
669669
return LoadIconForSkin(name, skinIndex);
670670
}
671671

672+
static readonly List<string> k_UserSideSupportedImageExtensions = new List<string> {".png"};
673+
672674
// Attempts to load a higher resolution icon if needed
673675
static Texture2D LoadGeneratedIconOrNormalIcon(string name)
674676
{
675677
Texture2D icon = null;
676678
if (GUIUtility.pixelsPerPoint > 1.0f)
677679
{
678-
icon = InnerLoadGeneratedIconOrNormalIcon(name + "@2x");
679-
if (icon != null)
680+
var imageExtension = Path.GetExtension(name);
681+
if (k_UserSideSupportedImageExtensions.Contains(imageExtension))
680682
{
681-
icon.pixelsPerPoint = 2.0f;
683+
var newName = $"{Path.GetFileNameWithoutExtension(name)}@2x{imageExtension}";
684+
var dirName = Path.GetDirectoryName(name);
685+
if (!string.IsNullOrEmpty(dirName))
686+
newName = $"{dirName}/{newName}";
687+
688+
icon = InnerLoadGeneratedIconOrNormalIcon(newName);
689+
}
690+
else
691+
{
692+
icon = InnerLoadGeneratedIconOrNormalIcon(name + "@2x");
682693
}
694+
695+
if (icon != null)
696+
icon.pixelsPerPoint = 2.0f;
683697
}
684698

685699
if (icon == null)
@@ -726,8 +740,8 @@ internal static Texture2D LoadIconForSkin(string name, int in_SkinIndex)
726740
//Remap file name for dark skin
727741
var newName = "d_" + Path.GetFileName(name);
728742
var dirName = Path.GetDirectoryName(name);
729-
if (!String.IsNullOrEmpty(dirName))
730-
newName = String.Format("{0}/{1}", dirName, newName);
743+
if (!string.IsNullOrEmpty(dirName))
744+
newName = $"{dirName}/{newName}";
731745

732746
Texture2D tex = LoadGeneratedIconOrNormalIcon(newName);
733747
if (!tex)

Editor/Mono/EditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ internal static void BuildWindowMenuListing()
11681168
}
11691169

11701170
[AttributeUsage(AttributeTargets.Class)]
1171-
internal class EditorWindowTitleAttribute : System.Attribute
1171+
public class EditorWindowTitleAttribute : System.Attribute
11721172
{
11731173
public string title { get; set; }
11741174
public string icon { get; set; }

Editor/Mono/GUI/ColorPicker.cs

Lines changed: 14 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ internal class ColorPicker : EditorWindow
4242
[SerializeField]
4343
bool m_ShowPresets = true;
4444

45-
[SerializeField]
46-
bool m_IsOSColorPicker = false;
4745
[SerializeField]
4846
bool m_ShowAlpha = true;
4947

@@ -1097,10 +1095,9 @@ void OnColorChanged(bool exitGUI = true)
10971095
if (m_DelegateView != null)
10981096
{
10991097
var e = EditorGUIUtility.CommandEvent(EventCommandNames.ColorPickerChanged);
1100-
if (!m_IsOSColorPicker)
1101-
Repaint();
1098+
Repaint();
11021099
m_DelegateView.SendEvent(e);
1103-
if (!m_IsOSColorPicker && exitGUI)
1100+
if (exitGUI)
11041101
GUIUtility.ExitGUI();
11051102
}
11061103
if (m_ColorChangedCallback != null)
@@ -1111,17 +1108,12 @@ void OnColorChanged(bool exitGUI = true)
11111108

11121109
private void SetColor(Color c)
11131110
{
1114-
if (m_IsOSColorPicker)
1115-
OSColorPicker.color = c;
1116-
else
1117-
{
1118-
m_Color.SetColorChannelHdr(RgbaChannel.R, c.r);
1119-
m_Color.SetColorChannelHdr(RgbaChannel.G, c.g);
1120-
m_Color.SetColorChannelHdr(RgbaChannel.B, c.b);
1121-
m_Color.SetColorChannelHdr(RgbaChannel.A, c.a);
1122-
OnColorChanged();
1123-
Repaint();
1124-
}
1111+
m_Color.SetColorChannelHdr(RgbaChannel.R, c.r);
1112+
m_Color.SetColorChannelHdr(RgbaChannel.G, c.g);
1113+
m_Color.SetColorChannelHdr(RgbaChannel.B, c.b);
1114+
m_Color.SetColorChannelHdr(RgbaChannel.A, c.a);
1115+
OnColorChanged();
1116+
Repaint();
11251117
}
11261118

11271119
public static void Show(GUIView viewToUpdate, Color col, bool showAlpha = true, bool hdr = false)
@@ -1148,7 +1140,6 @@ static void Show(GUIView viewToUpdate, Action<Color> colorChangedCallback, Color
11481140

11491141
if (cp.m_HDR)
11501142
{
1151-
cp.m_IsOSColorPicker = false;
11521143
cp.m_SliderMode = (SliderMode)EditorPrefs.GetInt(k_SliderModeHDRPrefKey, (int)SliderMode.RGB);
11531144
}
11541145
else
@@ -1157,51 +1148,18 @@ static void Show(GUIView viewToUpdate, Action<Color> colorChangedCallback, Color
11571148
cp.m_Color.exposureValue = 0;
11581149
}
11591150

1160-
if (cp.m_IsOSColorPicker)
1161-
{
1162-
cp.SetColor(col);
1163-
OSColorPicker.Show(showAlpha);
1164-
}
1165-
else
1166-
{
1167-
cp.titleContent = hdr ? EditorGUIUtility.TrTextContent("HDR Color") : EditorGUIUtility.TrTextContent("Color");
1168-
float height = EditorPrefs.GetInt(k_HeightPrefKey, (int)cp.position.height);
1169-
cp.minSize = new Vector2(Styles.fixedWindowWidth, height);
1170-
cp.maxSize = new Vector2(Styles.fixedWindowWidth, height);
1171-
cp.InitializePresetsLibraryIfNeeded(); // Ensure the heavy lifting of loading presets is done before window is visible
1172-
cp.ShowAuxWindow();
1173-
}
1174-
}
1175-
1176-
void PollOSColorPicker()
1177-
{
1178-
if (m_IsOSColorPicker)
1179-
{
1180-
if (!OSColorPicker.visible || Application.platform != RuntimePlatform.OSXEditor)
1181-
{
1182-
DestroyImmediate(this);
1183-
}
1184-
else
1185-
{
1186-
Color c = OSColorPicker.color;
1187-
if (m_Color.color != c)
1188-
{
1189-
m_Color.SetColorChannel(RgbaChannel.R, c.r);
1190-
m_Color.SetColorChannel(RgbaChannel.G, c.g);
1191-
m_Color.SetColorChannel(RgbaChannel.B, c.b);
1192-
m_Color.SetColorChannel(RgbaChannel.A, c.a);
1193-
OnColorChanged();
1194-
}
1195-
}
1196-
}
1151+
cp.titleContent = hdr ? EditorGUIUtility.TrTextContent("HDR Color") : EditorGUIUtility.TrTextContent("Color");
1152+
float height = EditorPrefs.GetInt(k_HeightPrefKey, (int)cp.position.height);
1153+
cp.minSize = new Vector2(Styles.fixedWindowWidth, height);
1154+
cp.maxSize = new Vector2(Styles.fixedWindowWidth, height);
1155+
cp.InitializePresetsLibraryIfNeeded(); // Ensure the heavy lifting of loading presets is done before window is visible
1156+
cp.ShowAuxWindow();
11971157
}
11981158

11991159
void OnEnable()
12001160
{
12011161
hideFlags = HideFlags.DontSave;
1202-
m_IsOSColorPicker = EditorPrefs.GetBool("UseOSColorPicker");
12031162
hideFlags = HideFlags.DontSave;
1204-
EditorApplication.update += PollOSColorPicker;
12051163
EditorGUIUtility.editingTextField = true; // To fix that color values is not directly editable when tabbing (case 557510)
12061164

12071165
m_SliderMode = (SliderMode)EditorPrefs.GetInt(k_SliderModePrefKey, (int)SliderMode.RGB);
@@ -1238,10 +1196,6 @@ public void OnDestroy()
12381196
if (m_AlphaTexture)
12391197
DestroyImmediate(m_AlphaTexture);
12401198
s_Instance = null;
1241-
if (m_IsOSColorPicker)
1242-
OSColorPicker.Close();
1243-
1244-
EditorApplication.update -= PollOSColorPicker;
12451199

12461200
if (m_ColorLibraryEditorState != null)
12471201
m_ColorLibraryEditorState.TransferEditorPrefsState(false);

Editor/Mono/GameView/GameView.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Linq;
1212
using System.Collections.Generic;
1313
using JetBrains.Annotations;
14+
using UnityEditorInternal.VR;
1415
using UnityEngine.XR;
1516
using FrameCapture = UnityEngine.Apple.FrameCapture;
1617
using FrameCaptureDestination = UnityEngine.Apple.FrameCaptureDestination;
@@ -571,7 +572,8 @@ private void DoToolbarGUI()
571572

572573
SubsystemManager.GetInstances(m_DisplaySubsystems);
573574
// Allow the user to select how the XR device will be rendered during "Play In Editor"
574-
if (PlayerSettings.virtualRealitySupported || (m_DisplaySubsystems.Count != 0 && !m_DisplaySubsystems[0].disableLegacyRenderer))
575+
if (VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget))
576+
|| (m_DisplaySubsystems.Count != 0 && !m_DisplaySubsystems[0].disableLegacyRenderer))
575577
{
576578
EditorGUI.BeginChangeCheck();
577579
GameViewRenderMode currentGameViewRenderMode = UnityEngine.XR.XRSettings.gameViewRenderMode;

Editor/Mono/Inspector/CameraEditor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using AnimatedBool = UnityEditor.AnimatedValues.AnimBool;
1313
using UnityEngine.Scripting;
1414
using UnityEditor.Modules;
15+
using UnityEditorInternal.VR;
1516
using Object = UnityEngine.Object;
1617

1718
namespace UnityEditor
@@ -405,7 +406,7 @@ public void DrawDynamicResolution()
405406

406407
public void DrawVR()
407408
{
408-
if (PlayerSettings.virtualRealitySupported)
409+
if (VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)))
409410
{
410411
EditorGUILayout.PropertyField(stereoSeparation);
411412
EditorGUILayout.PropertyField(stereoConvergence);
@@ -518,7 +519,7 @@ public void OnEnable()
518519
var c = (Camera)target;
519520
m_ShowBGColorOptions.value = !clearFlagsHasMultipleValues && (c.clearFlags == CameraClearFlags.SolidColor || c.clearFlags == CameraClearFlags.Skybox);
520521
m_ShowOrthoOptions.value = c.orthographic;
521-
m_ShowTargetEyeOption.value = targetEyeValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported;
522+
m_ShowTargetEyeOption.value = targetEyeValue != (int)StereoTargetEyeMask.Both || VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));
522523

523524
m_ShowBGColorOptions.valueChanged.AddListener(Repaint);
524525
m_ShowOrthoOptions.valueChanged.AddListener(Repaint);
@@ -667,7 +668,7 @@ public override void OnInspectorGUI()
667668
m_ShowOrthoOptions.target = !orthographicHasMultipleValues && c.orthographic;
668669

669670
bool displaySubsystemPresent = displayDescriptors.Count > 0;
670-
m_ShowTargetEyeOption.target = targetEyeValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported || displaySubsystemPresent;
671+
m_ShowTargetEyeOption.target = targetEyeValue != (int)StereoTargetEyeMask.Both || VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)) || displaySubsystemPresent;
671672

672673
settings.DrawClearFlags();
673674

Editor/Mono/Inspector/CanvasEditor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using UnityEngine;
66
using UnityEditor.AnimatedValues;
7+
using UnityEditorInternal.VR;
78

89
namespace UnityEditor
910
{
@@ -124,7 +125,7 @@ void OnDisable()
124125

125126
private void AllRootCanvases()
126127
{
127-
if (PlayerSettings.virtualRealitySupported && (m_RenderMode.enumValueIndex == (int)RenderMode.ScreenSpaceOverlay))
128+
if (VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)) && (m_RenderMode.enumValueIndex == (int)RenderMode.ScreenSpaceOverlay))
128129
{
129130
EditorGUILayout.HelpBox("Using a render mode of ScreenSpaceOverlay while VR is enabled will cause the Canvas to continue to incur a rendering cost, even though the Canvas will not be visible in VR.", MessageType.Warning);
130131
}

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.IO;
1414
using System.Linq;
1515
using UnityEditor.Modules;
16+
using UnityEditorInternal.VR;
1617
using UnityEngine.Events;
1718
using UnityEngine.SceneManagement;
1819
using GraphicsDeviceType = UnityEngine.Rendering.GraphicsDeviceType;
@@ -890,7 +891,7 @@ public void ResolutionSectionGUI(BuildTargetGroup targetGroup, ISettingEditorExt
890891

891892
EditorGUILayout.PropertyField(m_DefaultScreenOrientation, SettingsContent.defaultScreenOrientation);
892893

893-
if (PlayerSettings.virtualRealitySupported)
894+
if (VREditor.GetVREnabledOnTargetGroup(targetGroup))
894895
{
895896
EditorGUILayout.HelpBox(SettingsContent.vrOrientationInfo.text, MessageType.Warning);
896897
}

Editor/Mono/OSColorPicker.bindings.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

Editor/Mono/PerceptionRemoting/HolographicEmulation/HolographicEmulationWindow.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ internal static void Init()
114114

115115
private void OnEnable()
116116
{
117-
titleContent = EditorGUIUtility.TrTextContent("Holographic");
117+
titleContent = EditorGUIUtility.TrTextContent("Holographic (Deprecated)");
118118
m_InPlayMode = EditorApplication.isPlayingOrWillChangePlaymode;
119119

120120
m_RemoteMachineHistory = EditorPrefs.GetString("HolographicRemoting.RemoteMachineHistory").Split(',');
@@ -319,6 +319,8 @@ private bool CheckOperatingSystem()
319319

320320
void OnGUI()
321321
{
322+
EditorGUILayout.HelpBox("Support for built-in XR is deprecated and will be retired in a future version of Unity. We recommend you use the Unity XR Plugin System, which you can install from Project Settings > XR Plugin Manager.", MessageType.Info);
323+
322324
if (!CheckOperatingSystem())
323325
{
324326
EditorGUILayout.HelpBox("You must be running Windows build 14318 or later to use Holographic Simulation or Remoting.", MessageType.Warning);

0 commit comments

Comments
 (0)