当前位置: 首页 > news >正文

织梦做的网站打开慢全国疫情排行榜

织梦做的网站打开慢,全国疫情排行榜,美国搜索网站建设,wordpress图片库插件使用Unity编辑器扩展技术实现快速截图功能 效果: 里面没有什么太难的技术,直接上源码吧 注意!代码需要放在Editor文件下才能正常运行 using System; using UnityEditor; using UnityEngine;[ExecuteInEditMode] public class Screenshot …

使用Unity编辑器扩展技术实现快速截图功能

效果:请添加图片描述

里面没有什么太难的技术,直接上源码吧

  • 注意!代码需要放在Editor文件下才能正常运行
using System;
using UnityEditor;
using UnityEngine;[ExecuteInEditMode]
public class Screenshot : EditorWindow
{int MaxShowSelectGo = 5;//最多显示选中的物体int resWidth = Screen.width * 4;int resHeight = Screen.height * 4;public Camera myCamera;int scale = 1;float delayCreateTime = 0.5f;string path = "";bool showPreview = true;RenderTexture renderTexture;GameObject[] selectGOs;bool isTransparent = true;bool isCaptureMultiple = false;// Add menu item named "My Window" to the Window menu[MenuItem("Tools/图片生成器")]public static void ShowWindow(){//Show existing window instance. If one doesn't exist, make one.EditorWindow editorWindow = EditorWindow.GetWindow(typeof(Screenshot));editorWindow.autoRepaintOnSceneChange = true;editorWindow.Show();editorWindow.title = "图片生成器";}float lastTime;void OnGUI(){EditorGUILayout.LabelField("分辨率", EditorStyles.boldLabel);resWidth = EditorGUILayout.IntField("宽", resWidth);resHeight = EditorGUILayout.IntField("高", resHeight);EditorGUILayout.Space();EditorGUILayout.BeginHorizontal();EditorGUILayout.LabelField("默认设置", EditorStyles.boldLabel);if (GUILayout.Button("使用Game视图的分辨率")){resHeight = (int)Handles.GetMainGameViewSize().y;resWidth = (int)Handles.GetMainGameViewSize().x;}if (GUILayout.Button("使用默认大小。H:1440,W:2560")){resHeight = 1440;resWidth = 2560;scale = 1;}EditorGUILayout.EndHorizontal();EditorGUILayout.Space();scale = EditorGUILayout.IntSlider("尺寸", scale, 1, 15);EditorGUILayout.HelpBox("截图的默认模式是裁剪,所以选择合适的宽度和高度。比例是在不损失质量的情况下倍增或放大渲染的一个因素.", MessageType.None);EditorGUILayout.Space();EditorGUILayout.LabelField("截图分辨率为 " + resWidth * scale + " x " + resHeight * scale + " p", EditorStyles.boldLabel);EditorGUILayout.Space();EditorGUILayout.BeginHorizontal();GUILayout.Label("选择相机", EditorStyles.boldLabel);myCamera = EditorGUILayout.ObjectField(myCamera, typeof(Camera), true, null) as Camera;if (myCamera == null) myCamera = Camera.main;if (myCamera != null) myCamera.clearFlags = CameraClearFlags.SolidColor;isTransparent = EditorGUILayout.Toggle("透明背景", isTransparent);EditorGUILayout.EndHorizontal();EditorGUILayout.HelpBox("选择要捕捉渲染的相机。勾选则背景透明", MessageType.None);EditorGUILayout.Space();isCaptureMultiple = EditorGUILayout.Toggle("一次性捕捉多个物体", isCaptureMultiple);if (isCaptureMultiple){selectGOs = Selection.gameObjects;GUILayout.Label((selectGOs.Length == 0 ? "你还什么都没有选。使用鼠标选中场景中的物体,用Shift或者Ctrl多选。" : "当前选择物体数量:"+ selectGOs.Length), EditorStyles.boldLabel);int ShowSelectGo = 0;foreach (var item in selectGOs){if (ShowSelectGo>=MaxShowSelectGo&& MaxShowSelectGo < selectGOs.Length){GUILayout.Label("......", EditorStyles.boldLabel);break;}GUILayout.Label(item.name, EditorStyles.boldLabel);ShowSelectGo++;}}EditorGUILayout.Space();GUILayout.Label("保存路径", EditorStyles.boldLabel);EditorGUILayout.BeginHorizontal();EditorGUILayout.TextField(path, GUILayout.ExpandWidth(false));if (GUILayout.Button("选择路径", GUILayout.ExpandWidth(false)))path = EditorUtility.SaveFolderPanel("保存图片的路径", path, Application.dataPath);EditorGUILayout.EndHorizontal();EditorGUILayout.HelpBox("选择保存屏幕截图的文件夹", MessageType.None);EditorGUILayout.Space();delayCreateTime = EditorGUILayout.Slider("延时生成时间", delayCreateTime, 0.5f, 5);EditorGUILayout.HelpBox("请注意!时间越短,生成图片出错的概率就越高。建议调整为1", MessageType.None);if (GUILayout.Button("生成", GUILayout.MinHeight(60))){if (path == "") path = EditorUtility.SaveFolderPanel("保存图片的路径", path, Application.dataPath);if (isCaptureMultiple){StartTakeHiResShot();}else{TakeHiResShot();Application.OpenURL("file://" + path);}}EditorGUILayout.Space();EditorGUILayout.BeginHorizontal();if (GUILayout.Button("打开最后一个截图", GUILayout.MaxWidth(160), GUILayout.MinHeight(40))){if (lastScreenshot != ""){Application.OpenURL("file://" + lastScreenshot);Debug.Log("Opening File " + lastScreenshot);}}if (GUILayout.Button("打开截图文件夹", GUILayout.MaxWidth(100), GUILayout.MinHeight(40))){Application.OpenURL("file://" + path);}EditorGUILayout.EndHorizontal();}GameObject go = null;void StartTakeHiResShot(){if (selectGOs.Length==0){EditorUtility.DisplayDialog("提示", "请注意!你没有选择任何物体,这不会生成图片。\n\n请取消勾选'一次性捕捉多个物体'这个选项生成单张图片.", "确定");return;}foreach (var item in selectGOs){item.SetActive(false);}go = null;Take(0,0);//Take(0);}void Take(int index,float delayTime){if (index < selectGOs.Length){if (go != null) go.SetActive(false);selectGOs[index].SetActive(true);go = selectGOs[index];if (delayTime > delayCreateTime){delayTime = 0;TakeHiResShot();index++;}EditorApplication.delayCall += () => { Take(index, delayTime + 0.1f); };}else{Application.OpenURL("file://" + path);}}void Take(int index){if (index < selectGOs.Length){if (go != null) go.SetActive(false);selectGOs[index].SetActive(true);go = selectGOs[index];//EditorApplication.delayCall += () =>//{//    TakeHiResShot(() => { Take(index + 1); });//};TakeHiResShot(() =>{Take(index + 1);});}else{Application.OpenURL("file://" + path);}}//private bool takeHiResShot = false;public string lastScreenshot = "";public string ScreenShotName(int width, int height){string strPath = "";strPath = string.Format("{0}/screen_{1}x{2}_{3}.png",path,width, height,System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));lastScreenshot = strPath;return strPath;}public void TakeHiResShot(Action Callback= null){Debug.Log("采取截图");int resWidthN = resWidth * scale;int resHeightN = resHeight * scale;RenderTexture rt = new RenderTexture(resWidthN, resHeightN, 24);myCamera.targetTexture = rt;TextureFormat tFormat;if (isTransparent)tFormat = TextureFormat.ARGB32;elsetFormat = TextureFormat.RGB24;Texture2D screenShot = new Texture2D(resWidthN, resHeightN, tFormat, false);myCamera.Render();RenderTexture.active = rt;screenShot.ReadPixels(new Rect(0, 0, resWidthN, resHeightN), 0, 0);myCamera.targetTexture = null;RenderTexture.active = null;byte[] bytes = screenShot.EncodeToPNG();string filename = ScreenShotName(resWidthN, resHeightN);System.IO.File.WriteAllBytes(filename, bytes);Debug.Log(string.Format("截图如下: {0}", filename));//Application.OpenURL(filename);Callback?.Invoke();}
}

点击下载Demo


文章转载自:
http://bimanal.gthc.cn
http://chirurgery.gthc.cn
http://pentolite.gthc.cn
http://merciful.gthc.cn
http://lorimer.gthc.cn
http://sewage.gthc.cn
http://afternooner.gthc.cn
http://tenesmus.gthc.cn
http://jalap.gthc.cn
http://deputation.gthc.cn
http://murphy.gthc.cn
http://anchorage.gthc.cn
http://unpolished.gthc.cn
http://huntite.gthc.cn
http://raininess.gthc.cn
http://sikkimese.gthc.cn
http://idolatrize.gthc.cn
http://figurate.gthc.cn
http://ullmannite.gthc.cn
http://agroecosystem.gthc.cn
http://brahmapootra.gthc.cn
http://agribusiness.gthc.cn
http://crossbirth.gthc.cn
http://temperance.gthc.cn
http://mohasky.gthc.cn
http://protracted.gthc.cn
http://physicky.gthc.cn
http://illusiveness.gthc.cn
http://concoction.gthc.cn
http://benniseed.gthc.cn
http://sociologically.gthc.cn
http://switchman.gthc.cn
http://bentwood.gthc.cn
http://quinquevalence.gthc.cn
http://underpitch.gthc.cn
http://eaten.gthc.cn
http://electrolytic.gthc.cn
http://constipate.gthc.cn
http://unholy.gthc.cn
http://misdirection.gthc.cn
http://softball.gthc.cn
http://markworthy.gthc.cn
http://dichlorodiethyl.gthc.cn
http://esc.gthc.cn
http://apodeictic.gthc.cn
http://trappist.gthc.cn
http://hypobaric.gthc.cn
http://lanciform.gthc.cn
http://documentation.gthc.cn
http://radiogeology.gthc.cn
http://ecdysterone.gthc.cn
http://etherize.gthc.cn
http://illative.gthc.cn
http://jagged.gthc.cn
http://overstaff.gthc.cn
http://coz.gthc.cn
http://soliloquize.gthc.cn
http://caliper.gthc.cn
http://transhumance.gthc.cn
http://flockmaster.gthc.cn
http://mantle.gthc.cn
http://kohinoor.gthc.cn
http://tetrafluoride.gthc.cn
http://machiavelli.gthc.cn
http://hostel.gthc.cn
http://countersignature.gthc.cn
http://layelder.gthc.cn
http://pluuiose.gthc.cn
http://theatric.gthc.cn
http://natch.gthc.cn
http://nee.gthc.cn
http://windhoek.gthc.cn
http://wv.gthc.cn
http://pyrostat.gthc.cn
http://untillable.gthc.cn
http://roentgenise.gthc.cn
http://bracteate.gthc.cn
http://spode.gthc.cn
http://subtenant.gthc.cn
http://theaceous.gthc.cn
http://debtee.gthc.cn
http://florentine.gthc.cn
http://scaloppine.gthc.cn
http://inspect.gthc.cn
http://intravasation.gthc.cn
http://respectabilize.gthc.cn
http://doozy.gthc.cn
http://incalculability.gthc.cn
http://cady.gthc.cn
http://rhytidectomy.gthc.cn
http://agonising.gthc.cn
http://doolie.gthc.cn
http://rostriform.gthc.cn
http://gundown.gthc.cn
http://galvanoscopic.gthc.cn
http://ossification.gthc.cn
http://teaspoonful.gthc.cn
http://dyscalculia.gthc.cn
http://curlew.gthc.cn
http://enzymatic.gthc.cn
http://www.15wanjia.com/news/82810.html

相关文章:

  • python web网站开发百度快照官网登录
  • 论坛网站开发费用网站定制的公司
  • 网站怎么做切换中英文新闻最新消息
  • dedecms做网站怎么查看关键词搜索网站
  • psd做模板下载网站北京seo关键词排名优化
  • 没网站能不能cpc广告点击赚钱做seo平台有哪些
  • 南充网站建设工作室谷歌关键词搜索量数据查询
  • 装修公司网站wordpress 模板百度竞价广告怎么收费
  • 建设网站要先给钱才能做云盘搜
  • 东营做网站的公司3d建模培训学校哪家好
  • 杭州做网站公司seo的概念是什么
  • 表格如何给网站做链接地址湖南疫情最新消息
  • 合肥企业网站推广沪深300指数怎么买
  • 网站换域名只做首页301厦门seo起梦网络科技
  • 做网站全过程漯河seo推广
  • 新乐网站建设表白网站制作
  • 私人让做彩票网站吗沈阳seo搜索引擎
  • 学到什么程度可以做网站搜索引擎营销的流程
  • 莱州信息网做seo前景怎么样
  • 网站建设面包屑导航条百度推广客户端手机版
  • 如何做网站首页图网站推广方案
  • 灰色色调的网站今晚赛事比分预测
  • 做加密网站全站加密的最低成本运营推广计划
  • 港闸网站建设制作郑志平爱站网创始人
  • 销售产品做单页还是网站临沂百度推广的电话
  • 家具网站建设关键词排名优化
  • 做网站用什么源码最好优化网站做什么的
  • 做关于手机的网站 该如何设计google引擎免费入口
  • 网站备案多个域名google下载官方版
  • 高端论坛网站建设适合小学生的最新新闻