Skip to content

Commit 7f7e3f5

Browse files
committed
UXF rig can destroy itself if another instance exists
1 parent 05750b7 commit 7f7e3f5

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

Assets/UXF/Examples/3_MultiScene_FootballAndRT/OtherScenes/ReactionExample.unity

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ MonoBehaviour:
545545
m_PersistentCalls:
546546
m_Calls: []
547547
m_FontData:
548-
m_Font: {fileID: 12800000, guid: 6858712ab402a3d43a59ba46412d9aad, type: 3}
548+
m_Font: {fileID: 12800000, guid: 8e3115908ec235d438039dbac1d40964, type: 3}
549549
m_FontSize: 50
550550
m_FontStyle: 0
551551
m_BestFit: 0
@@ -715,7 +715,7 @@ RectTransform:
715715
m_AnchorMin: {x: 0, y: 1}
716716
m_AnchorMax: {x: 1, y: 1}
717717
m_AnchoredPosition: {x: 0, y: 0}
718-
m_SizeDelta: {x: -200, y: 80}
718+
m_SizeDelta: {x: -100, y: 80}
719719
m_Pivot: {x: 0.5, y: 1}
720720
--- !u!114 &2014450706
721721
MonoBehaviour:
@@ -736,7 +736,7 @@ MonoBehaviour:
736736
m_PersistentCalls:
737737
m_Calls: []
738738
m_FontData:
739-
m_Font: {fileID: 12800000, guid: 6858712ab402a3d43a59ba46412d9aad, type: 3}
739+
m_Font: {fileID: 12800000, guid: 8e3115908ec235d438039dbac1d40964, type: 3}
740740
m_FontSize: 24
741741
m_FontStyle: 0
742742
m_BestFit: 0

Assets/UXF/Scripts/Session.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public class Session : MonoBehaviour, ISettingsContainer, IDataAssociatable
3535
public bool endAfterLastTrial = false;
3636

3737
/// <summary>
38-
/// If enabled, you do not need to reference this session component in a public field, you can simply call "Session.instance".
38+
/// If enabled, you do not need to reference this session component in a public field, you can simply call "Session.instance". This object will be destroyed if another session component is the main instance.
3939
/// </summary>
40-
[Tooltip("If enabled, you do not need to reference this session component in a public field, you can simply call \"Session.instance\".")]
40+
[Tooltip("If enabled, you do not need to reference this session component in a public field, you can simply call \"Session.instance\". This object will be destroyed if another session component is the main instance.")]
4141
public bool setAsMainInstance = true;
4242

4343
/// <summary>
@@ -257,7 +257,15 @@ public class Session : MonoBehaviour, ISettingsContainer, IDataAssociatable
257257
/// </summary>
258258
void Awake()
259259
{
260-
if (setAsMainInstance) instance = this;
260+
if (setAsMainInstance)
261+
{
262+
if (instance != null && !ReferenceEquals(instance, this))
263+
{
264+
Destroy(this.gameObject);
265+
return;
266+
}
267+
instance = this;
268+
}
261269
if (dontDestroyOnLoadNewScene && Application.isPlaying) DontDestroyOnLoad(gameObject);
262270
if (endAfterLastTrial) onTrialEnd.AddListener(EndIfLastTrial);
263271
}

Assets/UXF/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.4
1+
2.2.5

ProjectSettings/EditorBuildSettings.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ EditorBuildSettings:
1717
- enabled: 0
1818
path: Assets/UXF/Examples/4_CorsiBlock/CorsiBlockExample.unity
1919
guid: d79ca1b5241496f4fba7622d23d6fa08
20-
- enabled: 0
20+
- enabled: 1
2121
path: Assets/UXF/Examples/3_MultiScene_FootballAndRT/OtherScenes/ShootingExample.unity
2222
guid: 1d5a4e0513b6be0428267c45d923520b
23-
- enabled: 0
23+
- enabled: 1
2424
path: Assets/UXF/Examples/3_MultiScene_FootballAndRT/OtherScenes/ReactionExample.unity
2525
guid: 7a79c722962e7d74eb856ff31b309b87
2626
- enabled: 0

0 commit comments

Comments
 (0)