예제 #1
0
        public bool PositionChanged()
        {
            if (BranchPosition.IsWorldPosition == false)
            {
                return(false);
            }
            BranchPosition.BoundsOffset = Origin.rect.size / 2;

            if (Origin.position != BranchPosition.GetPositionIn(Camera, Canvas))
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Updates the direction of the branch based on the quadrant the origin is currently located in.
        /// </summary>
        private void UpdateDirection()
        {
            if (BranchPosition.IsWorldPosition)
            {
                BranchPosition.BoundsOffset = Origin.rect.size / 2;
                Origin.position             = BranchPosition.GetPositionIn(Camera, Canvas);
            }

            var relativePos = Origin.anchoredPosition - Target.anchoredPosition;
            var dir         = new Vector3(Mathf.Sign(relativePos.x), Mathf.Sign(relativePos.y), 1f);

            if (dir.Equals(CurrentQuadrant))
            {
                return;
            }
            CurrentQuadrant = dir;
            SetOriginScale();
        }