public async void DeleteAssetAsync()
    {
        if (itemFont.itemID != 0)
        {
            //Do Delete
            this.GetComponent <Button>().interactable = false;
            LoadingPanelUI loadingPanelUI = GetComponentInChildren <LoadingPanelUI>(true);
            loadingPanelUI.gameObject.SetActive(true);
            loadingPanelUI.ChangeText("Please Wait", "Deleting Asset");

            CatalogueItemDetail thisDetail = new CatalogueItemDetail();
            foreach (CatalogueItemDetail detail in catalogueManager._CatalogueItemDetails)
            {
                if (detail.ItemID == this.itemFont.itemID)
                {
                    thisDetail = detail;
                }
            }
            catalogueManager._CatalogueItemDetails.Remove(thisDetail);

            catalogueManager.ResyncCatalogueDatabaseAsync();
            //Debug.Log(thisDetail.CatalogueItemDirectory);

            using (DropboxClient dbx = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
            {
                Debug.Log("/Assets/Fonts/" + thisDetail.ItemID);
                await cmd_Dropbox.DeleteAssetFolderAsync(dbx, "/Assets/Fonts/" + thisDetail.ItemID.ToString("D5"));

                Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemFont.friendlyName + " Deleted");
            }

            string localAssetPath = "/" + catalogueManager._DatabaseUID + "/Assets/Fonts/" + this.itemFont.itemID.ToString("D5") + "/";
            cmd_File.DeleteFolder(Application.persistentDataPath + localAssetPath, true);

            foreach (CatalogueItemThumnail_Font goFont in GameObject.FindWithTag("ThumbnailGrid").GetComponentsInChildren <CatalogueItemThumnail_Font>())
            {
                if (goFont.assetID == this.itemFont.itemID)
                {
                    Destroy(goFont.gameObject);
                    break;
                }
            }
            loadingPanelUI.gameObject.SetActive(false);
            MessageBox.Show("Boom Shaka Laka", "Asset Now Deleted", () =>
            {
                GetComponent <PopupItemController>().HideDialog(0);
            });
        }
        else
        {
            GetComponent <PopupItemController>().HideDialog(0);
        }
    }
Ejemplo n.º 2
0
    public async void SaveAssetAsync()
    {
        if (string.IsNullOrEmpty(assetFriendlyName.text))
        {
            MessageBox.Show("Error", "Asset Name Is Missing", () => { });
            return;
        }

        if (itemSkybox.itemID == 0)
        {
            if (string.IsNullOrEmpty(tempTextureFrontPath))
            {
                MessageBox.Show("Error", "Minimum:\nFront Texture 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_Skybox";

        if (itemSkybox.itemID == 0)
        {
            itemSkybox = new CatalogueItem_Skybox
            {
                friendlyName     = assetFriendlyName.text,
                itemID           = itemSkybox.itemID,
                modifiedDate     = DateTime.Now.ToString(),
                tags             = tagsInputField.text.Split('#'),
                favourite        = favouritesToggle.isOn,
                itemTypeCategory = skyboxTypeToggle.isOn ? 2 : 1,
                isSixSided       = !skyboxTypeToggle.isOn,
            };

            catalogueManager._CreatedAssetCount++;
            itemSkybox.itemID = catalogueManager._CreatedAssetCount;
            CatalogueItemDetail itemDetail = new CatalogueItemDetail
            {
                ItemType = CatalogueItemDetail.ItemTypes.Skybox,
                ItemID   = catalogueManager._CreatedAssetCount,
                CatalogueItemDirectory = "/Assets/Skyboxes/" + catalogueManager._CreatedAssetCount.ToString("D5") + "/",
                DateModified           = DateTime.Now.ToString(),
                FriendlyName           = itemSkybox.friendlyName,
                ItemTypeCategory       = skyboxTypeToggle.isOn ? 2 : 1,
            };

            string localAssetPath = "/" + catalogueManager._DatabaseUID + itemDetail.CatalogueItemDirectory + "/";
            cmd_File.DeleteFolder(Application.persistentDataPath + localAssetPath, false);
            Directory.CreateDirectory(Application.persistentDataPath + localAssetPath);

            if (tempTextureFrontPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureFrontPath);
                File.Copy(tempTextureFrontPath, Application.persistentDataPath + path, true);
                itemSkybox.textureFrontPath = path;
            }
            if (tempTextureBackPath != null && !skyboxTypeToggle.isOn)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureBackPath);
                File.Copy(tempTextureBackPath, Application.persistentDataPath + path, true);
                itemSkybox.textureBackPath = path;
            }
            if (tempTextureLeftPath != null && !skyboxTypeToggle.isOn)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureLeftPath);
                File.Copy(tempTextureLeftPath, Application.persistentDataPath + path, true);
                itemSkybox.textureLeftPath = path;
            }
            if (tempTextureRightPath != null && !skyboxTypeToggle.isOn)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureRightPath);
                File.Copy(tempTextureRightPath, Application.persistentDataPath + path, true);
                itemSkybox.textureRightPath = path;
            }
            if (tempTextureUpPath != null && !skyboxTypeToggle.isOn)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureUpPath);
                File.Copy(tempTextureUpPath, Application.persistentDataPath + path, true);
                itemSkybox.textureUpPath = path;
            }
            if (tempTextureDownPath != null && !skyboxTypeToggle.isOn)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureDownPath);
                File.Copy(tempTextureDownPath, Application.persistentDataPath + path, true);
                itemSkybox.textureDownPath = path;
            }

            cmd_File.SerializeObject(Application.persistentDataPath + localAssetPath, itemFileName, itemSkybox);
            catalogueManager._CatalogueItemDetails.Add(itemDetail);
            catalogueManager.ResyncCatalogueDatabaseAsync();

            using (DropboxClient dbx = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
            {
                if (tempTextureFrontPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureFrontPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureFrontPath));
                }
                if (tempTextureBackPath != null && !skyboxTypeToggle.isOn)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureBackPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureBackPath));
                }
                if (tempTextureLeftPath != null && !skyboxTypeToggle.isOn)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureLeftPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureLeftPath));
                }
                if (tempTextureRightPath != null && !skyboxTypeToggle.isOn)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureRightPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureRightPath));
                }
                if (tempTextureUpPath != null && !skyboxTypeToggle.isOn)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureUpPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureUpPath));
                }
                if (tempTextureDownPath != null && !skyboxTypeToggle.isOn)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureDownPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureDownPath));
                }

                await cmd_Dropbox.UploadObjAsync(dbx, itemSkybox, itemDetail.CatalogueItemDirectory, itemFileName);

                Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemSkybox.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", itemSkybox);
        }

        else
        {
            foreach (CatalogueItemDetail itemDetail in catalogueManager._CatalogueItemDetails)
            {
                if (itemDetail.ItemID == itemSkybox.itemID)
                {
                    itemDetail.DateModified  = DateTime.Now.ToString();
                    itemSkybox.modifiedDate  = DateTime.Now.ToString();
                    itemDetail.FriendlyName  = assetFriendlyName.text;
                    itemSkybox.friendlyName  = assetFriendlyName.text;
                    itemSkybox.tags          = tagsInputField.text.Split('#');
                    itemSkybox.favourite     = favouritesToggle.isOn;
                    itemThumbnail.lable.text = assetFriendlyName.text;
                    itemThumbnail.ObjectParse(itemSkybox);
                    catalogueManager.ResyncCatalogueDatabaseAsync();
                    using (DropboxClient dropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
                    {
                        await cmd_Dropbox.UploadObjAsync(dropboxClient, itemSkybox, itemDetail.CatalogueItemDirectory, itemFileName);

                        Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemSkybox.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, itemSkybox);
                        return;
                    }
                }
            }
        }
        loadingPanelUI.gameObject.SetActive(false);
        this.GetComponent <Button>().interactable = true;
    }
    public async void SaveAssetAsync()
    {
        if (string.IsNullOrEmpty(assetFriendlyName.text))
        {
            MessageBox.Show("Error", "Asset Name Is Missing", () => { });
            return;
        }

        if (itemModel.itemID == 0)
        {
            if (string.IsNullOrEmpty(tempModelPath))
            {
                MessageBox.Show("Error", "Must Import Model", () => { });
                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_Model";

        if (itemModel.itemID == 0)
        {
            itemModel = new CatalogueItem_Model
            {
                friendlyName     = assetFriendlyName.text,
                itemID           = itemModel.itemID,
                modifiedDate     = DateTime.Now.ToString(),
                tags             = tagsInputField.text.Split('#'),
                favourite        = favouritesToggle.isOn,
                itemTypeCategory = categoryDropDown.value,
                savePos          = new CustomVector3(modelViewParent.transform.localPosition),
                saveRot          = new CustomVector3(modelViewParent.transform.localEulerAngles),
                saveScale        = new CustomVector3(modelViewParent.transform.localScale),
            };
        }

        //Screenshot
        Texture2D tex = new Texture2D(renderTextureNew.height, renderTextureNew.height);

        RenderTexture.active = renderTextureNew;
        float offsetX = (renderTextureNew.width - renderTextureNew.height) / 2;

        tex.ReadPixels(new Rect(offsetX, 0, renderTextureNew.height, renderTextureNew.height), 0, 0);
        tex.Apply();
        itemModel.thumnailData = tex.EncodeToPNG();

        if (itemModel.itemID == 0)
        {
            //Copy All Files
            catalogueManager._CreatedAssetCount++;
            itemModel.itemID = catalogueManager._CreatedAssetCount;
            CatalogueItemDetail itemDetail = new CatalogueItemDetail
            {
                ItemType = CatalogueItemDetail.ItemTypes.Model,
                ItemID   = catalogueManager._CreatedAssetCount,
                CatalogueItemDirectory = "/Assets/Models/" + catalogueManager._CreatedAssetCount.ToString("D5") + "/",
                DateModified           = DateTime.Now.ToString(),
                FriendlyName           = itemModel.friendlyName,
                ItemTypeCategory       = categoryDropDown.value,
            };

            string localAssetPath = "/" + catalogueManager._DatabaseUID + itemDetail.CatalogueItemDirectory + "/";
            //Debug.Log(_LocalAssetPath);
            cmd_File.DeleteFolder(Application.persistentDataPath + localAssetPath, false);
            Directory.CreateDirectory(Application.persistentDataPath + localAssetPath);

            if (tempModelPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempModelPath);
                File.Copy(tempModelPath, Application.persistentDataPath + path, true);
                itemModel.modelPath = path;
            }

            if (tempTextureColourPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureColourPath);
                File.Copy(tempTextureColourPath, Application.persistentDataPath + path, true);
                itemModel.textureColourPath = path;
            }

            if (tempTextureNormalPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureNormalPath);
                File.Copy(tempTextureNormalPath, Application.persistentDataPath + path, true);
                itemModel.textureNormalPath = path;
            }

            if (tempTextureDisplacementPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureDisplacementPath);
                File.Copy(tempTextureDisplacementPath, Application.persistentDataPath + path, true);
                itemModel.textureDisplacementPath = path;
            }

            if (tempTextureSpecularPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureSpecularPath);
                File.Copy(tempTextureSpecularPath, Application.persistentDataPath + path, true);
                itemModel.textureSpecularPath = path;
            }

            if (tempTextureOcclusionPath != null)
            {
                string path = localAssetPath + "/" + Path.GetFileName(tempTextureOcclusionPath);
                File.Copy(tempTextureOcclusionPath, Application.persistentDataPath + path, true);
                itemModel.textureOcclusionPath = path;
            }

            cmd_File.SerializeObject(Application.persistentDataPath + localAssetPath, itemFileName, itemModel);
            catalogueManager._CatalogueItemDetails.Add(itemDetail);
            catalogueManager.ResyncCatalogueDatabaseAsync();

            using (DropboxClient dbx = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
            {
                if (tempModelPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempModelPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempModelPath));
                }

                if (tempTextureColourPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureColourPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureColourPath));
                }

                if (tempTextureNormalPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureNormalPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureNormalPath));
                }

                if (tempTextureDisplacementPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureDisplacementPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureDisplacementPath));
                }

                if (tempTextureSpecularPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureSpecularPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureSpecularPath));
                }

                if (tempTextureOcclusionPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(dbx, tempTextureOcclusionPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureOcclusionPath));
                }

                await cmd_Dropbox.UploadObjAsync(dbx, itemModel, itemDetail.CatalogueItemDirectory, itemFileName);

                Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemModel.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", itemModel);
        }
        else
        {
            foreach (CatalogueItemDetail itemDetail in catalogueManager._CatalogueItemDetails)
            {
                if (itemDetail.ItemID == itemModel.itemID)
                {
                    itemDetail.DateModified    = DateTime.Now.ToString();
                    itemModel.modifiedDate     = DateTime.Now.ToString();
                    itemDetail.FriendlyName    = assetFriendlyName.text;
                    itemModel.friendlyName     = assetFriendlyName.text;
                    itemModel.tags             = tagsInputField.text.Split('#');
                    itemModel.favourite        = favouritesToggle.isOn;
                    itemModel.itemTypeCategory = categoryDropDown.value;
                    itemModel.savePos          = new CustomVector3(modelViewParent.transform.localPosition);
                    itemModel.saveRot          = new CustomVector3(modelViewParent.transform.localEulerAngles);
                    itemModel.saveScale        = new CustomVector3(modelViewParent.transform.localScale);
                    itemThumbnail.lable.text   = assetFriendlyName.text;
                    itemThumbnail.ObjectParse(itemModel);
                    catalogueManager.ResyncCatalogueDatabaseAsync();
                    using (DropboxClient dropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
                    {
                        await cmd_Dropbox.UploadObjAsync(dropboxClient, itemModel, itemDetail.CatalogueItemDirectory, itemFileName);

                        Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemModel.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, itemModel);
                        return;
                    }
                }
            }
        }
        loadingPanelUI.gameObject.SetActive(false);
        this.GetComponent <Button>().interactable = true;
    }
Ejemplo n.º 4
0
    public async void SaveAssetAsync()
    {
        if (string.IsNullOrEmpty(assetFriendlyName.text))
        {
            MessageBox.Show("Error", "Asset Name Is Missing", () => { });
            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_Tile";

        if (itemTile._ItemID == 0)
        {
            itemTile = new CatalogueItem_Tile
            {
                _FriendlyName    = assetFriendlyName.text,
                _ItemID          = itemTile._ItemID,
                _ModifiedDate    = DateTime.Now.ToString(),
                tags             = tagsInputField.text.Split('#'),
                favourite        = favouritesToggle.isOn,
                itemTypeCategory = categoryDropDown.value,
                //Does not seem to be neccasary any more
                //_TextureColourPath = Application.persistentDataPath + itemTile._TextureColourPath,
                //_TextureNormalPath = Application.persistentDataPath + itemTile._TextureNormalPath,
                //_TextureDisplacementPath = Application.persistentDataPath + itemTile._TextureDisplacementPath,
                //_TextureSpecularPath = Application.persistentDataPath + itemTile._TextureSpecularPath,
                //_TextureOcclusionPath = Application.persistentDataPath + itemTile._TextureOcclusionPath,
            };
        }


        if (itemTile._ItemID == 0) //New Asset
        {
            //Copy All Files

            catalogueManager._CreatedAssetCount++;
            itemTile._ItemID = catalogueManager._CreatedAssetCount;
            CatalogueItemDetail itemDetail = new CatalogueItemDetail
            {
                ItemType = CatalogueItemDetail.ItemTypes.Tile,
                ItemID   = catalogueManager._CreatedAssetCount,
                CatalogueItemDirectory = "/Assets/Tiles/" + catalogueManager._CreatedAssetCount.ToString("D5") + "/",
                DateModified           = DateTime.Now.ToString(),
                FriendlyName           = itemTile._FriendlyName,
                ItemTypeCategory       = categoryDropDown.value,
            };

            string _LocalAssetPath = "/" + catalogueManager._DatabaseUID + itemDetail.CatalogueItemDirectory + "/";
            //Debug.Log(_LocalAssetPath);
            cmd_File.DeleteFolder(Application.persistentDataPath + _LocalAssetPath, false);

            Directory.CreateDirectory(Application.persistentDataPath + _LocalAssetPath);

            if (tempTextureColourPath != null)
            {
                string path = _LocalAssetPath + "/" + Path.GetFileName(tempTextureColourPath);
                File.Copy(tempTextureColourPath, Application.persistentDataPath + path, true);
                itemTile._TextureColourPath = path;
            }
            if (tempTextureNormalPath != null)
            {
                string path = _LocalAssetPath + "/" + Path.GetFileName(tempTextureNormalPath);
                File.Copy(tempTextureNormalPath, Application.persistentDataPath + path, true);
                itemTile._TextureNormalPath = path;
            }
            if (tempTextureDisplacementPath != null)
            {
                string path = _LocalAssetPath + "/" + Path.GetFileName(tempTextureDisplacementPath);
                File.Copy(tempTextureDisplacementPath, Application.persistentDataPath + path, true);
                itemTile._TextureDisplacementPath = path;
            }
            if (tempTextureSpecularPath != null)
            {
                string path = _LocalAssetPath + "/" + Path.GetFileName(tempTextureSpecularPath);
                File.Copy(tempTextureSpecularPath, Application.persistentDataPath + path, true);
                itemTile._TextureSpecularPath = path;
            }
            if (tempTextureOcclusionPath != null)
            {
                string path = _LocalAssetPath + "/" + Path.GetFileName(tempTextureOcclusionPath);
                File.Copy(tempTextureOcclusionPath, Application.persistentDataPath + path, true);
                itemTile._TextureOcclusionPath = path;
            }

            cmd_File.SerializeObject(Application.persistentDataPath + _LocalAssetPath, _ItemFileName, itemTile);
            catalogueManager._CatalogueItemDetails.Add(itemDetail);
            catalogueManager.ResyncCatalogueDatabaseAsync();

            using (DropboxClient _DropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
            {
                if (tempTextureColourPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(_DropboxClient, tempTextureColourPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureColourPath));
                }

                if (tempTextureNormalPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(_DropboxClient, tempTextureNormalPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureNormalPath));
                }

                if (tempTextureDisplacementPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(_DropboxClient, tempTextureDisplacementPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureDisplacementPath));
                }

                if (tempTextureSpecularPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(_DropboxClient, tempTextureSpecularPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureSpecularPath));
                }

                if (tempTextureOcclusionPath != null)
                {
                    await cmd_Dropbox.UploadFileAsync(_DropboxClient, tempTextureOcclusionPath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempTextureOcclusionPath));
                }

                await cmd_Dropbox.UploadObjAsync(_DropboxClient, itemTile, itemDetail.CatalogueItemDirectory, _ItemFileName);

                Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemTile._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", itemTile);
        }
        else
        {
            foreach (CatalogueItemDetail itemDetail in catalogueManager._CatalogueItemDetails)
            {
                if (itemDetail.ItemID == itemTile._ItemID)
                {
                    itemDetail.DateModified   = DateTime.Now.ToString();
                    itemTile._ModifiedDate    = DateTime.Now.ToString();
                    itemDetail.FriendlyName   = assetFriendlyName.text;
                    itemTile._FriendlyName    = assetFriendlyName.text;
                    itemTile.tags             = tagsInputField.text.Split('#');
                    itemTile.favourite        = favouritesToggle.isOn;
                    itemTile.itemTypeCategory = categoryDropDown.value;
                    itemThumbnail.lable.text  = assetFriendlyName.text;
                    itemThumbnail.ObjectParse(itemTile);
                    catalogueManager.ResyncCatalogueDatabaseAsync();
                    using (DropboxClient dropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
                    {
                        await cmd_Dropbox.UploadObjAsync(dropboxClient, itemTile, itemDetail.CatalogueItemDirectory, _ItemFileName);

                        Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemTile._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, itemTile);
                        return;
                    }
                }
            }
        }
        loadingPanelUI.gameObject.SetActive(false);
        this.GetComponent <Button>().interactable = true;
    }
    public async void SaveAssetAsync()
    {
        if (string.IsNullOrEmpty(assetFriendlyName.text))
        {
            MessageBox.Show("Error", "Asset Name Is Missing", () => { });
            return;
        }
        if (itemFont.itemID == 0)
        {
            if (string.IsNullOrEmpty(tempFontFilePath))
            {
                MessageBox.Show("Error", "No Font File Selected", () => { });
                return;
            }
        }

        this.GetComponent <Button>().interactable = false;
        LoadingPanelUI loadingPanelUI = GetComponentInChildren <LoadingPanelUI>(true);

        loadingPanelUI.gameObject.SetActive(true);
        loadingPanelUI.ChangeText("Please Wait", "Assets Uploading");

        const string catalogueItemFileName  = "CatalogueItem.asscat";
        const string itemThumnailPrefabName = "AssetThumnail_Font";

        if (itemFont.itemID == 0) //New Asset
        {
            catalogueManager._CreatedAssetCount++;

            CatalogueItemDetail itemDetail = new CatalogueItemDetail
            {
                ItemType = CatalogueItemDetail.ItemTypes.Font,
                ItemID   = catalogueManager._CreatedAssetCount,
                CatalogueItemDirectory = "/Assets/Fonts/" + catalogueManager._CreatedAssetCount.ToString("D5") + "/",
                DateModified           = DateTime.Now.ToString(),
                FriendlyName           = assetFriendlyName.text,
                ItemTypeCategory       = 0,
            };

            string localAssetPath = "/" + catalogueManager._DatabaseUID + itemDetail.CatalogueItemDirectory + "/";
            string localFontPath  = localAssetPath + "/" + Path.GetFileName(tempFontFilePath);
            cmd_File.DeleteFolder(Application.persistentDataPath + localAssetPath, false);
            Directory.CreateDirectory(Application.persistentDataPath + localAssetPath);

            File.Copy(tempFontFilePath, Application.persistentDataPath + localFontPath, true);

            itemFont = new CatalogueItem_Font
            {
                friendlyName     = assetFriendlyName.text,
                itemID           = catalogueManager._CreatedAssetCount,
                modifiedDate     = DateTime.Now.ToString(),
                fontPath         = localFontPath,
                thumnailData     = RenderFontTextToBitmapArray(256, 256, new System.Drawing.Font(fontCollection.Families[0], 28), renderTextStringShort, System.Drawing.Brushes.GhostWhite),
                tags             = tagsInputField.text.Split('#'),
                itemTypeCategory = 0,
                favourite        = favouritesToggle.isOn,
            };


            cmd_File.SerializeObject(Application.persistentDataPath + localAssetPath, catalogueItemFileName, itemFont);
            catalogueManager._CatalogueItemDetails.Add(itemDetail);
            catalogueManager.ResyncCatalogueDatabaseAsync();

            using (DropboxClient dbx = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
            {
                await cmd_Dropbox.UploadFileAsync(dbx, tempFontFilePath, itemDetail.CatalogueItemDirectory, Path.GetFileName(tempFontFilePath));

                await cmd_Dropbox.UploadObjAsync(dbx, itemFont, itemDetail.CatalogueItemDirectory, catalogueItemFileName);

                Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemFont.friendlyName + " Created");
                MessageBox.Show("Boom Shaka Laka", "Asset Now Added", () =>
                {
                    GetComponent <PopupItemController>().HideDialog(0);
                });
            }

            GameObject go = Instantiate(Resources.Load(itemThumnailPrefabName) as GameObject, GameObject.FindWithTag("ThumbnailGrid").transform);
            go.SendMessage("ObjectParse", itemFont);
        }
        else //Update Asset
        {
            foreach (CatalogueItemDetail itemDetail in catalogueManager._CatalogueItemDetails)
            {
                if (itemDetail.ItemID == itemFont.itemID)
                {
                    itemDetail.DateModified   = DateTime.Now.ToString();
                    itemFont.modifiedDate     = DateTime.Now.ToString();
                    itemDetail.FriendlyName   = assetFriendlyName.text;
                    itemFont.friendlyName     = assetFriendlyName.text;
                    itemFont.tags             = tagsInputField.text.Split('#');
                    itemFont.favourite        = favouritesToggle.isOn;
                    itemFont.itemTypeCategory = 0;
                    itemThumbnail.lable.text  = assetFriendlyName.text;
                    itemThumbnail.ObjectParse(itemFont);
                    catalogueManager.ResyncCatalogueDatabaseAsync();
                    using (DropboxClient dropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
                    {
                        await cmd_Dropbox.UploadObjAsync(dropboxClient, itemFont, itemDetail.CatalogueItemDirectory, catalogueItemFileName);

                        Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + itemFont.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, catalogueItemFileName, itemFont);
                    return;
                }
            }
        }
        loadingPanelUI.gameObject.SetActive(false);
        this.GetComponent <Button>().interactable = true;
    }
Ejemplo n.º 6
0
    public async void SaveAssetAsync()
    {
        if (string.IsNullOrEmpty(_AssetName.text))
        {
            MessageBox.Show("Error", "Asset Name Is Missing", () => { });
            return;
        }

        this.GetComponent <Button>().interactable = false;
        LoadingPanelUI loadingPanelUI = GetComponentInChildren <LoadingPanelUI>(true);

        loadingPanelUI.gameObject.SetActive(true);
        loadingPanelUI.ChangeText("Please Wait", "Uploading");

        const string _ItemFileName       = "CatalogueItem.asscat";
        const string _ThumnailPrefabName = "AssetThumnail_ConeSnip";

        _CatalogueManager = GameObject.FindWithTag("CatalogueManager").GetComponent <CatalogueManager>();

        _ItemCodeSnip = new CatalogueItem_CodeSnip
        {
            _FriendlyName    = _AssetName.text,
            _CodeText        = _CodeEditor.mainText.text,
            _ItemID          = _ItemCodeSnip._ItemID,
            _ModifiedDate    = DateTime.Now.ToString(),
            tags             = tagsInputField.text.Split('#'),
            itemTypeCategory = 0,
            favourite        = favouritesToggle.isOn,
        };

        if (_ItemCodeSnip._ItemID == 0) //New Asset
        {
            _CatalogueManager._CreatedAssetCount++;
            _ItemCodeSnip._ItemID = _CatalogueManager._CreatedAssetCount;
            CatalogueItemDetail _ItemDetail = new CatalogueItemDetail
            {
                ItemType = CatalogueItemDetail.ItemTypes.CodeSnip,
                ItemID   = _CatalogueManager._CreatedAssetCount,
                CatalogueItemDirectory = "/Assets/CodeSnips/" + _CatalogueManager._CreatedAssetCount.ToString("D5") + "/",
                DateModified           = DateTime.Now.ToString(),
                FriendlyName           = _ItemCodeSnip._FriendlyName,
                ItemTypeCategory       = 0,
            };

            _CatalogueManager._CatalogueItemDetails.Add(_ItemDetail);
            _CatalogueManager.ResyncCatalogueDatabaseAsync();

            string _LocalAssetPath = Application.persistentDataPath + "/" + _CatalogueManager._DatabaseUID + _ItemDetail.CatalogueItemDirectory + "/";
            cmd_File.DeleteFolder(_LocalAssetPath, false);

            using (DropboxClient _DropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
            {
                await cmd_Dropbox.UploadObjAsync(_DropboxClient, _ItemCodeSnip, _ItemDetail.CatalogueItemDirectory, _ItemFileName);

                Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + _ItemCodeSnip._FriendlyName + " Created");
                MessageBox.Show("Boom Shaka Laka", "Asset Now Added", () =>
                {
                    GetComponent <PopupItemController>().HideDialog(0);
                });
            }

            Directory.CreateDirectory(_LocalAssetPath);
            cmd_File.SerializeObject(_LocalAssetPath, _ItemFileName, _ItemCodeSnip);
            GameObject go = Instantiate(Resources.Load(_ThumnailPrefabName) as GameObject, GameObject.FindWithTag("ThumbnailGrid").transform);
            go.SendMessage("ObjectParse", _ItemCodeSnip);
        }
        else
        {
            foreach (CatalogueItemDetail _itemDetail in _CatalogueManager._CatalogueItemDetails)
            {
                if (_itemDetail.ItemID == _ItemCodeSnip._ItemID)
                {
                    _itemDetail.DateModified  = DateTime.Now.ToString();
                    _itemDetail.FriendlyName  = _ItemCodeSnip._FriendlyName;
                    _ItemThumbnail.lable.text = _ItemCodeSnip._FriendlyName;
                    _ItemThumbnail.ObjectParse(_ItemCodeSnip);
                    _CatalogueManager.ResyncCatalogueDatabaseAsync();
                    using (DropboxClient dropboxClient = new DropboxClient(AvoEx.AesEncryptor.DecryptString(PlayerPrefs.GetString("Token"))))
                    {
                        await cmd_Dropbox.UploadObjAsync(dropboxClient, _ItemCodeSnip, _itemDetail.CatalogueItemDirectory, _ItemFileName);

                        Debug.Log("LOG:" + DateTime.Now.ToString() + " - " + _ItemCodeSnip._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, _ItemCodeSnip);
                    return;
                }
            }
        }
        loadingPanelUI.gameObject.SetActive(false);
        this.GetComponent <Button>().interactable = true;
    }