1.上官网 选择对应版本 https://www.gisinternals.com/query.html?content=filelist&file=release-1930-x64-gdal-3-6-3-mapserver-8-0-0.zip
选择Stable Releases 然后选择对应得版本

点进来后,一般下载第一个

- 把图中dll放到 Unity的Assets文件夹下面我们之前建立的Plugins文件夹下.
 
网上看到说只放这个文件夹下的dll就行 但是我实际测试中不可以,还需要放 bin目录下所有的dll,这样运行才不会报错

3.进行测试
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GDALTest : MonoBehaviour
{
    void Start()
    {
        Gdal.AllRegister();
        Dataset ds = Gdal.Open(@"D:\mayawenunity\GDALTest\tin_TinRaste11.tif", Access.GA_ReadOnly);
        int w = ds.RasterXSize;
        int h = ds.RasterYSize;
        print("image width=" + w + ",height=" + h);
    }
}4.发现还会有报错(进行坐标系转换的时候),需访问压缩包中的一个数据库

5.将proj.db放到unity中

重新测试:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GDALTest : MonoBehaviour
{
    [SerializeField] string PROJSearchPath = Application.streamingAssetsPath + "/Data/proj9";
    void Start()
    {
        Gdal.AllRegister();
         Osr.SetPROJSearchPath(PROJSearchPath);
        Dataset ds = Gdal.Open(@"D:\mayawenunity\GDALTest\tin_TinRaste11.tif", Access.GA_ReadOnly);
        int w = ds.RasterXSize;
        int h = ds.RasterYSize;
        Debug.Log("image width=" + w + ",height=" + h);
    }
}至此报错全部解决.










