< Summary

Class:Builder.DCLBuilderBridge
Assembly:Builder
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Builder/Scripts/DCLBuilderBridge.cs
Covered lines:118
Uncovered lines:185
Coverable lines:303
Total lines:688
Line coverage:38.9% (118 of 303)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DCLBuilderBridge()0%110100%
MousePayload()0%2100%
PreloadFile(...)0%42600%
GetMousePosition(...)0%20400%
SelectGizmo(...)0%12300%
ResetObject()0%12300%
ZoomDelta(...)0%20400%
SetPlayMode(...)0%12300%
TakeScreenshot(...)0%12300%
ResetBuilderScene()0%5.515072.73%
SetBuilderCameraPosition(...)0%56700%
SetBuilderCameraRotation(...)0%72800%
ResetBuilderCameraZoom()0%12300%
SetGridResolution(...)0%12300%
OnBuilderKeyDown(...)0%12300%
UnloadBuilderScene(...)0%6200%
SetSelectedEntities(...)0%12300%
GetCameraTargetBuilder(...)0%12300%
SetBuilderConfiguration(...)0%20400%
GetLoadedScene()0%330100%
Awake()0%8.018095.45%
Start()0%110100%
Update()0%2.52050%
OnEntityIsAdded(...)0%3.033085.71%
OnEntityIsRemoved(...)0%3.143075%
OnEntityShapeUpdated(...)0%110100%
OnEnable()0%220100%
OnDisable()0%110100%
OnObjectDragEnd()0%12300%
OnObjectDrag()0%2100%
OnGizmoTransformObjectEnded(...)0%12300%
OnGizmoTransformObject(...)0%2100%
OnObjectSelected(...)0%2100%
OnNoObjectSelected()0%2100%
OnSelectionChanged(...)0%2100%
NotifyGizmosTransformEvent(...)0%2100%
NotifyGizmosSelectedEvent(...)0%2100%
TakeScreenshotRoutine()0%20400%
SetPlayMode(...)0%72800%
OnRenderingStateChanged(...)0%6200%
SetCaptureKeyboardInputEnabled(...)0%2100%
SetCurrentScene()0%4.14081.82%
HideHUDs()0%3.033085.71%
OnDestroy()0%220100%
AddBuilderEntityComponent(...)0%110100%
ProcessEntityBoundaries(...)0%5.515072.73%
SendOutOfBoundariesEntities()0%2100%
EvaluateSelectedEntitiesPosition()0%20400%
SetupRendererPipeline()0%220100%
SetupQualitySettings()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Builder/Scripts/DCLBuilderBridge.cs

#LineLine coverage
 1using System;
 2using Builder.Gizmos;
 3using DCL;
 4using DCL.Components;
 5using DCL.Configuration;
 6using DCL.Controllers;
 7using DCL.Helpers;
 8using DCL.Interface;
 9using DCL.Models;
 10using System.Collections;
 11using System.Collections.Generic;
 12using DCL.Camera;
 13using UnityEngine;
 14using UnityEngine.Rendering;
 15using Environment = DCL.Environment;
 16using Object = UnityEngine.Object;
 17
 18namespace Builder
 19{
 20    public class DCLBuilderBridge : MonoBehaviour
 21    {
 22        public DCLBuilderRaycast builderRaycast;
 23
 24        static bool LOG_MESSAGES = false;
 25
 26        public delegate void SetGridResolutionDelegate(float position, float rotation, float scale);
 27
 28        public static System.Action<float> OnZoomFromUI;
 29        public static System.Action<string> OnSelectGizmo;
 30        public static System.Action OnResetObject;
 31        public static System.Action<DCLBuilderEntity> OnEntityAdded;
 32        public static System.Action<DCLBuilderEntity> OnEntityRemoved;
 33        public static System.Action<bool> OnPreviewModeChanged;
 34        public static System.Action OnResetBuilderScene;
 35        public static System.Action<Vector3> OnSetCameraPosition;
 36        public static System.Action<float, float> OnSetCameraRotation;
 37        public static System.Action OnResetCameraZoom;
 38        public static System.Action<KeyCode> OnSetKeyDown;
 39        public static event SetGridResolutionDelegate OnSetGridResolution;
 40        public static System.Action<ParcelScene> OnSceneChanged;
 41        public static System.Action<string[]> OnBuilderSelectEntity;
 42
 43        private MouseCatcher mouseCatcher;
 44        private ParcelScene currentScene;
 45        private CameraController cameraController;
 46        private CursorController cursorController;
 47        private Vector3 defaultCharacterPosition;
 48
 49        private bool isPreviewMode = false;
 150        private List<string> outOfBoundariesEntitiesId = new List<string>();
 51        private int lastEntitiesOutOfBoundariesCount = 0;
 52        private List<EditableEntity> selectedEntities;
 53        private bool entitiesMoved = false;
 54
 55        private bool isGameObjectActive = false;
 56
 57        private Coroutine screenshotCoroutine = null;
 58
 159        private DCLBuilderWebInterface builderWebInterface = new DCLBuilderWebInterface();
 60
 61        [System.Serializable]
 62        private class MousePayload
 63        {
 064            public string id = string.Empty;
 65            public float x = 0;
 66            public float y = 0;
 67        }
 68
 69        [System.Serializable]
 70        private class SetGridResolutionPayload
 71        {
 72            public float position = 0;
 73            public float rotation = 0;
 74            public float scale = 0;
 75        }
 76
 77        [System.Serializable]
 78        private class SelectedEntitiesPayload
 79        {
 80            public string[] entities = null;
 81        };
 82
 83        #region "Messages from Explorer"
 84
 85        public void PreloadFile(string url)
 86        {
 087            if (LOG_MESSAGES)
 088                Debug.Log($"RECEIVE: PreloadFile {url}");
 089            if (currentScene != null)
 90            {
 091                string[] split = url.Split('\t');
 092                string hash = split[0];
 093                string file = split[1];
 94
 095                if (!currentScene.contentProvider.fileToHash.ContainsKey(file.ToLower()))
 96                {
 097                    currentScene.contentProvider.fileToHash.Add(file.ToLower(), hash);
 98                }
 99
 0100                if (file.EndsWith(".glb") || file.EndsWith(".gltf"))
 101                {
 0102                    AssetPromise_PrefetchGLTF gltfPromise = new AssetPromise_PrefetchGLTF(currentScene.contentProvider, 
 0103                    AssetPromiseKeeper_GLTF.i.Keep(gltfPromise);
 104                }
 105            }
 0106        }
 107
 108        public void GetMousePosition(string newJson)
 109        {
 0110            if (LOG_MESSAGES)
 0111                Debug.Log($"RECEIVE: GetMousePosition {newJson}");
 0112            MousePayload m = Utils.SafeFromJson<MousePayload>(newJson);
 113
 0114            Vector3 mousePosition = new Vector3(m.x, Screen.height - m.y, 0);
 115            Vector3 hitPoint;
 116
 0117            if (builderRaycast.RaycastToGround(mousePosition, out hitPoint))
 118            {
 0119                if (LOG_MESSAGES)
 0120                    Debug.Log($"SEND: ReportMousePosition {m.id} {hitPoint}");
 0121                WebInterface.ReportMousePosition(hitPoint, m.id);
 122            }
 0123        }
 124
 125        public void SelectGizmo(string gizmoType)
 126        {
 0127            if (LOG_MESSAGES)
 0128                Debug.Log($"RECEIVE: SelectGizmo {gizmoType}");
 0129            OnSelectGizmo?.Invoke(gizmoType);
 0130        }
 131
 132        public void ResetObject()
 133        {
 0134            if (LOG_MESSAGES)
 0135                Debug.Log($"RECEIVE: ResetObject");
 0136            OnResetObject?.Invoke();
 0137        }
 138
 139        public void ZoomDelta(string delta)
 140        {
 0141            if (LOG_MESSAGES)
 0142                Debug.Log($"RECEIVE: ZoomDelta {delta}");
 0143            float d = 0;
 0144            if (float.TryParse(delta, out d))
 145            {
 0146                OnZoomFromUI?.Invoke(d);
 147            }
 0148        }
 149
 150        public void SetPlayMode(string on)
 151        {
 0152            if (LOG_MESSAGES)
 0153                Debug.Log($"RECEIVE: SetPlayMode {on}");
 0154            bool isPreview = false;
 0155            if (bool.TryParse(on, out isPreview))
 156            {
 0157                SetPlayMode(isPreview);
 158            }
 0159        }
 160
 161        public void TakeScreenshot(string id)
 162        {
 0163            if (LOG_MESSAGES)
 0164                Debug.Log($"RECEIVE: TakeScreenshot {id}");
 0165            if (screenshotCoroutine != null)
 166            {
 0167                StopCoroutine(screenshotCoroutine);
 168            }
 169
 0170            screenshotCoroutine = StartCoroutine(TakeScreenshotRoutine(id));
 0171        }
 172
 173        public void ResetBuilderScene()
 174        {
 1175            if (LOG_MESSAGES)
 0176                Debug.Log($"RECEIVE: ResetBuilderScene");
 1177            OnResetBuilderScene?.Invoke();
 1178            DCLCharacterController.i?.gameObject.SetActive(false);
 1179            outOfBoundariesEntitiesId.Clear();
 180
 1181            if (currentScene)
 182            {
 0183                currentScene.OnEntityAdded -= OnEntityIsAdded;
 0184                currentScene.OnEntityRemoved -= OnEntityIsRemoved;
 185            }
 186
 1187            SetCurrentScene();
 1188            HideHUDs();
 1189        }
 190
 191        public void SetBuilderCameraPosition(string position)
 192        {
 0193            if (LOG_MESSAGES)
 0194                Debug.Log($"RECEIVE: SetBuilderCameraPosition {position}");
 0195            if (!string.IsNullOrEmpty(position))
 196            {
 0197                string[] splitPositionStr = position.Split(',');
 0198                if (splitPositionStr.Length == 3)
 199                {
 0200                    float x, y, z = 0;
 0201                    float.TryParse(splitPositionStr[0], out x);
 0202                    float.TryParse(splitPositionStr[1], out y);
 0203                    float.TryParse(splitPositionStr[2], out z);
 204
 0205                    if (isPreviewMode)
 206                    {
 0207                        DCLCharacterController.i?.SetPosition(new Vector3(x, y, z));
 0208                    }
 209                    else
 210                    {
 0211                        OnSetCameraPosition?.Invoke(new Vector3(x, y, z));
 212                    }
 213                }
 214            }
 0215        }
 216
 217        public void SetBuilderCameraRotation(string yawpitchRotation)
 218        {
 0219            if (LOG_MESSAGES)
 0220                Debug.Log($"RECEIVE: SetBuilderCameraRotation {yawpitchRotation}");
 0221            if (!string.IsNullOrEmpty(yawpitchRotation))
 222            {
 0223                string[] splitRotationStr = yawpitchRotation.Split(',');
 0224                if (splitRotationStr.Length == 2)
 225                {
 0226                    float yaw, pitch = 0;
 0227                    float.TryParse(splitRotationStr[0], out yaw);
 0228                    float.TryParse(splitRotationStr[1], out pitch);
 229
 0230                    if (isPreviewMode)
 231                    {
 0232                        if (DCLCharacterController.i != null)
 233                        {
 0234                            DCLCharacterController.i.transform.rotation = Quaternion.Euler(0f, yaw * Mathf.Rad2Deg, 0f);
 235                        }
 236
 0237                        if (cameraController)
 238                        {
 0239                            var cameraRotation = new CameraController.SetRotationPayload()
 240                            {
 241                                x = pitch * Mathf.Rad2Deg,
 242                                y = 0,
 243                                z = 0
 244                            };
 0245                            cameraController.SetRotation(JsonUtility.ToJson(cameraRotation));
 246                        }
 0247                    }
 248                    else
 249                    {
 0250                        OnSetCameraRotation?.Invoke(yaw * Mathf.Rad2Deg, pitch * Mathf.Rad2Deg);
 251                    }
 252                }
 253            }
 0254        }
 255
 256        public void ResetBuilderCameraZoom()
 257        {
 0258            if (LOG_MESSAGES)
 0259                Debug.Log($"RECEIVE: ResetBuilderCameraZoom");
 0260            OnResetCameraZoom?.Invoke();
 0261        }
 262
 263        public void SetGridResolution(string payloadJson)
 264        {
 0265            if (LOG_MESSAGES)
 0266                Debug.Log($"RECEIVE: SetGridResolution {payloadJson}");
 267            try
 268            {
 0269                SetGridResolutionPayload payload = JsonUtility.FromJson<SetGridResolutionPayload>(payloadJson);
 0270                OnSetGridResolution?.Invoke(payload.position, payload.rotation, payload.scale);
 0271            }
 0272            catch (System.ArgumentException e)
 273            {
 0274                Debug.LogError("Error parsing bBuilder's SetGridResolution Json = " + payloadJson + " " + e.ToString());
 0275            }
 0276        }
 277
 278        public void OnBuilderKeyDown(string key)
 279        {
 280            KeyCode keyCode;
 0281            if (System.Enum.TryParse(key, false, out keyCode))
 282            {
 0283                OnSetKeyDown?.Invoke(keyCode);
 284            }
 0285        }
 286
 287        public void UnloadBuilderScene(string sceneKey)
 288        {
 0289            if (LOG_MESSAGES)
 0290                Debug.Log($"RECEIVE: UnloadBuilderScene {sceneKey}");
 0291            Environment.i.world.sceneController.UnloadScene(sceneKey);
 0292        }
 293
 294        public void SetSelectedEntities(string msj)
 295        {
 0296            if (LOG_MESSAGES)
 0297                Debug.Log($"RECEIVE: SelectEntity {msj}");
 0298            SelectedEntitiesPayload payload = JsonUtility.FromJson<SelectedEntitiesPayload>(msj);
 0299            OnBuilderSelectEntity?.Invoke(payload.entities);
 0300        }
 301
 302        public void GetCameraTargetBuilder(string id)
 303        {
 0304            if (LOG_MESSAGES)
 0305                Debug.Log($"RECEIVE: GetCameraTargetBuilder {id}");
 306            Vector3 targetPosition;
 0307            Camera builderCamera = builderRaycast.builderCamera;
 0308            if (builderRaycast.RaycastToGround(builderCamera.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.he
 309                out targetPosition))
 310            {
 0311                builderWebInterface.SendCameraTargetPosition(targetPosition, id);
 312            }
 0313        }
 314
 315        public void SetBuilderConfiguration(string payloadJson)
 316        {
 0317            if (LOG_MESSAGES)
 0318                Debug.Log($"RECEIVE: SetBuilderConfiguration {payloadJson}");
 0319            DCLBuilderConfig.SetConfig(payloadJson);
 320
 0321            if (!currentScene)
 0322                return;
 323
 0324            if (DCLBuilderConfig.config.environment.disableFloor)
 325            {
 0326                currentScene.RemoveDebugPlane();
 0327            }
 328            else
 329            {
 0330                currentScene.InitializeDebugPlane();
 331            }
 0332        }
 333
 334        #endregion
 335
 336        private static ParcelScene GetLoadedScene()
 337        {
 2338            ParcelScene loadedScene = null;
 2339            IWorldState worldState = Environment.i.world.state;
 340
 2341            if (worldState != null && worldState.loadedScenes.Count > 0)
 342            {
 2343                using (var iterator = worldState.loadedScenes.GetEnumerator())
 344                {
 2345                    iterator.MoveNext();
 2346                    loadedScene = iterator.Current.Value as ParcelScene;
 2347                }
 348            }
 349
 2350            return loadedScene;
 351        }
 352
 353        private void Awake()
 354        {
 355            // NOTE: we need to set the quality settings before renderer pipeline is copy and modified
 1356            SetupQualitySettings();
 1357            SetupRendererPipeline();
 358
 1359            cameraController = Object.FindObjectOfType<CameraController>();
 1360            cursorController = Object.FindObjectOfType<CursorController>();
 1361            mouseCatcher = InitialSceneReferences.i?.mouseCatcher;
 1362            var playerAvatarController = Object.FindObjectOfType<PlayerAvatarController>();
 363
 1364            if (mouseCatcher != null)
 365            {
 0366                mouseCatcher.enabled = false;
 367            }
 368
 1369            if (DCLCharacterController.i)
 370            {
 1371                defaultCharacterPosition = DCLCharacterController.i.transform.position;
 1372                DCLCharacterController.i.initialPositionAlreadySet = true;
 1373                DCLCharacterController.i.characterAlwaysEnabled = false;
 1374                DCLCharacterController.i.gameObject.SetActive(false);
 375            }
 376
 1377            if (cameraController)
 378            {
 1379                cameraController.gameObject.SetActive(false);
 380            }
 381
 1382            if (cursorController)
 383            {
 1384                cursorController.gameObject.SetActive(false);
 385            }
 386
 387            // NOTE: no third person camera in builder yet, so avoid rendering being locked waiting for avatar.
 1388            if (playerAvatarController)
 389            {
 1390                CommonScriptableObjects.rendererState.RemoveLock(playerAvatarController);
 391            }
 392
 1393            Environment.i.platform.debugController.HideFPSPanel();
 1394            SetCaptureKeyboardInputEnabled(false);
 1395        }
 396
 397        private void Start()
 398        {
 1399            SetCurrentScene();
 1400            builderWebInterface.SendBuilderSceneStart(currentScene.sceneData.id);
 1401        }
 402
 403        private void Update()
 404        {
 11405            if (lastEntitiesOutOfBoundariesCount != outOfBoundariesEntitiesId.Count)
 406            {
 0407                lastEntitiesOutOfBoundariesCount = outOfBoundariesEntitiesId.Count;
 0408                SendOutOfBoundariesEntities();
 409            }
 11410        }
 411
 412        private void OnEntityIsAdded(IDCLEntity entity)
 413        {
 1414            if (isPreviewMode)
 0415                return;
 416
 1417            var builderEntity = AddBuilderEntityComponent(entity);
 1418            OnEntityAdded?.Invoke(builderEntity);
 419
 1420            entity.OnShapeUpdated += OnEntityShapeUpdated;
 421
 1422            builderWebInterface.SendEntityStartLoad(entity);
 1423        }
 424
 425        private void OnEntityIsRemoved(IDCLEntity entity)
 426        {
 1427            var builderEntity = entity.gameObject.GetComponent<DCLBuilderEntity>();
 428
 1429            if (builderEntity != null)
 430            {
 1431                OnEntityRemoved?.Invoke(builderEntity);
 432            }
 0433        }
 434
 435        private void OnEntityShapeUpdated(IDCLEntity entity)
 436        {
 1437            entity.OnShapeUpdated -= OnEntityShapeUpdated;
 438
 1439            builderWebInterface.SendEntityFinishLoad(entity);
 1440        }
 441
 442        private void OnEnable()
 443        {
 1444            if (!isGameObjectActive)
 445            {
 1446                DCLBuilderObjectDragger.OnDraggingObjectEnd += OnObjectDragEnd;
 1447                DCLBuilderObjectDragger.OnDraggingObject += OnObjectDrag;
 1448                DCLBuilderObjectSelector.OnMarkObjectSelected += OnObjectSelected;
 1449                DCLBuilderObjectSelector.OnNoObjectSelected += OnNoObjectSelected;
 1450                DCLBuilderObjectSelector.OnSelectedObjectListChanged += OnSelectionChanged;
 1451                DCLBuilderGizmoManager.OnGizmoTransformObjectEnd += OnGizmoTransformObjectEnded;
 1452                DCLBuilderGizmoManager.OnGizmoTransformObject += OnGizmoTransformObject;
 1453                DCLBuilderEntity.OnEntityShapeUpdated += ProcessEntityBoundaries;
 1454                DCLBuilderEntity.OnEntityTransformUpdated += ProcessEntityBoundaries;
 1455                CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
 456            }
 457
 1458            isGameObjectActive = true;
 1459        }
 460
 461        private void OnDisable()
 462        {
 1463            isGameObjectActive = false;
 1464            DCLBuilderObjectDragger.OnDraggingObjectEnd -= OnObjectDragEnd;
 1465            DCLBuilderObjectDragger.OnDraggingObject -= OnObjectDrag;
 1466            DCLBuilderObjectSelector.OnMarkObjectSelected -= OnObjectSelected;
 1467            DCLBuilderObjectSelector.OnNoObjectSelected -= OnNoObjectSelected;
 1468            DCLBuilderObjectSelector.OnSelectedObjectListChanged -= OnSelectionChanged;
 1469            DCLBuilderGizmoManager.OnGizmoTransformObjectEnd -= OnGizmoTransformObjectEnded;
 1470            DCLBuilderGizmoManager.OnGizmoTransformObject -= OnGizmoTransformObject;
 1471            DCLBuilderEntity.OnEntityShapeUpdated -= ProcessEntityBoundaries;
 1472            DCLBuilderEntity.OnEntityTransformUpdated -= ProcessEntityBoundaries;
 1473            CommonScriptableObjects.rendererState.OnChange -= OnRenderingStateChanged;
 1474        }
 475
 476        private void OnObjectDragEnd()
 477        {
 0478            if (selectedEntities != null && entitiesMoved)
 479            {
 0480                NotifyGizmosTransformEvent(selectedEntities, DCLGizmos.Gizmo.NONE);
 481            }
 482
 0483            entitiesMoved = false;
 0484        }
 485
 486        private void OnObjectDrag()
 487        {
 0488            EvaluateSelectedEntitiesPosition();
 0489            entitiesMoved = true;
 0490        }
 491
 492        private void OnGizmoTransformObjectEnded(string gizmoType)
 493        {
 0494            if (selectedEntities != null && entitiesMoved)
 495            {
 0496                NotifyGizmosTransformEvent(selectedEntities, gizmoType);
 497            }
 498
 0499            entitiesMoved = false;
 0500        }
 501
 502        private void OnGizmoTransformObject(string gizmoType)
 503        {
 0504            EvaluateSelectedEntitiesPosition();
 0505            entitiesMoved = true;
 0506        }
 507
 0508        private void OnObjectSelected(EditableEntity entity, string gizmoType) { NotifyGizmosSelectedEvent(entity, gizmo
 509
 0510        private void OnNoObjectSelected() { NotifyGizmosSelectedEvent(null, DCLGizmos.Gizmo.NONE); }
 511
 0512        private void OnSelectionChanged(Transform selectionParent, List<EditableEntity> selectedEntitiesList) { selected
 513
 0514        private void NotifyGizmosTransformEvent(List<EditableEntity> entities, string gizmoType) { builderWebInterface.S
 515
 0516        private void NotifyGizmosSelectedEvent(EditableEntity entity, string gizmoType) { builderWebInterface.SendEntity
 517
 518        private IEnumerator TakeScreenshotRoutine(string id)
 519        {
 0520            yield return new WaitForEndOfFrame();
 521
 0522            var texture = ScreenCapture.CaptureScreenshotAsTexture();
 0523            if (LOG_MESSAGES)
 0524                Debug.Log($"SEND: SendScreenshot {id}");
 0525            WebInterface.SendScreenshot("data:image/png;base64," + System.Convert.ToBase64String(texture.EncodeToPNG()),
 0526            Destroy(texture);
 0527        }
 528
 529        private void SetPlayMode(bool isPreview)
 530        {
 0531            isPreviewMode = isPreview;
 0532            OnPreviewModeChanged?.Invoke(isPreview);
 533
 0534            if (DCLCharacterController.i)
 535            {
 0536                DCLCharacterController.i.SetPosition(defaultCharacterPosition);
 0537                DCLCharacterController.i.gameObject.SetActive(isPreview);
 0538                DCLCharacterController.i.ResetGround();
 539            }
 540
 0541            if (mouseCatcher != null)
 542            {
 0543                mouseCatcher.enabled = isPreview;
 0544                if (!isPreview)
 0545                    mouseCatcher.UnlockCursor();
 546            }
 547
 0548            cameraController?.gameObject.SetActive(isPreviewMode);
 0549            cursorController?.gameObject.SetActive(isPreviewMode);
 550
 0551            if (!isPreview)
 552            {
 0553                HideHUDs();
 554            }
 555
 0556            SetCaptureKeyboardInputEnabled(isPreview);
 0557        }
 558
 559        private void OnRenderingStateChanged(bool renderingEnabled, bool prevState)
 560        {
 0561            if (renderingEnabled)
 562            {
 0563                ParcelSettings.VISUAL_LOADING_ENABLED = false;
 564            }
 0565        }
 566
 567        private void SetCaptureKeyboardInputEnabled(bool value)
 568        {
 569#if !(UNITY_EDITOR || UNITY_STANDALONE) && UNITY_WEBGL
 570            WebGLInput.captureAllKeyboardInput = value;
 571#endif
 0572        }
 573
 574        private void SetCurrentScene()
 575        {
 2576            currentScene = GetLoadedScene();
 577
 2578            if (currentScene)
 579            {
 2580                currentScene.OnEntityAdded += OnEntityIsAdded;
 2581                currentScene.OnEntityRemoved += OnEntityIsRemoved;
 2582                currentScene.metricsController = new DCLBuilderSceneMetricsController(currentScene);
 583
 2584                if (DCLBuilderConfig.config.environment.disableFloor)
 585                {
 0586                    currentScene.RemoveDebugPlane();
 0587                }
 588                else
 589                {
 2590                    currentScene.InitializeDebugPlane();
 591                }
 592
 2593                OnSceneChanged?.Invoke(currentScene);
 594            }
 2595        }
 596
 597        private void HideHUDs()
 598        {
 599            IHUD hud;
 62600            for (int i = 0; i < (int)HUDElementID.COUNT; i++)
 601            {
 30602                hud = Environment.i.hud.controller.GetHUDElement((HUDElementID) i);
 30603                if (hud != null)
 604                {
 0605                    hud.SetVisibility(false);
 606                }
 607            }
 1608        }
 609
 610        private void OnDestroy()
 611        {
 1612            if (currentScene)
 613            {
 1614                currentScene.OnEntityAdded -= OnEntityIsAdded;
 1615                currentScene.OnEntityRemoved -= OnEntityIsRemoved;
 616            }
 1617        }
 618
 619        private DCLBuilderEntity AddBuilderEntityComponent(IDCLEntity entity)
 620        {
 1621            DCLBuilderEntity builderComponent = Utils.GetOrCreateComponent<DCLBuilderEntity>(entity.gameObject);
 1622            builderComponent.SetEntity(entity);
 1623            return builderComponent;
 624        }
 625
 626        private void ProcessEntityBoundaries(DCLBuilderEntity entity)
 627        {
 1628            string entityId = entity.rootEntity.entityId;
 1629            int entityIndexInList = outOfBoundariesEntitiesId.IndexOf(entityId);
 630
 1631            bool wasInsideSceneBoundaries = entityIndexInList == -1;
 1632            bool isInsideSceneBoundaries = entity.IsInsideSceneBoundaries();
 633
 1634            if (wasInsideSceneBoundaries && !isInsideSceneBoundaries)
 635            {
 0636                outOfBoundariesEntitiesId.Add(entityId);
 0637            }
 1638            else if (!wasInsideSceneBoundaries && isInsideSceneBoundaries)
 639            {
 0640                outOfBoundariesEntitiesId.RemoveAt(entityIndexInList);
 641            }
 642
 1643            Environment.i.world.sceneBoundsChecker?.EvaluateEntityPosition(entity.rootEntity);
 1644        }
 645
 0646        private void SendOutOfBoundariesEntities() { builderWebInterface.SendEntitiesOutOfBoundaries(outOfBoundariesEnti
 647
 648        private void EvaluateSelectedEntitiesPosition()
 649        {
 0650            if (selectedEntities != null)
 651            {
 0652                for (int i = 0; i < selectedEntities.Count; i++)
 653                {
 0654                    Environment.i.world.sceneBoundsChecker?.EvaluateEntityPosition(selectedEntities[i].rootEntity);
 655                }
 656            }
 0657        }
 658
 659        private void SetupRendererPipeline()
 660        {
 1661            UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset lwrpa = ScriptableObject.Instantiate(GraphicsSe
 662
 1663            if (lwrpa != null)
 664            {
 1665                lwrpa.shadowDepthBias = 3;
 1666                lwrpa.shadowDistance = 80f;
 1667                GraphicsSettings.renderPipelineAsset = lwrpa;
 668            }
 1669        }
 670
 671        private void SetupQualitySettings()
 672        {
 1673            DCL.SettingsData.QualitySettings settings = new DCL.SettingsData.QualitySettings()
 674            {
 675                baseResolution = DCL.SettingsData.QualitySettings.BaseResolution.BaseRes_1080,
 676                antiAliasing = UnityEngine.Rendering.Universal.MsaaQuality._2x,
 677                renderScale = 1,
 678                shadows = true,
 679                softShadows = true,
 680                shadowResolution = UnityEngine.Rendering.Universal.ShadowResolution._256,
 681                cameraDrawDistance = 100,
 682                bloom = true,
 683                colorGrading = true
 684            };
 1685            Settings.i.ApplyQualitySettings(settings);
 1686        }
 687    }
 688}

Methods/Properties

DCLBuilderBridge()
MousePayload()
PreloadFile(System.String)
GetMousePosition(System.String)
SelectGizmo(System.String)
ResetObject()
ZoomDelta(System.String)
SetPlayMode(System.String)
TakeScreenshot(System.String)
ResetBuilderScene()
SetBuilderCameraPosition(System.String)
SetBuilderCameraRotation(System.String)
ResetBuilderCameraZoom()
SetGridResolution(System.String)
OnBuilderKeyDown(System.String)
UnloadBuilderScene(System.String)
SetSelectedEntities(System.String)
GetCameraTargetBuilder(System.String)
SetBuilderConfiguration(System.String)
GetLoadedScene()
Awake()
Start()
Update()
OnEntityIsAdded(DCL.Models.IDCLEntity)
OnEntityIsRemoved(DCL.Models.IDCLEntity)
OnEntityShapeUpdated(DCL.Models.IDCLEntity)
OnEnable()
OnDisable()
OnObjectDragEnd()
OnObjectDrag()
OnGizmoTransformObjectEnded(System.String)
OnGizmoTransformObject(System.String)
OnObjectSelected(EditableEntity, System.String)
OnNoObjectSelected()
OnSelectionChanged(UnityEngine.Transform, System.Collections.Generic.List[EditableEntity])
NotifyGizmosTransformEvent(System.Collections.Generic.List[EditableEntity], System.String)
NotifyGizmosSelectedEvent(EditableEntity, System.String)
TakeScreenshotRoutine()
SetPlayMode(System.Boolean)
OnRenderingStateChanged(System.Boolean, System.Boolean)
SetCaptureKeyboardInputEnabled(System.Boolean)
SetCurrentScene()
HideHUDs()
OnDestroy()
AddBuilderEntityComponent(DCL.Models.IDCLEntity)
ProcessEntityBoundaries(Builder.DCLBuilderEntity)
SendOutOfBoundariesEntities()
EvaluateSelectedEntitiesPosition()
SetupRendererPipeline()
SetupQualitySettings()