< Summary

Class:DCL.Interface.WebInterfaceUUIDEvent[TPayload]
Assembly:WebInterface
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs
Covered lines:1
Uncovered lines:0
Coverable lines:1
Total lines:1623
Line coverage:100% (1 of 1)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UUIDEvent()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using DCL.CameraTool;
 4using DCL.Helpers;
 5using DCL.Models;
 6using Newtonsoft.Json;
 7using UnityEngine;
 8using Ray = UnityEngine.Ray;
 9
 10#if UNITY_WEBGL && !UNITY_EDITOR
 11using System.Runtime.InteropServices;
 12#endif
 13
 14namespace DCL.Interface
 15{
 16    /**
 17     * This class contains the outgoing interface of Decentraland.
 18     * You must call those functions to interact with the WebInterface.
 19     *
 20     * The messages comming from the WebInterface instead, are reported directly to
 21     * the handler GameObject by name.
 22     */
 23    public static class WebInterface
 24    {
 25        public static bool VERBOSE = false;
 26
 27        [System.Serializable]
 28        public class ReportPositionPayload
 29        {
 30            /** Camera position, world space */
 31            public Vector3 position;
 32
 33            /** Character rotation */
 34            public Quaternion rotation;
 35
 36            /** Camera rotation */
 37            public Quaternion cameraRotation;
 38
 39            /** Camera height, relative to the feet of the avatar or ground */
 40            public float playerHeight;
 41
 42            public Vector3 mousePosition;
 43
 44            public string id;
 45        }
 46
 47        [System.Serializable]
 48        public abstract class ControlEvent
 49        {
 50            public string eventType;
 51        }
 52
 53        public abstract class ControlEvent<T> : ControlEvent
 54        {
 55            public T payload;
 56
 57            protected ControlEvent(string eventType, T payload)
 58            {
 59                this.eventType = eventType;
 60                this.payload = payload;
 61            }
 62        }
 63
 64        [System.Serializable]
 65        public class SceneReady : ControlEvent<SceneReady.Payload>
 66        {
 67            [System.Serializable]
 68            public class Payload
 69            {
 70                public string sceneId;
 71            }
 72
 73            public SceneReady(string sceneId) : base("SceneReady", new Payload() { sceneId = sceneId }) { }
 74        }
 75
 76        [System.Serializable]
 77        public class ActivateRenderingACK : ControlEvent<object>
 78        {
 79            public ActivateRenderingACK() : base("ActivateRenderingACK", null) { }
 80        }
 81
 82        [System.Serializable]
 83        public class DeactivateRenderingACK : ControlEvent<object>
 84        {
 85            public DeactivateRenderingACK() : base("DeactivateRenderingACK", null) { }
 86        }
 87
 88        [System.Serializable]
 89        public class SceneEvent<T>
 90        {
 91            public string sceneId;
 92            public string eventType;
 93            public T payload;
 94        }
 95
 96        [System.Serializable]
 97        public class AllScenesEvent<T>
 98        {
 99            public string eventType;
 100            public T payload;
 101        }
 102
 103        [System.Serializable]
 104        public class UUIDEvent<TPayload>
 105            where TPayload : class, new()
 106        {
 107            public string uuid;
 121108            public TPayload payload = new TPayload();
 109        }
 110
 111        public enum ACTION_BUTTON
 112        {
 113            POINTER = 0,
 114            PRIMARY = 1,
 115            SECONDARY = 2,
 116            ANY = 3,
 117            FORWARD = 4,
 118            BACKWARD = 5,
 119            RIGHT = 6,
 120            LEFT = 7,
 121            JUMP = 8,
 122            WALK = 9,
 123            ACTION_3 = 10,
 124            ACTION_4 = 11,
 125            ACTION_5 = 12,
 126            ACTION_6 = 13
 127        }
 128
 129        [System.Serializable]
 130        public class OnClickEvent : UUIDEvent<OnClickEventPayload> { };
 131
 132        [System.Serializable]
 133        public class CameraModePayload
 134        {
 135            public CameraMode.ModeId cameraMode;
 136        };
 137
 138        [System.Serializable]
 139        public class Web3UseResponsePayload
 140        {
 141            public string id;
 142            public bool result;
 143        };
 144
 145        [System.Serializable]
 146        public class IdleStateChangedPayload
 147        {
 148            public bool isIdle;
 149        };
 150
 151        [System.Serializable]
 152        public class OnPointerDownEvent : UUIDEvent<OnPointerEventPayload> { };
 153
 154        [System.Serializable]
 155        public class OnGlobalPointerEvent
 156        {
 157            public OnGlobalPointerEventPayload payload = new OnGlobalPointerEventPayload();
 158        };
 159
 160        [System.Serializable]
 161        public class OnPointerUpEvent : UUIDEvent<OnPointerEventPayload> { };
 162
 163        [System.Serializable]
 164        private class OnTextSubmitEvent : UUIDEvent<OnTextSubmitEventPayload> { };
 165
 166        [System.Serializable]
 167        private class OnTextInputChangeEvent : UUIDEvent<OnTextInputChangeEventPayload> { };
 168
 169        [System.Serializable]
 170        private class OnTextInputChangeTextEvent : UUIDEvent<OnTextInputChangeTextEventPayload> { };
 171
 172        [System.Serializable]
 173        private class OnScrollChangeEvent : UUIDEvent<OnScrollChangeEventPayload> { };
 174
 175        [System.Serializable]
 176        private class OnFocusEvent : UUIDEvent<EmptyPayload> { };
 177
 178        [System.Serializable]
 179        private class OnBlurEvent : UUIDEvent<EmptyPayload> { };
 180
 181        [System.Serializable]
 182        public class OnEnterEvent : UUIDEvent<OnEnterEventPayload> { };
 183
 184        [System.Serializable]
 185        public class OnClickEventPayload
 186        {
 187            public ACTION_BUTTON buttonId = ACTION_BUTTON.POINTER;
 188        }
 189
 190        [System.Serializable]
 191        public class SendChatMessageEvent
 192        {
 193            public ChatMessage message;
 194        }
 195
 196        [System.Serializable]
 197        public class RemoveEntityComponentsPayLoad
 198        {
 199            public string entityId;
 200            public string componentId;
 201        };
 202
 203        [System.Serializable]
 204        public class StoreSceneStateEvent
 205        {
 206            public string type = "StoreSceneState";
 207            public string payload = "";
 208        };
 209
 210        [System.Serializable]
 211        public class OnPointerEventPayload
 212        {
 213            [System.Serializable]
 214            public class Hit
 215            {
 216                public Vector3 origin;
 217                public float length;
 218                public Vector3 hitPoint;
 219                public Vector3 normal;
 220                public Vector3 worldNormal;
 221                public string meshName;
 222                public string entityId;
 223            }
 224
 225            public ACTION_BUTTON buttonId;
 226            public Vector3 origin;
 227            public Vector3 direction;
 228            public Hit hit;
 229        }
 230
 231        [System.Serializable]
 232        public class OnGlobalPointerEventPayload : OnPointerEventPayload
 233        {
 234            public enum InputEventType
 235            {
 236                DOWN,
 237                UP
 238            }
 239
 240            public InputEventType type;
 241        }
 242
 243        [System.Serializable]
 244        public class OnTextSubmitEventPayload
 245        {
 246            public string id;
 247            public string text;
 248        }
 249
 250        [System.Serializable]
 251        public class OnTextInputChangeEventPayload
 252        {
 253            public string value;
 254        }
 255
 256        [System.Serializable]
 257        public class OnTextInputChangeTextEventPayload
 258        {
 259            [System.Serializable]
 260            public class Payload
 261            {
 262                public string value;
 263                public bool isSubmit;
 264            }
 265
 266            public Payload value = new Payload();
 267        }
 268
 269        [System.Serializable]
 270        public class OnScrollChangeEventPayload
 271        {
 272            public Vector2 value;
 273            public int pointerId;
 274        }
 275
 276        [System.Serializable]
 277        public class EmptyPayload { }
 278
 279        [System.Serializable]
 280        public class MetricsModel
 281        {
 282            public int meshes;
 283            public int bodies;
 284            public int materials;
 285            public int textures;
 286            public int triangles;
 287            public int entities;
 288
 289            public static MetricsModel operator +(MetricsModel lhs, MetricsModel rhs)
 290            {
 291                return new MetricsModel()
 292                {
 293                    meshes = lhs.meshes + rhs.meshes,
 294                    bodies = lhs.bodies + rhs.bodies,
 295                    materials = lhs.materials + rhs.materials,
 296                    textures = lhs.textures + rhs.textures,
 297                    triangles = lhs.triangles + rhs.triangles,
 298                    entities = lhs.entities + rhs.entities
 299                };
 300            }
 301        }
 302
 303        [System.Serializable]
 304        private class OnMetricsUpdate
 305        {
 306            public MetricsModel given = new MetricsModel();
 307            public MetricsModel limit = new MetricsModel();
 308        }
 309
 310        [System.Serializable]
 311        public class OnEnterEventPayload { }
 312
 313        [System.Serializable]
 314        public class TransformPayload
 315        {
 316            public Vector3 position = Vector3.zero;
 317            public Quaternion rotation = Quaternion.identity;
 318            public Vector3 scale = Vector3.one;
 319        }
 320
 321        public class OnSendScreenshot
 322        {
 323            public string id;
 324            public string encodedTexture;
 325        };
 326
 327        [System.Serializable]
 328        public class GotoEvent
 329        {
 330            public int x;
 331            public int y;
 332        };
 333
 334        [System.Serializable]
 335        public class BaseResolution
 336        {
 337            public int baseResolution;
 338        };
 339
 340        //-----------------------------------------------------
 341        // Raycast
 342        [System.Serializable]
 343        public class RayInfo
 344        {
 345            public Vector3 origin;
 346            public Vector3 direction;
 347            public float distance;
 348        }
 349
 350        [System.Serializable]
 351        public class RaycastHitInfo
 352        {
 353            public bool didHit;
 354            public RayInfo ray;
 355
 356            public Vector3 hitPoint;
 357            public Vector3 hitNormal;
 358        }
 359
 360        [System.Serializable]
 361        public class HitEntityInfo
 362        {
 363            public string entityId;
 364            public string meshName;
 365        }
 366
 367        [System.Serializable]
 368        public class RaycastHitEntity : RaycastHitInfo
 369        {
 370            public HitEntityInfo entity;
 371        }
 372
 373        [System.Serializable]
 374        public class RaycastHitEntities : RaycastHitInfo
 375        {
 376            public RaycastHitEntity[] entities;
 377        }
 378
 379        [System.Serializable]
 380        public class RaycastResponse<T> where T : RaycastHitInfo
 381        {
 382            public string queryId;
 383            public string queryType;
 384            public T payload;
 385        }
 386
 387        // Note (Zak): We need to explicitly define this classes for the JsonUtility to
 388        // be able to serialize them
 389        [System.Serializable]
 390        public class RaycastHitFirstResponse : RaycastResponse<RaycastHitEntity> { }
 391
 392        [System.Serializable]
 393        public class RaycastHitAllResponse : RaycastResponse<RaycastHitEntities> { }
 394
 395        [System.Serializable]
 396        public class SendExpressionPayload
 397        {
 398            public string id;
 399            public long timestamp;
 400        }
 401
 402        [System.Serializable]
 403        public class UserAcceptedCollectiblesPayload
 404        {
 405            public string id;
 406        }
 407
 408        [System.Serializable]
 409        public class SendBlockPlayerPayload
 410        {
 411            public string userId;
 412        }
 413
 414        [Serializable]
 415        private class SendReportPlayerPayload
 416        {
 417            public string userId;
 418            public string name;
 419        }
 420
 421        [Serializable]
 422        private class SendReportScenePayload
 423        {
 424            public string sceneId;
 425        }
 426
 427        [System.Serializable]
 428        public class SendUnblockPlayerPayload
 429        {
 430            public string userId;
 431        }
 432
 433        [System.Serializable]
 434        public class TutorialStepPayload
 435        {
 436            public int tutorialStep;
 437        }
 438
 439        [System.Serializable]
 440        public class PerformanceReportPayload
 441        {
 442            public string samples;
 443            public bool fpsIsCapped;
 444            public int hiccupsInThousandFrames;
 445            public float hiccupsTime;
 446            public float totalTime;
 447            public int gltfInProgress;
 448            public int gltfFailed;
 449            public int gltfCancelled;
 450            public int gltfLoaded;
 451            public int abInProgress;
 452            public int abFailed;
 453            public int abCancelled;
 454            public int abLoaded;
 455            public int gltfTexturesLoaded;
 456            public int abTexturesLoaded;
 457            public int promiseTexturesLoaded;
 458            public int enqueuedMessages;
 459            public int processedMessages;
 460            public int playerCount;
 461            public int loadRadius;
 462            public Dictionary<string, long> sceneScores;
 463            public object drawCalls; //int *
 464            public object memoryReserved; //long, in total bytes *
 465            public object memoryUsage; //long, in total bytes *
 466            public object totalGCAlloc; //long, in total bytes, its the sum of all GCAllocs per frame over 1000 frames *
 467
 468            //* is NULL if SendProfilerMetrics is false
 469        }
 470
 471        [System.Serializable]
 472        public class SystemInfoReportPayload
 473        {
 474            public string graphicsDeviceName = SystemInfo.graphicsDeviceName;
 475            public string graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion;
 476            public int graphicsMemorySize = SystemInfo.graphicsMemorySize;
 477            public string processorType = SystemInfo.processorType;
 478            public int processorCount = SystemInfo.processorCount;
 479            public int systemMemorySize = SystemInfo.systemMemorySize;
 480
 481            // TODO: remove useBinaryTransform after ECS7 is fully in prod
 482            public bool useBinaryTransform = true;
 483        }
 484
 485        [System.Serializable]
 486        public class GenericAnalyticPayload
 487        {
 488            public string eventName;
 489            public Dictionary<object, object> data;
 490        }
 491
 492        [System.Serializable]
 493        public class PerformanceHiccupPayload
 494        {
 495            public int hiccupsInThousandFrames;
 496            public float hiccupsTime;
 497            public float totalTime;
 498        }
 499
 500        [System.Serializable]
 501        public class TermsOfServiceResponsePayload
 502        {
 503            public string sceneId;
 504            public bool dontShowAgain;
 505            public bool accepted;
 506        }
 507
 508        [System.Serializable]
 509        public class OpenURLPayload
 510        {
 511            public string url;
 512        }
 513
 514        [System.Serializable]
 515        public class GIFSetupPayload
 516        {
 517            public string imageSource;
 518            public string id;
 519            public bool isWebGL1;
 520        }
 521
 522        [System.Serializable]
 523        public class RequestScenesInfoAroundParcelPayload
 524        {
 525            public Vector2 parcel;
 526            public int scenesAround;
 527        }
 528
 529        [System.Serializable]
 530        public class AudioStreamingPayload
 531        {
 532            public string url;
 533            public bool play;
 534            public float volume;
 535        }
 536
 537        [System.Serializable]
 538        public class SetScenesLoadRadiusPayload
 539        {
 540            public float newRadius;
 541        }
 542
 543        [System.Serializable]
 544        public class SetVoiceChatRecordingPayload
 545        {
 546            public bool recording;
 547        }
 548
 549        [System.Serializable]
 550        public class ApplySettingsPayload
 551        {
 552            public float voiceChatVolume;
 553            public int voiceChatAllowCategory;
 554        }
 555
 556        [System.Serializable]
 557        public class JumpInPayload
 558        {
 559            public FriendsController.UserStatus.Realm realm = new FriendsController.UserStatus.Realm();
 560            public Vector2 gridPosition;
 561        }
 562
 563        [System.Serializable]
 564        public class LoadingFeedbackMessage
 565        {
 566            public string message;
 567            public int loadPercentage;
 568        }
 569
 570        [System.Serializable]
 571        public class AnalyticsPayload
 572        {
 573            [System.Serializable]
 574            public class Property
 575            {
 576                public string key;
 577                public string value;
 578
 579                public Property(string key, string value)
 580                {
 581                    this.key = key;
 582                    this.value = value;
 583                }
 584            }
 585
 586            public string name;
 587            public Property[] properties;
 588        }
 589
 590        [System.Serializable]
 591        public class DelightedSurveyEnabledPayload
 592        {
 593            public bool enabled;
 594        }
 595
 596        [System.Serializable]
 597        public class ExternalActionSceneEventPayload
 598        {
 599            public string type;
 600            public string payload;
 601        }
 602
 603        [System.Serializable]
 604        public class MuteUserPayload
 605        {
 606            public string[] usersId;
 607            public bool mute;
 608        }
 609
 610        [System.Serializable]
 611        public class CloseUserAvatarPayload
 612        {
 613            public bool isSignUpFlow;
 614        }
 615
 616        [System.Serializable]
 617        public class StringPayload
 618        {
 619            public string value;
 620        }
 621
 622        [System.Serializable]
 623        public class KillPortableExperiencePayload
 624        {
 625            public string portableExperienceId;
 626        }
 627
 628        [System.Serializable]
 629        public class SetDisabledPortableExperiencesPayload
 630        {
 631            public string[] idsToDisable;
 632        }
 633
 634        [System.Serializable]
 635        public class WearablesRequestFiltersPayload
 636        {
 637            public string ownedByUser;
 638            public string[] wearableIds;
 639            public string[] collectionIds;
 640            public string thirdPartyId;
 641        }
 642
 643        [System.Serializable]
 644        public class EmotesRequestFiltersPayload
 645        {
 646            public string ownedByUser;
 647            public string[] emoteIds;
 648            public string[] collectionIds;
 649            public string thirdPartyId;
 650        }
 651
 652        [System.Serializable]
 653        public class RequestWearablesPayload
 654        {
 655            public WearablesRequestFiltersPayload filters;
 656            public string context;
 657        }
 658
 659        [System.Serializable]
 660        public class RequestEmotesPayload
 661        {
 662            public EmotesRequestFiltersPayload filters;
 663            public string context;
 664        }
 665
 666        [System.Serializable]
 667        public class HeadersPayload
 668        {
 669            public string method;
 670            public string url;
 671            public Dictionary<string, object> metadata = new Dictionary<string, object>();
 672        }
 673
 674        [System.Serializable]
 675        public class SearchENSOwnerPayload
 676        {
 677            public string name;
 678            public int maxResults;
 679        }
 680
 681        [System.Serializable]
 682        public class UnpublishScenePayload
 683        {
 684            public string coordinates;
 685        }
 686
 687        [System.Serializable]
 688        public class AvatarStateBase
 689        {
 690            public string type;
 691            public string avatarShapeId;
 692        }
 693
 694        [System.Serializable]
 695        public class AvatarStateSceneChanged : AvatarStateBase
 696        {
 697            public string sceneId;
 698        }
 699
 700        [System.Serializable]
 701        public class AvatarOnClickPayload
 702        {
 703            public string userId;
 704            public RayInfo ray = new RayInfo();
 705        }
 706
 707        [System.Serializable]
 708        public class TimeReportPayload
 709        {
 710            public float timeNormalizationFactor;
 711            public float cycleTime;
 712            public bool isPaused;
 713            public float time;
 714        }
 715
 716#if UNITY_WEBGL && !UNITY_EDITOR
 717    /**
 718     * This method is called after the first render. It marks the loading of the
 719     * rest of the JS client.
 720     */
 721    [DllImport("__Internal")] public static extern void StartDecentraland();
 722    [DllImport("__Internal")] public static extern void MessageFromEngine(string type, string message);
 723    [DllImport("__Internal")] public static extern string GetGraphicCard();
 724    [DllImport("__Internal")] public static extern void BinaryMessageFromEngine(string sceneId, byte[] bytes, int size);
 725
 726    public static System.Action<string, string> OnMessageFromEngine;
 727#else
 728        public static Action<string, string> OnMessageFromEngine
 729        {
 730            set
 731            {
 732                OnMessage = value;
 733                if (OnMessage != null)
 734                {
 735                    ProcessQueuedMessages();
 736                }
 737            }
 738            get => OnMessage;
 739        }
 740        private static Action<string, string> OnMessage;
 741
 742        private static bool hasQueuedMessages = false;
 743        private static List<(string, string)> queuedMessages = new List<(string, string)>();
 744        public static void StartDecentraland() { }
 745        public static bool CheckURLParam(string targetParam) { return false; }
 746        public static string GetURLParam(string targetParam) { return String.Empty; }
 747
 748        public static void MessageFromEngine(string type, string message)
 749        {
 750            if (OnMessageFromEngine != null)
 751            {
 752                if (hasQueuedMessages)
 753                {
 754                    ProcessQueuedMessages();
 755                }
 756
 757                OnMessageFromEngine.Invoke(type, message);
 758                if (VERBOSE)
 759                {
 760                    Debug.Log("MessageFromEngine called with: " + type + ", " + message);
 761                }
 762            }
 763            else
 764            {
 765                lock (queuedMessages)
 766                {
 767                    queuedMessages.Add((type, message));
 768                }
 769
 770                hasQueuedMessages = true;
 771            }
 772        }
 773
 774        private static void ProcessQueuedMessages()
 775        {
 776            hasQueuedMessages = false;
 777            lock (queuedMessages)
 778            {
 779                foreach ((string type, string payload) in queuedMessages)
 780                {
 781                    MessageFromEngine(type, payload);
 782                }
 783
 784                queuedMessages.Clear();
 785            }
 786        }
 787
 788        public static string GetGraphicCard() => "In Editor Graphic Card";
 789#endif
 790
 791        public static void SendMessage(string type)
 792        {
 793            // sending an empty JSON object to be compatible with other messages
 794            MessageFromEngine(type, "{}");
 795        }
 796
 797        public static void SendMessage<T>(string type, T message)
 798        {
 799            string messageJson = JsonUtility.ToJson(message);
 800            SendJson(type, messageJson);
 801        }
 802
 803        public static void SendJson(string type, string json)
 804        {
 805            if (VERBOSE)
 806            {
 807                Debug.Log($"Sending message: " + json);
 808            }
 809
 810            MessageFromEngine(type, json);
 811        }
 812
 813        private static ReportPositionPayload positionPayload = new ReportPositionPayload();
 814        private static CameraModePayload cameraModePayload = new CameraModePayload();
 815        private static Web3UseResponsePayload web3UseResponsePayload = new Web3UseResponsePayload();
 816        private static IdleStateChangedPayload idleStateChangedPayload = new IdleStateChangedPayload();
 817        private static OnMetricsUpdate onMetricsUpdate = new OnMetricsUpdate();
 818        private static OnClickEvent onClickEvent = new OnClickEvent();
 819        private static OnPointerDownEvent onPointerDownEvent = new OnPointerDownEvent();
 820        private static OnPointerUpEvent onPointerUpEvent = new OnPointerUpEvent();
 821        private static OnTextSubmitEvent onTextSubmitEvent = new OnTextSubmitEvent();
 822        private static OnTextInputChangeEvent onTextInputChangeEvent = new OnTextInputChangeEvent();
 823        private static OnTextInputChangeTextEvent onTextInputChangeTextEvent = new OnTextInputChangeTextEvent();
 824        private static OnScrollChangeEvent onScrollChangeEvent = new OnScrollChangeEvent();
 825        private static OnFocusEvent onFocusEvent = new OnFocusEvent();
 826        private static OnBlurEvent onBlurEvent = new OnBlurEvent();
 827        private static OnEnterEvent onEnterEvent = new OnEnterEvent();
 828        private static OnSendScreenshot onSendScreenshot = new OnSendScreenshot();
 829        private static OnPointerEventPayload onPointerEventPayload = new OnPointerEventPayload();
 830        private static OnGlobalPointerEventPayload onGlobalPointerEventPayload = new OnGlobalPointerEventPayload();
 831        private static OnGlobalPointerEvent onGlobalPointerEvent = new OnGlobalPointerEvent();
 832        private static AudioStreamingPayload onAudioStreamingEvent = new AudioStreamingPayload();
 833        private static SetVoiceChatRecordingPayload setVoiceChatRecordingPayload = new SetVoiceChatRecordingPayload();
 834        private static SetScenesLoadRadiusPayload setScenesLoadRadiusPayload = new SetScenesLoadRadiusPayload();
 835        private static ApplySettingsPayload applySettingsPayload = new ApplySettingsPayload();
 836        private static GIFSetupPayload gifSetupPayload = new GIFSetupPayload();
 837        private static JumpInPayload jumpInPayload = new JumpInPayload();
 838        private static GotoEvent gotoEvent = new GotoEvent();
 839        private static SendChatMessageEvent sendChatMessageEvent = new SendChatMessageEvent();
 840        private static BaseResolution baseResEvent = new BaseResolution();
 841        private static AnalyticsPayload analyticsEvent = new AnalyticsPayload();
 842        private static DelightedSurveyEnabledPayload delightedSurveyEnabled = new DelightedSurveyEnabledPayload();
 843        private static ExternalActionSceneEventPayload sceneExternalActionEvent = new ExternalActionSceneEventPayload();
 844        private static MuteUserPayload muteUserEvent = new MuteUserPayload();
 845        private static StoreSceneStateEvent storeSceneState = new StoreSceneStateEvent();
 846        private static CloseUserAvatarPayload closeUserAvatarPayload = new CloseUserAvatarPayload();
 847        private static StringPayload stringPayload = new StringPayload();
 848        private static KillPortableExperiencePayload killPortableExperiencePayload = new KillPortableExperiencePayload()
 849        private static SetDisabledPortableExperiencesPayload setDisabledPortableExperiencesPayload = new SetDisabledPort
 850        private static RequestWearablesPayload requestWearablesPayload = new RequestWearablesPayload();
 851        private static RequestEmotesPayload requestEmotesPayload = new RequestEmotesPayload();
 852        private static SearchENSOwnerPayload searchEnsOwnerPayload = new SearchENSOwnerPayload();
 853        private static HeadersPayload headersPayload = new HeadersPayload();
 854        private static AvatarStateBase avatarStatePayload = new AvatarStateBase();
 855        private static AvatarStateSceneChanged avatarSceneChangedPayload = new AvatarStateSceneChanged();
 856        public static AvatarOnClickPayload avatarOnClickPayload = new AvatarOnClickPayload();
 857        private static UUIDEvent<EmptyPayload> onPointerHoverEnterEvent = new UUIDEvent<EmptyPayload>();
 858        private static UUIDEvent<EmptyPayload> onPointerHoverExitEvent = new UUIDEvent<EmptyPayload>();
 859        private static TimeReportPayload timeReportPayload = new TimeReportPayload();
 860
 861        public static void SendSceneEvent<T>(string sceneId, string eventType, T payload)
 862        {
 863            SceneEvent<T> sceneEvent = new SceneEvent<T>();
 864            sceneEvent.sceneId = sceneId;
 865            sceneEvent.eventType = eventType;
 866            sceneEvent.payload = payload;
 867
 868            SendMessage("SceneEvent", sceneEvent);
 869        }
 870
 871        private static void SendAllScenesEvent<T>(string eventType, T payload)
 872        {
 873            AllScenesEvent<T> allScenesEvent = new AllScenesEvent<T>();
 874            allScenesEvent.eventType = eventType;
 875            allScenesEvent.payload = payload;
 876
 877            SendMessage("AllScenesEvent", allScenesEvent);
 878        }
 879
 880        public static void ReportPosition(Vector3 position, Quaternion rotation, float playerHeight, Quaternion cameraRo
 881        {
 882            positionPayload.position = position;
 883            positionPayload.rotation = rotation;
 884            positionPayload.playerHeight = playerHeight;
 885            positionPayload.cameraRotation = cameraRotation;
 886
 887            SendMessage("ReportPosition", positionPayload);
 888        }
 889
 890        public static void ReportCameraChanged(CameraMode.ModeId cameraMode) { ReportCameraChanged(cameraMode, null); }
 891
 892        public static void ReportCameraChanged(CameraMode.ModeId cameraMode, string targetSceneId)
 893        {
 894            cameraModePayload.cameraMode = cameraMode;
 895            if (!string.IsNullOrEmpty(targetSceneId))
 896            {
 897                SendSceneEvent(targetSceneId, "cameraModeChanged", cameraModePayload);
 898            }
 899            else
 900            {
 901                SendAllScenesEvent("cameraModeChanged", cameraModePayload);
 902            }
 903        }
 904
 905        public static void Web3UseResponse(string id, bool result)
 906        {
 907            web3UseResponsePayload.id = id;
 908            web3UseResponsePayload.result = result;
 909            SendMessage("Web3UseResponse", web3UseResponsePayload);
 910        }
 911
 912        public static void ReportIdleStateChanged(bool isIdle)
 913        {
 914            idleStateChangedPayload.isIdle = isIdle;
 915            SendAllScenesEvent("idleStateChanged", idleStateChangedPayload);
 916        }
 917
 918        public static void ReportControlEvent<T>(T controlEvent) where T : ControlEvent { SendMessage("ControlEvent", co
 919
 920        public static void SendRequestHeadersForUrl(string eventName, string method, string url, Dictionary<string, obje
 921        {
 922            headersPayload.method = method;
 923            headersPayload.url = url;
 924            if (metadata != null)
 925                headersPayload.metadata = metadata;
 926            SendMessage(eventName, headersPayload);
 927        }
 928
 929        public static void BuilderInWorldMessage(string type, string message) { MessageFromEngine(type, message); }
 930
 931        public static void ReportOnClickEvent(string sceneId, string uuid)
 932        {
 933            if (string.IsNullOrEmpty(uuid))
 934            {
 935                return;
 936            }
 937
 938            onClickEvent.uuid = uuid;
 939
 940            SendSceneEvent(sceneId, "uuidEvent", onClickEvent);
 941        }
 942
 943        // TODO: Add sceneNumber to this response
 944        private static void ReportRaycastResult<T, P>(string sceneId, string queryId, string queryType, P payload) where
 945        {
 946            T response = new T();
 947            response.queryId = queryId;
 948            response.queryType = queryType;
 949            response.payload = payload;
 950
 951            SendSceneEvent<T>(sceneId, "raycastResponse", response);
 952        }
 953
 954        public static void ReportRaycastHitFirstResult(string sceneId, string queryId, RaycastType raycastType, RaycastH
 955
 956        public static void ReportRaycastHitAllResult(string sceneId, string queryId, RaycastType raycastType, RaycastHit
 957
 958        private static OnPointerEventPayload.Hit CreateHitObject(string entityId, string meshName, Vector3 point,
 959            Vector3 normal, float distance)
 960        {
 961            OnPointerEventPayload.Hit hit = new OnPointerEventPayload.Hit();
 962
 963            hit.hitPoint = point;
 964            hit.length = distance;
 965            hit.normal = normal;
 966            hit.worldNormal = normal;
 967            hit.meshName = meshName;
 968            hit.entityId = entityId;
 969
 970            return hit;
 971        }
 972
 973        private static void SetPointerEventPayload(OnPointerEventPayload pointerEventPayload, ACTION_BUTTON buttonId,
 974            string entityId, string meshName, Ray ray, Vector3 point, Vector3 normal, float distance,
 975            bool isHitInfoValid)
 976        {
 977            pointerEventPayload.origin = ray.origin;
 978            pointerEventPayload.direction = ray.direction;
 979            pointerEventPayload.buttonId = buttonId;
 980
 981            if (isHitInfoValid)
 982                pointerEventPayload.hit = CreateHitObject(entityId, meshName, point, normal, distance);
 983            else
 984                pointerEventPayload.hit = null;
 985        }
 986
 987        public static void ReportGlobalPointerDownEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal,
 988            float distance, string sceneId, string entityId = "0", string meshName = null, bool isHitInfoValid = false)
 989        {
 990            SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId,
 991                entityId, meshName, ray, point, normal, distance,
 992                isHitInfoValid);
 993            onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.DOWN;
 994
 995            onGlobalPointerEvent.payload = onGlobalPointerEventPayload;
 996
 997            SendSceneEvent(sceneId, "actionButtonEvent", onGlobalPointerEvent);
 998        }
 999
 1000        public static void ReportGlobalPointerUpEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal,
 1001            float distance, string sceneId, string entityId = "0", string meshName = null, bool isHitInfoValid = false)
 1002        {
 1003            SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId,
 1004                entityId, meshName, ray, point, normal, distance,
 1005                isHitInfoValid);
 1006            onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.UP;
 1007
 1008            onGlobalPointerEvent.payload = onGlobalPointerEventPayload;
 1009
 1010            SendSceneEvent(sceneId, "actionButtonEvent", onGlobalPointerEvent);
 1011        }
 1012
 1013        public static void ReportOnPointerDownEvent(ACTION_BUTTON buttonId, string sceneId, string uuid,
 1014            string entityId, string meshName, Ray ray, Vector3 point, Vector3 normal, float distance)
 1015        {
 1016            if (string.IsNullOrEmpty(uuid))
 1017            {
 1018                return;
 1019            }
 1020
 1021            onPointerDownEvent.uuid = uuid;
 1022            SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point,
 1023                normal, distance, isHitInfoValid: true);
 1024            onPointerDownEvent.payload = onPointerEventPayload;
 1025
 1026            SendSceneEvent(sceneId, "uuidEvent", onPointerDownEvent);
 1027        }
 1028
 1029        public static void ReportOnPointerUpEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, string entityId,
 1030            string meshName, Ray ray, Vector3 point, Vector3 normal, float distance)
 1031        {
 1032            if (string.IsNullOrEmpty(uuid))
 1033            {
 1034                return;
 1035            }
 1036
 1037            onPointerUpEvent.uuid = uuid;
 1038            SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point,
 1039                normal, distance, isHitInfoValid: true);
 1040            onPointerUpEvent.payload = onPointerEventPayload;
 1041
 1042            SendSceneEvent(sceneId, "uuidEvent", onPointerUpEvent);
 1043        }
 1044
 1045        public static void ReportOnTextSubmitEvent(string sceneId, string uuid, string text)
 1046        {
 1047            if (string.IsNullOrEmpty(uuid))
 1048            {
 1049                return;
 1050            }
 1051
 1052            onTextSubmitEvent.uuid = uuid;
 1053            onTextSubmitEvent.payload.text = text;
 1054
 1055            SendSceneEvent(sceneId, "uuidEvent", onTextSubmitEvent);
 1056        }
 1057
 1058        public static void ReportOnTextInputChangedEvent(string sceneId, string uuid, string text)
 1059        {
 1060            if (string.IsNullOrEmpty(uuid))
 1061            {
 1062                return;
 1063            }
 1064
 1065            onTextInputChangeEvent.uuid = uuid;
 1066            onTextInputChangeEvent.payload.value = text;
 1067
 1068            SendSceneEvent(sceneId, "uuidEvent", onTextInputChangeEvent);
 1069        }
 1070
 1071        public static void ReportOnTextInputChangedTextEvent(string sceneId, string uuid, string text, bool isSubmit)
 1072        {
 1073            if (string.IsNullOrEmpty(uuid))
 1074            {
 1075                return;
 1076            }
 1077
 1078            onTextInputChangeTextEvent.uuid = uuid;
 1079            onTextInputChangeTextEvent.payload.value.value = text;
 1080            onTextInputChangeTextEvent.payload.value.isSubmit = isSubmit;
 1081
 1082            SendSceneEvent(sceneId, "uuidEvent", onTextInputChangeTextEvent);
 1083        }
 1084
 1085        public static void ReportOnFocusEvent(string sceneId, string uuid)
 1086        {
 1087            if (string.IsNullOrEmpty(uuid))
 1088            {
 1089                return;
 1090            }
 1091
 1092            onFocusEvent.uuid = uuid;
 1093            SendSceneEvent(sceneId, "uuidEvent", onFocusEvent);
 1094        }
 1095
 1096        public static void ReportOnBlurEvent(string sceneId, string uuid)
 1097        {
 1098            if (string.IsNullOrEmpty(uuid))
 1099            {
 1100                return;
 1101            }
 1102
 1103            onBlurEvent.uuid = uuid;
 1104            SendSceneEvent(sceneId, "uuidEvent", onBlurEvent);
 1105        }
 1106
 1107        public static void ReportOnScrollChange(string sceneId, string uuid, Vector2 value, int pointerId)
 1108        {
 1109            if (string.IsNullOrEmpty(uuid))
 1110            {
 1111                return;
 1112            }
 1113
 1114            onScrollChangeEvent.uuid = uuid;
 1115            onScrollChangeEvent.payload.value = value;
 1116            onScrollChangeEvent.payload.pointerId = pointerId;
 1117
 1118            SendSceneEvent(sceneId, "uuidEvent", onScrollChangeEvent);
 1119        }
 1120
 1121        public static void ReportEvent<T>(string sceneId, T @event) { SendSceneEvent(sceneId, "uuidEvent", @event); }
 1122
 1123        public static void ReportOnMetricsUpdate(string sceneId, MetricsModel current,
 1124            MetricsModel limit)
 1125        {
 1126            onMetricsUpdate.given = current;
 1127            onMetricsUpdate.limit = limit;
 1128
 1129            SendSceneEvent(sceneId, "metricsUpdate", onMetricsUpdate);
 1130        }
 1131
 1132        public static void ReportOnEnterEvent(string sceneId, string uuid)
 1133        {
 1134            if (string.IsNullOrEmpty(uuid))
 1135                return;
 1136
 1137            onEnterEvent.uuid = uuid;
 1138
 1139            SendSceneEvent(sceneId, "uuidEvent", onEnterEvent);
 1140        }
 1141
 1142        public static void LogOut() { SendMessage("LogOut"); }
 1143
 1144        public static void RedirectToSignUp() { SendMessage("RedirectToSignUp"); }
 1145
 1146        public static void PreloadFinished(string sceneId) { SendMessage("PreloadFinished", sceneId); }
 1147
 1148        public static void ReportMousePosition(Vector3 mousePosition, string id)
 1149        {
 1150            positionPayload.mousePosition = mousePosition;
 1151            positionPayload.id = id;
 1152            SendMessage("ReportMousePosition", positionPayload);
 1153        }
 1154
 1155        public static void SendScreenshot(string encodedTexture, string id)
 1156        {
 1157            onSendScreenshot.encodedTexture = encodedTexture;
 1158            onSendScreenshot.id = id;
 1159            SendMessage("SendScreenshot", onSendScreenshot);
 1160        }
 1161
 1162        public static void SetDelightedSurveyEnabled(bool enabled)
 1163        {
 1164            delightedSurveyEnabled.enabled = enabled;
 1165            SendMessage("SetDelightedSurveyEnabled", delightedSurveyEnabled);
 1166        }
 1167
 1168        public static void SetScenesLoadRadius(float newRadius)
 1169        {
 1170            setScenesLoadRadiusPayload.newRadius = newRadius;
 1171            SendMessage("SetScenesLoadRadius", setScenesLoadRadiusPayload);
 1172        }
 1173
 1174        [System.Serializable]
 1175        public class SaveAvatarPayload
 1176        {
 1177            public string face256;
 1178            public string body;
 1179            public bool isSignUpFlow;
 1180            public AvatarModel avatar;
 1181        }
 1182
 1183        public static class RendererAuthenticationType
 1184        {
 1185            public static string Guest => "guest";
 1186            public static string WalletConnect => "wallet_connect";
 1187        }
 1188
 1189        [System.Serializable]
 1190        public class SendAuthenticationPayload
 1191        {
 1192            public string rendererAuthenticationType;
 1193        }
 1194
 1195        [System.Serializable]
 1196        public class SendPassportPayload
 1197        {
 1198            public string name;
 1199            public string email;
 1200        }
 1201
 1202        [System.Serializable]
 1203        public class SendSaveUserUnverifiedNamePayload
 1204        {
 1205            public string newUnverifiedName;
 1206        }
 1207
 1208        [System.Serializable]
 1209        public class SendSaveUserDescriptionPayload
 1210        {
 1211            public string description;
 1212
 1213            public SendSaveUserDescriptionPayload(string description) { this.description = description; }
 1214        }
 1215
 1216        [Serializable]
 1217        public class SendVideoProgressEvent
 1218        {
 1219            public string componentId;
 1220            public string sceneId;
 1221            public string videoTextureId;
 1222            public int status;
 1223            public float currentOffset;
 1224            public float videoLength;
 1225        }
 1226
 1227        public static void RequestOwnProfileUpdate() { SendMessage("RequestOwnProfileUpdate"); }
 1228
 1229        public static void SendSaveAvatar(AvatarModel avatar, Texture2D face256Snapshot, Texture2D bodySnapshot, bool is
 1230        {
 1231            var payload = new SaveAvatarPayload()
 1232            {
 1233                avatar = avatar,
 1234                face256 = System.Convert.ToBase64String(face256Snapshot.EncodeToPNG()),
 1235                body = System.Convert.ToBase64String(bodySnapshot.EncodeToPNG()),
 1236                isSignUpFlow = isSignUpFlow
 1237            };
 1238            SendMessage("SaveUserAvatar", payload);
 1239        }
 1240
 1241        public static void SendAuthentication(string rendererAuthenticationType) { SendMessage("SendAuthentication", new
 1242
 1243        public static void SendPassport(string name, string email) { SendMessage("SendPassport", new SendPassportPayload
 1244
 1245        public static void SendSaveUserUnverifiedName(string newName)
 1246        {
 1247            var payload = new SendSaveUserUnverifiedNamePayload()
 1248            {
 1249                newUnverifiedName = newName
 1250            };
 1251
 1252            SendMessage("SaveUserUnverifiedName", payload);
 1253        }
 1254
 1255        public static void SendSaveUserDescription(string about) { SendMessage("SaveUserDescription", new SendSaveUserDe
 1256
 1257        public static void SendUserAcceptedCollectibles(string airdropId) { SendMessage("UserAcceptedCollectibles", new 
 1258
 1259        public static void SaveUserTutorialStep(int newTutorialStep) { SendMessage("SaveUserTutorialStep", new TutorialS
 1260
 1261        public static void SendPerformanceReport(string performanceReportPayload)
 1262        {
 1263            SendJson("PerformanceReport", performanceReportPayload);
 1264        }
 1265
 1266        public static void SendSystemInfoReport() { SendMessage("SystemInfoReport", new SystemInfoReportPayload()); }
 1267
 1268        public static void SendTermsOfServiceResponse(string sceneId, bool accepted, bool dontShowAgain)
 1269        {
 1270            var payload = new TermsOfServiceResponsePayload()
 1271            {
 1272                sceneId = sceneId,
 1273                accepted = accepted,
 1274                dontShowAgain = dontShowAgain
 1275            };
 1276            SendMessage("TermsOfServiceResponse", payload);
 1277        }
 1278
 1279        public static void SendExpression(string expressionID, long timestamp)
 1280        {
 1281            SendMessage("TriggerExpression", new SendExpressionPayload()
 1282            {
 1283                id = expressionID,
 1284                timestamp = timestamp
 1285            });
 1286        }
 1287
 1288        public static void OpenURL(string url)
 1289        {
 1290#if UNITY_WEBGL
 1291            SendMessage("OpenWebURL", new OpenURLPayload { url = url });
 1292#else
 1293            Application.OpenURL(url);
 1294#endif
 1295        }
 1296
 1297        public static void PublishStatefulScene(ProtocolV2.PublishPayload payload) { MessageFromEngine("PublishSceneStat
 1298
 1299        public static void StartIsolatedMode(IsolatedConfig config) { MessageFromEngine("StartIsolatedMode", JsonConvert
 1300
 1301        public static void StopIsolatedMode(IsolatedConfig config) { MessageFromEngine("StopIsolatedMode", JsonConvert.S
 1302
 1303        public static void SendReportScene(string sceneID)
 1304        {
 1305            SendMessage("ReportScene", new SendReportScenePayload
 1306            {
 1307                sceneId = sceneID
 1308            });
 1309        }
 1310
 1311        public static void SendReportPlayer(string playerId, string playerName)
 1312        {
 1313            SendMessage("ReportPlayer", new SendReportPlayerPayload
 1314            {
 1315                userId = playerId,
 1316                name = playerName
 1317            });
 1318        }
 1319
 1320        public static void SendBlockPlayer(string userId)
 1321        {
 1322            SendMessage("BlockPlayer", new SendBlockPlayerPayload()
 1323            {
 1324                userId = userId
 1325            });
 1326        }
 1327
 1328        public static void SendUnblockPlayer(string userId)
 1329        {
 1330            SendMessage("UnblockPlayer", new SendUnblockPlayerPayload()
 1331            {
 1332                userId = userId
 1333            });
 1334        }
 1335
 1336        public static void RequestScenesInfoAroundParcel(Vector2 parcel, int maxScenesArea)
 1337        {
 1338            SendMessage("RequestScenesInfoInArea", new RequestScenesInfoAroundParcelPayload()
 1339            {
 1340                parcel = parcel,
 1341                scenesAround = maxScenesArea
 1342            });
 1343        }
 1344
 1345        public static void SendAudioStreamEvent(string url, bool play, float volume)
 1346        {
 1347            onAudioStreamingEvent.url = url;
 1348            onAudioStreamingEvent.play = play;
 1349            onAudioStreamingEvent.volume = volume;
 1350            SendMessage("SetAudioStream", onAudioStreamingEvent);
 1351        }
 1352
 1353        public static void JoinVoiceChat() { SendMessage("JoinVoiceChat"); }
 1354
 1355        public static void LeaveVoiceChat() { SendMessage("LeaveVoiceChat"); }
 1356
 1357        public static void SendSetVoiceChatRecording(bool recording)
 1358        {
 1359            setVoiceChatRecordingPayload.recording = recording;
 1360            SendMessage("SetVoiceChatRecording", setVoiceChatRecordingPayload);
 1361        }
 1362
 1363        public static void ToggleVoiceChatRecording() { SendMessage("ToggleVoiceChatRecording"); }
 1364
 1365        public static void ApplySettings(float voiceChatVolume, int voiceChatAllowCategory)
 1366        {
 1367            applySettingsPayload.voiceChatVolume = voiceChatVolume;
 1368            applySettingsPayload.voiceChatAllowCategory = voiceChatAllowCategory;
 1369            SendMessage("ApplySettings", applySettingsPayload);
 1370        }
 1371
 1372        public static void RequestGIFProcessor(string gifURL, string gifId, bool isWebGL1)
 1373        {
 1374            gifSetupPayload.imageSource = gifURL;
 1375            gifSetupPayload.id = gifId;
 1376            gifSetupPayload.isWebGL1 = isWebGL1;
 1377
 1378            SendMessage("RequestGIFProcessor", gifSetupPayload);
 1379        }
 1380
 1381        public static void DeleteGIF(string id)
 1382        {
 1383            stringPayload.value = id;
 1384            SendMessage("DeleteGIF", stringPayload);
 1385        }
 1386
 1387        public static void GoTo(int x, int y)
 1388        {
 1389            gotoEvent.x = x;
 1390            gotoEvent.y = y;
 1391            SendMessage("GoTo", gotoEvent);
 1392        }
 1393
 1394        public static void GoToCrowd() { SendMessage("GoToCrowd"); }
 1395
 1396        public static void GoToMagic() { SendMessage("GoToMagic"); }
 1397
 1398        public static void JumpIn(int x, int y, string serverName, string layerName)
 1399        {
 1400            jumpInPayload.realm.serverName = serverName;
 1401            jumpInPayload.realm.layer = layerName;
 1402
 1403            jumpInPayload.gridPosition.x = x;
 1404            jumpInPayload.gridPosition.y = y;
 1405
 1406            SendMessage("JumpIn", jumpInPayload);
 1407        }
 1408
 1409        public static void SendChatMessage(ChatMessage message)
 1410        {
 1411            sendChatMessageEvent.message = message;
 1412            SendMessage("SendChatMessage", sendChatMessageEvent);
 1413        }
 1414
 1415        public static void UpdateFriendshipStatus(FriendsController.FriendshipUpdateStatusMessage message) { SendMessage
 1416
 1417        public static void ScenesLoadingFeedback(LoadingFeedbackMessage message) { SendMessage("ScenesLoadingFeedback", 
 1418
 1419        public static void FetchHotScenes() { SendMessage("FetchHotScenes"); }
 1420
 1421        public static void SetBaseResolution(int resolution)
 1422        {
 1423            baseResEvent.baseResolution = resolution;
 1424            SendMessage("SetBaseResolution", baseResEvent);
 1425        }
 1426
 1427        public static void ReportAnalyticsEvent(string eventName) { ReportAnalyticsEvent(eventName, null); }
 1428
 1429        public static void ReportAnalyticsEvent(string eventName, AnalyticsPayload.Property[] eventProperties)
 1430        {
 1431            analyticsEvent.name = eventName;
 1432            analyticsEvent.properties = eventProperties;
 1433            SendMessage("Track", analyticsEvent);
 1434        }
 1435
 1436        public static void FetchBalanceOfMANA() { SendMessage("FetchBalanceOfMANA"); }
 1437
 1438        public static void SendSceneExternalActionEvent(string sceneId, string type, string payload)
 1439        {
 1440            sceneExternalActionEvent.type = type;
 1441            sceneExternalActionEvent.payload = payload;
 1442            SendSceneEvent(sceneId, "externalAction", sceneExternalActionEvent);
 1443        }
 1444
 1445        public static void SetMuteUsers(string[] usersId, bool mute)
 1446        {
 1447            muteUserEvent.usersId = usersId;
 1448            muteUserEvent.mute = mute;
 1449            SendMessage("SetMuteUsers", muteUserEvent);
 1450        }
 1451
 1452        public static void SendCloseUserAvatar(bool isSignUpFlow)
 1453        {
 1454            closeUserAvatarPayload.isSignUpFlow = isSignUpFlow;
 1455            SendMessage("CloseUserAvatar", closeUserAvatarPayload);
 1456        }
 1457
 1458        // Warning: Use this method only for PEXs non-associated to smart wearables.
 1459        //          For PEX associated to smart wearables use 'SetDisabledPortableExperiences'.
 1460        public static void KillPortableExperience(string portableExperienceId)
 1461        {
 1462            killPortableExperiencePayload.portableExperienceId = portableExperienceId;
 1463            SendMessage("KillPortableExperience", killPortableExperiencePayload);
 1464        }
 1465
 1466        public static void RequestThirdPartyWearables(
 1467            string ownedByUser,
 1468            string thirdPartyCollectionId,
 1469            string context)
 1470        {
 1471            requestWearablesPayload.filters = new WearablesRequestFiltersPayload
 1472            {
 1473                ownedByUser = ownedByUser,
 1474                thirdPartyId = thirdPartyCollectionId,
 1475                collectionIds = null,
 1476                wearableIds = null
 1477            };
 1478
 1479            requestWearablesPayload.context = context;
 1480
 1481            SendMessage("RequestWearables", requestWearablesPayload);
 1482        }
 1483
 1484        public static void SetDisabledPortableExperiences(string[] idsToDisable)
 1485        {
 1486            setDisabledPortableExperiencesPayload.idsToDisable = idsToDisable;
 1487            SendMessage("SetDisabledPortableExperiences", setDisabledPortableExperiencesPayload);
 1488        }
 1489
 1490        public static void RequestWearables(
 1491            string ownedByUser,
 1492            string[] wearableIds,
 1493            string[] collectionIds,
 1494            string context)
 1495        {
 1496            requestWearablesPayload.filters = new WearablesRequestFiltersPayload
 1497            {
 1498                ownedByUser = ownedByUser,
 1499                wearableIds = wearableIds,
 1500                collectionIds = collectionIds,
 1501                thirdPartyId = null
 1502            };
 1503
 1504            requestWearablesPayload.context = context;
 1505
 1506            SendMessage("RequestWearables", requestWearablesPayload);
 1507        }
 1508
 1509        public static void RequestEmotes(
 1510            string ownedByUser,
 1511            string[] emoteIds,
 1512            string[] collectionIds,
 1513            string context)
 1514        {
 1515            requestEmotesPayload.filters = new EmotesRequestFiltersPayload()
 1516            {
 1517                ownedByUser = ownedByUser,
 1518                emoteIds = emoteIds,
 1519                collectionIds = collectionIds,
 1520                thirdPartyId = null
 1521            };
 1522
 1523            requestEmotesPayload.context = context;
 1524
 1525            SendMessage("RequestEmotes", requestEmotesPayload);
 1526        }
 1527
 1528        public static void SearchENSOwner(string name, int maxResults)
 1529        {
 1530            searchEnsOwnerPayload.name = name;
 1531            searchEnsOwnerPayload.maxResults = maxResults;
 1532
 1533            SendMessage("SearchENSOwner", searchEnsOwnerPayload);
 1534        }
 1535
 1536        public static void RequestUserProfile(string userId)
 1537        {
 1538            stringPayload.value = userId;
 1539            SendMessage("RequestUserProfile", stringPayload);
 1540        }
 1541
 1542        public static void ReportAvatarFatalError() { SendMessage("ReportAvatarFatalError"); }
 1543
 1544        public static void UnpublishScene(Vector2Int sceneCoordinates)
 1545        {
 1546            var payload = new UnpublishScenePayload() { coordinates = $"{sceneCoordinates.x},{sceneCoordinates.y}" };
 1547            SendMessage("UnpublishScene", payload);
 1548        }
 1549
 1550        public static void NotifyStatusThroughChat(string message)
 1551        {
 1552            stringPayload.value = message;
 1553            SendMessage("NotifyStatusThroughChat", stringPayload);
 1554        }
 1555
 1556        public static void ReportVideoProgressEvent(
 1557            string componentId,
 1558            string sceneId,
 1559            string videoClipId,
 1560            int videoStatus,
 1561            float currentOffset,
 1562            float length)
 1563        {
 1564            SendVideoProgressEvent progressEvent = new SendVideoProgressEvent()
 1565            {
 1566                componentId = componentId,
 1567                sceneId = sceneId,
 1568                videoTextureId = videoClipId,
 1569                status = videoStatus,
 1570                currentOffset = currentOffset,
 1571                videoLength = length
 1572            };
 1573
 1574            SendMessage("VideoProgressEvent", progressEvent);
 1575        }
 1576
 1577        public static void ReportAvatarRemoved(string avatarId)
 1578        {
 1579            avatarStatePayload.type = "Removed";
 1580            avatarStatePayload.avatarShapeId = avatarId;
 1581            SendMessage("ReportAvatarState", avatarStatePayload);
 1582        }
 1583
 1584        public static void ReportAvatarSceneChanged(string avatarId, string sceneId)
 1585        {
 1586            avatarSceneChangedPayload.type = "SceneChanged";
 1587            avatarSceneChangedPayload.avatarShapeId = avatarId;
 1588            avatarSceneChangedPayload.sceneId = sceneId;
 1589            SendMessage("ReportAvatarState", avatarSceneChangedPayload);
 1590        }
 1591
 1592        public static void ReportAvatarClick(string sceneId, string userId, Vector3 rayOrigin, Vector3 rayDirection, flo
 1593        {
 1594            avatarOnClickPayload.userId = userId;
 1595            avatarOnClickPayload.ray.origin = rayOrigin;
 1596            avatarOnClickPayload.ray.direction = rayDirection;
 1597            avatarOnClickPayload.ray.distance = distance;
 1598
 1599            SendSceneEvent(sceneId, "playerClicked", avatarOnClickPayload);
 1600        }
 1601
 1602        public static void ReportOnPointerHoverEnterEvent(string sceneId, string uuid)
 1603        {
 1604            onPointerHoverEnterEvent.uuid = uuid;
 1605            SendSceneEvent(sceneId, "uuidEvent", onPointerHoverEnterEvent);
 1606        }
 1607
 1608        public static void ReportOnPointerHoverExitEvent(string sceneId, string uuid)
 1609        {
 1610            onPointerHoverExitEvent.uuid = uuid;
 1611            SendSceneEvent(sceneId, "uuidEvent", onPointerHoverExitEvent);
 1612        }
 1613
 1614        public static void ReportTime(float time, bool isPaused, float timeNormalizationFactor, float cycleTime)
 1615        {
 1616            timeReportPayload.time = time;
 1617            timeReportPayload.isPaused = isPaused;
 1618            timeReportPayload.timeNormalizationFactor = timeNormalizationFactor;
 1619            timeReportPayload.cycleTime = cycleTime;
 1620            SendMessage("ReportDecentralandTime", timeReportPayload);
 1621        }
 1622    }
 1623}

Methods/Properties

UUIDEvent()