Beispiel #1
0
 public override void UpdateGUI(bool force)
 {
     if (!HasFocus() || force)
     {
         try
         {
             var value = (U)System.Convert.ChangeType(m_Value, typeof(U));
             m_Field.SetValueWithoutNotify(value);
         }
         catch (System.Exception ex)
         {
             Debug.LogError("Catching exception to not break graph in UpdateGUI" + ex.Message);
         }
     }
 }
        static INotifyValueChanged <F> CreateFieldS <F>(string _label, F _value, Type _realFieldType, Action <object> _onValueChanged)
        {
            INotifyValueChanged <F> fieldDrawer = null;

            // 如果没有Drawer创建方法,返回空
            if (!fieldDrawerCreatorMap.TryGetValue(typeof(F), out Func <Type, BindableElement> drawerCreator))
            {
                return(null);
            }

            // 创建Drawer,设置初始值,注册onValueChanged方法
            fieldDrawer = drawerCreator(_realFieldType) as INotifyValueChanged <F>;
            fieldDrawer.SetValueWithoutNotify(_value);
            fieldDrawer.RegisterValueChangedCallback((e) =>
            {
                _onValueChanged(e.newValue);
            });

            BaseField <F> tDrawer = fieldDrawer as BaseField <F>;

            tDrawer.label = _label;
            return(fieldDrawer);
        }