Beispiel #1
0
        public RectTransform Render(GameOption gameOption, Transform parent = null)
        {
            parent = parent == null ? transform : parent;
            switch (gameOption)
            {
            case SliderOption sliderOption:
                var sliderObject = Instantiate(SliderPrefab, parent);
                sliderObject.GetComponent <SliderOptionRenderer>().GameOption = sliderOption;
                return(sliderObject.GetComponent <RectTransform>());

            case ToggleOption toggleOption:
                var toggleObject = Instantiate(TogglePrefab, parent);
                toggleObject.GetComponent <ToggleOptionRenderer>().GameOption = toggleOption;
                return(toggleObject.GetComponent <RectTransform>());

            default:
                throw new InvalidOperationException("WHAT DID YOU DOOOOOOOO");
            }
        }
Beispiel #2
0
 /// <summary>
 /// A method to be used as <see cref="GameOption.DisplayLabel_RenderFunction"/> if the user does not pass a new function to the <see cref="ToggleOption"/> constructor.
 /// </summary>
 /// <param name="gameOption"></param>
 /// <returns></returns>
 private static string DisplayLabel_RenderFunction_ToggleOverride(GameOption gameOption) => gameOption.DisplayName;
Beispiel #3
0
 protected override void UpdateDisplay()
 {
     Toggle.SetIsOnWithoutNotify(GameOption.ValueAs <bool>());
 }