예제 #1
0
        public void CreateDebugSlider(string titleText, Color sliderColor, DebugFloat floatValue, float maxValue, float minValue)
        {
            if (registeredSliders == null)
            {
                registeredSliders = new List <string>();
            }
            if (registeredSliders.Contains(titleText))
            {
                return;
            }
            registeredSliders.Add(titleText);
            GameObject  newSlider = Instantiate(sliderPrefab, vertLayout);
            DebugSlider slider    = newSlider.GetComponent <DebugSlider>();

            slider.Init(titleText, sliderColor, floatValue, maxValue, minValue);
            sliders.Add(slider);
            newSlider.transform.SetAsFirstSibling();
        }
예제 #2
0
 public void Init(string titleText, Color sliderColor, DebugFloat floatValue, float maxValue, float minValue)
 {
     //UnityEngine.Debug.Log("Creating Debug Slider: " + titleText + ", " + floatValue);
     titleLabel.text    = titleText;
     sliderBG.color     = new Color(sliderColor.r / 2f, sliderColor.g / 2f, sliderColor.b / 2f);
     sliderHandle.color = sliderColor;
     slider.maxValue    = maxValue;
     slider.minValue    = minValue;
     this.floatValue    = floatValue;
     if (PlayerPrefs.HasKey("DEBUG_" + titleLabel.text))
     {
         float value = PlayerPrefs.GetFloat("DEBUG_" + titleLabel.text);
         //UnityEngine.Debug.Log("Loaded saved value " + value + " with key: " + "DEBUG_" + titleLabel.text);
         slider.value = value;
         floatValue.UpdateValue(value);
         valueLabel.text = value.ToString();
     }
     else
     {
         slider.value    = floatValue;
         valueLabel.text = floatValue.ToString();
     }
 }