diff --git a/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/AvatarShape/AvatarShape.cs b/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/AvatarShape/AvatarShape.cs index 1897c0dbb0..583b86a2ca 100644 --- a/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/AvatarShape/AvatarShape.cs +++ b/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/AvatarShape/AvatarShape.cs @@ -89,6 +89,13 @@ public class AvatarShape : MonoBehaviour, IHideAvatarAreaHandler, IPoolableObjec private Service emotesCatalog; private IAvatarEmotesController emotesController; private AvatarSceneEmoteHandler sceneEmoteHandler; + private IBaseAvatarReferences baseAvatarReferences; + private readonly OnPointerEvent.Model viewProfilePointerModel = new () + { + type = OnPointerDown.NAME, + button = WebInterface.ACTION_BUTTON.POINTER.ToString(), + hoverText = "View Profile", + }; public IAvatar internalAvatar => avatar; private void Awake() @@ -108,7 +115,7 @@ private void Awake() //Ensure base avatar references - var baseAvatarReferences = baseAvatarContainer.GetComponentInChildren() ?? Instantiate(baseAvatarReferencesPrefab, baseAvatarContainer); + baseAvatarReferences = baseAvatarContainer.GetComponentInChildren() ?? Instantiate(baseAvatarReferencesPrefab, baseAvatarContainer); avatar = avatarFactory.Ref.CreateAvatarWithHologram(avatarContainer, new BaseAvatar(baseAvatarReferences), animator, avatarLOD, visibility); @@ -116,8 +123,7 @@ private void Awake() sceneEmoteHandler = new AvatarSceneEmoteHandler( emotesController, - Environment.i.serviceLocator.Get(), - new UserProfileWebInterfaceBridge()); + Environment.i.serviceLocator.Get()); avatarReporterController ??= new AvatarReporterController(Environment.i.world.state); @@ -222,16 +228,11 @@ public async void ApplyModel(IParcelScene scene, IDCLEntity entity, PBAvatarShap UpdatePlayerStatus(entity, model); onPointerDown.Initialize( - new OnPointerEvent.Model() - { - type = OnPointerDown.NAME, - button = WebInterface.ACTION_BUTTON.POINTER.ToString(), - hoverText = "View Profile" - }, + viewProfilePointerModel, entity, player ); - outlineOnHover.Initialize(new OnPointerEvent.Model(), entity, player.avatar); + outlineOnHover.Initialize(entity, player.avatar); avatarCollider.gameObject.SetActive(true); @@ -342,7 +343,7 @@ internal void UpdatePlayerStatus(IDCLEntity entity, PBAvatarShape model) float height = AvatarSystemUtils.AVATAR_Y_OFFSET + avatar.extents.y; - anchorPoints.Prepare(avatarContainer.transform, avatar.GetBones(), height); + anchorPoints.Prepare(avatarContainer.transform, baseAvatarReferences.Anchors, height); player.playerName.SetIsTalking(model.Talking); player.playerName.SetYOffset(Mathf.Max(MINIMUM_PLAYERNAME_HEIGHT, height)); diff --git a/unity-renderer/Assets/Rendering/LoadingAvatar/CrossSection/LoadingAvatar.prefab b/unity-renderer/Assets/Rendering/LoadingAvatar/CrossSection/LoadingAvatar.prefab index 0fdcb5073a..f72a1891a9 100644 --- a/unity-renderer/Assets/Rendering/LoadingAvatar/CrossSection/LoadingAvatar.prefab +++ b/unity-renderer/Assets/Rendering/LoadingAvatar/CrossSection/LoadingAvatar.prefab @@ -23,6 +23,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9157638741447638595} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -31,7 +32,6 @@ Transform: - {fileID: 9157638743213904766} - {fileID: 9157638742714293301} m_Father: {fileID: 9157638742130759987} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 179.994, z: 0} --- !u!1 &9157638741986789727 GameObject: @@ -58,13 +58,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9157638741986789727} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 9157638742714293301} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} --- !u!198 &9157638741986789722 ParticleSystem: @@ -284,6 +284,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -313,6 +314,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 startSize: @@ -634,6 +636,7 @@ ParticleSystem: m_PostInfinity: 2 m_RotationOrder: 4 randomizeRotationDirection: 0 + gravitySource: 0 maxNumParticles: 1000 customEmitterVelocity: {x: 0, y: 0, z: 0} size3D: 0 @@ -1381,6 +1384,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 minGradient: @@ -1410,6 +1414,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 UVModule: @@ -3630,6 +3635,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -3659,6 +3665,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 range: {x: 0, y: 1} @@ -4036,6 +4043,7 @@ ParticleSystem: m_RotationOrder: 4 minVertexDistance: 0.2 textureMode: 0 + textureScale: {x: 1, y: 1} ribbonCount: 1 shadowBias: 0.5 worldSpace: 0 @@ -4078,6 +4086,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -4107,6 +4116,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 widthOverTrail: @@ -4194,6 +4204,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -4223,6 +4234,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 CustomDataModule: @@ -4261,6 +4273,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -4290,6 +4303,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel0: Color @@ -4543,6 +4557,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -4572,6 +4587,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel1: Color @@ -4887,6 +4903,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9157638742130759986} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -4895,7 +4912,6 @@ Transform: - {fileID: 9157638741447638592} - {fileID: 7068074174682034621} m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &4766333532709993497 MonoBehaviour: @@ -4912,6 +4928,11 @@ MonoBehaviour: skinnedMeshRenderer: {fileID: 8082704895018960386} armatureContainer: {fileID: 7068074174682034621} particlesContainer: {fileID: 9157638741447638595} + anchors: + - AnchorName: Avatar_LeftHand + Bone: {fileID: 1012629841675324211} + - AnchorName: Avatar_RightHand + Bone: {fileID: 8806991813208880745} ghostMinColor: {r: 0.24313726, g: 0.7372549, b: 1.4980392, a: 0.24705882} ghostMaxColor: {r: 0.24313726, g: 1.4980392, b: 0.7607843, a: 0} fadeGhostSpeed: 2.5 @@ -4941,13 +4962,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9157638742248015941} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 9157638742714293301} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} --- !u!198 &9157638742248015936 ParticleSystem: @@ -5167,6 +5188,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -5196,6 +5218,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 startSize: @@ -5517,6 +5540,7 @@ ParticleSystem: m_PostInfinity: 2 m_RotationOrder: 4 randomizeRotationDirection: 0 + gravitySource: 0 maxNumParticles: 1000 customEmitterVelocity: {x: 0, y: 0, z: 0} size3D: 0 @@ -6255,6 +6279,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 minGradient: @@ -6284,6 +6309,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 UVModule: @@ -8504,6 +8530,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -8533,6 +8560,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 range: {x: 0, y: 1} @@ -8910,6 +8938,7 @@ ParticleSystem: m_RotationOrder: 4 minVertexDistance: 0.2 textureMode: 0 + textureScale: {x: 1, y: 1} ribbonCount: 1 shadowBias: 0.5 worldSpace: 0 @@ -8952,6 +8981,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -8981,6 +9011,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 widthOverTrail: @@ -9068,6 +9099,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -9097,6 +9129,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 CustomDataModule: @@ -9135,6 +9168,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -9164,6 +9198,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel0: Color @@ -9417,6 +9452,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -9446,6 +9482,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel1: Color @@ -9762,6 +9799,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9157638742714293300} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -9770,7 +9808,6 @@ Transform: - {fileID: 9157638741986789724} - {fileID: 9157638742248015938} m_Father: {fileID: 9157638741447638592} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} --- !u!198 &9157638742714293299 ParticleSystem: @@ -9990,6 +10027,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -10019,6 +10057,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 startSize: @@ -10340,6 +10379,7 @@ ParticleSystem: m_PostInfinity: 2 m_RotationOrder: 4 randomizeRotationDirection: 0 + gravitySource: 0 maxNumParticles: 1000 customEmitterVelocity: {x: 0, y: 0, z: 0} size3D: 0 @@ -11078,6 +11118,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 minGradient: @@ -11107,6 +11148,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 UVModule: @@ -13327,6 +13369,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -13356,6 +13399,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 range: {x: 0, y: 1} @@ -13733,6 +13777,7 @@ ParticleSystem: m_RotationOrder: 4 minVertexDistance: 0.2 textureMode: 0 + textureScale: {x: 1, y: 1} ribbonCount: 1 shadowBias: 0.5 worldSpace: 0 @@ -13775,6 +13820,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -13804,6 +13850,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 widthOverTrail: @@ -13891,6 +13938,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -13920,6 +13968,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 CustomDataModule: @@ -13958,6 +14007,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -13987,6 +14037,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel0: Color @@ -14240,6 +14291,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -14269,6 +14321,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel1: Color @@ -14585,13 +14638,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 9157638743213904753} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 9157638741447638592} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} --- !u!198 &9157638743213904764 ParticleSystem: @@ -14811,6 +14864,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -14840,6 +14894,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 startSize: @@ -15161,6 +15216,7 @@ ParticleSystem: m_PostInfinity: 2 m_RotationOrder: 4 randomizeRotationDirection: 0 + gravitySource: 0 maxNumParticles: 1000 customEmitterVelocity: {x: 0, y: 0, z: 0} size3D: 0 @@ -15899,6 +15955,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 minGradient: @@ -15928,6 +15985,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 4 UVModule: @@ -18148,6 +18206,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -18177,6 +18236,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 range: {x: 0, y: 1} @@ -18554,6 +18614,7 @@ ParticleSystem: m_RotationOrder: 4 minVertexDistance: 0.2 textureMode: 0 + textureScale: {x: 1, y: 1} ribbonCount: 1 shadowBias: 0.5 worldSpace: 0 @@ -18596,6 +18657,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -18625,6 +18687,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 widthOverTrail: @@ -18712,6 +18775,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -18741,6 +18805,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 CustomDataModule: @@ -18779,6 +18844,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -18808,6 +18874,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel0: Color @@ -19061,6 +19128,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 minGradient: @@ -19090,6 +19158,7 @@ ParticleSystem: atime6: 0 atime7: 0 m_Mode: 0 + m_ColorSpace: -1 m_NumColorKeys: 2 m_NumAlphaKeys: 2 colorLabel1: Color @@ -19386,6 +19455,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 9157638742130759987} m_Modifications: - target: {fileID: 1785260624521939365, guid: ffee176dc073145748f97a170835fe04, @@ -19449,7 +19519,16 @@ PrefabInstance: value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: ffee176dc073145748f97a170835fe04, type: 3} +--- !u!4 &1012629841675324211 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 5319823815903354524, guid: ffee176dc073145748f97a170835fe04, + type: 3} + m_PrefabInstance: {fileID: 5178676586828895663} + m_PrefabAsset: {fileID: 0} --- !u!4 &7068074174682034621 stripped Transform: m_CorrespondingSourceObject: {fileID: 2722569914141991954, guid: ffee176dc073145748f97a170835fe04, @@ -19462,3 +19541,9 @@ SkinnedMeshRenderer: type: 3} m_PrefabInstance: {fileID: 5178676586828895663} m_PrefabAsset: {fileID: 0} +--- !u!4 &8806991813208880745 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 4460501582525965254, guid: ffee176dc073145748f97a170835fe04, + type: 3} + m_PrefabInstance: {fileID: 5178676586828895663} + m_PrefabAsset: {fileID: 0} diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/BaseAvatarReferences.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/BaseAvatarReferences.cs index 474e366ab2..55702586a5 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/BaseAvatarReferences.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/BaseAvatarReferences.cs @@ -3,6 +3,13 @@ namespace AvatarSystem { + [Serializable] + public struct AvatarAnchorPoint + { + public string AnchorName; + public Transform Bone; + } + [Serializable] public class BaseAvatarReferences : MonoBehaviour, IBaseAvatarReferences { @@ -10,6 +17,7 @@ public class BaseAvatarReferences : MonoBehaviour, IBaseAvatarReferences public SkinnedMeshRenderer skinnedMeshRenderer; public Transform armatureContainer; public GameObject particlesContainer; + public AvatarAnchorPoint[] anchors; [Header("Ghost Settings")] [ColorUsage(true, true)] public Color ghostMinColor; @@ -18,6 +26,10 @@ public class BaseAvatarReferences : MonoBehaviour, IBaseAvatarReferences public float revealSpeed = 2f; public SkinnedMeshRenderer SkinnedMeshRenderer => skinnedMeshRenderer; + + private (string AnchorName, Transform Bone)[] anchorsCache; + public (string AnchorName, Transform Bone)[] Anchors => anchorsCache ??= CacheAnchors(); + public Transform ArmatureContainer => armatureContainer; public GameObject ParticlesContainer => particlesContainer; public Color GhostMinColor => ghostMinColor; @@ -25,6 +37,19 @@ public class BaseAvatarReferences : MonoBehaviour, IBaseAvatarReferences public float FadeGhostSpeed => fadeGhostSpeed; public float RevealSpeed => revealSpeed; + private (string AnchorName, Transform Bone)[] CacheAnchors() + { + var cachedAnchors = new (string, Transform)[anchors.Length]; + + for (var i = 0; i < anchors.Length; i++) + { + AvatarAnchorPoint anchorPoint = anchors[i]; + cachedAnchors[i] = (anchorPoint.AnchorName, anchorPoint.Bone); + } + + return cachedAnchors; + } + public void Dispose() { Destroy(gameObject); diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/IBaseAvatarReferences.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/IBaseAvatarReferences.cs index 6665c3d7aa..d5f14cbf67 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/IBaseAvatarReferences.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/AvatarSystem/IBaseAvatarReferences.cs @@ -6,6 +6,7 @@ namespace AvatarSystem public interface IBaseAvatarReferences : IDisposable { SkinnedMeshRenderer SkinnedMeshRenderer { get; } + (string AnchorName, Transform Bone)[] Anchors { get; } Transform ArmatureContainer { get; } GameObject ParticlesContainer { get; } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Implementation/AvatarAnchorPoints.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Implementation/AvatarAnchorPoints.cs index 0183ec20a4..f90b868dfe 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Implementation/AvatarAnchorPoints.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Implementation/AvatarAnchorPoints.cs @@ -1,39 +1,33 @@ using System.Collections.Generic; -using System.Linq; using UnityEngine; public class AvatarAnchorPoints : IAvatarAnchorPoints { - private static readonly Dictionary boneMapping = new Dictionary() + private static readonly Dictionary boneMapping = new () { { AvatarAnchorPointIds.LeftHand, "Avatar_LeftHand" }, { AvatarAnchorPointIds.RightHand, "Avatar_RightHand" }, }; - private readonly Dictionary boneTransformMapping = new Dictionary(); + private readonly Dictionary boneTransformMapping = new (); private Transform avatarTransform; private float nameTagY; - void IAvatarAnchorPoints.Prepare(Transform avatarTransform, Transform[] bones, float nameTagY) + void IAvatarAnchorPoints.Prepare(Transform avatarTransform, (string AnchorName, Transform Bone)[] anchors, float nameTagY) { this.avatarTransform = avatarTransform; this.nameTagY = nameTagY; - boneTransformMapping.Clear(); - - if(bones == null) + if (anchors == null) return; - foreach (var bone in bones) - { - if (TryGetIdFromBoneName(bone.name, out AvatarAnchorPointIds anchorPointId)) - { - boneTransformMapping.Add(anchorPointId, bone); - } - } + foreach ((string AnchorName, Transform Bone) anchor in anchors) + foreach (KeyValuePair boneMap in boneMapping) + if (anchor.AnchorName == boneMap.Value) + boneTransformMapping[boneMap.Key] = anchor.Bone; } - + (Vector3 position, Quaternion rotation, Vector3 scale) IAvatarAnchorPoints.GetTransform(AvatarAnchorPointIds anchorPointId) { if (anchorPointId == AvatarAnchorPointIds.Position && avatarTransform != null) @@ -55,11 +49,4 @@ void IAvatarAnchorPoints.Prepare(Transform avatarTransform, Transform[] bones, f } return (Vector3.zero, Quaternion.identity, Vector3.one); } - - private static bool TryGetIdFromBoneName(string boneName, out AvatarAnchorPointIds id) - { - var result = boneMapping.FirstOrDefault(pair => pair.Value == boneName); - id = result.Key; - return !string.IsNullOrEmpty(result.Value); - } -} \ No newline at end of file +} diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Interfaces/IAvatarAnchorPoints.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Interfaces/IAvatarAnchorPoints.cs index 8beef20c00..f462db0b50 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Interfaces/IAvatarAnchorPoints.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnchorPoints/Interfaces/IAvatarAnchorPoints.cs @@ -2,6 +2,6 @@ public interface IAvatarAnchorPoints { - void Prepare(Transform avatarTransform, Transform[] bones, float nameTagY); + void Prepare(Transform avatarTransform, (string AnchorName, Transform Bone)[] anchors, float nameTagY); (Vector3 position, Quaternion rotation, Vector3 scale) GetTransform(AvatarAnchorPointIds anchorPointId); -} \ No newline at end of file +} diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnimatorLegacy.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnimatorLegacy.cs index 00e8b4326f..7aa68f5f9d 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnimatorLegacy.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnimatorLegacy.cs @@ -354,8 +354,7 @@ private void State_Expression(BlackBoard bb) { int emoteLoop = GetCurrentEmoteLoopCount(); - // Disabled temporally - //if (emoteLoop != lastEmoteLoopCount) { UserProfile.GetOwnUserProfile().SetAvatarExpression(bb.expressionTriggerId, UserProfile.EmoteSource.EmoteLoop, true); } + if (emoteLoop != lastEmoteLoopCount) { UserProfile.GetOwnUserProfile().SetAvatarExpression(bb.expressionTriggerId, UserProfile.EmoteSource.EmoteLoop, true); } lastEmoteLoopCount = emoteLoop; } @@ -401,13 +400,12 @@ private void StopEmoteInternal(bool immediate) if (!string.IsNullOrEmpty(blackboard.expressionTriggerId)) animation.Blend(blackboard.expressionTriggerId, 0, !immediate ? EXPRESSION_EXIT_TRANSITION_TIME : 0); - // Disabled Temporally // Instantly replicate our emote status and position - /*if (isOwnPlayer && !string.IsNullOrEmpty(blackboard.expressionTriggerId)) + if (isOwnPlayer && !string.IsNullOrEmpty(blackboard.expressionTriggerId)) { DCLCharacterController.i.ReportMovement(); UserProfile.GetOwnUserProfile().SetAvatarExpression("", UserProfile.EmoteSource.EmoteCancel, true); - }*/ + } blackboard.expressionTriggerId = null; blackboard.shouldLoop = false; @@ -465,7 +463,7 @@ public void PlayEmote(string emoteId, long timestamps, bool spatial, bool occlud // Triggering an emote manually updates the timestamp, the looping emote by itself sends a timestamp of -1 // so if we are already using an emote that looped and we receive the play emote command with that timestamp, we ignore - if ( /*isTheSameLoopingEmote && */timestamps < 0) + if (isTheSameLoopingEmote && timestamps < 0) return; blackboard.expressionTriggerId = emoteId; diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarOnPointerDown/AvatarOutlineOnHoverEvent.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarOnPointerDown/AvatarOutlineOnHoverEvent.cs index 4735b78c2e..feb6e4a309 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarOnPointerDown/AvatarOutlineOnHoverEvent.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarOnPointerDown/AvatarOutlineOnHoverEvent.cs @@ -22,17 +22,22 @@ public class AvatarOutlineOnHoverEvent : MonoBehaviour, IUnlockedCursorInputEven public event Action OnPointerEnterReport; public event Action OnPointerExitReport; - public void Initialize(OnPointerEvent.Model model, IDCLEntity entity, IAvatar avatar) + private bool isInitialized; + + public void Initialize(IDCLEntity entity, IAvatar avatar) { + if (isInitialized) return; this.entity = entity; this.avatar = avatar; - this.model = model; + model = new OnPointerEvent.Model(); CommonScriptableObjects.allUIHidden.OnChange += AllUIHiddenChanged; + isInitialized = true; } private void OnDestroy() { + isInitialized = false; CommonScriptableObjects.allUIHidden.OnChange -= AllUIHiddenChanged; } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarSceneEmoteHandler.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarSceneEmoteHandler.cs index 3cb19497c2..1e61b8ebc1 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarSceneEmoteHandler.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarSceneEmoteHandler.cs @@ -14,18 +14,16 @@ public class AvatarSceneEmoteHandler { private readonly IAvatarEmotesController emotesController; private readonly IEmotesService emotesService; - private readonly IUserProfileBridge userProfileBridge; - private readonly HashSet equippedEmotes; + private readonly HashSet equippedEmotes; private long lamportTimestamp; - internal CancellationTokenSource cts; + private CancellationTokenSource cts; - public AvatarSceneEmoteHandler(IAvatarEmotesController emotesController, IEmotesService emotesService, IUserProfileBridge userProfileBridge) + public AvatarSceneEmoteHandler(IAvatarEmotesController emotesController, IEmotesService emotesService) { this.emotesController = emotesController; this.emotesService = emotesService; - this.userProfileBridge = userProfileBridge; - this.equippedEmotes = new HashSet(); + equippedEmotes = new HashSet(); } public bool IsSceneEmote(string emoteId) => @@ -43,32 +41,40 @@ public async UniTask LoadAndPlayEmote(string bodyShapeId, string emoteId) var emoteKey = new EmoteBodyId(bodyShapeId, emoteId); + if (equippedEmotes.Contains(emoteId)) + { + TriggerEmote(emoteId, timestamp); + return; + } + try { var loadedEmote = await emotesService.RequestEmote(emoteKey, cts.Token); emotesController.EquipEmote(emoteId, loadedEmote); - equippedEmotes.Add(emoteKey); + equippedEmotes.Add(emoteId); - //avoid playing emote if timestamp has change, - //meaning a new emote was trigger while this one was loading - if (timestamp == lamportTimestamp) - { - emotesController.PlayEmote(emoteId, lamportTimestamp); - userProfileBridge.GetOwn().SetAvatarExpression(emoteId, UserProfile.EmoteSource.EmoteLoop, true); - } + TriggerEmote(emoteId, timestamp); } catch (OperationCanceledException) { } catch (Exception e) { Debug.LogException(e); } } + private void TriggerEmote(string emoteId, long timestamp) + { + //avoid playing emote if timestamp has change, + //meaning a new emote was trigger while this one was loading + if (timestamp == lamportTimestamp) + emotesController.PlayEmote(emoteId, lamportTimestamp); + } + public void CleanUp() { cts?.SafeCancelAndDispose(); cts = null; - foreach (var emoteData in equippedEmotes) - emotesController?.UnEquipEmote(emoteData.EmoteId); + foreach (string emoteId in equippedEmotes) + emotesController?.UnEquipEmote(emoteId); equippedEmotes.Clear(); } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs index 8a3362a82d..d495d091cd 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.cs @@ -36,6 +36,7 @@ public class AvatarShape : BaseComponent, IHideAvatarAreaHandler, IHidePassportA [SerializeField] internal GameObject playerNameContainer; [SerializeField] private Transform baseAvatarContainer; [SerializeField] internal BaseAvatarReferences baseAvatarReferencesPrefab; + internal IPlayerName playerName; internal IAvatarReporterController avatarReporterController; @@ -60,6 +61,13 @@ public class AvatarShape : BaseComponent, IHideAvatarAreaHandler, IHidePassportA public override string componentName => "avatarShape"; private AvatarSceneEmoteHandler sceneEmoteHandler; private IAvatarEmotesController emotesController; + private IBaseAvatarReferences baseAvatarReferences; + private readonly OnPointerEvent.Model pointerEventModel = new () + { + type = OnPointerDown.NAME, + button = WebInterface.ACTION_BUTTON.POINTER.ToString(), + hoverText = "View Profile", + }; private void Awake() { @@ -78,13 +86,9 @@ private void Awake() sceneEmoteHandler = new AvatarSceneEmoteHandler( emotesController, - Environment.i.serviceLocator.Get(), - new UserProfileWebInterfaceBridge()); + Environment.i.serviceLocator.Get()); - if (avatarReporterController == null) - { - avatarReporterController = new AvatarReporterController(Environment.i.world.state); - } + if (avatarReporterController == null) { avatarReporterController = new AvatarReporterController(Environment.i.world.state); } } public override void Initialize(IParcelScene scene, IDCLEntity entity) @@ -111,7 +115,7 @@ private IAvatar GetAvatarWithHologram() Visibility visibility = new Visibility(); // Due to how we set our pools (and how the objets are cloned in), we might find that the original item already had the baseAvatar when returned to the pool. - var baseAvatarReferences = baseAvatarContainer.GetComponentInChildren() ?? Instantiate(baseAvatarReferencesPrefab, baseAvatarContainer); + baseAvatarReferences = baseAvatarContainer.GetComponentInChildren() ?? Instantiate(baseAvatarReferencesPrefab, baseAvatarContainer); return Environment.i.serviceLocator.Get() .CreateAvatarWithHologram( @@ -261,16 +265,11 @@ public override IEnumerator ApplyChanges(BaseModel newModel) UpdatePlayerStatus(model); onPointerDown.Initialize( - new OnPointerEvent.Model() - { - type = OnPointerDown.NAME, - button = WebInterface.ACTION_BUTTON.POINTER.ToString(), - hoverText = "View Profile" - }, + pointerEventModel, entity, player ); - outlineOnHover.Initialize(new OnPointerEvent.Model(), entity, player?.avatar); + outlineOnHover.Initialize(entity, player?.avatar); avatarCollider.gameObject.SetActive(true); @@ -318,10 +317,7 @@ private void UpdatePlayerStatus(AvatarModel model) bool isNew = player == null; - if (isNew) - { - player = new Player(); - } + if (isNew) { player = new Player(); } bool isNameDirty = player.name != model.name; @@ -356,7 +352,7 @@ private void UpdatePlayerStatus(AvatarModel model) float height = AvatarSystemUtils.AVATAR_Y_OFFSET + avatar.extents.y; - anchorPoints.Prepare(avatarContainer.transform, avatar.GetBones(), height); + anchorPoints.Prepare(avatarContainer.transform, baseAvatarReferences.Anchors, height); player.playerName.SetIsTalking(model.talking); player.playerName.SetYOffset(Mathf.Max(MINIMUM_PLAYERNAME_HEIGHT, height)); @@ -386,10 +382,7 @@ private void OnEntityTransformChanged(object newModel) private void OnEntityTransformChanged(in Vector3 position, in Quaternion rotation, bool inmediate) { - if (isGlobalSceneAvatar) - { - avatarMovementController.OnTransformChanged(position, rotation, inmediate); - } + if (isGlobalSceneAvatar) { avatarMovementController.OnTransformChanged(position, rotation, inmediate); } else { var scenePosition = Utils.GridToWorldPosition(entity.scene.sceneData.basePosition.x, entity.scene.sceneData.basePosition.y); @@ -437,10 +430,7 @@ public void RemoveHideAvatarModifier() public void ApplyHidePassportModifier() { - if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.DISABLE_PASSPORT)) - { - DisablePassport(); - } + if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.DISABLE_PASSPORT)) { DisablePassport(); } currentActiveModifiers.AddRefCount(AvatarModifierAreaID.DISABLE_PASSPORT); } @@ -449,10 +439,7 @@ public void RemoveHidePassportModifier() { currentActiveModifiers.RemoveRefCount(AvatarModifierAreaID.DISABLE_PASSPORT); - if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.DISABLE_PASSPORT)) - { - EnablePasssport(); - } + if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.DISABLE_PASSPORT)) { EnablePasssport(); } } private void EnablePasssport() @@ -492,10 +479,7 @@ public override void Cleanup() currentLazyObserver?.RemoveListener(avatar.SetImpostorTexture); avatar.Dispose(); - if (poolableObject != null) - { - poolableObject.OnRelease -= Cleanup; - } + if (poolableObject != null) { poolableObject.OnRelease -= Cleanup; } onPointerDown.OnPointerDownReport -= PlayerClicked; onPointerDown.OnPointerEnterReport -= PlayerPointerEnter; diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.prefab b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.prefab index f3fd6050eb..2217a5e527 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.prefab +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.prefab @@ -91,6 +91,7 @@ MonoBehaviour: baseAvatarContainer: {fileID: 4288110136316019743} baseAvatarReferencesPrefab: {fileID: 4766333532709993497, guid: 7bf2abf753051c34c9e0a568a90fc0f0, type: 3} + boneAnchors: [] everythingIsLoaded: 0 --- !u!114 &122622683908687435 MonoBehaviour: diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Tests/AvatarSceneEmoteHandlerShould.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Tests/AvatarSceneEmoteHandlerShould.cs index b1dfef081d..88cc955b4b 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Tests/AvatarSceneEmoteHandlerShould.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Tests/AvatarSceneEmoteHandlerShould.cs @@ -24,7 +24,7 @@ public void SetUp() emotesService = Substitute.For(); emotesController = Substitute.For(); userProfileBridge = Substitute.For(); - handler = new AvatarSceneEmoteHandler(emotesController, emotesService, userProfileBridge); + handler = new AvatarSceneEmoteHandler(emotesController, emotesService); } [Test] diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs index e1b4e2c777..9fe8f55e57 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/PlayerAvatarController/PlayerAvatarController.cs @@ -45,6 +45,13 @@ public class PlayerAvatarController : MonoBehaviour, IHideAvatarAreaHandler, IHi private ISocialAnalytics socialAnalytics; private BaseVariable<(string playerId, string source)> currentPlayerInfoCardId; private IAvatar avatar; + private IBaseAvatarReferences baseAvatarReferences; + private readonly OnPointerEvent.Model pointerEventModel = new () + { + type = OnPointerDown.NAME, + button = WebInterface.ACTION_BUTTON.POINTER.ToString(), + hoverText = "View My Profile", + }; public IAvatar Avatar => avatar; @@ -94,7 +101,7 @@ private IAvatar GetStandardAvatar() private IAvatar GetAvatarWithHologram() { - var baseAvatarReferences = baseAvatarContainer.GetComponentInChildren() ?? Instantiate(baseAvatarReferencesPrefab, baseAvatarContainer); + baseAvatarReferences = baseAvatarContainer.GetComponentInChildren() ?? Instantiate(baseAvatarReferencesPrefab, baseAvatarContainer); return Environment.i.serviceLocator.Get().CreateAvatarWithHologram( avatarContainer, @@ -242,7 +249,7 @@ private async UniTaskVoid LoadingAvatarRoutine(UserProfile profile, Cancellation finally { IAvatarAnchorPoints anchorPoints = new AvatarAnchorPoints(); - anchorPoints.Prepare(avatarContainer.transform, avatar.GetBones(), AvatarSystemUtils.AVATAR_Y_OFFSET + avatar.extents.y); + anchorPoints.Prepare(avatarContainer.transform, baseAvatarReferences.Anchors, AvatarSystemUtils.AVATAR_Y_OFFSET + avatar.extents.y); var player = new Player { @@ -261,19 +268,14 @@ private async UniTaskVoid LoadingAvatarRoutine(UserProfile profile, Cancellation DataStore.i.common.isPlayerRendererLoaded.Set(true); onPointerDown.Initialize( - new OnPointerEvent.Model - { - type = OnPointerDown.NAME, - button = WebInterface.ACTION_BUTTON.POINTER.ToString(), - hoverText = "View My Profile", - }, + pointerEventModel, null, player ); onPointerDown.ShouldBeInteractableWhenMouseIsLocked = false; - outlineOnHover.Initialize(new OnPointerEvent.Model(), null, avatar); + outlineOnHover.Initialize(null, avatar); outlineOnHover.ShouldBeHoveredWhenMouseIsLocked = false; bool isClickingOwnAvatarEnabled = DataStore.i.featureFlags.flags.Get().IsFeatureEnabled("click_own_avatar_passport"); diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs index 4b82a4a7a4..3259ecbaff 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarModel/AvatarModel.cs @@ -1,10 +1,10 @@ -using System; using DCL.Helpers; +using Decentraland.Sdk.Ecs6; +using MainScripts.DCL.Components; +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; -using Decentraland.Sdk.Ecs6; -using MainScripts.DCL.Components; [Serializable] public class AvatarModel : BaseModel @@ -79,6 +79,26 @@ public override BaseModel GetDataFromPb(ComponentBodyPayload pbModel) return model; } + private bool IsListContainedIn(List first, List second) + { + foreach (string item in first) + + // This contains is slow + if (!second.Contains(item)) + return false; + + return true; + } + + private bool IsHashSetContainedIn(HashSet first, HashSet second) + { + foreach (string item in first) + if (!second.Contains(item)) + return false; + + return true; + } + public bool HaveSameWearablesAndColors(AvatarModel other) { if (other == null) @@ -86,13 +106,13 @@ public bool HaveSameWearablesAndColors(AvatarModel other) //wearables are the same if (!(wearables.Count == other.wearables.Count - && wearables.All(other.wearables.Contains) - && other.wearables.All(wearables.Contains))) + && IsListContainedIn(wearables, other.wearables) + && IsListContainedIn(other.wearables, wearables))) return false; if (!(forceRender.Count == other.forceRender.Count - && forceRender.All(other.forceRender.Contains) - && other.forceRender.All(forceRender.Contains))) + && IsHashSetContainedIn(forceRender, other.forceRender) + && IsHashSetContainedIn(other.forceRender, forceRender))) return false; //emotes are the same @@ -107,11 +127,18 @@ public bool HaveSameWearablesAndColors(AvatarModel other) if (emotes.Count != other.emotes.Count) return false; - for (var i = 0; i < emotes.Count; i++) + foreach (AvatarEmoteEntry emote in emotes) { - AvatarEmoteEntry emote = emotes[i]; + var found = false; + + foreach (AvatarEmoteEntry t in other.emotes) + if (t.urn == emote.urn) + { + found = true; + break; + } - if (other.emotes.FirstOrDefault(x => x.urn == emote.urn) == null) + if (!found) return false; } } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/CollidersManager/CollidersManager.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/CollidersManager/CollidersManager.cs index e0b3faeee2..bb6b70d8a7 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/CollidersManager/CollidersManager.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/CollidersManager/CollidersManager.cs @@ -62,11 +62,14 @@ public void AddOrUpdateEntityCollider(IDCLEntity entity, Collider collider) if (!collidersList.Contains(collider)) collidersList.Add(collider); - ColliderInfo info = new ColliderInfo(); - info.entity = entity; - info.meshName = GetMeshName(collider); - info.scene = entity.scene; - AddOrUpdateColliderInfo(collider, info); + if (!colliderInfo.ContainsKey(collider)) + { + var info = new ColliderInfo(); + info.entity = entity; + info.meshName = GetMeshName(collider); + info.scene = entity.scene; + AddOrUpdateColliderInfo(collider, info); + } // Note (Zak): avoid adding the event multiple times entity.OnCleanupEvent -= OnEntityCleanUpEvent; @@ -130,7 +133,7 @@ public void ConfigureColliders(GameObject meshGameObject, bool hasCollision, boo entity.meshesInfo.colliders.Clear(); if (colliderLayer == -1) - colliderLayer = DCL.Configuration.PhysicsLayers.defaultLayer; + colliderLayer = PhysicsLayers.defaultLayer; Collider collider; int onClickLayer = PhysicsLayers.onPointerEventLayer; // meshes can have an OnPointerEvent child collider that should be ignored