Exemple #1
0
        protected override void DrawChangeableElements()
        {
            base.DrawChangeableElements();
            var myClass = target as TwoWayDataBinding;

            var evntGenericMenu = new GenericMenu();

            for (var index = 0; index < myClass.DstChangedEvents.Count; index++)
            {
                var dstEvent = myClass.DstChangedEvents[index];
                var index1   = index;
                evntGenericMenu.AddItem(new GUIContent(dstEvent), index == _eventIdx, () =>
                {
                    _eventIdx = index1;
                    UpdateSerializedProperties();
                });
            }

            var isSelectedDstEventValid = _eventIdx >= 0 && myClass.DstChangedEvents.Count > _eventIdx;

            if (!isSelectedDstEventValid)
            {
                EditorGUILayout.HelpBox("Destination Changed Event is no longer valid consider fixing it!", MessageType.Error);
            }

            EditorGUILayoutHelper.PopGenericMenuAsDropDown(new GUIContent("Destination Changed Event"), new GUIContent(isSelectedDstEventValid ? myClass.DstChangedEvents[_eventIdx] : "Empty"), evntGenericMenu, contentColor: isSelectedDstEventValid ? (Color?)null : Color.red);
        }
Exemple #2
0
        protected override void DrawChangeableElements()
        {
            base.DrawChangeableElements();

            var myClass        = target as CollectionViewSource;
            var srcGenericMenu = new GenericMenu();

            for (var index = 0; index < _srcNameProp.Count; index++)
            {
                var srcCollection = _srcNameProp[index];
                var index1        = index;
                srcGenericMenu.AddItem(new GUIContent(srcCollection), index == _srcIndex, () =>
                {
                    _srcIndex = index1;
                    UpdateSerializedProperties();
                });
            }

            var isSelectedCollectionValid = _srcIndex >= 0 && _srcNameProp.Count > _srcIndex;

            if (!isSelectedCollectionValid)
            {
                EditorGUILayout.HelpBox("Source Collection Property is no longer valid consider fixing it! If you refactored the name of property you can reserialize it with attribute usage, click here to get needed attribute copied in you clip board.", MessageType.Error);
                var rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
                {
                    $"[{nameof(FormerlyBindedAs)}(\"{myClass.SrcCollectionName.PropertyName}\")]".CopyToClipboard();
                }
            }

            EditorGUILayoutHelper.PopGenericMenuAsDropDown(new GUIContent("Source Collection"), new GUIContent(isSelectedCollectionValid ? _srcNameProp[_srcIndex] : (myClass.SrcCollectionName is null ? "Empty" : myClass.SrcCollectionName.PropertyName)), srcGenericMenu, contentColor: isSelectedCollectionValid ? (Color?)null : Color.red);
        }