Skip to content

Commit 0ecd19c

Browse files
author
Unity Technologies
committed
Unity 2019.1.13f1 C# reference source code
1 parent 4a3cd1c commit 0ecd19c

File tree

15 files changed

+61
-19
lines changed

15 files changed

+61
-19
lines changed

Editor/Mono/EditorHandles/VertexSnapping.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private static void UpdateVertexSnappingOffset()
108108

109109
// Important to reset handleOffset before querying handlePosition,
110110
// since handlePosition depends on handleOffset.
111+
Tools.InvalidateHandlePosition();
111112
Tools.handleOffset = Vector3.zero;
112113
Tools.handleOffset = near - Tools.handlePosition;
113114
}

Editor/Mono/GUI/Tools/BuiltinTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ protected override void ToolGUI(SceneView view, Vector3 handlePosition, bool isS
406406
GUI.color = fadedColor;
407407
}
408408

409-
Vector3 oldPivot = Tools.GetHandlePosition();
409+
Vector3 oldPivot = Tools.cachedHandlePosition;
410410

411411
// Pivot handle
412412
if (!Tools.vertexDragging)

Editor/Mono/GUI/Tools/EditorToolContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ internal static EditorTool activeTool
8383

8484
Tools.SyncToolEnum();
8585

86+
Tools.InvalidateHandlePosition();
87+
8688
s_ChangingActiveTool = false;
8789
}
8890
}

Editor/Mono/GUI/Tools/Tools.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,27 @@ internal static bool viewToolActive
134134
}
135135
}
136136

137+
static Vector3 s_HandlePosition;
138+
static bool s_HandlePositionComputed;
139+
140+
internal static Vector3 cachedHandlePosition
141+
{
142+
get
143+
{
144+
if (!s_HandlePositionComputed)
145+
{
146+
s_HandlePosition = GetHandlePosition();
147+
s_HandlePositionComputed = true;
148+
}
149+
return s_HandlePosition;
150+
}
151+
}
152+
153+
internal static void InvalidateHandlePosition()
154+
{
155+
s_HandlePositionComputed = false;
156+
}
157+
137158
public static Vector3 handlePosition
138159
{
139160
get
@@ -145,7 +166,7 @@ public static Vector3 handlePosition
145166
if (s_LockHandlePositionActive)
146167
return s_LockHandlePosition;
147168

148-
return GetHandlePosition();
169+
return cachedHandlePosition;
149170
}
150171
}
151172

@@ -278,6 +299,7 @@ public static PivotMode pivotMode
278299
{
279300
get.m_PivotMode = value;
280301
EditorPrefs.SetInt("PivotMode", (int)pivotMode);
302+
InvalidateHandlePosition();
281303
}
282304
}
283305
}
@@ -405,6 +427,7 @@ private void OnEnable()
405427
internal static void OnSelectionChange()
406428
{
407429
ResetGlobalHandleRotation();
430+
InvalidateHandlePosition();
408431
localHandleOffset = Vector3.zero;
409432
}
410433

Editor/Mono/Inspector/InspectorWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Overflow = UnityEngine.UIElements.Overflow;
2525

2626
using AssetImporterEditor = UnityEditor.Experimental.AssetImporters.AssetImporterEditor;
27+
using UnityEditor.SceneManagement;
2728

2829
namespace UnityEditor
2930
{
@@ -449,7 +450,7 @@ void ExtractPrefabComponents()
449450
return;
450451

451452
m_ComponentsInPrefabSource = sourceGo.GetComponents<Component>();
452-
var removedComponentsList = PrefabUtility.GetRemovedComponents(PrefabUtility.GetOutermostPrefabInstanceRoot(go));
453+
var removedComponentsList = PrefabOverridesUtility.GetRemovedComponentsForSingleGameObject(go);
453454
for (int i = 0; i < removedComponentsList.Count; i++)
454455
{
455456
m_RemovedComponents.Add(removedComponentsList[i].assetComponent);

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,8 @@ void OnEnable()
505505
}
506506

507507
for (int i = 0; i < m_SectionAnimators.Length; i++)
508-
m_SectionAnimators[i] = new AnimBool(m_SelectedSection.value == i, Repaint);
509-
510-
m_ShowDefaultIsNativeResolution.valueChanged.AddListener(Repaint);
511-
m_ShowResolution.valueChanged.AddListener(Repaint);
508+
m_SectionAnimators[i] = new AnimBool(m_SelectedSection.value == i);
509+
SetValueChangeListeners(Repaint);
512510

513511
m_VRSettings = new VR.PlayerSettingsEditorVR(this);
514512

@@ -519,13 +517,19 @@ void OnEnable()
519517
s_GraphicsDeviceLists.Clear();
520518
}
521519

522-
public void SetSectionOpenListener(UnityAction action)
520+
public void SetValueChangeListeners(UnityAction action)
523521
{
524522
for (int i = 0; i < m_SectionAnimators.Length; i++)
525523
{
526524
m_SectionAnimators[i].valueChanged.RemoveAllListeners();
527525
m_SectionAnimators[i].valueChanged.AddListener(action);
528526
}
527+
528+
m_ShowDefaultIsNativeResolution.valueChanged.RemoveAllListeners();
529+
m_ShowDefaultIsNativeResolution.valueChanged.AddListener(action);
530+
531+
m_ShowResolution.valueChanged.RemoveAllListeners();
532+
m_ShowResolution.valueChanged.AddListener(action);
529533
}
530534

531535
public override bool UseDefaultMargins()
@@ -2597,7 +2601,7 @@ internal static SettingsProvider CreateProjectSettingsProvider()
25972601
SettingsProvider.GetSearchKeywordsFromGUIContentProperties<SettingsContent>());
25982602
provider.activateHandler = (searchContext, rootElement) =>
25992603
{
2600-
(provider.settingsEditor as PlayerSettingsEditor)?.SetSectionOpenListener(provider.Repaint);
2604+
(provider.settingsEditor as PlayerSettingsEditor)?.SetValueChangeListeners(provider.Repaint);
26012605
};
26022606
return provider;
26032607
}

Editor/Mono/Prefabs/PrefabOverrides/PrefabOverridesUtility.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,25 @@ public static List<RemovedComponent> GetRemovedComponents(GameObject prefabInsta
121121
var prefabInstanceRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(prefabInstance);
122122

123123
// From root of asset traverse all children and detect any Components that are not present on the instance object (these must be deleted)
124-
TransformVisitor transformVisitor = new TransformVisitor();
125124
var removedComponents = new List<RemovedComponent>();
126125
if (PrefabUtility.IsDisconnectedFromPrefabAsset(prefabInstance))
127126
return removedComponents;
128-
127+
TransformVisitor transformVisitor = new TransformVisitor();
129128
transformVisitor.VisitAll(prefabInstanceRoot.transform, CheckForRemovedComponents, removedComponents);
130129
return removedComponents;
131130
}
132131

132+
public static List<RemovedComponent> GetRemovedComponentsForSingleGameObject(GameObject prefabInstance)
133+
{
134+
ThrowExceptionIfNullOrNotPartOfPrefabInstance(prefabInstance);
135+
136+
var removedComponents = new List<RemovedComponent>();
137+
if (PrefabUtility.IsDisconnectedFromPrefabAsset(prefabInstance))
138+
return removedComponents;
139+
CheckForRemovedComponents(prefabInstance.transform, removedComponents);
140+
return removedComponents;
141+
}
142+
133143
static void CheckForRemovedComponents(Transform transform, object userData)
134144
{
135145
GameObject instanceGameObject = transform.gameObject;

Editor/Mono/SceneView/SceneView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ protected virtual void OnGUI()
22482248
if (evt.type == EventType.Repaint)
22492249
{
22502250
s_MouseRects.Clear();
2251+
Tools.InvalidateHandlePosition(); // Some cases that should invalidate the cached position are not handled correctly yet so we refresh it once per frame
22512252
Profiler.BeginSample("SceneView.Repaint");
22522253
}
22532254

Modules/TerrainEditor/PaintTools/PaintHeightTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class PaintHeightTool : TerrainPaintTool<PaintHeightTool>
1414
const string toolName = "Raise or Lower Terrain";
1515

1616
[FormerlyPrefKeyAs("Terrain/Raise Height", "f1")]
17-
[Shortcut("Terrain/Raise or Lower Terrain", typeof(TerrainToolShortcutContext))]
17+
[Shortcut("Terrain/Raise or Lower Terrain", typeof(TerrainToolShortcutContext), KeyCode.F1)]
1818
static void SelectShortcut(ShortcutArguments args)
1919
{
2020
TerrainToolShortcutContext context = (TerrainToolShortcutContext)args.context;

Modules/TerrainEditor/PaintTools/PaintTextureTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class PaintTextureTool : TerrainPaintTool<PaintTextureTool>
2626
bool m_ShowLayerEditor = false;
2727

2828
[FormerlyPrefKeyAs("Terrain/Texture Paint", "f4")]
29-
[Shortcut("Terrain/Paint Texture", typeof(TerrainToolShortcutContext))]
29+
[Shortcut("Terrain/Paint Texture", typeof(TerrainToolShortcutContext), KeyCode.F4)]
3030
static void SelectShortcut(ShortcutArguments args)
3131
{
3232
TerrainToolShortcutContext context = (TerrainToolShortcutContext)args.context;

0 commit comments

Comments
 (0)