コード例 #1
0
    public override void Enable()
    {
        var node = nodeTarget as StringNode;

        var textArea = new TextField(-1, true, false, '*')
        {
            value = node.output
        };

        textArea.Children().First().style.unityTextAlign = TextAnchor.UpperLeft;
        textArea.style.width  = 200;
        textArea.style.height = 100;
        textArea.RegisterValueChangedCallback(v => {
            owner.RegisterCompleteObjectUndo("Edit string node");
            node.output = v.newValue;
        });
        controlsContainer.Add(textArea);
    }
コード例 #2
0
        static VisualElement GenerateCommentSection()
        {
            var commentSection = EditorUIGenerator.GenerateSection();

            commentSection.Add(EditorUIGenerator.GenerateLabel(LabelType.h1, "コメント"));
            commentSection.Add(EditorUIGenerator.GenerateLabel(LabelType.h2, "表示名"));
            var displayNameField = new TextField();

            commentSection.Add(displayNameField);

            commentSection.Add(EditorUIGenerator.GenerateLabel(LabelType.h2, "ユーザー名"));
            var userNameField = new TextField();

            commentSection.Add(userNameField);

            commentSection.Add(EditorUIGenerator.GenerateLabel(LabelType.h2, "コメント内容"));

            var commentContentField = new TextField();

            commentContentField.style.unityTextAlign = TextAnchor.UpperLeft;
            commentContentField.multiline            = true;
            commentContentField.style.height         = 50;
            foreach (var child in commentContentField.Children())
            {
                child.style.unityTextAlign = TextAnchor.UpperLeft;
            }

            commentSection.Add(commentContentField);

            var commentSendButton = new Button(() =>
            {
                SendComment(displayNameField.value, userNameField.value, commentContentField.value);
                displayNameField.value    = "";
                userNameField.value       = "";
                commentContentField.value = "";
            })
            {
                text = "コメントを送信"
            };

            commentSection.Add(commentSendButton);
            return(commentSection);
        }
コード例 #3
0
        public VisualElement CreateView()
        {
            var container  = new VisualElement();
            var topSection = new VisualElement()
            {
                style = { flexDirection = FlexDirection.Row }
            };

            container.Add(topSection);

            {
                var thumbnailSection = new VisualElement();

                thumbnailSection.Add(thumbnailView.CreateView());

                var changeImageButton = new Button(() =>
                {
                    if (!updatingVenue)
                    {
                        newThumbnailPath =
                            EditorUtility.OpenFilePanelWithFilters(
                                "画像を選択",
                                "",
                                new[] { "Image files", "png,jpg,jpeg", "All files", "*" }
                                );
                        thumbnailView.SetImagePath(newThumbnailPath);
                        UpdateVenue();
                    }
                })
                {
                    text = "画像を変更"
                };
                thumbnailSection.Add(changeImageButton);

                topSection.Add(thumbnailSection);
            }

            {
                var editSection = new VisualElement()
                {
                    style = { flexGrow = 1 }
                };

                var venueIdSection = new VisualElement()
                {
                    style = { flexDirection = FlexDirection.Row }
                };
                venueIdSection.Add(new Label($"会場id: {venue.VenueId.Value}")
                {
                    style = { color = new StyleColor(Color.gray) }
                });
                venueIdSection.Add(new Button(() => EditorGUIUtility.systemCopyBuffer = venue.VenueId.Value)
                {
                    text = "copy"
                });

                editSection.Add(venueIdSection);

                editSection.Add(new Label("名前"));
                var venueName = new TextField();
                venueName.value = venue.Name;
                venueName.RegisterValueChangedCallback(ev =>
                {
                    newVenueName       = ev.newValue;
                    reactiveEdited.Val = true;
                });
                editSection.Add(venueName);

                editSection.Add(new Label("説明"));
                var venueDesc = new TextField()
                {
                    multiline = true,
                    style     = { height = 40, unityTextAlign = TextAnchor.UpperLeft },
                };
                foreach (var child in venueDesc.Children())
                {
                    child.style.unityTextAlign = TextAnchor.UpperLeft;
                }

                venueDesc.value = venue.Description;
                venueDesc.RegisterValueChangedCallback(ev =>
                {
                    newVenueDesc       = ev.newValue;
                    reactiveEdited.Val = true;
                });
                editSection.Add(venueDesc);

                var buttons = new VisualElement()
                {
                    style = { flexDirection = FlexDirection.Row }
                };
                var applyEdit = new Button(() =>
                {
                    if (!updatingVenue)
                    {
                        UpdateVenue();
                    }
                })
                {
                    text = "変更を保存"
                };
                var cancelEdit = new Button(() =>
                {
                    venueName.SetValueWithoutNotify(venue.Name);
                    venueDesc.SetValueWithoutNotify(venue.Description);
                    reactiveEdited.Val = false;
                })
                {
                    text = "キャンセル"
                };
                buttons.Add(applyEdit);
                buttons.Add(cancelEdit);
                ReactiveBinder.Bind(reactiveEdited, edited =>
                {
                    buttons.style.display = edited ? DisplayStyle.Flex : DisplayStyle.None;
                });

                editSection.Add(buttons);

                editSection.Add(new IMGUIContainer(() =>
                {
                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        EditorGUILayout.HelpBox(errorMessage, MessageType.Error);
                    }
                }));

                topSection.Add(editSection);
            }

            return(container);
        }