public IEnumerator TestOnClickEvent()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerRectShape
            UIContainerRect uiContainerRectShape =
                TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                           CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainerRectShape.routine);

            // Update UIContainerRectShape properties
            uiContainerRectShape = scene.SharedComponentUpdate(uiContainerRectShape.id, JsonUtility.ToJson(new UIContainerRect.Model
            {
                parentComponent  = screenSpaceShape.id,
                thickness        = 5,
                color            = new Color(0.2f, 0.7f, 0.05f, 1f),
                isPointerBlocker = false,
                width            = new UIValue(275f),
                height           = new UIValue(130f),
                positionX        = new UIValue(-30f),
                positionY        = new UIValue(-15f),
                hAlign           = "right",
                vAlign           = "bottom",
                onClick          = "UUIDFakeEventId"
            })) as UIContainerRect;

            yield return(uiContainerRectShape.routine);

            //------------------------------------------------------------------------
            // Test click events
            bool eventResult = false;

            yield return(TestHelpers.TestUIClickEventPropagation(
                             scene.sceneData.id,
                             uiContainerRectShape.model.onClick,
                             uiContainerRectShape.referencesContainer.childHookRectTransform,
                             (bool res) =>
            {
                // Check image object clicking triggers the correct event
                eventResult = res;
            }));

            Assert.IsTrue(eventResult);
        }
Exemple #2
0
        public IEnumerator TestChildrenAreHandledCorrectly()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerStack
            UIContainerStack uiContainerStack =
                TestHelpers.SharedComponentCreate <UIContainerStack, UIContainerStack.Model>(scene,
                                                                                             CLASS_ID.UI_CONTAINER_STACK);

            yield return(uiContainerStack.routine);


            // Create 1st child object
            UIContainerRect childComponent1 = TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(
                scene, CLASS_ID.UI_CONTAINER_RECT,
                new UIContainerRect.Model()
            {
                parentComponent = uiContainerStack.id
            });

            yield return(childComponent1.routine);

            Assert.IsTrue(uiContainerStack.stackContainers.ContainsKey(childComponent1.id));
            Assert.IsTrue(childComponent1.referencesContainer.transform.parent.gameObject ==
                          uiContainerStack.stackContainers[childComponent1.id]);

            // Create 2nd child object
            UIImage childComponent2 = TestHelpers.SharedComponentCreate <UIImage, UIImage.Model>(scene,
                                                                                                 CLASS_ID.UI_IMAGE_SHAPE,
                                                                                                 new UIImage.Model
            {
                parentComponent = uiContainerStack.id,
            });

            yield return(childComponent2.routine);

            Assert.IsTrue(uiContainerStack.stackContainers.ContainsKey(childComponent2.id));
            Assert.IsTrue(childComponent2.referencesContainer.transform.parent.gameObject ==
                          uiContainerStack.stackContainers[childComponent2.id]);

            screenSpaceShape.Dispose();
            yield return(null);
        }
        public IEnumerator TestParenting()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerRectShape
            UIContainerRect uiContainerRectShape =
                TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                           CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainerRectShape.routine);

            // Update UIContainerRectShape parent
            scene.SharedComponentUpdate(uiContainerRectShape.id, JsonUtility.ToJson(new UIContainerRect.Model
            {
                parentComponent = screenSpaceShape.id,
            }));
            yield return(uiContainerRectShape.routine);

            // Check updated parent
            Assert.IsTrue(uiContainerRectShape.referencesContainer.transform.parent ==
                          screenSpaceShape.childHookRectTransform);

            // Create 2nd UIContainerRectShape
            UIContainerRect uiContainerRectShape2 =
                TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                           CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainerRectShape2.routine);

            // Update UIContainerRectShape parent to the previous container
            scene.SharedComponentUpdate(uiContainerRectShape2.id, JsonUtility.ToJson(new UIContainerRect.Model
            {
                parentComponent = uiContainerRectShape.id,
            }));
            yield return(uiContainerRectShape2.routine);

            // Check updated parent
            Assert.IsTrue(uiContainerRectShape2.referencesContainer.transform.parent ==
                          uiContainerRectShape.childHookRectTransform);

            screenSpaceShape.Dispose();
        }
        public IEnumerator TestNormalizedSize()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerRectShape
            UIContainerRect uiContainerRectShape = TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                                                              CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainerRectShape.routine);

            // Update UIContainerRectShape properties
            yield return(TestHelpers.SharedComponentUpdate(uiContainerRectShape,
                                                           new UIContainerRect.Model
            {
                parentComponent = screenSpaceShape.id,
                width = new UIValue(50, UIValue.Unit.PERCENT),
                height = new UIValue(30, UIValue.Unit.PERCENT)
            }));

            yield return(uiContainerRectShape.routine);

            UnityEngine.UI.Image image =
                uiContainerRectShape.childHookRectTransform.GetComponent <UnityEngine.UI.Image>();

            // Check updated properties are applied correctly
            Assert.AreEqual(screenSpaceShape.childHookRectTransform.rect.width * 0.5f,
                            uiContainerRectShape.childHookRectTransform.rect.width, 0.01f);
            Assert.AreEqual(screenSpaceShape.childHookRectTransform.rect.height * 0.3f,
                            uiContainerRectShape.childHookRectTransform.rect.height, 0.01f);

            yield return(new WaitForAllMessagesProcessed());

            screenSpaceShape.Dispose();
        }
        public IEnumerator TestOnClickEvent()
        {
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            Assert.IsFalse(screenSpaceShape == null);

            DCLTexture texture =
                TestHelpers.CreateDCLTexture(scene, DCL.Helpers.Utils.GetTestsAssetsPath() + "/Images/atlas.png");

            yield return(texture.routine);

            UIImage uiImage = TestHelpers.SharedComponentCreate <UIImage, UIImage.Model>(scene, CLASS_ID.UI_IMAGE_SHAPE);

            yield return(uiImage.routine);

            string uiImageOnClickEventId = "UUIDFakeEventId";

            yield return(TestHelpers.SharedComponentUpdate(uiImage, new UIImage.Model
            {
                parentComponent = screenSpaceShape.id,
                source = texture.id,
                width = new UIValue(128f),
                height = new UIValue(128f),
                onClick = uiImageOnClickEventId
            }));

            bool eventResult = false;

            yield return(TestHelpers.TestUIClickEventPropagation(
                             scene.sceneData.id,
                             uiImageOnClickEventId,
                             (RectTransform)uiImage.referencesContainer.image.transform,
                             (bool res) =>
            {
                // Check image object clicking triggers the correct event
                eventResult = res;
            }));

            Assert.IsTrue(eventResult);

            // Check UI children won't trigger the parent/root image component event
            UIContainerRect uiContainer =
                TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                           CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainer.routine);

            yield return(TestHelpers.SharedComponentUpdate(uiContainer, new UIContainerRect.Model
            {
                parentComponent = uiImage.id
            }));

            eventResult = false;

            yield return(TestHelpers.TestUIClickEventPropagation(
                             scene.sceneData.id,
                             uiImageOnClickEventId,
                             (RectTransform)uiContainer.referencesContainer.image.transform,
                             (bool res) =>
            {
                // Check image object clicking doesn't trigger event
                eventResult = res;
            }));

            Assert.IsFalse(eventResult);

            yield return(null);

            yield return(null);

            yield return(null);

            yield return(null);
        }
Exemple #6
0
        public BaseDisposable SharedComponentCreate(string id, string name, int classId)
        {
            SceneController.i.OnMessageDecodeStart?.Invoke("ComponentCreated");
            sharedComponentCreatedMessage.id      = id;
            sharedComponentCreatedMessage.name    = name;
            sharedComponentCreatedMessage.classId = classId;
            SceneController.i.OnMessageDecodeEnds?.Invoke("ComponentCreated");

            BaseDisposable disposableComponent;

            if (disposableComponents.TryGetValue(sharedComponentCreatedMessage.id, out disposableComponent))
            {
                return(disposableComponent);
            }

            BaseDisposable newComponent = null;

            switch ((CLASS_ID)sharedComponentCreatedMessage.classId)
            {
            case CLASS_ID.BOX_SHAPE:
            {
                newComponent = new BoxShape(this);
                break;
            }

            case CLASS_ID.SPHERE_SHAPE:
            {
                newComponent = new SphereShape(this);
                break;
            }

            case CLASS_ID.CONE_SHAPE:
            {
                newComponent = new ConeShape(this);
                break;
            }

            case CLASS_ID.CYLINDER_SHAPE:
            {
                newComponent = new CylinderShape(this);
                break;
            }

            case CLASS_ID.PLANE_SHAPE:
            {
                newComponent = new PlaneShape(this);
                break;
            }

            case CLASS_ID.GLTF_SHAPE:
            {
                newComponent = new GLTFShape(this);
                break;
            }

            case CLASS_ID.NFT_SHAPE:
            {
                newComponent = new NFTShape(this);
                break;
            }

            case CLASS_ID.OBJ_SHAPE:
            {
                newComponent = new OBJShape(this);
                break;
            }

            case CLASS_ID.BASIC_MATERIAL:
            {
                newComponent = new BasicMaterial(this);
                break;
            }

            case CLASS_ID.PBR_MATERIAL:
            {
                newComponent = new PBRMaterial(this);
                break;
            }

            case CLASS_ID.AUDIO_CLIP:
            {
                newComponent = new DCLAudioClip(this);
                break;
            }

            case CLASS_ID.TEXTURE:
            {
                newComponent = new DCLTexture(this);
                break;
            }

            case CLASS_ID.UI_INPUT_TEXT_SHAPE:
            {
                newComponent = new UIInputText(this);
                break;
            }

            case CLASS_ID.UI_FULLSCREEN_SHAPE:
            case CLASS_ID.UI_SCREEN_SPACE_SHAPE:
            {
                if (uiScreenSpace == null)
                {
                    newComponent = new UIScreenSpace(this);
                }

                break;
            }

            case CLASS_ID.UI_CONTAINER_RECT:
            {
                newComponent = new UIContainerRect(this);
                break;
            }

            case CLASS_ID.UI_SLIDER_SHAPE:
            {
                newComponent = new UIScrollRect(this);
                break;
            }

            case CLASS_ID.UI_CONTAINER_STACK:
            {
                newComponent = new UIContainerStack(this);
                break;
            }

            case CLASS_ID.UI_IMAGE_SHAPE:
            {
                newComponent = new UIImage(this);
                break;
            }

            case CLASS_ID.UI_TEXT_SHAPE:
            {
                newComponent = new UIText(this);
                break;
            }

            case CLASS_ID.VIDEO_CLIP:
            {
                newComponent = new DCLVideoClip(this);
                break;
            }

            case CLASS_ID.VIDEO_TEXTURE:
            {
                newComponent = new DCLVideoTexture(this);
                break;
            }

            case CLASS_ID.FONT:
            {
                newComponent = new DCLFont(this);
                break;
            }

            default:
                Debug.LogError($"Unknown classId");
                break;
            }

            if (newComponent != null)
            {
                newComponent.id = sharedComponentCreatedMessage.id;
                disposableComponents.Add(sharedComponentCreatedMessage.id, newComponent);

                if (state != State.READY)
                {
                    disposableNotReady.Add(id);
                }
            }

            return(newComponent);
        }
Exemple #7
0
        public IEnumerator AdaptSizeIsAppliedCorrectly()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerStack
            UIContainerStack uiContainerStack =
                TestHelpers.SharedComponentCreate <UIContainerStack, UIContainerStack.Model>(scene,
                                                                                             CLASS_ID.UI_CONTAINER_STACK,
                                                                                             new UIContainerStack.Model
            {
                width  = new UIValue(500f),
                height = new UIValue(300f)
            });

            yield return(uiContainerStack.routine);

            // Create 1st child object
            UIContainerRect childComponent1 = TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(
                scene, CLASS_ID.UI_CONTAINER_RECT,
                new UIContainerRect.Model
            {
                parentComponent = uiContainerStack.id,
                width           = new UIValue(130f),
                height          = new UIValue(70f)
            });

            yield return(childComponent1.routine);

            // Create 2nd child object
            UIImage childComponent2 = TestHelpers.SharedComponentCreate <UIImage, UIImage.Model>(scene,
                                                                                                 CLASS_ID.UI_IMAGE_SHAPE,
                                                                                                 new UIImage.Model
            {
                parentComponent = uiContainerStack.id,
                width           = new UIValue(75f),
                height          = new UIValue(35f)
            });

            yield return(childComponent2.routine);

            // Create 3rd child object
            UIInputText childComponent3 = TestHelpers.SharedComponentCreate <UIInputText, UIInputText.Model>(scene,
                                                                                                             CLASS_ID.UI_INPUT_TEXT_SHAPE,
                                                                                                             new UIInputText.Model
            {
                parentComponent = uiContainerStack.id,
                width           = new UIValue(150f),
                height          = new UIValue(50f)
            });

            yield return(childComponent3.routine);


            yield return(TestHelpers.SharedComponentUpdate(uiContainerStack,
                                                           new UIContainerStack.Model
            {
                adaptHeight = true,
                adaptWidth = true,
            }));

            yield return(null);

            // Check stacked components position
            Assert.AreEqual(150f, uiContainerStack.childHookRectTransform.rect.width, 0.01f);
            Assert.AreEqual(
                childComponent1.referencesContainer.rectTransform.rect.height + childComponent2.referencesContainer
                .rectTransform.rect.height
                + childComponent3.referencesContainer
                .rectTransform.rect.height,
                uiContainerStack.childHookRectTransform.rect.height, 0.01f);

            screenSpaceShape.Dispose();
            yield return(null);
        }
Exemple #8
0
        public IEnumerator HorizontalStackIsAppliedCorrectly()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerStack
            UIContainerStack uiContainerStack =
                TestHelpers.SharedComponentCreate <UIContainerStack, UIContainerStack.Model>(scene,
                                                                                             CLASS_ID.UI_CONTAINER_STACK);

            yield return(uiContainerStack.routine);

            yield return(TestHelpers.SharedComponentUpdate(uiContainerStack,
                                                           new UIContainerStack.Model
            {
                width = new UIValue(500f),
                height = new UIValue(300f),
                stackOrientation = UIContainerStack.StackOrientation.HORIZONTAL
            }));

            // Check container stack was initialized correctly
            Assert.IsTrue(uiContainerStack != null);

            var layoutGroup = uiContainerStack.referencesContainer.GetComponentInChildren <HorizontalLayoutGroup>();

            Assert.IsTrue(layoutGroup != null);
            Assert.IsFalse(layoutGroup.childControlHeight);
            Assert.IsFalse(layoutGroup.childControlWidth);
            Assert.IsFalse(layoutGroup.childForceExpandWidth);
            Assert.IsFalse(layoutGroup.childForceExpandHeight);

            // Create 1st child object
            UIContainerRect childComponent1 = TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(
                scene, CLASS_ID.UI_CONTAINER_RECT,
                new UIContainerRect.Model
            {
                parentComponent = uiContainerStack.id,
                width           = new UIValue(130f),
                height          = new UIValue(70f)
            });

            yield return(childComponent1.routine);

            // Create 2nd child object
            UIImage childComponent2 = TestHelpers.SharedComponentCreate <UIImage, UIImage.Model>(scene,
                                                                                                 CLASS_ID.UI_IMAGE_SHAPE,
                                                                                                 new UIImage.Model
            {
                parentComponent = uiContainerStack.id,
                width           = new UIValue(75f),
                height          = new UIValue(35f)
            });

            yield return(childComponent2.routine);

            /// Create 3rd child object
            UIInputText childComponent3 = TestHelpers.SharedComponentCreate <UIInputText, UIInputText.Model>(scene,
                                                                                                             CLASS_ID.UI_INPUT_TEXT_SHAPE,
                                                                                                             new UIInputText.Model
            {
                parentComponent = uiContainerStack.id,
                width           = new UIValue(150f),
                height          = new UIValue(50f)
            });

            yield return(childComponent3.routine);

            RectTransform child1RT = childComponent1.referencesContainer.transform.parent as RectTransform;
            RectTransform child2RT = childComponent2.referencesContainer.transform.parent as RectTransform;
            RectTransform child3RT = childComponent3.referencesContainer.transform.parent as RectTransform;

            Assert.AreEqual(new Vector2(65, -35).ToString(), child1RT.anchoredPosition.ToString());
            Assert.AreEqual(new Vector2(167.5f, -17.5f).ToString(), child2RT.anchoredPosition.ToString());
            Assert.AreEqual(new Vector2(280, -25).ToString(), child3RT.anchoredPosition.ToString());

            Assert.AreEqual(new Vector2(130, 70).ToString(), child1RT.sizeDelta.ToString());
            Assert.AreEqual(new Vector2(75, 35).ToString(), child2RT.sizeDelta.ToString());
            Assert.AreEqual(new Vector2(150, 50).ToString(), child3RT.sizeDelta.ToString());

            screenSpaceShape.Dispose();
            yield return(null);
        }
Exemple #9
0
        public BaseDisposable SharedComponentCreate(string id, int classId)
        {
            BaseDisposable disposableComponent;

            if (disposableComponents.TryGetValue(id, out disposableComponent))
            {
                return(disposableComponent);
            }

            BaseDisposable newComponent = null;

            switch ((CLASS_ID)classId)
            {
            case CLASS_ID.BOX_SHAPE:
            {
                newComponent = new BoxShape(this);
                break;
            }

            case CLASS_ID.SPHERE_SHAPE:
            {
                newComponent = new SphereShape(this);
                break;
            }

            case CLASS_ID.CONE_SHAPE:
            {
                newComponent = new ConeShape(this);
                break;
            }

            case CLASS_ID.CYLINDER_SHAPE:
            {
                newComponent = new CylinderShape(this);
                break;
            }

            case CLASS_ID.PLANE_SHAPE:
            {
                newComponent = new PlaneShape(this);
                break;
            }

            case CLASS_ID.GLTF_SHAPE:
            {
                newComponent = new GLTFShape(this);
                break;
            }

            case CLASS_ID.NFT_SHAPE:
            {
                newComponent = new NFTShape(this);
                break;
            }

            case CLASS_ID.OBJ_SHAPE:
            {
                newComponent = new OBJShape(this);
                break;
            }

            case CLASS_ID.BASIC_MATERIAL:
            {
                newComponent = new BasicMaterial(this);
                break;
            }

            case CLASS_ID.PBR_MATERIAL:
            {
                newComponent = new PBRMaterial(this);
                break;
            }

            case CLASS_ID.AUDIO_CLIP:
            {
                newComponent = new DCLAudioClip(this);
                break;
            }

            case CLASS_ID.TEXTURE:
            {
                newComponent = new DCLTexture(this);
                break;
            }

            case CLASS_ID.UI_INPUT_TEXT_SHAPE:
            {
                newComponent = new UIInputText(this);
                break;
            }

            case CLASS_ID.UI_FULLSCREEN_SHAPE:
            case CLASS_ID.UI_SCREEN_SPACE_SHAPE:
            {
                if (GetSharedComponent <UIScreenSpace>() == null)
                {
                    newComponent = new UIScreenSpace(this);
                }

                break;
            }

            case CLASS_ID.UI_CONTAINER_RECT:
            {
                newComponent = new UIContainerRect(this);
                break;
            }

            case CLASS_ID.UI_SLIDER_SHAPE:
            {
                newComponent = new UIScrollRect(this);
                break;
            }

            case CLASS_ID.UI_CONTAINER_STACK:
            {
                newComponent = new UIContainerStack(this);
                break;
            }

            case CLASS_ID.UI_IMAGE_SHAPE:
            {
                newComponent = new UIImage(this);
                break;
            }

            case CLASS_ID.UI_TEXT_SHAPE:
            {
                newComponent = new UIText(this);
                break;
            }

            case CLASS_ID.VIDEO_CLIP:
            {
                newComponent = new DCLVideoClip(this);
                break;
            }

            case CLASS_ID.VIDEO_TEXTURE:
            {
                newComponent = new DCLVideoTexture(this);
                break;
            }

            case CLASS_ID.FONT:
            {
                newComponent = new DCLFont(this);
                break;
            }

            case CLASS_ID.NAME:
            {
                newComponent = new DCLName(this);
                break;
            }

            case CLASS_ID.LOCKED_ON_EDIT:
            {
                newComponent = new DCLLockedOnEdit(this);
                break;
            }

            case CLASS_ID.VISIBLE_ON_EDIT:
            {
                newComponent = new DCLVisibleOnEdit(this);
                break;
            }

            default:
                Debug.LogError($"Unknown classId");
                break;
            }

            if (newComponent != null)
            {
                newComponent.id = id;
                disposableComponents.Add(id, newComponent);
                OnAddSharedComponent?.Invoke(id, newComponent);
            }

            return(newComponent);
        }
        public IEnumerator OnPointerHoverFeedbackIsBlockedByUI()
        {
            IDCLEntity entity;
            BoxShape   shape;

            shape = TestHelpers.InstantiateEntityWithShape <BoxShape, BoxShape.Model>(
                scene,
                DCL.Models.CLASS_ID.BOX_SHAPE,
                Vector3.zero,
                out entity,
                new BoxShape.Model()
            {
            });

            TestHelpers.SetEntityTransform(scene, entity, new Vector3(8, 2, 10), Quaternion.identity, new Vector3(3, 3, 3));
            yield return(shape.routine);

            var onPointerDownModel = new OnPointerDown.Model()
            {
                type = OnPointerDown.NAME,
                uuid = "pointerevent-1"
            };
            var component = TestHelpers.EntityComponentCreate <OnPointerDown, OnPointerDown.Model>(scene, entity,
                                                                                                   onPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);

            Assert.IsTrue(component != null);

            yield return(null);

            DCLCharacterController.i.SetPosition(new Vector3(8, 1, 7f));

            var cameraController = GameObject.FindObjectOfType <CameraController>();

            // Rotate camera towards the interactive object
            cameraController.SetRotation(45, 0, 0);

            yield return(null);

            var hoverCanvasController = InteractionHoverCanvasController.i;

            Assert.IsNotNull(hoverCanvasController);

            // Check hover feedback is enabled
            Assert.IsTrue(hoverCanvasController.canvas.enabled);

            // Put UI in the middle
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            UIContainerRect uiContainerRectShape =
                TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                           CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainerRectShape.routine);

            yield return(null);

            // Check hover feedback is no longer enabled
            Assert.IsFalse(hoverCanvasController.canvas.enabled);

            DCLCharacterController.i.ResumeGravity();
        }
        public IEnumerator TestPropertiesAreAppliedCorrectly()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            // Create UIContainerRectShape
            UIContainerRect uiContainerRectShape =
                TestHelpers.SharedComponentCreate <UIContainerRect, UIContainerRect.Model>(scene,
                                                                                           CLASS_ID.UI_CONTAINER_RECT);

            yield return(uiContainerRectShape.routine);

            UnityEngine.UI.Image image = uiContainerRectShape.referencesContainer.image;

            // Check default properties are applied correctly
            Assert.AreEqual(0f, uiContainerRectShape.referencesContainer.canvasGroup.alpha);
            Assert.IsTrue(image.GetComponent <Outline>() == null);
            Assert.IsTrue(image.color == new Color(0f, 0f, 0f, 0f));
            Assert.IsTrue(uiContainerRectShape.referencesContainer.canvasGroup.blocksRaycasts);
            Assert.AreEqual(100f, uiContainerRectShape.childHookRectTransform.rect.width);
            Assert.AreEqual(50f, uiContainerRectShape.childHookRectTransform.rect.height);
            Assert.AreEqual(Vector3.zero, uiContainerRectShape.childHookRectTransform.localPosition);

            // Update UIContainerRectShape properties
            uiContainerRectShape = scene.SharedComponentUpdate(uiContainerRectShape.id, JsonUtility.ToJson(new UIContainerRect.Model
            {
                parentComponent  = screenSpaceShape.id,
                thickness        = 5,
                color            = new Color(0.2f, 0.7f, 0.05f, 1f),
                isPointerBlocker = false,
                width            = new UIValue(275f),
                height           = new UIValue(130f),
                positionX        = new UIValue(-30f),
                positionY        = new UIValue(-15f),
                hAlign           = "right",
                vAlign           = "bottom"
            })) as UIContainerRect;

            yield return(uiContainerRectShape.routine);

            // Check updated properties are applied correctly
            Assert.AreEqual(1f, uiContainerRectShape.referencesContainer.canvasGroup.alpha);
            Assert.IsTrue(uiContainerRectShape.referencesContainer.transform.parent == screenSpaceShape.childHookRectTransform);
            Assert.IsTrue(image.GetComponent <Outline>() != null);
            Assert.IsTrue(image.color == new Color(0.2f, 0.7f, 0.05f, 1f));
            Assert.IsFalse(uiContainerRectShape.referencesContainer.canvasGroup.blocksRaycasts);
            Assert.AreEqual(275f, uiContainerRectShape.childHookRectTransform.rect.width);
            Assert.AreEqual(130f, uiContainerRectShape.childHookRectTransform.rect.height);
            Assert.IsTrue(uiContainerRectShape.referencesContainer.layoutGroup.childAlignment == TextAnchor.LowerRight);

            Vector2 alignedPosition = CalculateAlignedAnchoredPosition(screenSpaceShape.childHookRectTransform.rect,
                                                                       uiContainerRectShape.childHookRectTransform.rect, "bottom", "right");

            alignedPosition += new Vector2(-30, -15); // apply offset position

            Assert.AreEqual(alignedPosition.ToString(),
                            uiContainerRectShape.childHookRectTransform.anchoredPosition.ToString());

            screenSpaceShape.Dispose();
        }