예제 #1
0
        private void UpdateFloatPosition()
        {
            float finalDesiredPositionZ = desiredPositionZ;

            if (!isInteractable)
            {
                finalDesiredPositionZ = 0.0f;
            }

            if (finalDesiredPositionZ != transform.localPosition.z)
            {
                Vector3 localPosition   = transform.localPosition;
                Vector3 desiredPosition = localPosition;
                desiredPosition.z       = finalDesiredPositionZ;
                localPosition           = Vector3.Lerp(localPosition, desiredPosition, Time.deltaTime * interpolationSpeed);
                transform.localPosition = localPosition;

                TiledPage page = GetPage();
                if (page != null)
                {
                    float diff = Mathf.Abs(localPosition.z);

                    if (diff < ((PARENT_CHANGE_THRESHOLD_PERCENT * hoverPositionZMeters) / GetMetersToCanvasScale()) &&
                        transform.parent == page.transform)
                    {
                        transform.SetParent(originalParent, true);
                        transform.SetAsLastSibling();
                    }
                    else if (isHovering && diff >= 0 && transform.parent == originalParent)
                    {
                        transform.SetParent(page.transform, true);
                    }
                }
            }
        }
예제 #2
0
 protected TiledPage GetPage()
 {
     if (page == null)
     {
         page = GetComponentInParent <TiledPage>();
     }
     return(page ? page : null);
 }
예제 #3
0
        public virtual void Reset()
        {
            OnPointerExit(null);

            transform.SetParent(originalParent, true);
            transform.localRotation = originalRotation;
            transform.localPosition = originalPosition;
            transform.localScale    = originalScale;

            page = null;
            metersToCanvasScale = null;
        }
예제 #4
0
        public override void ApplyEffect(BaseScrollEffect.UpdateData updateData)
        {
            TiledPage tiledPage = updateData.page.GetComponent <TiledPage>();

            if (tiledPage == null)
            {
                Debug.LogError("Page (" + updateData.page.name + ") does not have TiledPage. " +
                               "Cannot apply TileScrollEffect.");
                return;
            }

            /// Calculate the distance between the scroll position and this page.
            float difference        = updateData.scrollOffset - updateData.pageOffset;
            float clampedDifference = Mathf.Clamp(difference, -updateData.spacing, updateData.spacing);

            tiledPage.ApplyScrollEffect(clampedDifference, updateData.spacing, updateData.isInteractable);
        }