From d487c13a4dcd50df2c8f522e146bef66be42f8b0 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Thu, 12 Sep 2024 01:29:34 +0000 Subject: [PATCH] Unity 6000.0.19f1 C# reference source code --- Editor/Mono/GUIView.cs | 2 +- Editor/Mono/HostView.cs | 6 +++++- Editor/Mono/Shaders/ShaderKeywordFilterData.cs | 8 ++++++++ Modules/TextCoreTextEngine/Managed/TextHandle.cs | 4 +--- Modules/UIElements/Core/Text/UITKTextHandle.cs | 6 +++++- README.md | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Editor/Mono/GUIView.cs b/Editor/Mono/GUIView.cs index 45095bafb..d2272cc78 100644 --- a/Editor/Mono/GUIView.cs +++ b/Editor/Mono/GUIView.cs @@ -290,8 +290,8 @@ public static void BeginOffsetArea(Rect screenRect, GUIContent content, GUIStyle public static void EndOffsetArea() { - GUILayoutUtility.EndLayoutGroup(); GUI.EndGroup(); + GUILayoutUtility.EndLayoutGroup(); } // we already have renderdoc integration done in GUIView but in cpp diff --git a/Editor/Mono/HostView.cs b/Editor/Mono/HostView.cs index b52ce0ba2..f546fbfed 100644 --- a/Editor/Mono/HostView.cs +++ b/Editor/Mono/HostView.cs @@ -538,12 +538,16 @@ public void InvokeOnGUI(Rect onGUIPosition) } finally { + // We explicitly called BeginOffsetArea outside this try-catch scope, + // so we need to always explicitly end it as well just like all other + // GUI scopes are responsible for dealing with ExitGUI properly. + EndOffsetArea(); + // We can't reset gui state after ExitGUI we just want to bail completely if (!(isExitGUIException || GUIUtility.guiIsExiting)) { CheckNotificationStatus(); - EndOffsetArea(); if (GUILayoutUtility.unbalancedgroupscount != 0) { Debug.LogError("GUI Error: Invalid GUILayout state in " + GetActualViewName() + " view. Verify that all layout Begin/End calls match"); diff --git a/Editor/Mono/Shaders/ShaderKeywordFilterData.cs b/Editor/Mono/Shaders/ShaderKeywordFilterData.cs index 046800add..bee4cdee9 100644 --- a/Editor/Mono/Shaders/ShaderKeywordFilterData.cs +++ b/Editor/Mono/Shaders/ShaderKeywordFilterData.cs @@ -195,6 +195,14 @@ internal static SettingsNode GatherFilterData(string nodeName, object containerO if (containerObject == null) return node; + // Unity objects have their own validity checking + if (containerObject is UnityEngine.Object) + { + var unityObject = containerObject as UnityEngine.Object; + if (!unityObject) + return node; + } + if (!visited.Add(containerObject)) return node; diff --git a/Modules/TextCoreTextEngine/Managed/TextHandle.cs b/Modules/TextCoreTextEngine/Managed/TextHandle.cs index cb7ea9532..9a8a7c248 100644 --- a/Modules/TextCoreTextEngine/Managed/TextHandle.cs +++ b/Modules/TextCoreTextEngine/Managed/TextHandle.cs @@ -167,14 +167,12 @@ public void AddTextInfoToTemporaryCache(int hashCode) public void RemoveTextInfoFromTemporaryCache() { - if (useAdvancedText) - return; s_TemporaryCache.RemoveTextInfoFromCache(this); } public void RemoveTextInfoFromPermanentCache() { - if (useAdvancedText) + if (textGenerationInfo != IntPtr.Zero) { TextGenerationInfo.Destroy(textGenerationInfo); textGenerationInfo = IntPtr.Zero; diff --git a/Modules/UIElements/Core/Text/UITKTextHandle.cs b/Modules/UIElements/Core/Text/UITKTextHandle.cs index 474166e87..abd9926e9 100644 --- a/Modules/UIElements/Core/Text/UITKTextHandle.cs +++ b/Modules/UIElements/Core/Text/UITKTextHandle.cs @@ -240,9 +240,13 @@ internal float GetVertexPadding(FontAsset fontAsset) private bool wasAdvancedTextEnabledForElement; internal override bool IsAdvancedTextEnabledForElement() { + // When it's called on a thread it automatically means it's not ATG, so we just return false. + if (JobsUtility.IsExecutingJob) + return false; + bool isEnabled = TextUtilities.IsAdvancedTextEnabledForElement(m_TextElement); // We need to cleanup caches to avoid exceptions when switching between advanced and non-advanced text - if (wasAdvancedTextEnabledForElement && !isEnabled && textGenerationInfo != IntPtr.Zero && !JobsUtility.IsExecutingJob) + if (wasAdvancedTextEnabledForElement && !isEnabled && textGenerationInfo != IntPtr.Zero) { TextGenerationInfo.Destroy(textGenerationInfo); textGenerationInfo = IntPtr.Zero; diff --git a/README.md b/README.md index 07eea4f8e..09466ee27 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 6000.0.18f1 C# reference source code +## Unity 6000.0.19f1 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only.