using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static DownLoadXRManager;

public class ImageLoadManager : MonoBehaviour
{
    string type = "";
    public Texture2D texture2D;
    public void loadimage(string path)
    {
        type="image";
        if(path==""||path==null)
        {
            return;
        }
        Debug.Log("开始下载图片===》"+path);
        DownLoadResources dlr = new DownLoadResources();
        dlr.path = path;
        // 文件上传
        DownLoadXRManager.DownLoadForTexture(dlr, msg =>
        {
            Debug.Log("开始下载图片== 完成=》"+path);
            texture2D=msg;
            this.transform.GetComponent<RawImage>().texture = msg;
        },(f)=>{


        });
    }
    public Texture2D pdftex;
    string pdfpath;
    public void loadPdf(string path)
    {

        type="pdf";
        if(path==""||path==null)
        {
            return;
        }
        Debug.Log("开始下载Pdf===》"+path);
        DownLoadResources dlr = new DownLoadResources();
        dlr.path = path;
        // 文件上传
        DownLoadXRManager.DownLoadForFilePath(dlr, msg =>
        {
            pdfpath=msg;
            this.transform.GetComponent<RawImage>().texture = pdftex;
           // this.transform.GetComponent<RawImage>().texture = msg;
        },(f)=>{


        });
    }

    public void showBigTexture()
    {
        if(type=="image")
        {
            TianJiWindowManager.Instance.showPoTexure2D(5,texture2D);
        }
        else
        {
            TianJiWindowManager.Instance.showPoPdf(6,pdfpath);
        }
    }
    void OnDestroy()
    {
       // Destroy(texture2D);
    }
}