< 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:1246
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.Helpers;
 4using DCL.Models;
 5using UnityEngine;
 6using Ray = UnityEngine.Ray;
 7
 8#if UNITY_WEBGL && !UNITY_EDITOR
 9using System.Runtime.InteropServices;
 10#endif
 11
 12namespace DCL.Interface
 13{
 14    /**
 15     * This class contains the outgoing interface of Decentraland.
 16     * You must call those functions to interact with the WebInterface.
 17     *
 18     * The messages comming from the WebInterface instead, are reported directly to
 19     * the handler GameObject by name.
 20     */
 21    public static class WebInterface
 22    {
 23        public static bool VERBOSE = false;
 24        public static System.Action<string, string> OnMessageFromEngine;
 25
 26        [System.Serializable]
 27        private class ReportPositionPayload
 28        {
 29            /** Camera position, world space */
 30            public Vector3 position;
 31
 32            /** Camera rotation */
 33            public Quaternion rotation;
 34
 35            /** Camera height, relative to the feet of the avatar or ground */
 36            public float playerHeight;
 37
 38            public Vector3 mousePosition;
 39
 40            public string id;
 41        }
 42
 43        [System.Serializable]
 44        public abstract class ControlEvent
 45        {
 46            public string eventType;
 47        }
 48
 49        public abstract class ControlEvent<T> : ControlEvent
 50        {
 51            public T payload;
 52
 53            protected ControlEvent(string eventType, T payload)
 54            {
 55                this.eventType = eventType;
 56                this.payload = payload;
 57            }
 58        }
 59
 60        [System.Serializable]
 61        public class StartStatefulMode : ControlEvent<StartStatefulMode.Payload>
 62        {
 63            [System.Serializable]
 64            public class Payload
 65            {
 66                public string sceneId;
 67            }
 68
 69            public StartStatefulMode(string sceneId) : base("StartStatefulMode", new Payload() { sceneId = sceneId }) { 
 70        }
 71
 72        [System.Serializable]
 73        public class StopStatefulMode : ControlEvent<StopStatefulMode.Payload>
 74        {
 75            [System.Serializable]
 76            public class Payload
 77            {
 78                public string sceneId;
 79            }
 80
 81            public StopStatefulMode(string sceneId) : base("StopStatefulMode", new Payload() { sceneId = sceneId }) { }
 82        }
 83
 84        [System.Serializable]
 85        public class SceneReady : ControlEvent<SceneReady.Payload>
 86        {
 87            [System.Serializable]
 88            public class Payload
 89            {
 90                public string sceneId;
 91            }
 92
 93            public SceneReady(string sceneId) : base("SceneReady", new Payload() { sceneId = sceneId }) { }
 94        }
 95
 96        [System.Serializable]
 97        public class ActivateRenderingACK : ControlEvent<object>
 98        {
 99            public ActivateRenderingACK() : base("ActivateRenderingACK", null) { }
 100        }
 101
 102        [System.Serializable]
 103        public class SceneEvent<T>
 104        {
 105            public string sceneId;
 106            public string eventType;
 107            public T payload;
 108        }
 109
 110        [System.Serializable]
 111        public class AllScenesEvent<T>
 112        {
 113            public string eventType;
 114            public T payload;
 115        }
 116
 117        [System.Serializable]
 118        public class UUIDEvent<TPayload>
 119            where TPayload : class, new()
 120        {
 121            public string uuid;
 43122            public TPayload payload = new TPayload();
 123        }
 124
 125        public enum ACTION_BUTTON
 126        {
 127            POINTER,
 128            PRIMARY,
 129            SECONDARY,
 130            ANY
 131        }
 132
 133        [System.Serializable]
 134        public class OnClickEvent : UUIDEvent<OnClickEventPayload> { };
 135
 136        [System.Serializable]
 137        public class CameraModePayload
 138        {
 139            public CameraMode.ModeId cameraMode;
 140        };
 141
 142        [System.Serializable]
 143        public class IdleStateChangedPayload
 144        {
 145            public bool isIdle;
 146        };
 147
 148        [System.Serializable]
 149        public class OnPointerDownEvent : UUIDEvent<OnPointerEventPayload> { };
 150
 151        [System.Serializable]
 152        public class OnGlobalPointerEvent
 153        {
 154            public OnGlobalPointerEventPayload payload = new OnGlobalPointerEventPayload();
 155        };
 156
 157        [System.Serializable]
 158        public class OnPointerUpEvent : UUIDEvent<OnPointerEventPayload> { };
 159
 160        [System.Serializable]
 161        private class OnTextSubmitEvent : UUIDEvent<OnTextSubmitEventPayload> { };
 162
 163        [System.Serializable]
 164        private class OnTextInputChangeEvent : UUIDEvent<OnTextInputChangeEventPayload> { };
 165
 166        [System.Serializable]
 167        private class OnScrollChangeEvent : UUIDEvent<OnScrollChangeEventPayload> { };
 168
 169        [System.Serializable]
 170        private class OnFocusEvent : UUIDEvent<EmptyPayload> { };
 171
 172        [System.Serializable]
 173        private class OnBlurEvent : UUIDEvent<EmptyPayload> { };
 174
 175        [System.Serializable]
 176        public class OnEnterEvent : UUIDEvent<OnEnterEventPayload> { };
 177
 178        [System.Serializable]
 179        public class OnClickEventPayload
 180        {
 181            public ACTION_BUTTON buttonId = ACTION_BUTTON.POINTER;
 182        }
 183
 184        [System.Serializable]
 185        public class SendChatMessageEvent
 186        {
 187            public ChatMessage message;
 188        }
 189
 190        [System.Serializable]
 191        public class RemoveEntityComponentsPayLoad
 192        {
 193            public string entityId;
 194            public string componentId;
 195        };
 196
 197        [System.Serializable]
 198        public class StoreSceneStateEvent
 199        {
 200            public string type = "StoreSceneState";
 201            public string payload = "";
 202        };
 203
 204        [System.Serializable]
 205        public class OnPointerEventPayload
 206        {
 207            [System.Serializable]
 208            public class Hit
 209            {
 210                public Vector3 origin;
 211                public float length;
 212                public Vector3 hitPoint;
 213                public Vector3 normal;
 214                public Vector3 worldNormal;
 215                public string meshName;
 216                public string entityId;
 217            }
 218
 219            public ACTION_BUTTON buttonId;
 220            public Vector3 origin;
 221            public Vector3 direction;
 222            public Hit hit;
 223        }
 224
 225        [System.Serializable]
 226        public class OnGlobalPointerEventPayload : OnPointerEventPayload
 227        {
 228            public enum InputEventType
 229            {
 230                DOWN,
 231                UP
 232            }
 233
 234            public InputEventType type;
 235        }
 236
 237        [System.Serializable]
 238        public class OnTextSubmitEventPayload
 239        {
 240            public string id;
 241            public string text;
 242        }
 243
 244        [System.Serializable]
 245        public class OnTextInputChangeEventPayload
 246        {
 247            public string value;
 248        }
 249
 250        [System.Serializable]
 251        public class OnScrollChangeEventPayload
 252        {
 253            public Vector2 value;
 254            public int pointerId;
 255        }
 256
 257        [System.Serializable]
 258        public class EmptyPayload { }
 259
 260        [System.Serializable]
 261        public class MetricsModel
 262        {
 263            public int meshes;
 264            public int bodies;
 265            public int materials;
 266            public int textures;
 267            public int triangles;
 268            public int entities;
 269
 270            public static MetricsModel operator + (MetricsModel lhs, MetricsModel rhs)
 271            {
 272                return new MetricsModel()
 273                {
 274                    meshes = lhs.meshes + rhs.meshes,
 275                    bodies = lhs.bodies + rhs.bodies,
 276                    materials = lhs.materials + rhs.materials,
 277                    textures = lhs.textures + rhs.textures,
 278                    triangles = lhs.triangles + rhs.triangles,
 279                    entities = lhs.entities + rhs.entities
 280                };
 281            }
 282        }
 283
 284        [System.Serializable]
 285        private class OnMetricsUpdate
 286        {
 287            public MetricsModel given = new MetricsModel();
 288            public MetricsModel limit = new MetricsModel();
 289        }
 290
 291        [System.Serializable]
 292        public class OnEnterEventPayload { }
 293
 294        [System.Serializable]
 295        public class TransformPayload
 296        {
 297            public Vector3 position = Vector3.zero;
 298            public Quaternion rotation = Quaternion.identity;
 299            public Vector3 scale = Vector3.one;
 300        }
 301
 302        public class OnSendScreenshot
 303        {
 304            public string id;
 305            public string encodedTexture;
 306        };
 307
 308        [System.Serializable]
 309        public class GotoEvent
 310        {
 311            public int x;
 312            public int y;
 313        };
 314
 315        [System.Serializable]
 316        public class BaseResolution
 317        {
 318            public int baseResolution;
 319        };
 320
 321        //-----------------------------------------------------
 322        // Raycast
 323        [System.Serializable]
 324        public class RayInfo
 325        {
 326            public Vector3 origin;
 327            public Vector3 direction;
 328            public float distance;
 329        }
 330
 331        [System.Serializable]
 332        public class RaycastHitInfo
 333        {
 334            public bool didHit;
 335            public RayInfo ray;
 336
 337            public Vector3 hitPoint;
 338            public Vector3 hitNormal;
 339        }
 340
 341        [System.Serializable]
 342        public class HitEntityInfo
 343        {
 344            public string entityId;
 345            public string meshName;
 346        }
 347
 348        [System.Serializable]
 349        public class RaycastHitEntity : RaycastHitInfo
 350        {
 351            public HitEntityInfo entity;
 352        }
 353
 354        [System.Serializable]
 355        public class RaycastHitEntities : RaycastHitInfo
 356        {
 357            public RaycastHitEntity[] entities;
 358        }
 359
 360        [System.Serializable]
 361        public class RaycastResponse<T> where T : RaycastHitInfo
 362        {
 363            public string queryId;
 364            public string queryType;
 365            public T payload;
 366        }
 367
 368        // Note (Zak): We need to explicitly define this classes for the JsonUtility to
 369        // be able to serialize them
 370        [System.Serializable]
 371        public class RaycastHitFirstResponse : RaycastResponse<RaycastHitEntity> { }
 372
 373        [System.Serializable]
 374        public class RaycastHitAllResponse : RaycastResponse<RaycastHitEntities> { }
 375
 376        [System.Serializable]
 377        public class SendExpressionPayload
 378        {
 379            public string id;
 380            public long timestamp;
 381        }
 382
 383        [System.Serializable]
 384        public class UserAcceptedCollectiblesPayload
 385        {
 386            public string id;
 387        }
 388
 389        [System.Serializable]
 390        public class SendBlockPlayerPayload
 391        {
 392            public string userId;
 393        }
 394
 395        [System.Serializable]
 396        public class SendUnblockPlayerPayload
 397        {
 398            public string userId;
 399        }
 400
 401        [System.Serializable]
 402        public class TutorialStepPayload
 403        {
 404            public int tutorialStep;
 405        }
 406
 407        [System.Serializable]
 408        public class PerformanceReportPayload
 409        {
 410            public string samples;
 411            public bool fpsIsCapped;
 412            public int hiccupsInThousandFrames;
 413            public float hiccupsTime;
 414            public float totalTime;
 415        }
 416
 417        [System.Serializable]
 418        public class SystemInfoReportPayload
 419        {
 420            public string graphicsDeviceName = SystemInfo.graphicsDeviceName;
 421            public string graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion;
 422            public int graphicsMemorySize = SystemInfo.graphicsMemorySize;
 423            public string processorType = SystemInfo.processorType;
 424            public int processorCount = SystemInfo.processorCount;
 425            public int systemMemorySize = SystemInfo.systemMemorySize;
 426        }
 427
 428        [System.Serializable]
 429        public class GenericAnalyticPayload
 430        {
 431            public string eventName;
 432            public Dictionary<object, object> data;
 433        }
 434
 435        [System.Serializable]
 436        public class PerformanceHiccupPayload
 437        {
 438            public int hiccupsInThousandFrames;
 439            public float hiccupsTime;
 440            public float totalTime;
 441        }
 442
 443        [System.Serializable]
 444        public class TermsOfServiceResponsePayload
 445        {
 446            public string sceneId;
 447            public bool dontShowAgain;
 448            public bool accepted;
 449        }
 450
 451        [System.Serializable]
 452        public class OpenURLPayload
 453        {
 454            public string url;
 455        }
 456
 457        [System.Serializable]
 458        public class SendUserEmailPayload
 459        {
 460            public string userEmail;
 461        }
 462
 463        [System.Serializable]
 464        public class GIFSetupPayload
 465        {
 466            public string imageSource;
 467            public string id;
 468            public bool isWebGL1;
 469        }
 470
 471        [System.Serializable]
 472        public class RequestScenesInfoAroundParcelPayload
 473        {
 474            public Vector2 parcel;
 475            public int scenesAround;
 476        }
 477
 478        [System.Serializable]
 479        public class AudioStreamingPayload
 480        {
 481            public string url;
 482            public bool play;
 483            public float volume;
 484        }
 485
 486        [System.Serializable]
 487        public class SetScenesLoadRadiusPayload
 488        {
 489            public float newRadius;
 490        }
 491
 492        [System.Serializable]
 493        public class SetVoiceChatRecordingPayload
 494        {
 495            public bool recording;
 496        }
 497
 498        [System.Serializable]
 499        public class ApplySettingsPayload
 500        {
 501            public float voiceChatVolume;
 502            public int voiceChatAllowCategory;
 503        }
 504
 505        [System.Serializable]
 506        public class JumpInPayload
 507        {
 508            public FriendsController.UserStatus.Realm realm = new FriendsController.UserStatus.Realm();
 509            public Vector2 gridPosition;
 510        }
 511
 512        [System.Serializable]
 513        public class LoadingFeedbackMessage
 514        {
 515            public string message;
 516            public int loadPercentage;
 517        }
 518
 519        [System.Serializable]
 520        public class AnalyticsPayload
 521        {
 522            [System.Serializable]
 523            public class Property
 524            {
 525                public string key;
 526                public string value;
 527
 528                public Property(string key, string value)
 529                {
 530                    this.key = key;
 531                    this.value = value;
 532                }
 533            }
 534
 535            public string name;
 536            public Property[] properties;
 537        }
 538
 539        [System.Serializable]
 540        public class DelightedSurveyEnabledPayload
 541        {
 542            public bool enabled;
 543        }
 544
 545        [System.Serializable]
 546        public class ExternalActionSceneEventPayload
 547        {
 548            public string type;
 549            public string payload;
 550        }
 551
 552        [System.Serializable]
 553        public class MuteUserPayload
 554        {
 555            public string[] usersId;
 556            public bool mute;
 557        }
 558
 559        [System.Serializable]
 560        public class CloseUserAvatarPayload
 561        {
 562            public bool isSignUpFlow;
 563        }
 564
 565        [System.Serializable]
 566        public class StringPayload
 567        {
 568            public string value;
 569        }
 570
 571        [System.Serializable]
 572        public class KillPortableExperiencePayload
 573        {
 574            public string portableExperienceId;
 575        }
 576
 577        [System.Serializable]
 578        public class WearablesRequestFiltersPayload
 579        {
 580            public string ownedByUser;
 581            public string[] wearableIds;
 582            public string[] collectionIds;
 583        }
 584
 585        [System.Serializable]
 586        public class RequestWearablesPayload
 587        {
 588            public WearablesRequestFiltersPayload filters;
 589            public string context;
 590        }
 591
 592        [System.Serializable]
 593        public class SearchENSOwnerPayload
 594        {
 595            public string name;
 596            public int maxResults;
 597        }
 598
 599        [System.Serializable]
 600        public class UnpublishScenePayload
 601        {
 602            public string coordinates;
 603        }
 604
 605#if UNITY_WEBGL && !UNITY_EDITOR
 606    /**
 607     * This method is called after the first render. It marks the loading of the
 608     * rest of the JS client.
 609     */
 610    [DllImport("__Internal")] public static extern void StartDecentraland();
 611    [DllImport("__Internal")] public static extern void MessageFromEngine(string type, string message);
 612    [DllImport("__Internal")] public static extern string GetGraphicCard();
 613#else
 614        public static void StartDecentraland() { }
 615
 616        public static void MessageFromEngine(string type, string message)
 617        {
 618            if (OnMessageFromEngine != null)
 619            {
 620                OnMessageFromEngine.Invoke(type, message);
 621            }
 622
 623            if (VERBOSE)
 624            {
 625                Debug.Log("MessageFromEngine called with: " + type + ", " + message);
 626            }
 627        }
 628
 629        public static string GetGraphicCard() => "In Editor Graphic Card";
 630#endif
 631
 632        public static void SendMessage(string type)
 633        {
 634            // sending an empty JSON object to be compatible with other messages
 635            MessageFromEngine(type, "{}");
 636        }
 637
 638        public static void SendMessage<T>(string type, T message)
 639        {
 640            string messageJson = JsonUtility.ToJson(message);
 641
 642            if (VERBOSE)
 643            {
 644                Debug.Log($"Sending message: " + messageJson);
 645            }
 646
 647            MessageFromEngine(type, messageJson);
 648        }
 649
 650        private static ReportPositionPayload positionPayload = new ReportPositionPayload();
 651        private static CameraModePayload cameraModePayload = new CameraModePayload();
 652        private static IdleStateChangedPayload idleStateChangedPayload = new IdleStateChangedPayload();
 653        private static OnMetricsUpdate onMetricsUpdate = new OnMetricsUpdate();
 654        private static OnClickEvent onClickEvent = new OnClickEvent();
 655        private static OnPointerDownEvent onPointerDownEvent = new OnPointerDownEvent();
 656        private static OnPointerUpEvent onPointerUpEvent = new OnPointerUpEvent();
 657        private static OnTextSubmitEvent onTextSubmitEvent = new OnTextSubmitEvent();
 658        private static OnTextInputChangeEvent onTextInputChangeEvent = new OnTextInputChangeEvent();
 659        private static OnScrollChangeEvent onScrollChangeEvent = new OnScrollChangeEvent();
 660        private static OnFocusEvent onFocusEvent = new OnFocusEvent();
 661        private static OnBlurEvent onBlurEvent = new OnBlurEvent();
 662        private static OnEnterEvent onEnterEvent = new OnEnterEvent();
 663        private static OnSendScreenshot onSendScreenshot = new OnSendScreenshot();
 664        private static OnPointerEventPayload onPointerEventPayload = new OnPointerEventPayload();
 665        private static OnGlobalPointerEventPayload onGlobalPointerEventPayload = new OnGlobalPointerEventPayload();
 666        private static OnGlobalPointerEvent onGlobalPointerEvent = new OnGlobalPointerEvent();
 667        private static AudioStreamingPayload onAudioStreamingEvent = new AudioStreamingPayload();
 668        private static SetVoiceChatRecordingPayload setVoiceChatRecordingPayload = new SetVoiceChatRecordingPayload();
 669        private static SetScenesLoadRadiusPayload setScenesLoadRadiusPayload = new SetScenesLoadRadiusPayload();
 670        private static ApplySettingsPayload applySettingsPayload = new ApplySettingsPayload();
 671        private static GIFSetupPayload gifSetupPayload = new GIFSetupPayload();
 672        private static JumpInPayload jumpInPayload = new JumpInPayload();
 673        private static GotoEvent gotoEvent = new GotoEvent();
 674        private static SendChatMessageEvent sendChatMessageEvent = new SendChatMessageEvent();
 675        private static BaseResolution baseResEvent = new BaseResolution();
 676        private static AnalyticsPayload analyticsEvent = new AnalyticsPayload();
 677        private static DelightedSurveyEnabledPayload delightedSurveyEnabled = new DelightedSurveyEnabledPayload();
 678        private static ExternalActionSceneEventPayload sceneExternalActionEvent = new ExternalActionSceneEventPayload();
 679        private static MuteUserPayload muteUserEvent = new MuteUserPayload();
 680        private static StoreSceneStateEvent storeSceneState = new StoreSceneStateEvent();
 681        private static CloseUserAvatarPayload closeUserAvatarPayload = new CloseUserAvatarPayload();
 682        private static StringPayload stringPayload = new StringPayload();
 683        private static KillPortableExperiencePayload killPortableExperiencePayload = new KillPortableExperiencePayload()
 684        private static RequestWearablesPayload requestWearablesPayload = new RequestWearablesPayload();
 685        private static SearchENSOwnerPayload searchEnsOwnerPayload = new SearchENSOwnerPayload();
 686
 687        public static void SendSceneEvent<T>(string sceneId, string eventType, T payload)
 688        {
 689            SceneEvent<T> sceneEvent = new SceneEvent<T>();
 690            sceneEvent.sceneId = sceneId;
 691            sceneEvent.eventType = eventType;
 692            sceneEvent.payload = payload;
 693
 694            SendMessage("SceneEvent", sceneEvent);
 695        }
 696
 697        private static void SendAllScenesEvent<T>(string eventType, T payload)
 698        {
 699            AllScenesEvent<T> allScenesEvent = new AllScenesEvent<T>();
 700            allScenesEvent.eventType = eventType;
 701            allScenesEvent.payload = payload;
 702
 703            SendMessage("AllScenesEvent", allScenesEvent);
 704        }
 705
 706        public static void ReportPosition(Vector3 position, Quaternion rotation, float playerHeight)
 707        {
 708            positionPayload.position = position;
 709            positionPayload.rotation = rotation;
 710            positionPayload.playerHeight = playerHeight;
 711
 712            SendMessage("ReportPosition", positionPayload);
 713        }
 714
 715        public static void ReportCameraChanged(CameraMode.ModeId cameraMode)
 716        {
 717            cameraModePayload.cameraMode = cameraMode;
 718            SendAllScenesEvent("cameraModeChanged", cameraModePayload);
 719        }
 720
 721        public static void ReportIdleStateChanged(bool isIdle)
 722        {
 723            idleStateChangedPayload.isIdle = isIdle;
 724            SendAllScenesEvent("idleStateChanged", idleStateChangedPayload);
 725        }
 726
 727        public static void ReportControlEvent<T>(T controlEvent) where T : ControlEvent { SendMessage("ControlEvent", co
 728
 729        public static void BuilderInWorldMessage(string type, string message) { MessageFromEngine(type, message); }
 730
 731        public static void ReportOnClickEvent(string sceneId, string uuid)
 732        {
 733            if (string.IsNullOrEmpty(uuid))
 734            {
 735                return;
 736            }
 737
 738            onClickEvent.uuid = uuid;
 739
 740            SendSceneEvent(sceneId, "uuidEvent", onClickEvent);
 741        }
 742
 743        private static void ReportRaycastResult<T, P>(string sceneId, string queryId, string queryType, P payload) where
 744        {
 745            T response = new T();
 746            response.queryId = queryId;
 747            response.queryType = queryType;
 748            response.payload = payload;
 749
 750            SendSceneEvent<T>(sceneId, "raycastResponse", response);
 751        }
 752
 753        public static void ReportRaycastHitFirstResult(string sceneId, string queryId, RaycastType raycastType, RaycastH
 754
 755        public static void ReportRaycastHitAllResult(string sceneId, string queryId, RaycastType raycastType, RaycastHit
 756
 757        private static OnPointerEventPayload.Hit CreateHitObject(string entityId, string meshName, Vector3 point, Vector
 758        {
 759            OnPointerEventPayload.Hit hit = new OnPointerEventPayload.Hit();
 760
 761            hit.hitPoint = point;
 762            hit.length = distance;
 763            hit.normal = normal;
 764            hit.worldNormal = normal;
 765            hit.meshName = meshName;
 766            hit.entityId = entityId;
 767
 768            return hit;
 769        }
 770
 771        private static void SetPointerEventPayload(OnPointerEventPayload pointerEventPayload, ACTION_BUTTON buttonId, st
 772        {
 773            pointerEventPayload.origin = ray.origin;
 774            pointerEventPayload.direction = ray.direction;
 775            pointerEventPayload.buttonId = buttonId;
 776
 777            if (isHitInfoValid)
 778                pointerEventPayload.hit = CreateHitObject(entityId, meshName, point, normal, distance);
 779            else
 780                pointerEventPayload.hit = null;
 781        }
 782
 783        public static void ReportGlobalPointerDownEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal, 
 784        {
 785            SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId, entityId, meshName, ra
 786            onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.DOWN;
 787
 788            onGlobalPointerEvent.payload = onGlobalPointerEventPayload;
 789
 790            SendSceneEvent(sceneId, "pointerEvent", onGlobalPointerEvent);
 791        }
 792
 793        public static void ReportGlobalPointerUpEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal, fl
 794        {
 795            SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId, entityId, meshName, ra
 796            onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.UP;
 797
 798            onGlobalPointerEvent.payload = onGlobalPointerEventPayload;
 799
 800            SendSceneEvent(sceneId, "pointerEvent", onGlobalPointerEvent);
 801        }
 802
 803        public static void ReportOnPointerDownEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, string entityId
 804        {
 805            if (string.IsNullOrEmpty(uuid))
 806            {
 807                return;
 808            }
 809
 810            onPointerDownEvent.uuid = uuid;
 811            SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point, normal, distance, is
 812            onPointerDownEvent.payload = onPointerEventPayload;
 813
 814            SendSceneEvent(sceneId, "uuidEvent", onPointerDownEvent);
 815        }
 816
 817        public static void ReportOnPointerUpEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, string entityId, 
 818        {
 819            if (string.IsNullOrEmpty(uuid))
 820            {
 821                return;
 822            }
 823
 824            onPointerUpEvent.uuid = uuid;
 825            SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point, normal, distance, is
 826            onPointerUpEvent.payload = onPointerEventPayload;
 827
 828            SendSceneEvent(sceneId, "uuidEvent", onPointerUpEvent);
 829        }
 830
 831        public static void ReportOnTextSubmitEvent(string sceneId, string uuid, string text)
 832        {
 833            if (string.IsNullOrEmpty(uuid))
 834            {
 835                return;
 836            }
 837
 838            onTextSubmitEvent.uuid = uuid;
 839            onTextSubmitEvent.payload.text = text;
 840
 841            SendSceneEvent(sceneId, "uuidEvent", onTextSubmitEvent);
 842        }
 843
 844        public static void ReportOnTextInputChangedEvent(string sceneId, string uuid, string text)
 845        {
 846            if (string.IsNullOrEmpty(uuid))
 847            {
 848                return;
 849            }
 850
 851            onTextInputChangeEvent.uuid = uuid;
 852            onTextInputChangeEvent.payload.value = text;
 853
 854            SendSceneEvent(sceneId, "uuidEvent", onTextInputChangeEvent);
 855        }
 856
 857        public static void ReportOnFocusEvent(string sceneId, string uuid)
 858        {
 859            if (string.IsNullOrEmpty(uuid))
 860            {
 861                return;
 862            }
 863
 864            onFocusEvent.uuid = uuid;
 865            SendSceneEvent(sceneId, "uuidEvent", onFocusEvent);
 866        }
 867
 868        public static void ReportOnBlurEvent(string sceneId, string uuid)
 869        {
 870            if (string.IsNullOrEmpty(uuid))
 871            {
 872                return;
 873            }
 874
 875            onBlurEvent.uuid = uuid;
 876            SendSceneEvent(sceneId, "uuidEvent", onBlurEvent);
 877        }
 878
 879        public static void ReportOnScrollChange(string sceneId, string uuid, Vector2 value, int pointerId)
 880        {
 881            if (string.IsNullOrEmpty(uuid))
 882            {
 883                return;
 884            }
 885
 886            onScrollChangeEvent.uuid = uuid;
 887            onScrollChangeEvent.payload.value = value;
 888            onScrollChangeEvent.payload.pointerId = pointerId;
 889
 890            SendSceneEvent(sceneId, "uuidEvent", onScrollChangeEvent);
 891        }
 892
 893        public static void ReportEvent<T>(string sceneId, T @event) { SendSceneEvent(sceneId, "uuidEvent", @event); }
 894
 895        public static void ReportOnMetricsUpdate(string sceneId, MetricsModel current,
 896            MetricsModel limit)
 897        {
 898            onMetricsUpdate.given = current;
 899            onMetricsUpdate.limit = limit;
 900
 901            SendSceneEvent(sceneId, "metricsUpdate", onMetricsUpdate);
 902        }
 903
 904        public static void ReportOnEnterEvent(string sceneId, string uuid)
 905        {
 906            if (string.IsNullOrEmpty(uuid))
 907                return;
 908
 909            onEnterEvent.uuid = uuid;
 910
 911            SendSceneEvent(sceneId, "uuidEvent", onEnterEvent);
 912        }
 913
 914        public static void LogOut() { SendMessage("LogOut"); }
 915
 916        public static void RedirectToSignUp() { SendMessage("RedirectToSignUp"); }
 917
 918        public static void PreloadFinished(string sceneId) { SendMessage("PreloadFinished", sceneId); }
 919
 920        public static void ReportMousePosition(Vector3 mousePosition, string id)
 921        {
 922            positionPayload.mousePosition = mousePosition;
 923            positionPayload.id = id;
 924            SendMessage("ReportMousePosition", positionPayload);
 925        }
 926
 927        public static void SendScreenshot(string encodedTexture, string id)
 928        {
 929            onSendScreenshot.encodedTexture = encodedTexture;
 930            onSendScreenshot.id = id;
 931            SendMessage("SendScreenshot", onSendScreenshot);
 932        }
 933
 934        public static void SetDelightedSurveyEnabled(bool enabled)
 935        {
 936            delightedSurveyEnabled.enabled = enabled;
 937            SendMessage("SetDelightedSurveyEnabled", delightedSurveyEnabled);
 938        }
 939
 940        public static void SetScenesLoadRadius(float newRadius)
 941        {
 942            setScenesLoadRadiusPayload.newRadius = newRadius;
 943            SendMessage("SetScenesLoadRadius", setScenesLoadRadiusPayload);
 944        }
 945
 946        [System.Serializable]
 947        public class SaveAvatarPayload
 948        {
 949            public string face;
 950            public string face128;
 951            public string face256;
 952            public string body;
 953            public bool isSignUpFlow;
 954            public AvatarModel avatar;
 955        }
 956
 957        public static class RendererAuthenticationType
 958        {
 959            public static string Guest => "guest";
 960            public static string WalletConnect => "wallet_connect";
 961        }
 962
 963        [System.Serializable]
 964        public class SendAuthenticationPayload
 965        {
 966            public string rendererAuthenticationType;
 967        }
 968
 969        [System.Serializable]
 970        public class SendPassportPayload
 971        {
 972            public string name;
 973            public string email;
 974        }
 975
 976        [System.Serializable]
 977        public class SendSaveUserUnverifiedNamePayload
 978        {
 979            public string newUnverifiedName;
 980        }
 981
 982        public static void RequestOwnProfileUpdate() { SendMessage("RequestOwnProfileUpdate"); }
 983
 984        public static void SendSaveAvatar(AvatarModel avatar, Texture2D faceSnapshot, Texture2D face128Snapshot, Texture
 985        {
 986            var payload = new SaveAvatarPayload()
 987            {
 988                avatar = avatar,
 989                face = System.Convert.ToBase64String(faceSnapshot.EncodeToPNG()),
 990                face128 = System.Convert.ToBase64String(face128Snapshot.EncodeToPNG()),
 991                face256 = System.Convert.ToBase64String(face256Snapshot.EncodeToPNG()),
 992                body = System.Convert.ToBase64String(bodySnapshot.EncodeToPNG()),
 993                isSignUpFlow = isSignUpFlow
 994            };
 995            SendMessage("SaveUserAvatar", payload);
 996        }
 997
 998        public static void SendAuthentication(string rendererAuthenticationType) { SendMessage("SendAuthentication", new
 999
 1000        public static void SendPassport(string name, string email) { SendMessage("SendPassport", new SendPassportPayload
 1001
 1002        public static void SendSaveUserUnverifiedName(string newName)
 1003        {
 1004            var payload = new SendSaveUserUnverifiedNamePayload()
 1005            {
 1006                newUnverifiedName = newName
 1007            };
 1008
 1009            SendMessage("SaveUserUnverifiedName", payload);
 1010        }
 1011
 1012        public static void SendUserAcceptedCollectibles(string airdropId) { SendMessage("UserAcceptedCollectibles", new 
 1013
 1014        public static void SaveUserTutorialStep(int newTutorialStep) { SendMessage("SaveUserTutorialStep", new TutorialS
 1015
 1016        public static void SendPerformanceReport(string encodedFrameTimesInMS, bool usingFPSCap, int hiccupsInThousandFr
 1017        {
 1018            SendMessage("PerformanceReport", new PerformanceReportPayload()
 1019            {
 1020                samples = encodedFrameTimesInMS,
 1021                fpsIsCapped = usingFPSCap,
 1022                hiccupsInThousandFrames = hiccupsInThousandFrames,
 1023                hiccupsTime = hiccupsTime,
 1024                totalTime = totalTime
 1025            });
 1026        }
 1027
 1028        public static void SendSystemInfoReport() { SendMessage("SystemInfoReport", new SystemInfoReportPayload()); }
 1029
 1030        public static void SendTermsOfServiceResponse(string sceneId, bool accepted, bool dontShowAgain)
 1031        {
 1032            var payload = new TermsOfServiceResponsePayload()
 1033            {
 1034                sceneId = sceneId,
 1035                accepted = accepted,
 1036                dontShowAgain = dontShowAgain
 1037            };
 1038            SendMessage("TermsOfServiceResponse", payload);
 1039        }
 1040
 1041        public static void SendExpression(string expressionID, long timestamp)
 1042        {
 1043            SendMessage("TriggerExpression", new SendExpressionPayload()
 1044            {
 1045                id = expressionID,
 1046                timestamp = timestamp
 1047            });
 1048        }
 1049
 1050        public static void ReportMotdClicked() { SendMessage("MotdConfirmClicked"); }
 1051
 1052        public static void OpenURL(string url) { SendMessage("OpenWebURL", new OpenURLPayload { url = url }); }
 1053
 1054        public static void SendReportScene(string sceneID) { SendMessage("ReportScene", sceneID); }
 1055
 1056        public static void SendReportPlayer(string playerName) { SendMessage("ReportPlayer", playerName); }
 1057
 1058        public static void SendBlockPlayer(string userId)
 1059        {
 1060            SendMessage("BlockPlayer", new SendBlockPlayerPayload()
 1061            {
 1062                userId = userId
 1063            });
 1064        }
 1065
 1066        public static void SendUnblockPlayer(string userId)
 1067        {
 1068            SendMessage("UnblockPlayer", new SendUnblockPlayerPayload()
 1069            {
 1070                userId = userId
 1071            });
 1072        }
 1073
 1074        public static void SendUserEmail(string email)
 1075        {
 1076            SendMessage("ReportUserEmail", new SendUserEmailPayload()
 1077            {
 1078                userEmail = email
 1079            });
 1080        }
 1081
 1082        public static void RequestScenesInfoAroundParcel(Vector2 parcel, int maxScenesArea)
 1083        {
 1084            SendMessage("RequestScenesInfoInArea", new RequestScenesInfoAroundParcelPayload()
 1085            {
 1086                parcel = parcel,
 1087                scenesAround = maxScenesArea
 1088            });
 1089        }
 1090
 1091        public static void SendAudioStreamEvent(string url, bool play, float volume)
 1092        {
 1093            onAudioStreamingEvent.url = url;
 1094            onAudioStreamingEvent.play = play;
 1095            onAudioStreamingEvent.volume = volume;
 1096            SendMessage("SetAudioStream", onAudioStreamingEvent);
 1097        }
 1098
 1099        public static void SendSetVoiceChatRecording(bool recording)
 1100        {
 1101            setVoiceChatRecordingPayload.recording = recording;
 1102            SendMessage("SetVoiceChatRecording", setVoiceChatRecordingPayload);
 1103        }
 1104
 1105        public static void ToggleVoiceChatRecording() { SendMessage("ToggleVoiceChatRecording"); }
 1106
 1107        public static void ApplySettings(float voiceChatVolume, int voiceChatAllowCategory)
 1108        {
 1109            applySettingsPayload.voiceChatVolume = voiceChatVolume;
 1110            applySettingsPayload.voiceChatAllowCategory = voiceChatAllowCategory;
 1111            SendMessage("ApplySettings", applySettingsPayload);
 1112        }
 1113
 1114        public static void RequestGIFProcessor(string gifURL, string gifId, bool isWebGL1)
 1115        {
 1116            gifSetupPayload.imageSource = gifURL;
 1117            gifSetupPayload.id = gifId;
 1118            gifSetupPayload.isWebGL1 = isWebGL1;
 1119
 1120            SendMessage("RequestGIFProcessor", gifSetupPayload);
 1121        }
 1122
 1123        public static void DeleteGIF(string id)
 1124        {
 1125            stringPayload.value = id;
 1126            SendMessage("DeleteGIF", stringPayload);
 1127        }
 1128
 1129        public static void GoTo(int x, int y)
 1130        {
 1131            gotoEvent.x = x;
 1132            gotoEvent.y = y;
 1133            SendMessage("GoTo", gotoEvent);
 1134        }
 1135
 1136        public static void GoToCrowd() { SendMessage("GoToCrowd"); }
 1137
 1138        public static void GoToMagic() { SendMessage("GoToMagic"); }
 1139
 1140        public static void JumpIn(int x, int y, string serverName, string layerName)
 1141        {
 1142            jumpInPayload.realm.serverName = serverName;
 1143            jumpInPayload.realm.layer = layerName;
 1144
 1145            jumpInPayload.gridPosition.x = x;
 1146            jumpInPayload.gridPosition.y = y;
 1147
 1148            SendMessage("JumpIn", jumpInPayload);
 1149        }
 1150
 1151        public static void SendChatMessage(ChatMessage message)
 1152        {
 1153            sendChatMessageEvent.message = message;
 1154            SendMessage("SendChatMessage", sendChatMessageEvent);
 1155        }
 1156
 1157        public static void UpdateFriendshipStatus(FriendsController.FriendshipUpdateStatusMessage message) { SendMessage
 1158
 1159        public static void ScenesLoadingFeedback(LoadingFeedbackMessage message) { SendMessage("ScenesLoadingFeedback", 
 1160
 1161        public static void FetchHotScenes() { SendMessage("FetchHotScenes"); }
 1162
 1163        public static void SetBaseResolution(int resolution)
 1164        {
 1165            baseResEvent.baseResolution = resolution;
 1166            SendMessage("SetBaseResolution", baseResEvent);
 1167        }
 1168
 1169        public static void ReportAnalyticsEvent(string eventName) { ReportAnalyticsEvent(eventName, null); }
 1170
 1171        public static void ReportAnalyticsEvent(string eventName, AnalyticsPayload.Property[] eventProperties)
 1172        {
 1173            analyticsEvent.name = eventName;
 1174            analyticsEvent.properties = eventProperties;
 1175            SendMessage("Track", analyticsEvent);
 1176        }
 1177
 1178        public static void FetchBalanceOfMANA() { SendMessage("FetchBalanceOfMANA"); }
 1179
 1180        public static void SendSceneExternalActionEvent(string sceneId, string type, string payload)
 1181        {
 1182            sceneExternalActionEvent.type = type;
 1183            sceneExternalActionEvent.payload = payload;
 1184            SendSceneEvent(sceneId, "externalAction", sceneExternalActionEvent);
 1185        }
 1186
 1187        public static void SetMuteUsers(string[] usersId, bool mute)
 1188        {
 1189            muteUserEvent.usersId = usersId;
 1190            muteUserEvent.mute = mute;
 1191            SendMessage("SetMuteUsers", muteUserEvent);
 1192        }
 1193
 1194        public static void SendCloseUserAvatar(bool isSignUpFlow)
 1195        {
 1196            closeUserAvatarPayload.isSignUpFlow = isSignUpFlow;
 1197            SendMessage("CloseUserAvatar", closeUserAvatarPayload);
 1198        }
 1199
 1200        public static void KillPortableExperience(string portableExperienceId)
 1201        {
 1202            killPortableExperiencePayload.portableExperienceId = portableExperienceId;
 1203            SendMessage("KillPortableExperience", killPortableExperiencePayload);
 1204        }
 1205
 1206        public static void RequestWearables(
 1207            string ownedByUser,
 1208            string[] wearableIds,
 1209            string[] collectionIds,
 1210            string context)
 1211        {
 1212            requestWearablesPayload.filters = new WearablesRequestFiltersPayload
 1213            {
 1214                ownedByUser = ownedByUser,
 1215                wearableIds = wearableIds,
 1216                collectionIds = collectionIds
 1217            };
 1218
 1219            requestWearablesPayload.context = context;
 1220
 1221            SendMessage("RequestWearables", requestWearablesPayload);
 1222        }
 1223
 1224        public static void SearchENSOwner(string name, int maxResults)
 1225        {
 1226            searchEnsOwnerPayload.name = name;
 1227            searchEnsOwnerPayload.maxResults = maxResults;
 1228
 1229            SendMessage("SearchENSOwner", searchEnsOwnerPayload);
 1230        }
 1231
 1232        public static void RequestUserProfile(string userId)
 1233        {
 1234            stringPayload.value = userId;
 1235            SendMessage("RequestUserProfile", stringPayload);
 1236        }
 1237
 1238        public static void ReportAvatarFatalError() { SendMessage("ReportAvatarFatalError"); }
 1239
 1240        public static void UnpublishScene(Vector2Int sceneCoordinates)
 1241        {
 1242            var payload = new UnpublishScenePayload() { coordinates = $"{sceneCoordinates.x},{sceneCoordinates.y}" };
 1243            SendMessage("UnpublishScene", payload);
 1244        }
 1245    }
 1246}

Methods/Properties

UUIDEvent()