From 9f7a96187f9846cc6e3211ef23c713b67c7e022d Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 22 Feb 2022 12:38:40 +0100 Subject: [PATCH] Make Possessable sitelocation static --- .../Scripts/Networking/HumanoidNetworking.cs | 2 -- Runtime/Sites/Scripts/Possessable.cs | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs b/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs index ae01075..5d639a9 100644 --- a/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs +++ b/Runtime/HumanoidFree/Scripts/Networking/HumanoidNetworking.cs @@ -154,8 +154,6 @@ namespace Passer.Humanoid { else name = humanoid.gameObject.name; - // Bug: - // The siteLocation should not be calculated dynamically every time because we could have moved to a new site! if (humanoid.remoteAvatar == null) { Possessable avatarPossessable = humanoid.avatarRig.GetComponent(); if (avatarPossessable != null) diff --git a/Runtime/Sites/Scripts/Possessable.cs b/Runtime/Sites/Scripts/Possessable.cs index 5579bb3..93b61fa 100644 --- a/Runtime/Sites/Scripts/Possessable.cs +++ b/Runtime/Sites/Scripts/Possessable.cs @@ -42,14 +42,18 @@ namespace Passer { /// public bool isUnique = false; + private string _siteLocation; public string siteLocation { get { - if (SiteNavigator.currentSite == null) - return ""; + if (_siteLocation == null) { - string siteLocation = SiteNavigator.currentSite.siteLocation; - //siteLocation = siteLocation.Substring(0, siteLocation.LastIndexOf("/")); - return (siteLocation + "_possessions"); + if (SiteNavigator.currentSite == null) + _siteLocation = ""; + + string siteLocation = SiteNavigator.currentSite.siteLocation; + _siteLocation = (siteLocation + "_possessions"); + } + return _siteLocation; } }