Ejemplo n.º 1
0
        /// <summary>
        /// Updates layout.
        /// </summary>
        public override bool UpdateLayout(bool notifyParent = true)
        {
            bool defaultDisableLayoutUpdate = DisableLayoutUpdate;

            DisableLayoutUpdate = true;

            if (Width == null)
            {
                Width = Orientation == ElementOrientation.Horizontal ? Length : Breadth;
            }
            if (Height == null)
            {
                Height = Orientation == ElementOrientation.Horizontal ? Breadth : Length;
            }

            // if vertical slider rotate slide region 90 degrees
            if (Orientation == ElementOrientation.Vertical)
            {
                SliderRegion.DisableLayoutUpdate = true;
                SliderRegion.Width  = new ElementSize(RectTransform.rect.height, ElementSizeUnit.Pixels);
                SliderRegion.Height = new ElementSize(RectTransform.rect.width, ElementSizeUnit.Pixels);
                SliderRegion.RectTransform.localRotation = Quaternion.Euler(new Vector3(0, 0, 90));
                SliderRegion.UpdateLayout(false);
                SliderRegion.DisableLayoutUpdate = false;
            }

            SliderFillImageView.Alignment   = IsReversed ? ElementAlignment.Right : ElementAlignment.Left;
            SliderHandleImageView.Alignment = IsReversed ? ElementAlignment.Right : ElementAlignment.Left;

            // update slider position
            UpdateSliderPosition(Value);

            DisableLayoutUpdate = defaultDisableLayoutUpdate;
            return(base.UpdateLayout(notifyParent));
        }
Ejemplo n.º 2
0
 // called each frame
 private void Update()
 {
     this.speed = waveTracker.SliderSpeed;
     MoveSlider();                                        // advance slider position
     CheckForTurnAround();                                // reverse speed if slider at end of bar
     if (Input.GetKeyDown(KeyCode.Space))                 // check for user input
     {
         SliderRegion activatedRegion = CheckForRegion(); // get region slider is over
         if (activatedRegion != null)
         {
             activatedRegion.UseRegion();
         }
         else  // if user missed
         {
             MissedRegion();
         }
     }
 }