根据自己的Unity的.Net版本在Unity中选择合适的配置文件:System.Drawing.dll;System,Windows.Forms.dll
文件路径:D:\Unity2019.3.0\Editor\Data\MonoBleedingEdge\lib\mono
先定义文件属性:
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class OpenFileName
{
public int structSize = 0;
public IntPtr dlgOwner = IntPtr.Zero;
public IntPtr instance = IntPtr.Zero;
public string filter = null;
public string customFilter = null;
public int maxCustFilter = 0;
public int filterIndex = 0;
public string file = null;
public int maxFile = 0;
public string fileTitle = null;
public int maxFileTitle = 0;
public string initialDir = null;
public string title = null;
public int flags = 0;

本文介绍如何在Unity中利用C#代码获取本地图片文件,并将其显示在游戏面板上。首先,需要引入System.Drawing和System.Windows.Forms.dll库,这些库可在Unity的特定目录下找到。接着,定义文件路径和图片属性,通过Button点击事件触发函数来选择并读取图片文件,最后将图片显示到游戏界面。
最低0.47元/天 解锁文章
16万+

被折叠的 条评论
为什么被折叠?



