예제 #1
0
 public void SetData(MToken data)
 {
     BinderUtil.SetValueToBinder(data, _mainBinder);
     for (var i = 0; i < _extendBinders.Count; i++)
     {
         BinderUtil.SetValueToBinder(data, _extendBinders[i]);
     }
 }
예제 #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);
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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;
            }
        }
예제 #8
0
 public MToken GetData()
 {
     return(BinderUtil.GetValueFromBinder(_mainBinder) as MBool);
 }
예제 #9
0
 public MToken GetData()
 {
     return(BinderUtil.GetValueFromBinder(_elementBinder));
 }
예제 #10
0
 public void SetData(MToken data)
 {
     _beforeReceiveEvent.Invoke();
     BinderUtil.SetValueToBinder(data, _elementBinder);
     _afterReceiveEvent.Invoke();
 }
예제 #11
0
 void OnEnable()
 {
     _allBinderValueTypes = BinderUtil.GetImplementedBinderValueTypes()
                            .Select(t => new EditorKit.SerializedType(t)).ToList();
 }