unity打开word pdf 等其他格式

public class OpenFileController : MonoBehaviour {
    string path;

//path可以不写路径,需要把被打开的文件放入到Resources文件夹中
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "a.mp4");
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "b.pdf");
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "c.png");
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "d.jpg");
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "e.xlsx");
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "f.doc");
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///" + path + "/Resources/" + "g.pptx");
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            path = Application.dataPath;
            Application.OpenURL("file:///C:/Users/a/Desktop/a.png");
        }
    }
    
}

你可能感兴趣的:(unity)