Exemple #1
0
 public void SetData(MToken data)
 {
     BinderUtil.SetValueToBinder(data, _mainBinder);
     for (var i = 0; i < _extendBinders.Count; i++)
     {
         BinderUtil.SetValueToBinder(data, _extendBinders[i]);
     }
 }
Exemple #2
0
        public bool HasEditorError()
        {
            if (BinderUtil.IsUnityEventHasError(_onValueChangeEvent))
            {
                return(true);
            }
            if (BinderUtil.IsUnityEventHasError(_onValueTrueEvent))
            {
                return(true);
            }
            if (BinderUtil.IsUnityEventHasError(_onValueFalseEvent))
            {
                return(true);
            }

            return(false);
        }
Exemple #3
0
        public void SetData(MObject data)
        {
            for (var i = 0; i < _binders.Count; i++)
            {
                var serializedBinder = _binders[i];
                //var modelMember = _modelMemberToBinderInfo[serializedBinder.FieldName];
                if (serializedBinder.BinderInstance == null)
                {
                    Debug.LogWarningFormat(this, "binder for [{0}] is null", serializedBinder.FieldName);
                    continue;
                }

                var value = data[serializedBinder.FieldName];

                BinderUtil.SetValueToBinder(value, serializedBinder.BinderInstance);
            }
        }
Exemple #4
0
        public MObject GetData()
        {
            var obj = new MObject();

            for (var i = 0; i < _binders.Count; i++)
            {
                var serializedBinder = _binders[i];

                if (serializedBinder.BinderInstance == null)
                {
                    Debug.LogWarningFormat(this, "binder for [{0}] is null", serializedBinder.FieldName);
                    continue;
                }

                obj.Add(serializedBinder.FieldName, BinderUtil.GetValueFromBinder(serializedBinder.BinderInstance));
            }
            return(obj);
        }
Exemple #5
0
        public bool HasEditorError()
        {
            if (_eventSettings == null || _eventSettings.Count == 0)
            {
                return(true);
            }

            if (_eventSettings.Any(s => s == null || BinderUtil.IsUnityEventHasError(s.Event)))
            {
                return(true);
            }

            if (GetComponent <Graphic>() == null)
            {
                return(true);
            }

            return(false);
        }
Exemple #6
0
        public bool HasEditorError()
        {
            if (_elementBinder == null)
            {
                return(true);
            }

            if (_elementType == ArrayElementTypeEnum.Custom &&
                TypeUtil.GetTypeWithAssemblyTypeString(_customElementTypeString) == null)
            {
                return(true);
            }

            if (BinderUtil.IsUnityEventHasError(_afterReceiveEvent))
            {
                return(true);
            }

            return(false);
        }
Exemple #7
0
        void DrawSerializeFields(Type modelType)
        {
            var beforeSerializedValues = new Dictionary <string, ModelObjectBinder.SerializedBinder>();

            for (var i = 0; i < _bindersProperty.arraySize; i++)
            {
                var element = _bindersProperty.GetArrayElementAtIndex(i);
                var value   = new ModelObjectBinder.SerializedBinder()
                {
                    FieldName      = element.FindPropertyRelative("FieldName").stringValue,
                    ManualInput    = element.FindPropertyRelative("ManualInput").boolValue,
                    TokenType      = (MTokenType)element.FindPropertyRelative("TokenType").intValue,
                    BinderInstance = element.FindPropertyRelative("BinderInstance").objectReferenceValue
                };
                if (!string.IsNullOrEmpty(value.FieldName))
                {
                    beforeSerializedValues.Add(value.FieldName, value);
                }
            }

            var afterSerializedValues = new List <ModelObjectBinder.SerializedBinder>();
            //var afterSerializedValues = new Dictionary<string, UnityEngine.Object>();
            var toSerializeMembers = BinderUtil.GetRequireBinderInfoFromModelMembers(modelType);

            foreach (var member in toSerializeMembers)
            {
                var fieldName = member.Key;
                ModelObjectBinder.SerializedBinder binderInfo;
                if (!beforeSerializedValues.TryGetValue(fieldName, out binderInfo))
                {
                    binderInfo = new ModelObjectBinder.SerializedBinder()
                    {
                        FieldName   = fieldName,
                        ManualInput = false,
                        TokenType   = member.Value.BinderInfo.TokenType
                    };
                }

                if (member.Value.BinderInfo.TokenType == MTokenType.Dynamic)
                {
                    EditorGUILayout.LabelField(fieldName, member.Value.BinderInfo.ValueTypeName + "is not supported. Use float instead.");
                }
                else
                {
                    binderInfo.BinderInstance = EditorKit.DrawBinderField(
                        fieldName, member.Value.BinderInfo.ValueTypeName, binderInfo.BinderInstance, member.Value.BinderInfo.InterfaceType);
                }
                afterSerializedValues.Add(binderInfo);
            }

            for (var i = beforeSerializedValues.Count - 1; i >= afterSerializedValues.Count; i--)
            {
                _bindersProperty.DeleteArrayElementAtIndex(i);
            }

            for (var i = 0; i < afterSerializedValues.Count; i++)
            {
                if (i >= _bindersProperty.arraySize)
                {
                    _bindersProperty.InsertArrayElementAtIndex(i);
                }
                var data    = afterSerializedValues[i];
                var element = _bindersProperty.GetArrayElementAtIndex(i);
                element.FindPropertyRelative("FieldName").stringValue = data.FieldName;
                element.FindPropertyRelative("ManualInput").boolValue = data.ManualInput;
                element.FindPropertyRelative("TokenType").intValue    = (int)data.TokenType;
                element.FindPropertyRelative("BinderInstance").objectReferenceValue = data.BinderInstance;
            }
        }
Exemple #8
0
 public MToken GetData()
 {
     return(BinderUtil.GetValueFromBinder(_mainBinder) as MBool);
 }
Exemple #9
0
 public MToken GetData()
 {
     return(BinderUtil.GetValueFromBinder(_elementBinder));
 }
Exemple #10
0
 public void SetData(MToken data)
 {
     _beforeReceiveEvent.Invoke();
     BinderUtil.SetValueToBinder(data, _elementBinder);
     _afterReceiveEvent.Invoke();
 }
 void OnEnable()
 {
     _allBinderValueTypes = BinderUtil.GetImplementedBinderValueTypes()
                            .Select(t => new EditorKit.SerializedType(t)).ToList();
 }