Exemplo n.º 1
0
        public BasicMaterial(IParcelScene scene) : base(scene)
        {
            material = new Material(Utils.EnsureResourcesMaterial("Materials/BasicShapeMaterial"));

            OnAttach += OnMaterialAttached;
            OnDetach += OnMaterialDetached;
        }
Exemplo n.º 2
0
 private void SetHitInfo(ref HitInfo hitInfo, RaycastHit hit, IParcelScene scene)
 {
     hitInfo.point    = WorldStateUtils.ConvertUnityToScenePosition(hit.point, scene);
     hitInfo.distance = hit.distance;
     hitInfo.normal   = hit.normal;
     hitInfo.collider = hit.collider;
 }
Exemplo n.º 3
0
        public static IEnumerator ApplyModelChanges(IParcelScene scene, TMP_Text text, Model model)
        {
            if (!string.IsNullOrEmpty(model.font))
            {
                yield return(DCLFont.SetFontFromComponent(scene, model.font, text));
            }

            text.text = model.value;

            text.color            = new Color(model.color.r, model.color.g, model.color.b, model.visible ? model.opacity : 0);
            text.fontSize         = (int)model.fontSize;
            text.richText         = true;
            text.overflowMode     = TextOverflowModes.Overflow;
            text.enableAutoSizing = model.fontAutoSize;

            text.margin =
                new Vector4
                (
                    (int)model.paddingLeft,
                    (int)model.paddingTop,
                    (int)model.paddingRight,
                    (int)model.paddingBottom
                );

            text.alignment   = GetAlignment(model.vTextAlign, model.hTextAlign);
            text.lineSpacing = model.lineSpacing;

            if (model.lineCount != 0)
            {
                text.maxVisibleLines = Mathf.Max(model.lineCount, 1);
            }
            else
            {
                text.maxVisibleLines = int.MaxValue;
            }

            text.enableWordWrapping = model.textWrapping && !text.enableAutoSizing;

            if (model.shadowOffsetX != 0 || model.shadowOffsetY != 0)
            {
                text.fontMaterial.EnableKeyword("UNDERLAY_ON");
                text.fontMaterial.SetColor("_UnderlayColor", model.shadowColor);
                text.fontMaterial.SetFloat("_UnderlaySoftness", model.shadowBlur);
            }
            else if (text.fontMaterial.IsKeywordEnabled("UNDERLAY_ON"))
            {
                text.fontMaterial.DisableKeyword("UNDERLAY_ON");
            }

            if (model.outlineWidth > 0f)
            {
                text.fontMaterial.EnableKeyword("OUTLINE_ON");
                text.outlineWidth = model.outlineWidth;
                text.outlineColor = model.outlineColor;
            }
            else if (text.fontMaterial.IsKeywordEnabled("OUTLINE_ON"))
            {
                text.fontMaterial.DisableKeyword("OUTLINE_ON");
            }
        }
Exemplo n.º 4
0
        public static IEnumerator SetFontFromComponent(IParcelScene scene, string componentId, TMP_Text text)
        {
            if (!scene.disposableComponents.ContainsKey(componentId))
            {
                Debug.Log($"couldn't fetch font, the DCLFont component with id {componentId} doesn't exist");
                yield break;
            }

            DCLFont fontComponent = scene.disposableComponents[componentId] as DCLFont;

            if (fontComponent == null)
            {
                Debug.Log($"couldn't fetch font, the shared component with id {componentId} is NOT a DCLFont");
                yield break;
            }

            while (!fontComponent.loaded && !fontComponent.error)
            {
                yield return(null);
            }

            if (!fontComponent.error)
            {
                text.font = fontComponent.fontAsset;
            }
        }
Exemplo n.º 5
0
        public PBRMaterial(IParcelScene scene) : base(scene)
        {
            model = new Model();

            LoadMaterial(PBR_MATERIAL_NAME);

            OnAttach += OnMaterialAttached;
            OnDetach += OnMaterialDetached;
        }
Exemplo n.º 6
0
        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
        {
            this.scene  = scene;
            this.entity = entity;

            if (transform.parent != entity.gameObject.transform)
            {
                transform.SetParent(entity.gameObject.transform, false);
            }
        }
        private void CalcSceneBoundaries(IParcelScene scene)
        {
            sceneBoundaryMin = Vector2.zero;
            sceneBoundaryMax = Vector2.zero;

            if (scene != null && scene.sceneData != null)
            {
                CalcSceneBoundaries(scene.sceneData);
            }
        }
Exemplo n.º 8
0
        private int SortScenesByDistanceMethod(IParcelScene sceneA, IParcelScene sceneB)
        {
            sortAuxiliaryVector = sceneA.sceneData.basePosition - currentGridSceneCoordinate;
            int dist1 = sortAuxiliaryVector.sqrMagnitude;

            sortAuxiliaryVector = sceneB.sceneData.basePosition - currentGridSceneCoordinate;
            int dist2 = sortAuxiliaryVector.sqrMagnitude;

            return(dist1 - dist2);
        }
Exemplo n.º 9
0
        public UIScreenSpace(IParcelScene scene) : base(scene)
        {
            DCLCharacterController.OnCharacterMoved += OnCharacterMoved;

            //Only no-dcl scenes are listening the the global visibility event
            if (!scene.isPersistent)
            {
                CommonScriptableObjects.allUIHidden.OnChange += AllUIHidden_OnChange;
            }
        }
Exemplo n.º 10
0
 public void IsolateScene(IParcelScene sceneToActive)
 {
     foreach (IParcelScene scene in Environment.i.world.state.scenesSortedByDistance)
     {
         if (scene != sceneToActive)
         {
             scene.GetSceneTransform().gameObject.SetActive(false);
         }
     }
 }
    private void SceneController_OnNewSceneAdded(IParcelScene scene)
    {
        var parcelScene = scene as ParcelScene;

        if (parcelScene == null)
        {
            return;
        }

        parcelScene.sceneLifecycleHandler.OnStateRefreshed += Scene_OnStateRefreshed;
    }
        public void SetParcelSceneCorrectly()
        {
            // Arrange
            IParcelScene testParcelScene = DCL.Environment.i.world.sceneController.CreateTestScene();

            // Act
            sceneLimitsController.SetParcelScene((ParcelScene)testParcelScene);

            // Assert
            Assert.AreEqual(testParcelScene, sceneLimitsController.currentParcelScene, "");
        }
Exemplo n.º 13
0
        public bool TryGetScene(string id, out IParcelScene scene)
        {
            scene = null;

            if (string.IsNullOrEmpty(id) || !loadedScenes.ContainsKey(id))
            {
                return(false);
            }

            scene = loadedScenes[id];
            return(true);
        }
    private void NewSceneAdded(IParcelScene newScene)
    {
        if (newScene.sceneData.id != sceneToEditId)
        {
            return;
        }

        Environment.i.world.sceneController.OnNewSceneAdded -= NewSceneAdded;

        sceneToEdit = (ParcelScene)Environment.i.world.state.GetScene(sceneToEditId);
        sceneToEdit.OnLoadingStateUpdated += UpdateSceneLoadingProgress;
    }
    public void TryStartEnterEditMode(bool activateCamera, IParcelScene targetScene = null, string source = "BuilderPanel")
    {
        if (sceneToEditId != null)
        {
            return;
        }

        FindSceneToEdit(targetScene);

        if (!UserHasPermissionOnParcelScene(sceneToEdit))
        {
            ShowGenericNotification(BIWSettings.LAND_EDITION_NOT_ALLOWED_BY_PERMISSIONS_MESSAGE);
            return;
        }
        else if (IsParcelSceneDeployedFromSDK(sceneToEdit))
        {
            ShowGenericNotification(BIWSettings.LAND_EDITION_NOT_ALLOWED_BY_SDK_LIMITATION_MESSAGE);
            return;
        }

        //If the scene is still not loaded, we return as we still can't enter in builder in world
        if (sceneToEditId != null)
        {
            return;
        }

        isEnteringEditMode  = true;
        previousAllUIHidden = CommonScriptableObjects.allUIHidden.Get();
        NotificationsController.i.allowNotifications = false;
        CommonScriptableObjects.allUIHidden.Set(true);
        NotificationsController.i.allowNotifications = true;
        inputController.inputTypeMode = InputTypeMode.BUILD_MODE_LOADING;
        initialLoadingController.Show();
        initialLoadingController.SetPercentage(0f);
        DataStore.i.appMode.Set(AppMode.BUILDER_IN_WORLD_EDITION);
        BIWAnalytics.StartEditorFlow(source);
        beginStartFlowTimeStamp = Time.realtimeSinceStartup;

        biwAudioHandler.gameObject.SetActive(true);
        //Note (Adrian) this should handle different when we have the full flow of the feature
        if (activateCamera)
        {
            modeController.ActivateCamera(sceneToEdit);
        }

        if (catalogAdded)
        {
            StartEditMode();
        }
    }
Exemplo n.º 16
0
        public SceneMetricsController(IParcelScene sceneOwner)
        {
            this.scene = sceneOwner;

            uniqueMeshesRefCount    = new Dictionary <Mesh, int>();
            uniqueMaterialsRefCount = new Dictionary <Material, int>();
            entitiesMetrics         = new Dictionary <IDCLEntity, EntityMetrics>();
            model = new SceneMetricsModel();

            if (VERBOSE)
            {
                Debug.Log("Start ScenePerformanceLimitsController...");
            }
        }
Exemplo n.º 17
0
        public static Vector3 ConvertPointInSceneToUnityPosition(Vector3 pos, IParcelScene scene = null)
        {
            if (scene == null)
            {
                scene = GetCurrentScene();

                if (scene == null)
                {
                    return(pos);
                }
            }

            return(ConvertPointInSceneToUnityPosition(pos, new Vector2Int(scene.sceneData.basePosition.x, scene.sceneData.basePosition.y)));
        }
Exemplo n.º 18
0
        public override void Initialize(IParcelScene scene, DecentralandEntity entity)
        {
            base.Initialize(scene, entity);

            if (model == null)
            {
                model = new OnPointerEvent.Model();
            }

            pointerEventHandler = new OnPointerEventHandler();
            SetEventColliders(entity);

            entity.OnShapeUpdated -= SetEventColliders;
            entity.OnShapeUpdated += SetEventColliders;
        }
Exemplo n.º 19
0
        public void ParseQuery(object payload, string sceneId)
        {
            IParcelScene scene = Environment.i.world.state.loadedScenes[sceneId];

            if (!(payload is RaycastQuery raycastQuery))
            {
                return;
            }

            Vector3 worldOrigin = raycastQuery.ray.origin + Utils.GridToWorldPosition(scene.sceneData.basePosition.x, scene.sceneData.basePosition.y);

            raycastQuery.ray.unityOrigin = PositionUtils.WorldToUnityPosition(worldOrigin);
            raycastQuery.sceneId         = sceneId;
            PhysicsCast.i.Query(raycastQuery);
        }
Exemplo n.º 20
0
        public static Vector3 ConvertUnityToScenePosition(Vector3 pos, IParcelScene scene = null)
        {
            if (scene == null)
            {
                scene = GetCurrentScene();

                if (scene == null)
                {
                    return(pos);
                }
            }

            Vector3 worldPosition = PositionUtils.UnityToWorldPosition(pos);

            return(worldPosition - Utils.GridToWorldPosition(scene.sceneData.basePosition.x, scene.sceneData.basePosition.y));
        }
    public void FindSceneToEdit(IParcelScene targetScene)
    {
        if (targetScene != null)
        {
            var parcelSceneTarget = (ParcelScene)targetScene;
            if (sceneToEdit != null && sceneToEdit != parcelSceneTarget)
            {
                actionController.Clear();
            }

            sceneToEdit = parcelSceneTarget;
        }
        else
        {
            FindSceneToEdit();
        }
    }
Exemplo n.º 22
0
        private void HitAll(RaycastQuery query)
        {
            WebInterface.RaycastHitEntities raycastHitEntities = new WebInterface.RaycastHitEntities();

            IParcelScene scene = null;

            Environment.i.world.state.TryGetScene(query.sceneId, out scene);

            RaycastResultInfoList raycastResults = raycastHandler.RaycastAll(GetUnityRayFromQuery(query), query.ray.distance, ~layerMaskTarget, scene);

            raycastHitEntities.ray = GetRayInfoFromQuery(query);

            if (raycastResults.hitInfo != null && raycastResults.hitInfo.Length > 0)
            {
                int count = raycastResults.hitInfo.Length;
                List <WebInterface.RaycastHitEntity> hitEntityInfoList = new List <WebInterface.RaycastHitEntity>();

                for (int i = 0; i < count; i++)
                {
                    var hitInfo = raycastResults.hitInfo[i];
                    CollidersManager.i.GetColliderInfo(hitInfo.hit.collider, out ColliderInfo colliderInfo);

                    if (hitInfo.isValid)
                    {
                        WebInterface.RaycastHitEntity hitEntity = new WebInterface.RaycastHitEntity();
                        hitEntity.didHit          = true;
                        hitEntity.ray             = raycastHitEntities.ray;
                        hitEntity.hitPoint        = hitInfo.hit.point;
                        hitEntity.hitNormal       = hitInfo.hit.normal;
                        hitEntity.entity          = new WebInterface.HitEntityInfo();
                        hitEntity.entity.entityId = colliderInfo.entity != null ? colliderInfo.entity.entityId : null;
                        hitEntity.entity.meshName = colliderInfo.meshName;
                        hitEntityInfoList.Add(hitEntity);
                    }
                }

                raycastHitEntities.didHit    = true;
                raycastHitEntities.hitPoint  = raycastResults.hitInfo[0].hit.point;
                raycastHitEntities.hitNormal = raycastResults.hitInfo[0].hit.normal;
                raycastHitEntities.entities  = hitEntityInfoList.ToArray();
            }

            WebInterface.ReportRaycastHitAllResult(query.sceneId, query.id, query.raycastType, raycastHitEntities);
        }
Exemplo n.º 23
0
        public static IEnumerator FetchTextureComponent(IParcelScene scene, string componentId,
                                                        System.Action <DCLTexture> OnFinish)
        {
            if (!scene.disposableComponents.ContainsKey(componentId))
            {
                Debug.Log($"couldn't fetch texture, the DCLTexture component with id {componentId} doesn't exist");
                yield break;
            }

            DCLTexture textureComponent = scene.disposableComponents[componentId] as DCLTexture;

            if (textureComponent == null)
            {
                Debug.Log($"couldn't fetch texture, the shared component with id {componentId} is NOT a DCLTexture");
                yield break;
            }

            yield return(new WaitUntil(() => textureComponent.texture != null));

            OnFinish.Invoke(textureComponent);
        }
Exemplo n.º 24
0
        private void SetRaycastInfoData(ref RaycastHitInfo hitInfo, IParcelScene scene)
        {
            if (hitInfo.hit.collider == null)
            {
                return;
            }

            if (!CollidersManager.i.GetColliderInfo(hitInfo.hit.collider, out ColliderInfo info))
            {
                return;
            }

            if (scene != null)
            {
                hitInfo.isValid = (info.scene == scene) || (scene is GlobalScene globalScene && globalScene.isPortableExperience);
            }
            else if (scene == null && WorldStateUtils.IsCharacterInsideScene(info.scene))
            {
                hitInfo.isValid = true;
            }
        }
    internal void ProcessOpenUrlRequest(IParcelScene scene, string url)
    {
        Uri uri;

        if (Uri.TryCreate(url, UriKind.Absolute, out uri))
        {
            if (trustedDomains.ContainsKey(scene.sceneData.id) && trustedDomains[scene.sceneData.id].Contains(uri.Host))
            {
                OpenUrl(url);
                return;
            }

            SetVisibility(true);
            Utils.UnlockCursor();
            view.RequestOpenUrl(uri, result =>
            {
                switch (result)
                {
                case ExternalUrlPromptView.ResultType.APPROVED_TRUSTED:
                    if (!trustedDomains.ContainsKey(scene.sceneData.id))
                    {
                        trustedDomains.Add(scene.sceneData.id, new HashSet <string>());
                    }

                    trustedDomains[scene.sceneData.id].Add(uri.Host);
                    OpenUrl(url);
                    break;

                case ExternalUrlPromptView.ResultType.APPROVED:
                    OpenUrl(url);
                    break;
                }

                SetVisibility(false);
            });
        }
    }
Exemplo n.º 26
0
        public override void Setup(IParcelScene scene, DecentralandEntity entity, UUIDComponent.Model model)
        {
            if (entity == null)
            {
                return;
            }

            this.entity = entity;
            this.scene  = scene;

            if (model == null)
            {
                this.model = new OnPointerEvent.Model();
            }
            else
            {
                this.model = (OnPointerEvent.Model)model;
            }

            Initialize();

            entity.OnShapeUpdated -= OnComponentUpdated;
            entity.OnShapeUpdated += OnComponentUpdated;
        }
Exemplo n.º 27
0
        public static bool IsCharacterInsideScene(IParcelScene scene)
        {
            Vector2Int gridPosition = Utils.WorldToGridPosition(CommonScriptableObjects.playerWorldPosition.Get());

            return(scene.IsInsideSceneBoundaries(gridPosition));
        }
Exemplo n.º 28
0
 public static Vector3 ConvertScenePositionToUnityPosition(IParcelScene scene = null)
 {
     return(ConvertPointInSceneToUnityPosition(Vector3.zero, scene));
 }
Exemplo n.º 29
0
 public static Vector3 ConvertSceneToUnityPosition(Vector3 pos, IParcelScene scene = null)
 {
     return(ConvertPointInSceneToUnityPosition(pos, scene));
 }
Exemplo n.º 30
0
 public CylinderShape(IParcelScene scene) : base(scene)
 {
     model = new Model();
 }