Skip to content

Commit fce5fa6

Browse files
committed
fix: gate avatar sim/inspector foldout when framework is in project
1 parent 31576e6 commit fce5fa6

7 files changed

Lines changed: 36 additions & 3 deletions

File tree

Basis/Packages/com.basis.sdk/BasisSDK.asmdef

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"precompiledReferences": [],
1717
"autoReferenced": true,
1818
"defineConstraints": [],
19-
"versionDefines": [],
19+
"versionDefines": [
20+
{
21+
"name": "com.basis.framework",
22+
"expression": "",
23+
"define": "BASIS_FRAMEWORK_EXISTS"
24+
}
25+
],
2026
"noEngineReferences": false
2127
}

Basis/Packages/com.basis.sdk/Scripts/Editor/BasisAvatarEditorPreviewBootstrap.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !BASIS_FRAMEWORK_EXISTS
12
using UnityEditor;
23

34
namespace Basis.Scripts.BasisSdk.Players.Editor
@@ -11,3 +12,4 @@ private static void Register()
1112
}
1213
}
1314
}
15+
#endif

Basis/Packages/com.basis.sdk/Scripts/Editor/BasisEditorPreviewLocalPlayer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !BASIS_FRAMEWORK_EXISTS
12
using Basis.Scripts.Animator_Driver;
23
using System.Threading.Tasks;
34
using UnityEditor;
@@ -121,3 +122,4 @@ public static void DisposeActive()
121122

122123
}
123124
}
125+
#endif

Basis/Packages/com.basis.sdk/Scripts/Editor/BasisEditorPreviewParametersFoldout.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !BASIS_FRAMEWORK_EXISTS
12
using UnityEditor;
23
using UnityEngine;
34
using UnityEngine.UIElements;
@@ -130,3 +131,4 @@ private static void DrawMicSection()
130131
}
131132
}
132133
}
134+
#endif

Basis/Packages/com.basis.sdk/Scripts/Editor/SDKInspector/BasisAvatarSDKInspector.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
public partial class BasisAvatarSDKInspector : Editor
1616
{
1717
private const string PendingTestInEditorAvatarIdSessionKey = "BasisAvatarSDKInspector.PendingTestInEditorAvatarId";
18+
// Unity's GlobalObjectId table isn't always populated on the first delayCall after
19+
// EnteredPlayMode (the play-mode scene reload races us). Retry a bounded number of
20+
// ticks so a transient null resolve doesn't drop the pending avatar.
21+
private const int MaxResolveAttempts = 30;
22+
private static int _resolveAttempts;
1823

1924
public delegate void BeforeTestInEditorHandler(GameObject clone);
2025
public static BeforeTestInEditorHandler OnBeforeTestInEditor;
@@ -50,6 +55,7 @@ private static void OnPlayModeStateChanged(PlayModeStateChange state)
5055
return;
5156
}
5257

58+
_resolveAttempts = 0;
5359
EditorApplication.delayCall -= TryExecutePendingTestInEditor;
5460
EditorApplication.delayCall += TryExecutePendingTestInEditor;
5561
}
@@ -59,23 +65,34 @@ private static void TryExecutePendingTestInEditor()
5965
string pendingAvatarId = GetPendingTestInEditorAvatarId();
6066
if (string.IsNullOrEmpty(pendingAvatarId))
6167
{
68+
_resolveAttempts = 0;
6269
return;
6370
}
6471

6572
if (!GlobalObjectId.TryParse(pendingAvatarId, out GlobalObjectId avatarId))
6673
{
6774
ClearPendingTestInEditorAvatarId();
75+
_resolveAttempts = 0;
6876
return;
6977
}
7078

7179
BasisAvatar avatar = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(avatarId) as BasisAvatar;
72-
ClearPendingTestInEditorAvatarId();
7380
if (avatar == null)
7481
{
75-
BasisDebug.LogError("Unable to resolve the pending avatar for Test In Editor.", BasisDebug.LogTag.Editor);
82+
if (++_resolveAttempts < MaxResolveAttempts)
83+
{
84+
EditorApplication.delayCall += TryExecutePendingTestInEditor;
85+
return;
86+
}
87+
88+
ClearPendingTestInEditorAvatarId();
89+
_resolveAttempts = 0;
90+
BasisDebug.LogError($"Unable to resolve the pending avatar for Test In Editor after {MaxResolveAttempts} attempts.", BasisDebug.LogTag.Editor);
7691
return;
7792
}
7893

94+
ClearPendingTestInEditorAvatarId();
95+
_resolveAttempts = 0;
7996
RequestAvatarLoad(avatar);
8097
}
8198

Basis/Packages/com.basis.sdk/Scripts/Sim/BasisAvatarSimMic.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !BASIS_FRAMEWORK_EXISTS
12
using Basis.Scripts.Drivers;
23
using UnityEngine;
34

@@ -56,3 +57,4 @@ private void OnAudioFilterRead(float[] data, int channels)
5657
private void OnDisable() => StopCapture();
5758
}
5859
}
60+
#endif

Basis/Packages/com.basis.sdk/Scripts/Sim/BasisAvatarSimPlayer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !BASIS_FRAMEWORK_EXISTS
12
using Basis.Scripts.BasisSdk;
23
using Basis.Scripts.BasisSdk.Helpers;
34
using Basis.Scripts.Drivers;
@@ -60,3 +61,4 @@ private void OnDestroy()
6061
}
6162
}
6263
}
64+
#endif

0 commit comments

Comments
 (0)