Skip to content

Commit 495cb07

Browse files
committed
cached more things into a single instance
1 parent e119945 commit 495cb07

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

Basis/Packages/com.basis.bundlemanagement/BasisBundleLoadAsset.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static async Task<GameObject> LoadFromWrapper(BasisTrackedBundleWrapper B
1919
{
2020
string ReplacedName = Generated.AssetToLoadName.Replace(".bundle", ".prefab");
2121

22-
AssetBundleRequest Request = BasisLoadableBundle.AssetBundle.LoadAssetAsync<GameObject>(ReplacedName);//assets/temporarystorage/19a260b00e5f474f8472fa9dea4ca2a920250227.prefab
22+
AssetBundleRequest Request = BasisLoadableBundle.AssetBundle.LoadAssetAsync<GameObject>(ReplacedName);
2323
await Request;
2424
GameObject loadedObject = Request.asset as GameObject;
2525
if (loadedObject == null)

Basis/Packages/com.basis.framework/Drivers/Local/BasisLocalAvatarDriver.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Basis.Scripts.BasisSdk.Players;
44
using Basis.Scripts.Common;
55
using Basis.Scripts.Device_Management;
6+
using Basis.Scripts.Player;
67
using Basis.Scripts.TransformBinders.BoneControl;
78
using GatorDragonGames.JigglePhysics;
89
using System;
@@ -11,7 +12,6 @@
1112
using UnityEngine;
1213
using UnityEngine.AddressableAssets;
1314
using UnityEngine.Animations.Rigging;
14-
using UnityEngine.Rendering;
1515

1616
namespace Basis.Scripts.Drivers
1717
{
@@ -22,8 +22,6 @@ namespace Basis.Scripts.Drivers
2222
[Serializable]
2323
public class BasisLocalAvatarDriver : BasisAvatarDriver
2424
{
25-
/// <summary>Addressable path to the T-Pose animator controller asset.</summary>
26-
public const string TPose = "Assets/Animator/Animated TPose.controller";
2725

2826
/// <summary>Addressables key for the default locomotion animator controller.</summary>
2927
public const string Locomotion = "Locomotion";
@@ -351,9 +349,7 @@ public void PutAvatarIntoTPose()
351349
{
352350
SavedruntimeAnimatorController = BasisLocalPlayer.Instance.BasisAvatar.Animator.runtimeAnimatorController;
353351
}
354-
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<RuntimeAnimatorController> op = Addressables.LoadAssetAsync<RuntimeAnimatorController>(TPose);
355-
RuntimeAnimatorController RAC = op.WaitForCompletion();
356-
BasisLocalPlayer.Instance.BasisAvatar.Animator.runtimeAnimatorController = RAC;
352+
BasisLocalPlayer.Instance.BasisAvatar.Animator.runtimeAnimatorController = BasisPlayerFactory.TposeController;
357353
ForceUpdateAnimator(BasisLocalPlayer.Instance.BasisAvatar.Animator);
358354
TposeStateChange?.Invoke();
359355

Basis/Packages/com.basis.framework/Drivers/Local/BasisLocalHandDriver.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Basis.Scripts.BasisSdk.Players;
22
using Basis.Scripts.Common;
33
using Basis.Scripts.Drivers;
4+
using Basis.Scripts.Player;
45
using System;
56
using System.Collections.Generic;
67
using System.Linq;
@@ -268,10 +269,7 @@ public void PutAvatarIntoTPose(Animator Anim)
268269
{
269270
BasisLocalAvatarDriver.SavedruntimeAnimatorController = Anim.runtimeAnimatorController;
270271
}
271-
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<RuntimeAnimatorController> op =
272-
Addressables.LoadAssetAsync<RuntimeAnimatorController>(BasisLocalAvatarDriver.TPose);
273-
RuntimeAnimatorController RAC = op.WaitForCompletion();
274-
Anim.runtimeAnimatorController = RAC;
272+
Anim.runtimeAnimatorController = BasisPlayerFactory.TposeController;
275273
float desiredTime = Time.deltaTime;
276274
Anim.Update(desiredTime);
277275
}

Basis/Packages/com.basis.framework/Players/Common/BasisPlayerFactory.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public static class BasisPlayerFactory
4747
/// </summary>
4848
public static UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<GameObject> RemoteHandle;
4949

50+
/// <summary>
51+
/// Tpose Handle
52+
/// </summary>
53+
public static UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<RuntimeAnimatorController> TposeHandle;
54+
55+
public static RuntimeAnimatorController TposeController;
56+
57+
/// <summary>Addressable path to the T-Pose animator controller asset.</summary>
58+
public const string TPose = "Assets/Animator/Animated TPose.controller";
5059
/// <summary>
5160
/// Loads the local and remote player prefabs from Addressables and caches them for instantiation.
5261
/// </summary>
@@ -61,6 +70,9 @@ public static void Initalize()
6170

6271
RemoteHandle = Addressables.LoadAssetAsync<GameObject>(RemotePlayerId);
6372
RemotePlayerReadyToSpawn = RemoteHandle.WaitForCompletion();
73+
74+
TposeHandle = Addressables.LoadAssetAsync<RuntimeAnimatorController>(TPose);
75+
TposeController = TposeHandle.WaitForCompletion();
6476
}
6577

6678
/// <summary>
@@ -74,6 +86,7 @@ public static void DeInitalize()
7486
{
7587
Addressables.Release(LocalHandle);
7688
Addressables.Release(RemoteHandle);
89+
Addressables.Release(TposeController);
7790
}
7891

7992
/// <summary>

0 commit comments

Comments
 (0)