资源描述:
《unity3d技术之editorgui.drawpreviewtexture 绘制预览纹理》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、staticfunctionDrawPreviewTexture(position:Rect,image:Texture,mat:Material=null,scaleMode:ScaleMode=ScaleMode.StretchToFill,imageAspect:float=0):voidParameters参数·positionRectangleonthescreentodrawthetexturewithin.屏幕上绘制纹理的矩形区域·imageTexturetodisplay.//显
2、示的纹理·scaleModeHowtoscaletheimagewhentheaspectratioofitdoesn'tfittheaspectratiotobedrawnwithin.当纹理的尺寸不适合这个区域时如何缩放·matMaterialtobeusedwhendrawingthetexture.当绘制纹理时使用的材质·imageAspectAspectratiotouseforthesourceimage.If0(thedefault),theaspectratiofromtheim
3、ageisused.用于源图片的纵横比。如果为0(默认),使用源图片的纵横比Description描述Drawsthetexturewithinarectangle.在矩形内绘制纹理。Ifmatisnull(thedefault),anappropriatematerialwillbechosenforaRGBMordoubleLDRlightmaporanormalmapandthefallbackblitmaterialwillbechosenotherwise.如果mat为空(默认),一个
4、适当的材料将被选择为RGBM或doubleLDR lightmap或者一个正常的贴图和背景材料,否则将使用被选择的材质PreviewTextureinanEditorWindow.编辑器中的预览纹理。//Loadatexture,displaythetexture,displayitsalphachanneland//showapreviewoftheinvertedtexture//加载并这个纹理,显示其Alpha通道,并显示该纹理的反向预览【狗刨学习网】classEditorGUIText
5、uresextendsEditorWindow{vartexture:Texture2D;varinvertedTexture:Texture2D;varshowInverted=false;@MenuItem("Examples/TexturePreviewer")staticfunctionInit(){varwindow=GetWindow(EditorGUITextures);window.position=Rect(0,0,400,200);window.Show();}functio
6、nOnGUI(){texture=EditorGUI.ObjectField(Rect(3,3,200,20),"AddaTexture:",texture,Texture);if(GUI.Button(Rect(208,3,position.width-210,20),"ProcessInverted")){if(invertedTexture)DestroyImmediate(invertedTexture);//Copythenewtexture//复制新的纹理invertedTextur
7、e=newTexture2D(texture.width,texture.height,texture.format,(texture.mipmapCount!=0));for(varm:int=0;m8、5,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