Example #1
0
 public void SetPreviewInstance(ColorPickerPreviewClickable instance)
 {
     _ColorPickerPreviewClickableInst = instance;
 }
Example #2
0
 public T AddColorPickerSetting <T>(string name, Color color, out ColorPickerPreviewClickable clickablePreview) where T : MonoBehaviour
 {
     return(AddColorPickerSetting <T>(name, "", color, out clickablePreview));
 }
Example #3
0
        public T AddColorPickerSetting <T>(string name, string hintText, Color color, out ColorPickerPreviewClickable clickablePreview) where T : MonoBehaviour
        {
            var        volumeSettings    = Resources.FindObjectsOfTypeAll <SwitchSettingsController>().FirstOrDefault();
            GameObject newSettingsObject = MonoBehaviour.Instantiate(volumeSettings.gameObject, transform);

            newSettingsObject.name = name;

            SwitchSettingsController volume    = newSettingsObject.GetComponent <SwitchSettingsController>();
            T newColorPickerSettingsController = (T)ReflectionUtil.CopyComponent(volume, typeof(MonoBehaviour), typeof(T), newSettingsObject);

            MonoBehaviour.DestroyImmediate(volume);

            GameObject.Destroy(newSettingsObject.GetComponentInChildren <HorizontalLayoutGroup>());
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("DecButton").gameObject);
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("ValueText").gameObject);
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("IncButton").gameObject);

            ColorPickerPreviewClickable cppc = new GameObject("ColorPickerPreviewClickable").AddComponent <ColorPickerPreviewClickable>();

            cppc.transform.SetParent(newSettingsObject.transform.Find("Value"), false);
            cppc.ImagePreview.color = color;
            (cppc.transform as RectTransform).localScale     = new Vector2(0.06f, 0.06f);
            (cppc.transform as RectTransform).localPosition += new Vector3(3f, 0.1f);
            clickablePreview = cppc;

            var tmpText = newSettingsObject.GetComponentInChildren <TMP_Text>();

            tmpText.text = name;
            if (hintText != String.Empty)
            {
                BeatSaberUI.AddHintText(tmpText.rectTransform, hintText);
            }

            viewController?.AddSubmenuOption(newSettingsObject);
            AddHooks(newColorPickerSettingsController);
            return(newColorPickerSettingsController);
        }
Example #4
0
 public override void Init()
 {
     _ColorPickerPreviewClickableInst = transform.GetComponentInChildren <ColorPickerPreviewClickable>();
     _ColorPickerPreviewClickableInst.ImagePreview.color = GetInitValue();
 }