示例#1
0
        public void Update(bool forceUpdate = false)
        {
            if (Dirty || forceUpdate)
            {
                if (spriteRenderer != null)
                {
                    spriteRenderer.sprite = State ? busySprite : idleSprite;
                }

                if (sizeUnitType == TouchUnitType.Pixels)
                {
                    var pixelSize = TouchUtility.RoundVector(size);
                    ScaleSpriteInPixels(spriteGameObject, spriteRenderer, pixelSize);
                    worldSize = pixelSize * TouchManager.PixelToWorld;
                }
                else
                {
                    ScaleSpriteInPercent(spriteGameObject, spriteRenderer, size);
                    worldSize = size * TouchManager.PercentToWorld;
                }

                Dirty = false;
            }

            if (spriteRenderer != null)
            {
                var color = State ? busyColor : idleColor;
                if (spriteRenderer.color != color)
                {
                    spriteRenderer.color = Utility.MoveColorTowards(spriteRenderer.color, color, 5.0f * Time.deltaTime);
                }
            }
        }
        public override void ConfigureControl()
        {
            var worldOffset = (Vector3)offset * TouchManager.UnitToWorld;

            transform.position = TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset;

            ScaleSprite(buttonGameObject, buttonRenderer, buttonSize);

            worldButtonSize = buttonSize * TouchManager.HalfUnitToWorld;
        }
示例#3
0
        protected Vector3 OffsetToWorldPosition(TouchControlAnchor anchor, Vector2 offset, TouchUnitType offsetUnitType)
        {
            Vector3 worldOffset;

            if (offsetUnitType == TouchUnitType.Pixels)
            {
                worldOffset = TouchUtility.RoundVector(offset) * TouchManager.PixelToWorld;
            }
            else
            {
                worldOffset = (Vector3)offset * TouchManager.PercentToWorld;
            }
            return(TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset);
        }
        public override void ConfigureControl()
        {
            var worldOffset = (Vector3)offset * TouchManager.UnitToWorld;

            resetPosition      = TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset;
            transform.position = resetPosition;

            ScaleSprite(ringGameObject, ringRenderer, ringSize);
            ScaleSprite(knobGameObject, knobRenderer, knobSize);

            worldActiveArea = TouchManager.ViewToWorldRect(activeArea);
            worldRingSize   = ringSize * TouchManager.HalfUnitToWorld;
            worldKnobSize   = knobSize * TouchManager.HalfUnitToWorld;
            worldKnobRange  = knobRange * TouchManager.HalfUnitToWorld;
        }
示例#5
0
 public void Update(bool forceUpdate)
 {
     if (Dirty || forceUpdate)
     {
         if (spriteRenderer != null)
         {
             spriteRenderer.sprite = ((!State) ? idleSprite : busySprite);
         }
         if (sizeUnitType == TouchUnitType.Pixels)
         {
             Vector2 a = TouchUtility.RoundVector(size);
             ScaleSpriteInPixels(spriteGameObject, spriteRenderer, a);
             worldSize = a * TouchManager.PixelToWorld;
         }
         else
         {
             ScaleSpriteInPercent(spriteGameObject, spriteRenderer, size);
             if (lockAspectRatio)
             {
                 worldSize = size * TouchManager.PercentToWorld;
             }
             else
             {
                 worldSize = Vector2.Scale(size, TouchManager.ViewSize);
             }
         }
         Dirty = false;
     }
     if (spriteRenderer != null)
     {
         Color color = (!State) ? idleColor : busyColor;
         if (spriteRenderer.color != color)
         {
             spriteRenderer.color = Utility.MoveColorTowards(spriteRenderer.color, color, 5f * Time.deltaTime);
         }
     }
 }
示例#6
0
        protected Vector3 OffsetToWorldPosition(TouchControlAnchor anchor, Vector2 offset, TouchUnitType offsetUnitType, bool lockAspectRatio)
        {
            Vector3 b = (offsetUnitType == TouchUnitType.Pixels) ? ((Vector3)(TouchUtility.RoundVector(offset) * TouchManager.PixelToWorld)) : ((!lockAspectRatio) ? Vector3.Scale(offset, TouchManager.ViewSize) : ((Vector3)offset * TouchManager.PercentToWorld));

            return(TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + b);
        }