Example #1
0
    public static float GetSelfParentPosition(RectTransform self, HorizontalOrientations orientation)
    {
        RectTransform parentTransform = ((RectTransform)self.parent.transform);
        float         rightPoint      = self.anchorMax.x * parentTransform.rect.width;
        float         leftPoint       = self.anchorMin.x * parentTransform.rect.width;

        if (orientation == HorizontalOrientations.Right)
        {
            return(parentTransform.rect.width - rightPoint);
        }
        else
        {
            return(0 - leftPoint);
        }
    }
Example #2
0
    public static Tweener MoveOutHorSide(RectTransform transformToMove, float movementSpeed, HorizontalOrientations moveOutTo, Ease ease = Ease.Unset)
    {
        Vector2 outsidePos             = transformToMove.anchoredPosition;
        float   widthCalculationObject = transformToMove.rect.width;

        outsidePos.x = GetSelfParentPosition(transformToMove, moveOutTo);

        if (moveOutTo == HorizontalOrientations.Right)
        {
            outsidePos.x += widthCalculationObject * transformToMove.pivot.x;
        }
        else
        {
            outsidePos.x -= widthCalculationObject * (1 - transformToMove.pivot.x);
        }


        return(transformToMove.DOAnchorPosX(outsidePos.x, movementSpeed).SetEase(ease));
    }
Example #3
0
 public static Tweener MoveOutHorSide(Transform transformToCastAndMove, float movementSpeed, HorizontalOrientations moveOutTo, Ease ease = Ease.Unset)
 {
     return(MoveOutHorSide((RectTransform)transformToCastAndMove, movementSpeed, moveOutTo, ease));
 }