Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 2998ee1

Browse files
author
Yuncong Zhang
authored
Merge pull request #243 from UnityTech/optimizeViewMetricsUpdate
avoid mark viewMetrics dirty in update, which will potentially leads …
2 parents a6995b2 + 31aa77c commit 2998ee1

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Runtime/editor/editor_utils.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public void Update() {
3131
public void OnEnable() {
3232
this._lastDevicePixelRatio = GameViewUtil.getGameViewDevicePixelRatio();
3333
}
34+
35+
public void onViewMetricsChanged() {
36+
37+
}
3438

3539
public float devicePixelRatio {
3640
get { return this._lastDevicePixelRatio; }

Runtime/engine/DisplayMetrics.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public interface DisplayMetrics {
2525
void OnEnable();
2626
void OnGUI();
2727
void Update();
28+
void onViewMetricsChanged();
2829

2930
float devicePixelRatio { get; }
3031

@@ -46,11 +47,14 @@ public void OnGUI() {
4647
}
4748

4849
public void Update() {
50+
51+
}
52+
53+
public void onViewMetricsChanged() {
4954
//view metrics marks dirty
5055
this._viewMetrics = null;
5156
}
5257

53-
5458
public float devicePixelRatio {
5559
get {
5660
if (this._devicePixelRatio > 0) {

Runtime/engine/UIWidgetsPanel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ bool _mouseEntered {
130130

131131
void _handleViewMetricsChanged(string method, List<JSONNode> args) {
132132
this._windowAdapter.onViewMetricsChanged();
133-
this._displayMetrics.Update();
133+
this._displayMetrics.onViewMetricsChanged();
134134
}
135135

136136
protected override void OnEnable() {

0 commit comments

Comments
 (0)