测试窗口
This commit is contained in:
BIN
Assets/ResRaw/zh.png
Normal file
BIN
Assets/ResRaw/zh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 485 KiB |
117
Assets/ResRaw/zh.png.meta
Normal file
117
Assets/ResRaw/zh.png.meta
Normal file
@@ -0,0 +1,117 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 923ba5fb2ce46d44581d5c34b247819a
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
72
Assets/Scripts/Editor/ImageViewerWindow.cs
Normal file
72
Assets/Scripts/Editor/ImageViewerWindow.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class SimpleImageViewerWindow : EditorWindow
|
||||
{
|
||||
private Texture2D image;
|
||||
private string imagePath = "Assets/ResRaw/zh.png";
|
||||
|
||||
// 手动设置显示尺寸
|
||||
private float displayWidth = 389f;
|
||||
private float displayHeight = 690f;
|
||||
|
||||
[MenuItem("NBC/ZH/Simple Image Viewer")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<SimpleImageViewerWindow>("Game");
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// 加载图片
|
||||
image = AssetDatabase.LoadAssetAtPath<Texture2D>(imagePath);
|
||||
if (image == null)
|
||||
{
|
||||
Debug.LogError($"无法加载图片: {imagePath}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox($"图片加载失败: {imagePath}", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// // 显示尺寸设置
|
||||
// EditorGUILayout.LabelField("显示尺寸设置", EditorStyles.boldLabel);
|
||||
// displayWidth = EditorGUILayout.FloatField("宽度", displayWidth);
|
||||
// displayHeight = EditorGUILayout.FloatField("高度", displayHeight);
|
||||
|
||||
// EditorGUILayout.Space();
|
||||
|
||||
// 计算居中所需的水平间距
|
||||
float horizontalSpace = (position.width - displayWidth) / 2;
|
||||
horizontalSpace = Mathf.Max(0, horizontalSpace);
|
||||
|
||||
// 创建水平布局来实现居中
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
// 左侧空白区域
|
||||
GUILayout.Space(horizontalSpace);
|
||||
|
||||
// 绘制图片
|
||||
Rect imageRect = GUILayoutUtility.GetRect(displayWidth, displayHeight);
|
||||
imageRect.width = displayWidth;
|
||||
imageRect.height = displayHeight;
|
||||
GUI.DrawTexture(imageRect, image, ScaleMode.StretchToFill);
|
||||
|
||||
// 右侧空白区域
|
||||
GUILayout.Space(horizontalSpace);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// // 显示图片信息
|
||||
// EditorGUILayout.Space();
|
||||
// EditorGUILayout.LabelField("图片信息", EditorStyles.boldLabel);
|
||||
// EditorGUILayout.LabelField($"路径: {imagePath}");
|
||||
// EditorGUILayout.LabelField($"Unity纹理尺寸: {image.width} x {image.height}");
|
||||
// EditorGUILayout.LabelField($"显示尺寸: {displayWidth} x {displayHeight}");
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Editor/ImageViewerWindow.cs.meta
Normal file
3
Assets/Scripts/Editor/ImageViewerWindow.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80b182f8bcff401aaaad3abc44492871
|
||||
timeCreated: 1757316527
|
||||
Reference in New Issue
Block a user