unity3D技术之EditorGUI.DrawPreviewTexture 绘制预览纹理.docx_第1页
unity3D技术之EditorGUI.DrawPreviewTexture 绘制预览纹理.docx_第2页
unity3D技术之EditorGUI.DrawPreviewTexture 绘制预览纹理.docx_第3页
unity3D技术之EditorGUI.DrawPreviewTexture 绘制预览纹理.docx_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

static function DrawPreviewTexture (position : Rect, image : Texture, mat : Material = null, scaleMode : ScaleMode = ScaleMode.StretchToFill, imageAspect : float = 0) : void Parameters参数 positionRectangle on the screen to draw the texture within.屏幕上绘制纹理的矩形区域 imageTexture to display. / 显示的纹理 scaleModeHow to scale the image when the aspect ratio of it doesnt fit the aspect ratio to be drawn within.当纹理的尺寸不适合这个区域时如何缩放 matMaterial to be used when drawing the texture. 当绘制纹理时使用的材质 imageAspectAspect ratio to use for the source image. If 0 (the default), the aspect ratio from the image is used. 用于源图片的纵横比。如果为0(默认),使用源图片的纵横比 Description描述Draws the texture within a rectangle.在矩形内绘制纹理。If mat is null (the default), an appropriate material will be chosen for a RGBM or doubleLDR lightmap or a normal map and the fallback blit material will be chosen otherwise. 如果mat为空(默认),一个适当的材料将被选择为RGBM或doubleLDRlightmap或者一个正常的贴图和背景材料,否则将使用被选择的材质Preview Texture in an Editor Window. 编辑器中的预览纹理。/ Load a texture, display the texture, display its alpha channel and/ show a preview of the inverted texture/加载并这个纹理,显示其Alpha通道,并显示该纹理的反向预览【狗刨学习网】class EditorGUITextures extends EditorWindow var texture : Texture2D;var invertedTexture : Texture2D;var showInverted = false;MenuItem(Examples/Texture Previewer)static function Init() var window = GetWindow(EditorGUITextures);window.position = Rect(0,0,400, 200);window.Show();function OnGUI() texture = EditorGUI.ObjectField(Rect(3,3,200,20),Add a Texture:,texture,Texture);if(GUI.Button(Rect(208,3, position.width - 210, 20),Process Inverted) if(invertedTexture)DestroyImmediate(invertedTexture);/Copy the new texture/复制新的纹理invertedTexture = new Texture2D(texture.width,texture.height,texture.format,(texture.mipmapCount != 0);for (var m : int = 0; m texture.mipmapCount; m+)invertedTexture.SetPixels(texture.GetPixels(m), m);InvertColors();showInverted = true;if(texture) EditorGUI.PrefixLabel(Rect(25,45,100,15),0,GUIContent(Preview:);EditorGUI.DrawPreviewTexture(Rect(25,60,100,100),texture);EditorGUI.PrefixLabel(Rect(150,45,100,15),0,GUIContent(Alpha:);EditorGUI.DrawTextureAlpha(Rect(150,60,100,100),texture);EditorGUI.PrefixLabel(Rect(275,45,100,15),0,GUIContent(Inverted:);if(showInverted)EditorGUI.DrawPreviewTexture(Rect(275,60,100,100),invertedTexture);if(GUI.Button(Rect(3,position.height - 25, position.width-6,20),Clear texture) texture = EditorGUIUtility.whiteTexture;showInverted = false; else EditorGUI.PrefixLabel(Rect(3,position.height - 25,position.width - 6, 20),0,GUIContent(No texture found);function InvertColors() for (var m : int = 0; m invertedTexture.mipmapCount; m+) var c : Color = invertedTexture.GetPixels(m);for (var i : int = 0 ;i c.Length; i+) c

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论