Skip to content

Commit 7ab3b49

Browse files
author
Unity Technologies
committed
Unity 6000.0.13f1 C# reference source code
1 parent 851a7bd commit 7ab3b49

File tree

81 files changed

+1426
-384
lines changed

Some content is hidden

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

81 files changed

+1426
-384
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ private static bool HasFlag(ResampleFlags flags, ResampleFlags flag)
129129
private AnimationClipPlayable m_CandidateClipPlayable;
130130
private AnimationClipPlayable m_DefaultPosePlayable;
131131
private bool m_UsesPostProcessComponents = false;
132-
HashSet<Object> m_ObjectsModifiedDuringAnimationMode = new HashSet<Object>();
133132

134133
private static ProfilerMarker s_ResampleAnimationMarker = new ProfilerMarker("AnimationWindowControl.ResampleAnimation");
135134

@@ -717,42 +716,30 @@ private bool AllowRecordingPrefabPropertyOverridesFor(UnityEngine.Object compone
717716
if (componentOrGameObject == null)
718717
throw new ArgumentNullException(nameof(componentOrGameObject));
719718

720-
GameObject inputGameObject = null;
721-
if (componentOrGameObject is Component)
722-
{
723-
inputGameObject = ((Component)componentOrGameObject).gameObject;
724-
}
725-
else if (componentOrGameObject is GameObject)
726-
{
727-
inputGameObject = (GameObject)componentOrGameObject;
728-
}
729-
else
730-
{
719+
if (componentOrGameObject is not Component && componentOrGameObject is not GameObject)
731720
return true;
732-
}
733721

734722
var rootOfAnimation = state.activeRootGameObject;
735723
if (rootOfAnimation == null)
736724
return true;
737725

738-
// If the input object is a child of the current root of animation then disallow recording of prefab property overrides
739-
// since the input object is currently being setup for animation recording
740-
return inputGameObject.transform.IsChildOf(rootOfAnimation.transform) == false;
726+
return false;
741727
}
742728

743729
void OnExitingAnimationMode()
744730
{
745731
Undo.postprocessModifications -= PostprocessAnimationRecordingModifications;
746732
PrefabUtility.allowRecordingPrefabPropertyOverridesFor -= AllowRecordingPrefabPropertyOverridesFor;
733+
}
747734

748-
// Ensures Prefab instance overrides are recorded for properties that was changed while in AnimationMode
749-
foreach (var obj in m_ObjectsModifiedDuringAnimationMode)
735+
void RecordPropertyOverridesForNonAnimatedProperties(UndoPropertyModification[] modifications)
736+
{
737+
PrefabUtility.allowRecordingPrefabPropertyOverridesFor -= AllowRecordingPrefabPropertyOverridesFor;
738+
foreach (var mod in modifications)
750739
{
751-
if (obj != null)
752-
EditorUtility.SetDirty(obj);
740+
PrefabUtility.RecordPrefabInstancePropertyModifications(mod.currentValue.target);
753741
}
754-
755-
m_ObjectsModifiedDuringAnimationMode.Clear();
742+
PrefabUtility.allowRecordingPrefabPropertyOverridesFor += AllowRecordingPrefabPropertyOverridesFor;
756743
}
757744

758745
private UndoPropertyModification[] PostprocessAnimationRecordingModifications(UndoPropertyModification[] modifications)
@@ -769,17 +756,15 @@ private UndoPropertyModification[] PostprocessAnimationRecordingModifications(Un
769756
else if (previewing)
770757
modifications = RegisterCandidates(modifications);
771758

759+
// Fix for UUM-61742: Unrecorded Prefab overloads should be recorded immediately
760+
RecordPropertyOverridesForNonAnimatedProperties(modifications);
761+
772762
RefreshDisplayNamesOnArrayTopologicalChange(modifications);
773763

774764
// Only resample when playable graph has been customized with post process nodes.
775765
if (m_UsesPostProcessComponents)
776766
ResampleAnimation(ResampleFlags.None);
777767

778-
foreach (var mod in modifications)
779-
{
780-
m_ObjectsModifiedDuringAnimationMode.Add(mod.currentValue.target);
781-
}
782-
783768
return modifications;
784769
}
785770

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
[assembly: InternalsVisibleTo("UnityEditor.Graphs")]
4646
[assembly: InternalsVisibleTo("UnityEditor.UWP.Extensions")]
4747
[assembly: InternalsVisibleTo("UnityEditor.iOS.Extensions.Common")]
48+
[assembly: InternalsVisibleTo("UnityEditor.Apple.Extensions.Common")]
4849
[assembly: InternalsVisibleTo("UnityEditor.iOS.Extensions")]
4950
[assembly: InternalsVisibleTo("UnityEditor.VisionOS.Extensions")]
5051
[assembly: InternalsVisibleTo("UnityEditor.AppleTV.Extensions")]

Editor/Mono/AssetStoreCachePathManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public enum ConfigStatus
1919
InvalidPath,
2020
ReadOnly,
2121
EnvironmentOverride,
22-
NotFound,
22+
Default,
2323
Failed
2424
};
2525

Editor/Mono/ConsoleWindow.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ internal static void UpdateLogStyleFixedHeights()
156156
ListViewState m_ListView;
157157
string m_ActiveText = "";
158158
StringBuilder m_CopyString;
159-
private int m_LastPingedEntryRow = -1;
160159
bool m_DevBuild;
161160
int m_CallstackTextStart = 0;
162161
private Mode m_ActiveMode = Mode.None;
@@ -457,18 +456,11 @@ void SetActiveEntry(LogEntry entry)
457456
m_CallstackTextStart = entry.callstackTextStartUTF16;
458457
var entryRow = LogEntries.GetEntryRowIndex(entry.globalLineIndex, m_IndexHintCache);
459458
m_IndexHintCache = entryRow;
460-
// ping object referred by the log entry
461-
if (entry.instanceID != 0 && m_LastPingedEntryRow != entryRow)
462-
{
463-
EditorGUIUtility.PingObject(entry.instanceID);
464-
m_LastPingedEntryRow = entryRow;
465-
}
466459
}
467460
else
468461
{
469462
m_CallstackTextStart = 0;
470463
m_ActiveText = string.Empty;
471-
m_LastPingedEntryRow = -1;
472464
m_ListView.row = -1;
473465
m_CopyString.Clear();
474466
m_ActiveMode = Mode.None;
@@ -637,8 +629,9 @@ internal void OnGUI()
637629
selectedRow = m_ListView.row;
638630
DestroyLatestRestoreEntry();
639631
LogEntry entry = new LogEntry();
640-
LogEntries.GetEntryInternal(m_ListView.row, entry);
641-
m_LastActiveEntryIndex = entry.globalLineIndex;
632+
LogEntries.GetEntryInternal(el.row, entry);
633+
if (entry.instanceID != 0 && e.clickCount != 2)
634+
EditorGUIUtility.PingObject(entry.instanceID);
642635
if (e.clickCount == 2)
643636
openSelectedItem = true;
644637
}

Editor/Mono/EditorGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6483,7 +6483,7 @@ internal static bool FoldoutInternal(Rect position, bool foldout, GUIContent con
64836483
// in the Inspector has different values. Don't show it when expanded, since the difference will be visible further down.
64846484
if (showMixedValue && !foldout)
64856485
{
6486-
style.Draw(drawRect, content, id, false);
6486+
style.Draw(drawRect, content, id, false, false);
64876487

64886488
BeginHandleMixedValueContentColor();
64896489
Rect fieldPosition = origPosition;
@@ -6493,7 +6493,7 @@ internal static bool FoldoutInternal(Rect position, bool foldout, GUIContent con
64936493
}
64946494
else
64956495
{
6496-
style.Draw(drawRect, content, id, foldout);
6496+
style.Draw(drawRect, content, id, foldout, false);
64976497
}
64986498
break;
64996499
case EventType.KeyDown:

Editor/Mono/GUI/DockArea.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private static class Styles
3737
public static readonly GUIStyle background = "dockarea";
3838
public static readonly float tabMinWidth = tab.GetFloat(StyleCatalogKeyword.minWidth, 50.0f);
3939
public static readonly float tabMaxWidth = tab.GetFloat(StyleCatalogKeyword.maxWidth, 150.0f);
40+
public static readonly float tabWidthPadding = tab.GetFloat(StyleCatalogKeyword.paddingRight);
41+
4042
public static readonly float tabDragWidth = EditorResources.GetStyle("tab-drag").GetFloat(StyleCatalogKeyword.width, 100.0f);
4143

4244
public static readonly GUIStyle tabScrollerPrevButton = new GUIStyle("dragtab scroller prev");
@@ -723,10 +725,9 @@ void AddTabToHere(object userData)
723725

724726
private float GetTabWidth(GUIStyle tabStyle, EditorWindow tabWindow)
725727
{
726-
var expectedWidth = tabStyle.CalcSize(tabWindow.titleContent).x;
727-
728-
return Mathf.Max(Mathf.Min(expectedWidth, Styles.tabMaxWidth),
729-
Styles.tabMinWidth);
728+
float minWidth, expectedWidth;
729+
tabStyle.CalcMinMaxWidth(tabWindow.titleContent, out minWidth, out expectedWidth);
730+
return Mathf.Max(Mathf.Min(expectedWidth, Styles.tabMaxWidth), Styles.tabMinWidth) + Styles.tabWidthPadding;
730731
}
731732

732733
private float GetTabWidth(GUIStyle tabStyle, int tabIndex)

Editor/Mono/ImportSettings/TextureImporterInspector.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,11 @@ void InitializeGUI()
659659
public override void OnEnable()
660660
{
661661
base.OnEnable();
662+
Initialize();
663+
}
662664

665+
void Initialize()
666+
{
663667
s_DefaultPlatformName = TextureImporter.defaultPlatformName; // Can't be called everywhere so we save it here for later use.
664668

665669
m_ShowAdvanced = EditorPrefs.GetBool("TextureImporterShowAdvanced", m_ShowAdvanced);
@@ -1501,6 +1505,7 @@ void TextureSettingsGUI()
15011505
}
15021506
}
15031507

1508+
15041509
public override void OnInspectorGUI()
15051510
{
15061511
serializedObject.Update();
@@ -1818,6 +1823,12 @@ public override void DrawPreview(Rect previewArea)
18181823
VirtualTexturing.System.Update();
18191824
}
18201825

1826+
internal override void PostSerializedObjectCreation()
1827+
{
1828+
base.PostSerializedObjectCreation();
1829+
Initialize();
1830+
}
1831+
18211832
private void RefreshPreviewChannelSelection()
18221833
{
18231834
//If the Preview is null or NOT the TextureInspector (e.g. ObjectPreview) then return, we do not need to refresh the preview channel selection

Editor/Mono/Inspector/Core/ScriptAttributeGUI/PropertyHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void HandleDrawnType(SerializedProperty property, Type drawnType, Type pr
117117
// Use PropertyDrawer on array elements, not on array itself.
118118
// If there's a PropertyAttribute on an array, we want to apply it to the individual array elements instead.
119119
// This is the only convenient way we can let the user apply PropertyDrawer attributes to elements inside an array.
120-
if (propertyType != null && propertyType.IsArrayOrList() && !attribute.applyToCollection)
120+
if (propertyType != null && propertyType.IsArrayOrList() && (attribute == null || !attribute.applyToCollection))
121121
return;
122122

123123
var propertyDrawerForType = CreatePropertyDrawerWithDefaultObjectReferences(drawerType);

Editor/Mono/Inspector/MinMaxCurvePropertyDrawer.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ static void DoMinMaxCurvesField(Rect position, int id, SerializedProperty proper
236236
public override VisualElement CreatePropertyGUI(SerializedProperty property)
237237
{
238238
const string StylesheetPath = "StyleSheets/ParticleSystem/ParticleSystem.uss";
239-
const string HideClass = "unity-hidden";
240239
const string AlignClass = "unity-base-field__aligned";
241240
const string InputClass = "unity-base-popup-field__input";
242241
const string RowClass = "unity-particle-system-min-max-curve__row";
@@ -245,7 +244,7 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
245244
PropertyField PrepareProperty(SerializedProperty prop, string label, VisualElement parent)
246245
{
247246
var propField = new PropertyField(prop, label);
248-
propField.AddToClassList(HideClass);
247+
propField.AddToClassList(UIElementsUtility.hiddenClassName);
249248
propField.AddToClassList(GrowClass);
250249
parent.Add(propField);
251250
return propField;
@@ -273,7 +272,7 @@ PropertyField PrepareProperty(SerializedProperty prop, string label, VisualEleme
273272
else DoMinMaxCurvesField(rect, m_Property.curveMin.GetHashCode(), m_Property.curveMax, m_Property.curveMin, m_Property.curveMultiplier, s_Styles.curveColor, s_Styles.curveBackgroundColor, xAxisLabel);
274273
if (EditorGUI.EndChangeCheck()) m_Property.curveMax.serializedObject.ApplyModifiedProperties();
275274
});
276-
region.AddToClassList(HideClass);
275+
region.AddToClassList(UIElementsUtility.hiddenClassName);
277276
region.AddToClassList(GrowClass);
278277
container.Add(region);
279278

@@ -286,7 +285,7 @@ PropertyField PrepareProperty(SerializedProperty prop, string label, VisualEleme
286285
m_Property.mode.intValue = (int)state;
287286
m_Property.mode.serializedObject.ApplyModifiedProperties();
288287

289-
constantMax.EnableInClassList(HideClass, state != MinMaxCurveState.k_Scalar && state != MinMaxCurveState.k_TwoScalars);
288+
constantMax.EnableInClassList(UIElementsUtility.hiddenClassName, state != MinMaxCurveState.k_Scalar && state != MinMaxCurveState.k_TwoScalars);
290289

291290
if(constantMax.Children().Count() > 0)
292291
{
@@ -305,8 +304,8 @@ PropertyField PrepareProperty(SerializedProperty prop, string label, VisualEleme
305304
}
306305
}
307306

308-
constantMin.EnableInClassList(HideClass, state != MinMaxCurveState.k_TwoScalars);
309-
region.EnableInClassList(HideClass, state != MinMaxCurveState.k_Curve && state != MinMaxCurveState.k_TwoCurves);
307+
constantMin.EnableInClassList(UIElementsUtility.hiddenClassName, state != MinMaxCurveState.k_TwoScalars);
308+
region.EnableInClassList(UIElementsUtility.hiddenClassName, state != MinMaxCurveState.k_Curve && state != MinMaxCurveState.k_TwoCurves);
310309
AnimationCurvePreviewCache.ClearCache();
311310
};
312311
mode.RegisterValueChangedCallback(valueChangeAction);

Editor/Mono/Inspector/RectTransformEditor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ void Vector2Field(Rect position,
651651
SerializedProperty xProperty = vec2Property.FindPropertyRelative("x");
652652
SerializedProperty yProperty = vec2Property.FindPropertyRelative("y");
653653

654-
EditorGUI.PrefixLabel(position, -1, label);
654+
int id = GUIUtility.GetControlID(label.GetHashCode(), FocusType.Keyboard, position);
655+
EditorGUI.PrefixLabel(position, id, label);
655656
float t = EditorGUIUtility.labelWidth;
656657
int l = EditorGUI.indentLevel;
657658
Rect r0 = GetColumnRect(position, 0);

Editor/Mono/Inspector/RenderPipelineEditorUtility.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ internal static int GetActiveMaxRenderingLayers()
9393
/// <returns>A list of tuples, each containing the maximum number of rendering layers and the name of the corresponding render pipeline type.</returns>
9494
internal static List<(int, string)> GetMaxRenderingLayersFromSettings()
9595
{
96+
using var hashset = HashSetPool<Type>.Get(out var types);
97+
9698
var result = new List<(int, string)>();
9799
var renderPipelineAssets = GraphicsSettings.allConfiguredRenderPipelines;
98100
foreach (var renderPipelineAsset in renderPipelineAssets)
99101
{
100102
var pipelineType = GetPipelineTypeFromPipelineAssetType(renderPipelineAsset.GetType());
101-
if (pipelineType == null)
103+
if (pipelineType == null || types.Contains(pipelineType))
102104
continue;
103105

104106
if (!EditorGraphicsSettings.TryGetRenderPipelineSettingsFromInterfaceForPipeline<RenderingLayersLimitSettings>(pipelineType, out var settings))
@@ -107,6 +109,7 @@ internal static int GetActiveMaxRenderingLayers()
107109
if (settings.Length == 0)
108110
continue;
109111

112+
types.Add(pipelineType);
110113
result.Add((settings[0].maxSupportedRenderingLayers, renderPipelineAsset.pipelineType.Name));
111114
}
112115

Editor/Mono/Inspector/TagManagerInspector.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,21 @@ void UpdateAllowanceAndMessages(BaseListView listView)
318318
listView.allowRemove = !tagManager.IsIndexReservedForDefaultRenderingLayer(renderingLayerCount - 1);
319319

320320
var viewport = listView.Q<VisualElement>("unity-content-viewport");
321-
viewport.Query<HelpBox>().Where(h => h.name == "MaximumSupportedRenderingLayers").ForEach(h => viewport.Remove(h));
321+
ClearHelpBoxes(viewport);
322322

323323
var maxRenderingLayers = RenderPipelineEditorUtility.GetMaxRenderingLayersFromSettings();
324324
AddInfoBoxesForMaximumValueRestriction(viewport, maxRenderingLayers);
325325
AddWarningMessageForUnsupportedLayers(viewport, maxRenderingLayers);
326326
}
327327

328+
void ClearHelpBoxes(VisualElement viewport)
329+
{
330+
viewport
331+
.Query<HelpBox>()
332+
.Where(h => h.name == "MaximumSupportedRenderingLayers")
333+
.ForEach(viewport.Remove);
334+
}
335+
328336
void AddInfoBoxesForMaximumValueRestriction(VisualElement viewport, List<(int, string)> maxRenderingLayers)
329337
{
330338
for (var i = 0; i < maxRenderingLayers.Count; i++)

Editor/Mono/Inspector/TextureInspector.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,28 @@ public static bool IsNormalMap(Texture t)
165165
}
166166

167167
protected virtual void OnEnable()
168+
{
169+
Initialize();
170+
}
171+
172+
void CacheSerializedProperties()
168173
{
169174
m_WrapU = serializedObject.FindProperty("m_TextureSettings.m_WrapU");
170175
m_WrapV = serializedObject.FindProperty("m_TextureSettings.m_WrapV");
171176
m_WrapW = serializedObject.FindProperty("m_TextureSettings.m_WrapW");
172177
m_FilterMode = serializedObject.FindProperty("m_TextureSettings.m_FilterMode");
173178
m_Aniso = serializedObject.FindProperty("m_TextureSettings.m_Aniso");
179+
}
174180

181+
void Initialize()
182+
{
183+
CacheSerializedProperties();
175184
RecordTextureMipLevels();
176-
177185
SetMipLevelDefaultForVT();
178186

179-
m_Texture3DPreview = CreateInstance<Texture3DPreview>();
187+
if(m_Texture3DPreview == null)
188+
m_Texture3DPreview = CreateInstance<Texture3DPreview>();
189+
180190
if (IsTexture3D())
181191
{
182192
m_Texture3DPreview.Texture = target as Texture;
@@ -343,6 +353,13 @@ public override void OnInspectorGUI()
343353
ApplySettingsToTextures();
344354
}
345355

356+
internal override void PostSerializedObjectCreation()
357+
{
358+
base.PostSerializedObjectCreation();
359+
360+
Initialize();
361+
}
362+
346363
// wrap/filter/aniso editors will change serialized object
347364
// but in case of textures we need an extra step to ApplySettings (so rendering uses new values)
348365
// alas we cant have good things: it will be PITA to make sure we always call that after applying changes to serialized object

Editor/Mono/Modules/ModuleManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ internal static string GetTargetStringFrom(BuildTarget target)
456456
{
457457
if (target == BuildTarget.NoTarget)
458458
throw new ArgumentException("target must be valid");
459-
459+
460460
return GetTargetStringFromBuildTarget(target);
461461
}
462462

@@ -493,7 +493,7 @@ internal static bool ShouldShowMultiDisplayOption()
493493
return true;
494494

495495
BuildTargetGroup curPlatform = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
496-
// In Editortests no platforms are installed and below would result in false, but we support.
496+
// In Editortests no platforms are installed and below would result in false, but we support.
497497
if (curPlatform == BuildTargetGroup.Standalone)
498498
return true;
499499

0 commit comments

Comments
 (0)