예제 #1
0
    public void SetImageFromPath(string PathToImage)
    {
        byte[] fileData = null;

        if (UIB_FileManager.FileExists(PathToImage))
        {
            fileData = UIB_FileManager.ReadFromBytes(PathToImage, UIB_FileTypes.Images);
            if (fileData == null)
            {
                return;
            }
            Texture2D tex = new Texture2D(2, 2);
            tex.LoadImage(fileData);
            var newSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0), 100.0f);
            if (BioImage != null)
            {
                BioImage.sprite = newSprite;
                BioImage.rectTransform.sizeDelta = new Vector2(1000, 1000);
            }
        }
    }
    private void TryDownloadFile(string filename, bool fallbackUsingBundle = false)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (!(UIB_FileManager.FileExists(UIB_PlatformManager.persistentDataPath + "android/assets/" + UIB_PlatformManager.platform + filename)))
        {
            //We don't have the file, first thing is to copy it from streaming assets
            //On Android, streaming assets are zipped so we need a special accessor
            print("file does not exist");
            GameObject.Find("FileManager").GetComponent <UIB_FileManager>().StartCoroutine("CreateStreamingAssetDirectories", filename);
            //record here that we have never updated files from the internet;
            PlayerPrefs.SetString("LastUpdated", new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToString());

            if (CheckInternet() && !DebugLocalAssetBundles)
            {
                print("Just copied all asset bundle files, checking for update");
                db_Manager.CheckIfObjectHasUpdate(UIB_PlatformManager.platform + filename, "heidi-latsky-dance");
            }
            else
            {
            }
        }
        else
        {
            //we have the file check for update
            if (CheckInternet() && !DebugLocalAssetBundles)
            {
                print("we have the file checking for update");
                db_Manager.CheckIfObjectHasUpdate(UIB_PlatformManager.platform + filename, "heidi-latsky-dance");
            }
        }
#else
        if (!(UIB_FileManager.FileExists(UIB_PlatformManager.persistentDataPath + UIB_PlatformManager.platform + filename)))
        {
            //we don't have the file, firs thing to do is copy it from streaming assets
            UIB_FileManager.WriteFromStreamingToPersistent(filename);
            // AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + UIB_PlatformManager.platform + filename);

            //record here that we have never updated files from the internet;
            PlayerPrefs.SetString("LastUpdated", new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToString());

            if (CheckInternet() && !DebugLocalAssetBundles)
            {
                db_Manager.CheckIfObjectHasUpdate(UIB_PlatformManager.platform + filename, "heidi-latsky-dance");
            }
            else
            {
            }
        }
        else
        {
            //we have the file check for update
            if (CheckInternet() && !DebugLocalAssetBundles)
            {
                db_Manager.CheckIfObjectHasUpdate(UIB_PlatformManager.platform + filename, "heidi-latsky-dance");
            }
        }
#endif
        //delete the streaming asset files
        UIB_FileManager.DeleteFile(filename);
        UIB_AssetBundleHelper.InsertAssetBundle(filename);
    }