Tidy up a part of the code

This commit is contained in:
Perfare
2017-02-12 04:57:24 +08:00
parent b580b293f3
commit 16ed347a30
14 changed files with 299 additions and 318 deletions

View File

@ -175,11 +175,11 @@ namespace Unity_Studio
preloadData.extension = ".AudioClip";
preloadData.InfoText += "Unknown";
}
preloadData.InfoText += "\n3D: " + m_3D.ToString();
preloadData.InfoText += "\n3D: " + m_3D;
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
}
}

View File

@ -188,7 +188,7 @@ namespace Unity_Studio
{
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
}
}

View File

@ -161,7 +161,7 @@ namespace Unity_Studio
{
public int m_NumItems;
public float m_Range = 1.0f;
public float m_Start = 0.0f;
public float m_Start;
public byte[] m_Data;
public byte m_BitSize;
}
@ -174,7 +174,7 @@ namespace Unity_Studio
switch (inputBytes.Length)
{
case 1:
result = (float)inputBytes[0] / 255.0f;
result = inputBytes[0] / 255.0f;
break;
case 2:
result = Half.ToHalf(inputBytes, 0);
@ -204,7 +204,7 @@ namespace Unity_Studio
}
int groupSize = pakData.m_BitSize; //bitSize * 8 values / 8 bits
byte[] group = new byte[groupSize];
int groupCount = (int)(pakData.m_NumItems / 8);
int groupCount = pakData.m_NumItems / 8;
for (int g = 0; g < groupCount; g++)
{
@ -229,7 +229,7 @@ namespace Unity_Studio
//m_NumItems is not necessarily a multiple of 8, so there can be one extra group with fewer values
int endBytes = pakData.m_Data.Length - groupCount * groupSize;
int endVal = (int)(pakData.m_NumItems - groupCount * 8);
int endVal = pakData.m_NumItems - groupCount * 8;
if (endBytes > 0)
{

View File

@ -55,7 +55,7 @@ namespace Unity_Studio
{
preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID;
}
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
}

View File

@ -33,7 +33,7 @@ namespace Unity_Studio
{
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
}
else
@ -56,7 +56,7 @@ namespace Unity_Studio
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
a_Stream.AlignStream(4);
m_PathName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());

View File

@ -141,8 +141,8 @@ namespace Unity_Studio
if (version[0] >= 4 || (version[0] == 3 && version[1] >= 4))
{
//AABB
float[] m_Center = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
float[] m_Extent = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
float[] m_Center = { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
float[] m_Extent = { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
bool m_DirtyAABB = a_Stream.ReadBoolean();
}
}

View File

@ -53,7 +53,7 @@ namespace Unity_Studio
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
a_Stream.AlignStream(4);

View File

@ -14,7 +14,7 @@ namespace Unity_Studio
public int m_Height;
public int m_CompleteImageSize;
public TextureFormat m_TextureFormat;
public bool m_MipMap = false;
public bool m_MipMap;
public bool m_IsReadable;
public bool m_ReadAllowed;
public int m_ImageCount;
@ -39,11 +39,11 @@ namespace Unity_Studio
private int dwFlags = 0x1 + 0x2 + 0x4 + 0x1000;
//public int dwHeight; m_Height
//public int dwWidth; m_Width
private int dwPitchOrLinearSize = 0x0;
private int dwPitchOrLinearSize;
private int dwMipMapCount = 0x1;
private int dwSize = 0x20;
private int dwFlags2;
private int dwFourCC = 0x0;
private int dwFourCC;
private int dwRGBBitCount;
private int dwRBitMask;
private int dwGBitMask;
@ -672,7 +672,7 @@ namespace Unity_Studio
}
else
{
preloadData.InfoText = "Width: " + m_Width.ToString() + "\nHeight: " + m_Height.ToString() + "\nFormat: ";
preloadData.InfoText = "Width: " + m_Width + "\nHeight: " + m_Height + "\nFormat: ";
string type = m_TextureFormat.ToString();
preloadData.InfoText += type;
@ -745,7 +745,7 @@ namespace Unity_Studio
}
preloadData.InfoText += "\nAnisotropic level: " + m_Aniso.ToString() + "\nMip map bias: " + m_MipBias.ToString();
preloadData.InfoText += "\nAnisotropic level: " + m_Aniso + "\nMip map bias: " + m_MipBias;
switch (m_WrapMode)
{
@ -755,7 +755,7 @@ namespace Unity_Studio
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
}
}
@ -906,6 +906,8 @@ namespace Unity_Studio
public Bitmap ConvertToBitmap(bool flip)
{
if (image_data == null || image_data.Length == 0)
return null;
Bitmap bitmap = null;
switch (m_TextureFormat)
{
@ -981,28 +983,20 @@ namespace Unity_Studio
private Bitmap BGRA32ToBitmap()
{
if (image_data.Length > 0)
{
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
var pObject = hObject.AddrOfPinnedObject();
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 4, PixelFormat.Format32bppArgb, pObject);
hObject.Free();
return bitmap;
}
return null;
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
var pObject = hObject.AddrOfPinnedObject();
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 4, PixelFormat.Format32bppArgb, pObject);
hObject.Free();
return bitmap;
}
private Bitmap RGB565ToBitmap()
{
if (image_data.Length > 0)
{
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
var pObject = hObject.AddrOfPinnedObject();
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 2, PixelFormat.Format16bppRgb565, pObject);
hObject.Free();
return bitmap;
}
return null;
var hObject = GCHandle.Alloc(image_data, GCHandleType.Pinned);
var pObject = hObject.AddrOfPinnedObject();
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 2, PixelFormat.Format16bppRgb565, pObject);
hObject.Free();
return bitmap;
}
private Bitmap PVRToBitmap(byte[] pvrdata)
@ -1126,8 +1120,8 @@ public enum TextureFormat
public static class KTXHeader
{
public static byte[] IDENTIFIER = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
public static byte[] ENDIANESS_LE = new byte[] { 1, 2, 3, 4 };
public static byte[] ENDIANESS_BE = new byte[] { 4, 3, 2, 1 };
public static byte[] ENDIANESS_LE = { 1, 2, 3, 4 };
public static byte[] ENDIANESS_BE = { 4, 3, 2, 1 };
// constants for glInternalFormat
public static int GL_ETC1_RGB8_OES = 0x8D64;

View File

@ -28,9 +28,9 @@ namespace Unity_Studio
}
m_GameObject = sourceFile.ReadPPtr();
m_LocalRotation = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
m_LocalPosition = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
m_LocalScale = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
m_LocalRotation = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
m_LocalPosition = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
m_LocalScale = new[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
int m_ChildrenCount = a_Stream.ReadInt32();
for (int j = 0; j < m_ChildrenCount; j++)
{