示例#1
0
        /// <summary>
        /// Gets a layer's raw scroll vector from an input value.
        /// </summary>
        /// <remarks>
        /// Useful for figuring out how much a layer will scroll without moving it.
        /// </remarks>
        public static Vector2 GetRawScrollVector(ScrollLayer layer, Vector2 scrollValue)
        {
            if (!instance)
            {
                Debug.LogError("Error: Trying to get raw scroll vector without a parallax manager!");
                return(Vector2.zero);
            }

            if (layer.isObjectLayer && !layer.objectLayerPixelSpace)
            {
                if (instance.GetScrollConstraints() == ScrollConstraints.X)
                {
                    return(instance.GetParallaxCamera().transform.right * -scrollValue.x * instance.baseSpeed * layer.GetScrollSpeed() * layer.GetScrollMod());
                }
                else if (instance.GetScrollConstraints() == ScrollConstraints.Y)
                {
                    return(instance.GetParallaxCamera().transform.up * -scrollValue.y * instance.baseSpeed * layer.GetScrollSpeed() * layer.GetScrollMod());
                }
                else
                {
                    Vector3 sV = (instance.GetParallaxCamera().transform.right * -scrollValue.x) + (instance.GetParallaxCamera().transform.up * -scrollValue.y);
                    return(sV * instance.baseSpeed * layer.GetScrollSpeed() * layer.GetScrollMod());
                }
            }
            else
            {
                return(scrollValue * instance.baseSpeed * layer.GetScrollSpeed() * layer.GetScrollMod());
            }
        }
示例#2
0
 /// <summary>
 /// Syncs the component to the scroll layer.
 /// </summary>
 /// <remarks>
 /// If you edit a scroll layer's properties through code and this component is present, you will need to call this method.
 /// </remarks>
 public void SyncToScrollLayer()
 {
     weight      = scrollLayer.GetWeight();
     scrollSpeed = scrollLayer.GetScrollSpeed();
     scrollMod   = scrollLayer.GetScrollMod();
     offset      = scrollLayer.offset;
     pixelOffset = scrollLayer.pixelOffset;
     padding     = scrollLayer.padding;
 }