Exemplo n.º 1
0
    public void ObjectParse(object parse)
    {
        CatalogueItem_Skybox item = parse as CatalogueItem_Skybox;

        this.tile  = item;
        lable.text = item.friendlyName;
        assetID    = item.itemID;
        favourite  = item.favourite;
        if (!string.IsNullOrEmpty(item.textureFrontPath))
        {
            WWW www = new WWW("file:///" + Application.persistentDataPath + item.textureFrontPath);
            thumbnail.texture = www.texture;
        }
    }
Exemplo n.º 2
0
 public void ObjectParse(CatalogueItem_Skybox skyboxParse, CatalogueItemThumnail_Skybox thumbnail)
 {
     //skybox = skyboxCamera.GetComponent<Skybox>();
     //skyboxMatSixClone = new Material(skyboxMatSix);
     //skyboxMatOneClone = new Material(skyboxMatOne);
     this.itemSkybox = skyboxParse;
     if (itemSkybox.itemID != 0)
     {
         //Existing Asset
         itemThumbnail          = thumbnail;
         assetFriendlyName.text = itemSkybox.friendlyName;
         tagsInputField.text    = string.Join("#", itemSkybox.tags);
         favouritesToggle.isOn  = itemSkybox.favourite;
         skyboxTypeToggle.isOn  = !itemSkybox.isSixSided;
         SetButtonLoadAccesLevel(ButtonAccessLevel.None, false);
         ReloadTexturesFromFile();
         texLoadViewGameObject.SetActive(false);
     }
 }
Exemplo n.º 3
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;
    }