Skip to content

Commit faa3b59

Browse files
committed
Popup's position is now persistent between sessions (#113)
1 parent e83c16c commit faa3b59

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Plugins/IngameDebugConsole/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= In-game Debug Console (v1.8.3) =
1+
= In-game Debug Console (v1.8.4) =
22

33
Documentation: https://github.com/yasirkula/UnityIngameDebugConsole
44
FAQ: https://github.com/yasirkula/UnityIngameDebugConsole#faq

Plugins/IngameDebugConsole/Scripts/DebugLogPopup.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public class DebugLogPopup : MonoBehaviour, IPointerClickHandler, IBeginDragHand
5353

5454
public bool IsVisible { get; private set; }
5555

56+
private Vector2 SavedNormalizedPosition
57+
{
58+
get => PlayerPrefs.HasKey("IDGPPos") ? JsonUtility.FromJson<Vector2>(PlayerPrefs.GetString("IDGPPos", "{}")) : new Vector2(0.5f, 0f); // Right edge by default
59+
set => PlayerPrefs.SetString("IDGPPos", JsonUtility.ToJson(value));
60+
}
61+
5662
private void Awake()
5763
{
5864
popupTransform = (RectTransform) transform;
@@ -62,14 +68,14 @@ private void Awake()
6268
normalColor = backgroundImage.color;
6369

6470
halfSize = popupTransform.sizeDelta * 0.5f;
65-
66-
Vector2 pos = popupTransform.anchoredPosition;
67-
if( pos.x != 0f || pos.y != 0f )
68-
normalizedPosition = pos.normalized; // Respect the initial popup position set in the prefab
69-
else
70-
normalizedPosition = new Vector2( 0.5f, 0f ); // Right edge by default
71+
normalizedPosition = SavedNormalizedPosition;
7172
}
7273

74+
protected void OnDestroy()
75+
{
76+
SavedNormalizedPosition = normalizedPosition;
77+
}
78+
7379
public void NewLogsArrived( int newInfo, int newWarning, int newError )
7480
{
7581
if( newInfo > 0 )

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.ingamedebugconsole",
33
"displayName": "In-game Debug Console",
4-
"version": "1.8.3",
4+
"version": "1.8.4",
55
"documentationUrl": "https://github.com/yasirkula/UnityIngameDebugConsole",
66
"changelogUrl": "https://github.com/yasirkula/UnityIngameDebugConsole/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityIngameDebugConsole/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)