using System.Collections.Generic; using System.Linq; using UnityEngine; namespace RosettaUI { /// /// UICustomのデフォルト設定登録 /// public static partial class UICustom { static UICustom() { RegisterDefaultPropertyAttributeFunc(); } private static void RegisterDefaultPropertyAttributeFunc() { RegisterPropertyAttributeFunc(RangeAttributeFunc); RegisterPropertyAttributeCreateTopElementFunc(HeaderAttributeFunc); RegisterPropertyAttributeCreateTopElementFunc(SpaceAttributeFunc); RegisterPropertyAttributeFunc(MultilineAttributeFunc); } #region PropertyAttributeFunc private static Element RangeAttributeFunc(RangeAttribute rangeAttribute, LabelElement label, IBinder binder) { var (minGetter, maxGetter) = RangeUtility.CreateGetterMinMax(rangeAttribute, binder.ValueType); return UI.Slider(label, binder, minGetter, maxGetter); } private static IEnumerable HeaderAttributeFunc(HeaderAttribute headerAttribute, Element _) { yield return UI.Space().SetHeight(18f); yield return UI.Label($"{headerAttribute.header}"); } private static IEnumerable SpaceAttributeFunc(SpaceAttribute spaceAttribute, Element _) { yield return UI.Space().SetHeight(spaceAttribute.height); } private static Element MultilineAttributeFunc(MultilineAttribute _, Element originalElement) { var textField = originalElement.Query().FirstOrDefault(); if (textField != null) { textField.IsMultiLine = true; } return originalElement; } #endregion } }