/// <summary>
        /// Create a slider at the specified position, assign it to a parent <c>Component</c> and return it.
        /// </summary>
        /// <remarks>
        /// Uses <c>STANDARD_UI_ELEMENT_HEIGHT</c> to determine the
        /// width and height of this object. Using other values might lead to weird results.
        /// </remarks>
        /// <param name="parent">The sliders's supposed parent.</param>
        /// <param name="name">The Unity name of the slider.</param>
        /// <param name="value">The default value of the slider.</param>
        /// <param name="min">The minimum value the slider can be set to.</param>
        /// <param name="min">The maximum value the slider can be set to.</param>
        /// <param name="x">The x-position of the slider, relative to the container's upper left corner.</param>
        /// <param name="y">The y-position of the slider, relative to the container's upper left corner.</param>
        /// <param name="width">The width of the slider. Note that this includes the label at the side.</param>
        /// <returns>The created slider.</returns>
        public static SelectableSliderHelper AddSliderToComponent(Component parent, string name, int value, int min, int max, float x, float y, float width)
        {
            SelectableSliderHelper slider = GameObject.Instantiate(sliderTemplate, parent.transform);

            slider.Set(value, min, max);
            (slider.transform as RectTransform).anchorMin = new Vector2(0, 1);
            (slider.transform as RectTransform).anchorMax = new Vector2(0, 1);
            (slider.transform as RectTransform).offsetMin = new Vector2(x, -y - 50);
            (slider.transform as RectTransform).offsetMax = new Vector2(x + width, -y);
            return(slider);
        }
Example #2
0
 private void UpdateProgressFilter()
 {
     progressMinSlider.Set(progressFilter.MinValue, 1, 9);
     progressMaxSlider.Set(progressFilter.MaxValue, 1, 9);
 }
Example #3
0
 // If UI elements can be changed by other UI elements, implement Update functions (in this case,
 // make sure that the max value is always >= the min value).
 private void UpdateCovenantFilter()
 {
     covenantMinSlider.Set(covenantFilter.MinValue, 0, 25);
     covenantMaxSlider.Set(covenantFilter.MaxValue, 0, 25);
 }