Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #33

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

test #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Editor/Mono/AssemblyInfo/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
[assembly: InternalsVisibleTo("UnityEditor.WindowsStandalone.Extensions")]
[assembly: InternalsVisibleTo("UnityEditor.OSXStandalone.Extensions")]
[assembly: InternalsVisibleTo("UnityEditor.Lumin.Extensions")]
[assembly: InternalsVisibleTo("UnityEditor.Stadia.Extensions")]
[assembly: InternalsVisibleTo("UnityEditor.GameCoreScarlett.Extensions")]
[assembly: InternalsVisibleTo("UnityEditor.GameCoreXboxOne.Extensions")]
[assembly: InternalsVisibleTo("UnityEditor.GameCoreCommon.Extensions")]
Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/AssetModificationProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ static Editability GetPathEditability(string assetPath)
{
// read-only asset locations (e.g. shared packages) are considered not editable
bool rootFolder, readOnly;
bool validPath = AssetDatabase.GetAssetFolderInfo(assetPath, out rootFolder, out readOnly);
bool validPath = AssetDatabase.TryGetAssetFolderInfo(assetPath, out rootFolder, out readOnly);
if (validPath && readOnly)
return Editability.Never;

Expand Down
3 changes: 1 addition & 2 deletions Editor/Mono/BuildPipeline/NamedBuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace UnityEditor.Build
public static readonly NamedBuildTarget XboxOne = new NamedBuildTarget("XboxOne");
public static readonly NamedBuildTarget tvOS = new NamedBuildTarget("tvOS");
public static readonly NamedBuildTarget NintendoSwitch = new NamedBuildTarget("Nintendo Switch");
[System.Obsolete("Stadia has been removed in 2023.1")]
public static readonly NamedBuildTarget Stadia = new NamedBuildTarget("Stadia");
public static readonly NamedBuildTarget LinuxHeadlessSimulation = new NamedBuildTarget("LinuxHeadlessSimulation");
[System.Obsolete("CloudRendering is deprecated, please use LinuxHeadlessSimulation (UnityUpgradable) -> LinuxHeadlessSimulation", false)]
Expand Down Expand Up @@ -99,8 +100,6 @@ public static NamedBuildTarget FromBuildTargetGroup(BuildTargetGroup buildTarget
return NamedBuildTarget.tvOS;
case BuildTargetGroup.Switch:
return NamedBuildTarget.NintendoSwitch;
case BuildTargetGroup.Stadia:
return NamedBuildTarget.Stadia;
case BuildTargetGroup.LinuxHeadlessSimulation:
return NamedBuildTarget.LinuxHeadlessSimulation;
case BuildTargetGroup.EmbeddedLinux:
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/BuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public enum BuildTarget
[System.Obsolete("Lumin has been removed in 2022.2")]
Lumin = 39,

[System.Obsolete("Stadia has been removed in 2023.1")]
Stadia = 40,

[System.Obsolete("CloudRendering is deprecated, please use LinuxHeadlessSimulation (UnityUpgradable) -> LinuxHeadlessSimulation", false)]
Expand Down
2 changes: 0 additions & 2 deletions Editor/Mono/BuildTargetConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ internal static class BuildTargetConverter
return RuntimePlatform.GameCoreXboxSeries;
case BuildTarget.GameCoreXboxOne:
return RuntimePlatform.GameCoreXboxOne;
case BuildTarget.Stadia:
return RuntimePlatform.Stadia;
case BuildTarget.EmbeddedLinux:
return RuntimePlatform.EmbeddedLinuxArm64;
case BuildTarget.QNX:
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/BuildTargetGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public enum BuildTargetGroup
[Obsolete("Lumin has been removed in 2022.2")]
Lumin = 28,

[Obsolete("Stadia has been removed in 2023.1")]
Stadia = 29,

[System.Obsolete("CloudRendering is deprecated, please use LinuxHeadlessSimulation (UnityUpgradable) -> LinuxHeadlessSimulation", false)]
Expand Down
20 changes: 0 additions & 20 deletions Editor/Mono/Collab/Softlocks/SoftlockViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,26 +336,6 @@ private static string GetDisplayCount(int count)
return totalLocksText;
}

// When the given 'text' exceeds the given 'width', out-of-bound characters
// are removed as well as a few more to display a trailing ellipsis.
// If 'text' does not exceed width, text is returned.
private string FitTextToWidth(string text, float width, GUIStyle style)
{
int characterCountVisible = style.GetNumCharactersThatFitWithinWidth(text, width);
if (characterCountVisible > 1 && characterCountVisible != text.Length)
{
string ellipsedText;
int characterLength = (characterCountVisible - 1);
if (!Instance.m_Cache.TryGetEllipsedNames(text, characterLength, out ellipsedText))
{
ellipsedText = text.Substring(0, characterLength) + (" \u2026"); // 'horizontal ellipsis' (U+2026) is: ...
Instance.m_Cache.StoreEllipsedNames(text, ellipsedText, characterLength);
}
return ellipsedText;
}
return text;
}

#endregion
#region GUI Content

Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/EditorApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ internal static ApplicationTitleDescriptor GetApplicationTitleDescriptor()

var desc = new ApplicationTitleDescriptor(
isTemporaryProject ? PlayerSettings.productName : Path.GetFileName(Path.GetDirectoryName(Application.dataPath)),
InternalEditorUtility.GetUnityDisplayVersion(),
(Unsupported.IsSourceBuild() || Unsupported.IsDeveloperMode()) ? InternalEditorUtility.GetUnityDisplayVersion() : InternalEditorUtility.GetUnityVersionDigits(),
activeSceneName,
BuildPipeline.GetBuildTargetGroupDisplayName(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)),
Coverage.enabled
Expand Down
33 changes: 21 additions & 12 deletions Editor/Mono/EditorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ private enum DragCandidateState

internal static SavedBool s_ShowRepaintDots = new SavedBool("ShowRepaintDots", true);

internal static readonly Regex s_HyperlinkRegex = new Regex(@"(?<=\b=')[^']*");
internal static readonly Regex s_ATagRegex = new Regex(@"(?<=\b="")[^""]*");
internal static readonly Regex s_LinkTagRegex = new Regex(@"(?<=\b=')[^']*");

static class Styles
{
Expand Down Expand Up @@ -1461,7 +1462,9 @@ private static bool HasClickedOnHyperlink(RecycledTextEditor editor, out Diction
if (!editor.HasClickedOnLink(mousePosition, out string link))
return false;

MatchCollection matches = s_HyperlinkRegex.Matches(link);
MatchCollection matches = s_ATagRegex.Matches(link);
if (matches.Count == 0)
matches = s_LinkTagRegex.Matches(link);

int endPreviousAttributeIndex = 0;
// for each attribute we need to find the attribute name
Expand Down Expand Up @@ -3906,15 +3909,8 @@ internal void SetEnumValueDelegate(object userData, string[] options, int select
}
}

internal static int DoPopup(Rect position, int controlID, int selected, GUIContent[] popupValues, GUIStyle style)
{
return DoPopup(position, controlID, selected, popupValues, null, style);
}

internal static int DoPopup(Rect position, int controlID, int selected, GUIContent[] popupValues, Func<int, bool> checkEnabled, GUIStyle style)
internal static GUIContent GetPopupButtonContent(int selected, GUIContent[] popupValues)
{
selected = PopupCallbackInfo.GetSelectedValueForControl(controlID, selected);

GUIContent buttonContent;
if (showMixedValue)
{
Expand All @@ -3927,8 +3923,21 @@ internal static int DoPopup(Rect position, int controlID, int selected, GUIConte
else
{
buttonContent = popupValues[selected];
buttonContent.text = EditorUtility.ParseMenuName(popupValues[selected].text);
}

return buttonContent;
}

internal static int DoPopup(Rect position, int controlID, int selected, GUIContent[] popupValues, GUIStyle style)
{
return DoPopup(position, controlID, selected, popupValues, null, style);
}

internal static int DoPopup(Rect position, int controlID, int selected, GUIContent[] popupValues, Func<int, bool> checkEnabled, GUIStyle style)
{
selected = PopupCallbackInfo.GetSelectedValueForControl(controlID, selected);

Event evt = Event.current;
switch (evt.type)
{
Expand All @@ -3941,7 +3950,7 @@ internal static int DoPopup(Rect position, int controlID, int selected, GUIConte
}

BeginHandleMixedValueContentColor();
style.Draw(position, buttonContent, controlID, false, position.Contains(Event.current.mousePosition));
style.Draw(position, GetPopupButtonContent(selected, popupValues), controlID, false, position.Contains(Event.current.mousePosition));
EndHandleMixedValueContentColor();

style.font = originalFont;
Expand Down Expand Up @@ -6064,7 +6073,7 @@ internal static void DoInspectorTitlebar(Rect position, int id, bool foldout, Ob
}
break;
case EventType.Repaint:
textStyle.Draw(textRect, EditorGUIUtility.TempContent(ObjectNames.GetInspectorTitle(targetObjs[0])), hovered, pressed, foldout, hasFocus);
textStyle.Draw(textRect, EditorGUIUtility.TempContent(ObjectNames.GetInspectorTitle(targetObjs[0], targetObjs.Length > 1)), hovered, pressed, foldout, hasFocus);
if (EditorGUIUtility.comparisonViewMode == EditorGUIUtility.ComparisonViewMode.None)
{
EditorStyles.optionsButtonStyle.Draw(settingsRect, GUIContent.none, id, foldout, settingsRect.Contains(Event.current.mousePosition));
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/EditorSettings.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ internal static extern string Internal_ProjectGenerationUserExtensions
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
internal static extern void SetEtcTextureCompressorDefaultBehavior();

[Obsolete("EditorSettings.useLegacyProbeSampleCount is deprecated. The legacy method of selecting probe sample counts will be removed in a future release.", false)]
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
public static extern bool useLegacyProbeSampleCount { get; set; }

Expand Down
48 changes: 45 additions & 3 deletions Editor/Mono/GI/LightBaker.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ public Resolution lightmapResolution(UInt32 index)
extern public void SetLightmapResolution(Resolution resolution);
extern public void SetEnvironment(Vector4 color);

extern public void SetBackend(Backend backend);
public extern ProbeRequest[] GetProbeRequests();
public extern void SetLightProbeRequests(ProbeRequest[] requests);
public extern LightmapRequest[] GetLightmapRequests();
Expand All @@ -549,9 +548,52 @@ public void SetProbePositions(Vector3[] positions)
SetProbePositions(positions.AsSpan());
}
public extern void SetProbePositions(ReadOnlySpan<Vector3> positions);

public extern Vector3[] GetProbePositions();
}
extern static public Result Bake(BakeInput input);

[StructLayout(LayoutKind.Sequential)]
public class DeviceSettings : IDisposable
{
static extern IntPtr Internal_Create();
[NativeMethod(IsThreadSafe = true)]

public extern bool Initialize(Backend backend);
static extern void Internal_Destroy(IntPtr ptr);

internal IntPtr m_Ptr;
internal bool m_OwnsPtr;

public DeviceSettings()
{
m_Ptr = Internal_Create();
m_OwnsPtr = true;
}
public DeviceSettings(IntPtr ptr)
{
m_Ptr = ptr;
m_OwnsPtr = false;
}
~DeviceSettings()
{
Destroy();
}

public void Dispose()
{
Destroy();
GC.SuppressFinalize(this);
}

void Destroy()
{
if (m_OwnsPtr && m_Ptr != IntPtr.Zero)
{
Internal_Destroy(m_Ptr);
m_Ptr = IntPtr.Zero;
}
}
}
extern static public Result Bake(BakeInput input, DeviceSettings deviceSettings);
}
}
19 changes: 19 additions & 0 deletions Editor/Mono/GI/Lightmapping.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ internal struct LightProbesConvergence
[NativeName("m_ConvergedProbeSetCount")] public int convergedProbeSetCount;
}

[UsedByNativeCode]
[NativeHeader("Editor/Src/GI/Progressive/PVRData.h")]
internal struct LightmapSize
{
[NativeName("m_Width")] public int width;
[NativeName("m_Height")] public int height;
}

[UsedByNativeCode]
[NativeHeader("Editor/Src/GI/Progressive/PVRData.h")]
internal struct RunningBakeInfo
{
[NativeName("m_LightmapSizes")] public LightmapSize[] lightmapSizes;
[NativeName("m_ProbePositions")] public UInt64 probePositions;
}

[UsedByNativeCode]
[NativeHeader("Editor/Src/GI/Progressive/PVRData.h")]
internal struct LightmapMemory
Expand Down Expand Up @@ -233,6 +249,9 @@ internal static FilterMode filterMode
[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
internal static extern LightmapConvergence GetLightmapConvergence(int lightmapIndex);

[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
internal static extern RunningBakeInfo GetRunningBakeInfo();

[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
internal static extern LightProbesConvergence GetLightProbesConvergence();

Expand Down
9 changes: 9 additions & 0 deletions Editor/Mono/GUI/AppStatusBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ static Styles()
const double k_CheckUnresponsiveFrequencyInSecond = 0.5;
const float k_ShowProgressThreshold = 0.5f;
private double m_LastUpdate;
private bool m_IsQuitting;

private bool showBakeMode
{
get
{
if (m_IsQuitting)
return false;

var settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();
return settings.bakedGI || settings.realtimeGI;
}
Expand Down Expand Up @@ -93,13 +97,16 @@ protected override void OnEnable()
Progress.added += RefreshProgressBar;
Progress.removed += RefreshProgressBar;
Progress.updated += RefreshProgressBar;

EditorApplication.editorApplicationQuit += OnQuit;
}

protected override void OnDisable()
{
Progress.added -= RefreshProgressBar;
Progress.removed -= RefreshProgressBar;
Progress.updated -= RefreshProgressBar;
EditorApplication.editorApplicationQuit -= OnQuit;
EditorApplication.delayCall -= DelayRepaint;
base.OnDisable();
}
Expand Down Expand Up @@ -474,6 +481,8 @@ private GUIContent GetBakeModeIcon(bool? bakeMode)

return Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate;
}
private void OnQuit()
=> m_IsQuitting = true;

[RequiredByNativeCode]
public static void StatusChanged()
Expand Down
9 changes: 8 additions & 1 deletion Editor/Mono/GUI/EditorCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,17 @@ private bool Init(Object obj, EditorFeatures requirements)
// Are we dealing with a Root Editor?
if (editor.GetType() != nonRootEditor.GetType())
{
// Try again, with a normal editor
// Destroy previous editor
UnityEngine.Object.DestroyImmediate(editor);
// Try again, with a non Root editor
editor = nonRootEditor;
onSceneDragMethodInfo = editor.GetType().GetMethod("OnSceneDrag", sceneDragReflectionFlags);
}
else
{
// Destroy unused non Root editor
UnityEngine.Object.DestroyImmediate(nonRootEditor);
}
}

if (onSceneDragMethodInfo != null)
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/GUI/Toolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void CreateContents()

protected override void OnDisable()
{
m_Root?.RemoveFromHierarchy();
base.OnDisable();
EditorApplication.modifierKeysChanged -= Repaint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override bool CanStartDrag(TreeViewItem targetItem, List<int> draggedItem
foreach (var draggedItemID in draggedItemIDs)
{
var path = AssetDatabase.GetAssetPath(draggedItemID);
if (AssetDatabase.IsValidFolder(path) && !AssetDatabase.GetAssetFolderInfo(path, out _, out _))
if (AssetDatabase.IsValidFolder(path) && !AssetDatabase.TryGetAssetFolderInfo(path, out _, out _))
return false;

}
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/GUI/WindowLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,7 @@ internal static SaveWindowLayout ShowWindow()
{
SaveWindowLayout w = GetWindowDontShow<SaveWindowLayout>();
w.minSize = w.maxSize = new Vector2(k_Width, k_Height);
w.m_Pos = new Rect(0, 0,k_Width, k_Height);
w.ShowAuxWindow();
return w;
}
Expand Down
23 changes: 5 additions & 18 deletions Editor/Mono/GameView/GameViewSizesMenuModifyItemUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ override public void OnGUI(Rect rect)
{
if (string.IsNullOrEmpty(displayText))
displayText = "Result";
else
displayText = GetCroppedText(displayText, cropWidth, EditorStyles.label);
GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label);

var clipping = EditorStyles.label.clipping;
EditorStyles.label.clipping = TextClipping.Ellipsis;
GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label, GUILayout.MaxWidth(cropWidth));
EditorStyles.label.clipping = clipping;
}
GUILayout.FlexibleSpace();
GUILayout.Space(margin);
Expand Down Expand Up @@ -133,21 +135,6 @@ override public void OnGUI(Rect rect)

GUILayout.Space(Styles.windowBottomPadding);
}

string GetCroppedText(string fullText, float cropWidth, GUIStyle style)
{
// Check if we need to crop
int characterCountVisible = style.GetNumCharactersThatFitWithinWidth(fullText, cropWidth);
if (characterCountVisible == -1)
{
return fullText;
}

if (characterCountVisible > 1 && characterCountVisible != fullText.Length)
return fullText.Substring(0, characterCountVisible - 1) + ("\u2026"); // 'horizontal ellipsis' (U+2026) is: ...
else
return fullText;
}
}
}

Expand Down
Loading