From 075a5d7ba1d4810dbd5e6fef176933dd52c51313 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 22 Feb 2022 13:32:04 +0100 Subject: [PATCH] Fix loading wrong Possession --- .../Scripts/Networking/HumanoidNetworking.cs | 20 +++++++++++-------- Runtime/Sites/Scripts/Possessable.cs | 4 ++-- .../Visitors/Scripts/VisitorPossessions.cs | 8 +++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs b/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs index 5d639a9..6d72eb2 100644 --- a/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs +++ b/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs @@ -156,17 +156,21 @@ namespace Passer.Humanoid { if (humanoid.remoteAvatar == null) { Possessable avatarPossessable = humanoid.avatarRig.GetComponent(); - if (avatarPossessable != null) + if (avatarPossessable != null) { possessionLocation = avatarPossessable.siteLocation; - - avatarPrefabName = humanoid.avatarRig.name; // .Substring(0, humanoid.avatarRig.name.Length - 7); + avatarPrefabName = avatarPossessable.assetPath; + } + else + avatarPrefabName = humanoid.avatarRig.name; // .Substring(0, humanoid.avatarRig.name.Length - 7); } else { Possessable avatarPossessable = humanoid.remoteAvatar.GetComponent(); - if (avatarPossessable != null) + if (avatarPossessable != null) { possessionLocation = avatarPossessable.siteLocation; - - avatarPrefabName = humanoid.remoteAvatar.name; + avatarPrefabName = avatarPossessable.assetPath; + } + else + avatarPrefabName = humanoid.remoteAvatar.name; } #if RemoteAvatarBundles @@ -291,7 +295,7 @@ namespace Passer.Humanoid { ); return; - } + } GameObject remoteAvatar = (GameObject)Resources.Load(msg.avatarPrefabName); if (remoteAvatar == null) { @@ -1545,7 +1549,7 @@ namespace Passer.Humanoid { if (msg.possessionLocation != null) { Debug.Log("Need to download avatar possession from " + msg.possessionLocation); HumanoidPlayer.instance.StartCoroutine( - VisitorPossessions.RetrievePossessableAsync(msg.possessionLocation, msg.avatarPrefabName, + VisitorPossessions.RetrievePossessableAsync(msg.possessionLocation, msg.avatarPrefabName, retrievedAvatar => ProcessRetrievedAvatar(networking, remoteHumanoid, retrievedAvatar)) ); return; diff --git a/Runtime/Sites/Scripts/Possessable.cs b/Runtime/Sites/Scripts/Possessable.cs index 13d74b1..89a0fad 100644 --- a/Runtime/Sites/Scripts/Possessable.cs +++ b/Runtime/Sites/Scripts/Possessable.cs @@ -49,7 +49,7 @@ namespace Passer { get { if (_siteLocation == null) DetermineSiteLocation(); - + return _siteLocation; } } @@ -67,7 +67,7 @@ namespace Passer { } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { - if (_siteLocation == null) + if (string.IsNullOrEmpty(_siteLocation)) DetermineSiteLocation(); } diff --git a/Runtime/Visitors/Scripts/VisitorPossessions.cs b/Runtime/Visitors/Scripts/VisitorPossessions.cs index d6f2815..ced7e15 100644 --- a/Runtime/Visitors/Scripts/VisitorPossessions.cs +++ b/Runtime/Visitors/Scripts/VisitorPossessions.cs @@ -314,12 +314,14 @@ namespace Passer { string possessableName = possessablePath; int lastSlashIx = possessablePath.LastIndexOf('/'); if (lastSlashIx >= 0) - possessableName = possessablePath.Substring( + 1); + possessableName = possessablePath.Substring(+1); - Debug.Log("Load: " + possessablePath); + possessableName = possessableName.ToLower(); + + Debug.Log("Load: " + possessableName); prefab = assetBundle.LoadAsset(possessableName); if (prefab == null) { - Debug.LogError("Could not load " + possessablePath); + Debug.LogError("Could not load " + possessableName); yield break; }