1 编辑模式(Editor)下:

string path = EditorUtility.OpenFilePanel("Load png Textures of Directory", "", "");
WWW ww=new WWW("file:///"+path);
print(ww.url);
yield return ww;
gui.texture=ww.texture;

2.非编辑模式:

OpenFileDialog ofd = new OpenFileDialog();   //new一个方法ofd.InitialDirectory ="file://"+UnityEngine.Application.dataPath;  //定义打开的默认文件夹位置//定义打开的默认文件夹位置
if(ofd.ShowDialog()==DialogResult.OK)
{//显示打开文件的窗口Debug.Log( ofd.FileName);
}

以上操作需要添加 System.Windows.Forms.dll,放在Plugins文件夹下,同时需要更改.net 2.0 Subset为.net2.0

3、unity3d调用win32打开对话框

DllTestusing UnityEngine;
using System.Collections;
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; public short    fileOffset = 0;public short    fileExtension = 0;public String   defExt = null; public IntPtr   custData = IntPtr.Zero;  public IntPtr   hook = IntPtr.Zero;  public String   templateName = null; public IntPtr   reservedPtr = IntPtr.Zero; public int      reservedInt = 0;public int      flagsEx = 0;
}public class DllTest
{
[DllImport("Comdlg32.dll",SetLastError=true,ThrowOnUnmappableChar=true, CharSet = CharSet.Auto)]          public static extern bool GetOpenFileName([ In, Out ] OpenFileName ofn );   public static  bool GetOpenFileName1([ In, Out ] OpenFileName ofn ){return GetOpenFileName(ofn);}
}
using UnityEngine;using System.Collections;using System.Text;using System.Runtime.InteropServices;using System;public class Test : MonoBehaviour {public GameObject plane;void OnGUI(){if(GUI.Button(new Rect(0,0,100,35),"OpenDialog")){OpenFileName ofn = new OpenFileName();ofn.structSize = Marshal.SizeOf(ofn);ofn.filter = "All Files\0*.*\0\0";ofn.file = new string(new char[256]);ofn.maxFile = ofn.file.Length;ofn.fileTitle = new string(new char[64]);ofn.maxFileTitle = ofn.fileTitle.Length;ofn.initialDir =UnityEngine.Application.dataPath;//默认路径ofn.title = "Open Project";ofn.defExt = "JPG";//显示文件的类型//注意 一下项目不一定要全选 但是0x00000008项不要缺少ofn.flags=0x00080000|0x00001000|0x00000800|0x00000200|0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIRif(DllTest.GetOpenFileName( ofn )){StartCoroutine(WaitLoad(ofn.file));//加载图片到panleDebug.Log( "Selected file with full path: {0}"+ofn.file );}}}IEnumerator WaitLoad(string fileName){WWW wwwTexture=new WWW("file://"+fileName);Debug.Log(wwwTexture.url);yield return wwwTexture;plane.renderer.material.mainTexture=wwwTexture.texture;}
}

												

unity3d 调用windows窗口相关推荐

  1. selenium 上传下载调用windows窗口--AutoIT

    AutoIT解决自动化上传下载文件调用Windows窗口 AutoIT 下载安装 使用AotuIt 操作windows上传窗口 1. 打开AutoIt定位窗口组件 2. 定位上传窗口属性 (鼠标选中F ...

  2. unity 实现调用Windows窗口/对话框交互

    Unity调用Window窗口 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人! (拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心 ...

  3. winform解决跨线程调用windows窗口控件

    private delegate void Start(int type);private void StartDele(int type) {if (this.InvokeRequired){Sta ...

  4. 用C#调用Windows API向指定窗口发送按键消息

    为什么80%的码农都做不了架构师?>>>    用C#调用Windows API向指定窗口发送 一.调用Windows API. C#下调用Windows API方法如下: 1.引入 ...

  5. Qt 调用 Windows 接口实现窗口置顶

    前言 用 Qt 做 Windows 软件开发,有时候会用到窗口置顶功能,其实 Qt 有自带的接口来实现窗口置顶,但是效果并不太理想,比如说没办法置顶于系统标题栏,或者在全屏状态下如果有键盘事件的时候窗 ...

  6. 用C#调用Windows API向指定窗口发送按键消息(转载)

    用C#调用Windows API向指定窗口发送按键消息 z 用C#调用Windows API向指定窗口发送 一.调用Windows API. C#下调用Windows API方法如下: 1.引入命名空 ...

  7. 调用Windows api 窗口截图

    分别调用windows api函数及CVI自带函数,完成对GRAPH界面的截图 界面设计如下图,右侧为graph控件的位置信息,调用API函数是完成对于选择窗口的固定位置进行截图,调用CVI自带函数则 ...

  8. 善于 调用Windows API

    前一段时间看见别人做的一个自动填写信息并且点击登录的程序,觉得很有意思. 其实就是在程序中调用Windows的API,那么如何调用,下面就做个简单的介绍. 写的简单粗暴, 不喜轻喷. 0.首先引入名称 ...

  9. java 调用windows bat脚本

    当我们需要在java程序中调用外部程序,我们可用通过Runtime.exec()调用来完成. The class java.lang.Runtime features a static method ...

最新文章

  1. predicate 列存储索引扫描_在SQL SERVER中导致索引查找变成索引扫描的问题分析
  2. 从大数据技术参考模型角度梳理大数据标准
  3. 回退进度_【蜕变】V7账号发展进度第47期:回归宝箱开个都是啥呀!瞬间无爱了...
  4. Yii的 Yii::$app-end()
  5. BurpSuite技巧之二重代理
  6. diff算法_vue源码解读 diff算法
  7. 如何将风险应用加入白名单_理财要如何将资金分散呢?可以参考风险分散和分享经济红利的思路...
  8. 卸载 windows_Windows 10可能很快会自动卸载有问题的Windows更新
  9. c++ string类_C++|细说STL string类概貌及底层细节
  10. 统计数字字符和空格 (15 分)
  11. JavaScript get set方法 ES5 ES6写法
  12. Typora MarkDown语法笔记(一)
  13. postgres 显示变量,如何在PostgreSQL查询中声明变量
  14. openmeeting开发心得及相关文档
  15. EasyAR WebAR开发
  16. 虚函数表和虚函数指针
  17. 抖音数据统计_抖音直播带货数据分析(最新教程)
  18. TCP-Hybla拥塞算法
  19. HIT-SCIR/Elmoformanylanguages安装记录
  20. PS 不能使用移动工具 因为目标图层被隐藏怎么办

热门文章

  1. 视频教程-C#Winform窗体与界面设计-C#
  2. 电脑java运行不了,为什么我的电脑不能运行java?
  3. 如何有效的在 60 秒内进行 Linux 服务器性能故障分析
  4. CC65 开发FC/NES 游戏(一)环境搭建(2021-04-27更新部分内容和修改部分错误介绍)
  5. mybatis中批量更新
  6. 尚硅谷Vue2学习笔记分享
  7. ubuntu18.04 + CUDA10 + CUDNN7 deb安装
  8. 【夏天再见】2017暑期回顾---“软件自由日”
  9. C语言小游戏大全,C语言贪吃蛇小游戏(附源码)
  10. 百度地图api根据经纬度获取详细地址