public void ObjectParse(object parse) { CatalogueItem_Graphic item = parse as CatalogueItem_Graphic; this.tile = item; lable.text = item.friendlyName; assetID = item.itemID; favourite = item.favourite; if (!string.IsNullOrEmpty(item.graphicPath)) { StartCoroutine(SetGraphicTexture(Application.persistentDataPath + item.graphicPath, thumbnail)); } }
public void ObjectParse(CatalogueItem_Graphic graphicParse, CatalogueItemThumnail_Graphic thumbnail) { this.itemGraphic = graphicParse; if (itemGraphic.itemID != 0) { //Existing Asset itemThumbnail = thumbnail; assetFriendlyName.text = itemGraphic.friendlyName; tagsInputField.text = string.Join("#", itemGraphic.tags); favouritesToggle.isOn = itemGraphic.favourite; categoryDropDown.value = itemGraphic.itemTypeCategory; StartCoroutine(SetGraphicTexture(Application.persistentDataPath + itemGraphic.graphicPath)); buttonImport.interactable = false; buttonImport.GetComponentInChildren <Text>().text = ""; } }
public async void SaveAssetAsync() { if (string.IsNullOrEmpty(assetFriendlyName.text)) { MessageBox.Show("Error", "Asset Name Is Missing", () => { }); return; } if (itemGraphic.itemID == 0) { if (string.IsNullOrEmpty(tempGraphicPath)) { MessageBox.Show("Error", "Image Required", () => { }); return; } } this.GetComponent <Button>().interactable = false; LoadingPanelUI loadingPanelUI = GetComponentInChildren <LoadingPanelUI>(true); loadingPanelUI.gameObject.SetActive(true); loadingPanelUI.ChangeText("Please Wait", "Assets Uploading"); const string itemFileName = "CatalogueItem.asscat"; const string thumnailPrefabName = "AssetThumnail_Graphic"; if (itemGraphic.itemID == 0) { catalogueManager._CreatedAssetCount++; CatalogueItemDetail itemDetail = new CatalogueItemDetail { ItemType = CatalogueItemDetail.ItemTypes.Graphic, ItemID = catalogueManager._CreatedAssetCount, CatalogueItemDirectory = "/Assets/Graphics/" + catalogueManager._CreatedAssetCount.ToString("D5") + "/", DateModified = DateTime.Now.ToString(), FriendlyName = assetFriendlyName.text, ItemTypeCategory = categoryDropDown.value, }; string localAssetPath = "/" + catalogueManager._DatabaseUID + itemDetail.CatalogueItemDirectory + "/"; cmd_File.DeleteFolder(Application.persistentDataPath + localAssetPath, false); Directory.CreateDirectory(Application.persistentDataPath + localAssetPath); string localGraphicPath = localAssetPath + "/" + Path.GetFileName(tempGraphicPath); File.Copy(tempGraphicPath, Application.persistentDataPath + localGraphicPath, true); itemGraphic = new CatalogueItem_Graphic { friendlyName = assetFriendlyName.text, itemID = catalogueManager._CreatedAssetCount, modifiedDate = DateTime.Now.ToString(), tags = tagsInputField.text.Split('#'), favourite = favouritesToggle.isOn, itemTypeCategory = categoryDropDown.value, isSliced = useSliceToggle.isOn, slicesX = xSlider.value, slicesY = ySlider.value, graphicPath = localGraphicPath, }; cmd_File.SerializeObject(Application.persistentDataPath + localAssetPath, itemFileName, itemGraphic); catalogueManager._CatalogueItemDetails.Add(itemDetail); catalogueManager.ResyncCatalogueDatabaseAsync(); using (DropboxClient dbx = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token")))) { await cmd_Dropbox.UploadFileAsync(dbx, tempGraphicPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempGraphicPath)); await cmd_Dropbox.UploadObjAsync(dbx, itemGraphic, itemDetail.CatalogueItemDirectory, itemFileName); Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemGraphic.friendlyName + " Created"); MessageBox.Show("Boom Shaka Laka", "Asset Now Added", () => { GetComponent <PopupItemController>().HideDialog(0); }); } GameObject go = Instantiate(Resources.Load(thumnailPrefabName) as GameObject, GameObject.FindWithTag("ThumbnailGrid").transform); go.SendMessage("ObjectParse", itemGraphic); } else { foreach (CatalogueItemDetail itemDetail in catalogueManager._CatalogueItemDetails) { if (itemDetail.ItemID == itemGraphic.itemID) { itemDetail.DateModified = DateTime.Now.ToString(); itemGraphic.modifiedDate = DateTime.Now.ToString(); itemDetail.FriendlyName = assetFriendlyName.text; itemGraphic.friendlyName = assetFriendlyName.text; itemGraphic.tags = tagsInputField.text.Split('#'); itemGraphic.favourite = favouritesToggle.isOn; itemGraphic.isSliced = useSliceToggle.isOn; itemGraphic.itemTypeCategory = categoryDropDown.value; itemGraphic.slicesX = xSlider.value; itemGraphic.slicesY = ySlider.value; itemThumbnail.lable.text = assetFriendlyName.text; itemThumbnail.ObjectParse(itemGraphic); catalogueManager.ResyncCatalogueDatabaseAsync(); using (DropboxClient dropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token")))) { await cmd_Dropbox.UploadObjAsync(dropboxClient, itemGraphic, itemDetail.CatalogueItemDirectory, itemFileName); Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemGraphic.friendlyName + " Updated"); MessageBox.Show("Boom Shaka Laka", "Asset Now Updated", () => { GetComponent <PopupItemController>().HideDialog(0); }); string localPath = Application.persistentDataPath + "/" + catalogueManager._DatabaseUID + itemDetail.CatalogueItemDirectory + "/"; cmd_File.SerializeObject(localPath, itemFileName, itemGraphic); return; } } } } loadingPanelUI.gameObject.SetActive(false); this.GetComponent <Button>().interactable = true; }