Exemple #1
0
        public void OnClickAddPackage()
        {
            string text        = oPackageForm.transform.Find("Content/InputField-Name").GetComponent <InputField>().text.Trim();
            string author      = oPackageForm.transform.Find("Content/InputField-Author").GetComponent <InputField>().text.Trim();
            string description = oPackageForm.transform.Find("Content/InputField-Description").GetComponent <InputField>().text.Trim();
            Sprite sprite      = oPackageForm.transform.Find("Content/ImageArea/Image").GetComponent <Image>().sprite;

            if (string.IsNullOrEmpty(text) ||
                string.IsNullOrEmpty(author) ||
                string.IsNullOrEmpty(description) ||
                sprite == null)
            {
                QEditorAlertUI.shared.Show("信息未填完整");
                return;
            }
            var package = editingPackage != null ? editingPackage : new QEditorService.PackageItem();

            package.name        = text;
            package.author      = author;
            package.description = description;
            package.thumb       = sprite.ToBase64();
            if (editingPackage != null)
            {
                QEditorService.shared.UpdatePackage(editingPackage);
                editingPackage = null;
            }
            else
            {
                QEditorService.shared.AddPackage(package);
            }
            oPackageForm.SetActive(false);
            oPackageForm.transform.Find("Content/InputField-Name").GetComponent <InputField>().text = "";
            oPackageForm.transform.Find("Content/ImageArea/Image").GetComponent <Image>().sprite    = null;
        }
Exemple #2
0
        void AdaptItem(Transform item, QEditorService.PackageItem package)
        {
            item.name = package.id;
            item.Find("Name").GetComponent <Text>().text        = package.name + "\n" + "作者:" + package.author;
            item.Find("Description").GetComponent <Text>().text = package.description;
            var thumbSprite = package.thumb == null ? null : SpriteExtensions.Base64ToSprite(package.thumb);

            item.Find("ImageCol/Image").GetComponent <Image>().sprite = thumbSprite;
        }
Exemple #3
0
        public void OpenPackageForm(string packageId = null)
        {
            oPackageForm.SetActive(true);
            bool editing = !string.IsNullOrEmpty(packageId.Trim());

            editingPackage = editing ? QEditorService.shared.GetPackageById(packageId) : null;
            string author = "";

#if UNITY_STANDALONE
            if (editingPackage == null || string.IsNullOrEmpty(editingPackage.author))
            {
                author = SteamFriends.GetPersonaName();
            }
            else
            {
                author = editing ? editingPackage.author : "";
            }
#endif
            oPackageForm.Query <InputField>("Content/InputField-Name").text        = editing ? editingPackage.name : "";
            oPackageForm.Query <InputField>("Content/InputField-Author").text      = author;
            oPackageForm.Query <InputField>("Content/InputField-Description").text = editing ? editingPackage.description : "";
            oPackageForm.Query <Image>("Content/ImageArea/Image").sprite           = editing ? editingPackage.thumb.ToSprite() : null;
        }