Exemplo n.º 1
0
        private void NewTagFieldOnChanged(TagField tagField)
        {
            tagField.SetTagNoEvent(new MaterialTag());
            tagField.Changed -= NewTagFieldOnChanged;
            var newTagField = new TagField();

            newTagField.Changed += NewTagFieldOnChanged;
            _tagsWrapper.Children.Add(newTagField);
        }
Exemplo n.º 2
0
        public override void OnLoaded()
        {
            Children.Add(_tagsWrapper = new VerticalLayout());

            var req = UnityWebRequest.Get(TagsUrl);

            req.downloadHandler = new DownloadHandlerBuffer();
            req.Send();
            while (req.error == null && req.downloadHandler.isDone == false)
            {
            }
            var responseText = req.downloadHandler.text;

            if (string.IsNullOrEmpty(responseText) == false)
            {
                var tags = Json.Deserialize <List <MaterialTag> >(responseText);

                _tagsWrapper.Children.Clear();
                foreach (var materialTag in tags)
                {
                    _tagsWrapper.Children.Add(new TagField {
                        Tag = materialTag
                    });
                }

                _materialTagsDb = tags.Select(p => new MaterialTag {
                    Id = p.Id, Name = p.Name, ChineseName = p.ChineseName
                }).ToList();

                var newTagField = new TagField();
                newTagField.Changed += NewTagFieldOnChanged;
                _tagsWrapper.Children.Add(newTagField);
            }

            var submitBtn = new Button {
                Content = "Submit"
            };

            submitBtn.Click += SaveTagsButtonOnClick;
            Children.Add(submitBtn);
        }