这里主要做了截屏和获取本地图片的功能,希望对你有用。代码不多注释齐全!
@晕,我犯了一个错误,就是 "/" 和 "\" 混合使用了,不过已经修改了,请大家放心!大家使用的时候注意Application.datapath的时候,使用的是 "/",可以不需要加@,但是使用 System.Environment.CurrentDirectory的时候,就需要使用到 @“\” ,因为它是换行符,所以要用@忽略它。
using UnityEngine; using System.Collections; using System.IO; /// <summary> /// 使用鼠标(像QQ截图一样)自由截取Unity程序中的任意地方 and 获取本地文件夹下的所有图片 /// </summary> public class ScreenShot : MonoBehaviour { string localPath; WWW www; Rect rect; float time; Vector2 pos1; Vector2 pos2; // 用来显示存放截图的 public Material image; // 用来显示从文件夹中获取的 public Material image1; // Use this for initialization void Start(){ } // Update is called once per frame void Update() { //点击鼠标左键,记录第一个位置 if(Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { pos1 = I
使用鼠标(像QQ截图一样)自由截取Unity程序中的任意地方 && 获取本地文件夹下的所有图片
最新推荐文章于 2022-11-17 15:35:45 发布