cleanup code

This commit is contained in:
Perfare 2017-04-10 03:13:08 +08:00
parent a928660dd3
commit d1ec1c29a4
13 changed files with 494 additions and 581 deletions

View File

@ -54,7 +54,7 @@ namespace SevenZip.Compression.LZMA
MemoryStream inStream = new MemoryStream(inputBytes);
MemoryStream outStream = new MemoryStream();
SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder();
Encoder encoder = new Encoder();
encoder.SetCoderProperties(propIDs, properties);
encoder.WriteCoderProperties(outStream);
long fileSize = inStream.Length;
@ -68,7 +68,7 @@ namespace SevenZip.Compression.LZMA
{
MemoryStream newInStream = new MemoryStream(inputBytes);
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
Decoder decoder = new Decoder();
newInStream.Seek(0, 0);
MemoryStream newOutStream = new MemoryStream();
@ -97,7 +97,7 @@ namespace SevenZip.Compression.LZMA
public static MemoryStream StreamDecompress(MemoryStream newInStream)
{
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
Decoder decoder = new Decoder();
newInStream.Seek(0, 0);
MemoryStream newOutStream = new MemoryStream();
@ -124,7 +124,7 @@ namespace SevenZip.Compression.LZMA
public static MemoryStream StreamDecompress(MemoryStream newInStream, long outSize)
{
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
Decoder decoder = new Decoder();
newInStream.Seek(0, 0);
MemoryStream newOutStream = new MemoryStream();

View File

@ -13,12 +13,12 @@ namespace Unity_Studio
public AboutBox()
{
InitializeComponent();
this.Text = String.Format("About {0}", AssemblyTitle);
this.labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
this.labelCopyright.Text = AssemblyCopyright;
this.labelCompanyName.Text = AssemblyCompany;
this.textBoxDescription.Text = AssemblyDescription;
Text = $"About {AssemblyTitle}";
labelProductName.Text = AssemblyProduct;
labelVersion.Text = $"Version {AssemblyVersion}";
labelCopyright.Text = AssemblyCopyright;
labelCompanyName.Text = AssemblyCompany;
textBoxDescription.Text = AssemblyDescription;
}
#region Assembly Attribute Accessors
@ -40,13 +40,7 @@ namespace Unity_Studio
}
}
public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
public string AssemblyDescription
{
@ -103,7 +97,7 @@ namespace Unity_Studio
private void okButton_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
}
}

View File

@ -27,12 +27,12 @@ namespace Unity_Studio
showExpOpt.Checked = (bool)Properties.Settings.Default["showExpOpt"];
converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"];
convertfsb.Checked = (bool)Properties.Settings.Default["convertfsb"];
string str = Properties.Settings.Default["convertType"] as string;
var str = (string)Properties.Settings.Default["convertType"];
foreach (Control c in panel1.Controls)
{
if (c.Text == str)
{
(c as RadioButton).Checked = true;
((RadioButton)c).Checked = true;
break;
}
}
@ -57,21 +57,21 @@ namespace Unity_Studio
Properties.Settings.Default["convertfsb"] = convertfsb.Checked;
foreach (Control c in panel1.Controls)
{
if ((c as RadioButton).Checked)
if (((RadioButton)c).Checked)
{
Properties.Settings.Default["convertType"] = c.Text;
break;
}
}
Properties.Settings.Default.Save();
this.DialogResult = DialogResult.OK;
this.Close();
DialogResult = DialogResult.OK;
Close();
}
private void fbxCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
DialogResult = DialogResult.Cancel;
Close();
}
private void exportDeformers_CheckedChanged(object sender, EventArgs e)

View File

@ -94,23 +94,21 @@ namespace Unity_Studio
if (readSwitch)
{
m_AudioData = new byte[m_Size];
if (m_Source == null)
{
a_Stream.Read(m_AudioData, 0, (int)m_Size);
m_AudioData = a_Stream.ReadBytes((int)m_Size);
}
else if (File.Exists(m_Source) ||
File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source))))
{
BinaryReader reader = new BinaryReader(File.OpenRead(m_Source));
reader.BaseStream.Position = m_Offset;
reader.Read(m_AudioData, 0, (int)m_Size);
m_AudioData = reader.ReadBytes((int)m_Size);
reader.Close();
}
else
{
EndianStream estream = null;
EndianStream estream;
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out estream))
{
estream.Position = m_Offset;

View File

@ -58,10 +58,10 @@ namespace Unity_Studio
m_Tag = a_Stream.ReadUInt16();
m_IsActive = a_Stream.ReadBoolean();
base.Text = m_Name;
Text = m_Name;
preloadData.Text = m_Name;
//name should be unique
base.Name = uniqueID;
Name = uniqueID;
}
}
}

View File

@ -168,15 +168,14 @@ namespace Unity_Studio
if (File.Exists(path) ||
File.Exists(path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(path))))
{
image_data = new byte[image_data_size];
BinaryReader reader = new BinaryReader(File.OpenRead(path));
reader.BaseStream.Position = offset;
reader.Read(image_data, 0, image_data_size);
image_data = reader.ReadBytes(image_data_size);
reader.Close();
}
else
{
EndianStream estream = null;
EndianStream estream;
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(path), out estream))
{
estream.Position = offset;
@ -186,8 +185,7 @@ namespace Unity_Studio
}
else
{
image_data = new byte[image_data_size];
a_Stream.Read(image_data, 0, image_data_size);
image_data = a_Stream.ReadBytes(image_data_size);
}
switch (m_TextureFormat)

View File

@ -138,11 +138,8 @@ namespace Unity_Studio
{
return member2;
}
else
{
member2.Add(member);
}
}
return member2;
}
}

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using Lz4;
using SevenZip.Compression.LZMA;
namespace Unity_Studio
{
@ -97,7 +97,7 @@ namespace Unity_Studio
byte[] lzmaBuffer = new byte[lzmaSize];
b_Stream.Read(lzmaBuffer, 0, lzmaSize);
using (var lzmaStream = new EndianStream(SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(new MemoryStream(lzmaBuffer)), EndianType.BigEndian))
using (var lzmaStream = new EndianStream(SevenZipHelper.StreamDecompress(new MemoryStream(lzmaBuffer)), EndianType.BigEndian))
{
getFiles(lzmaStream, 0);
}
@ -166,15 +166,14 @@ namespace Unity_Studio
EndianStream blocksInfo;
switch (flag & 0x3F)
{
default:
case 0://None
default://None
{
blocksInfo = new EndianStream(new MemoryStream(blocksInfoBytes), EndianType.BigEndian);
break;
}
case 1://LZMA
{
blocksInfo = new EndianStream(SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(new MemoryStream(blocksInfoBytes)), EndianType.BigEndian);
blocksInfo = new EndianStream(SevenZipHelper.StreamDecompress(new MemoryStream(blocksInfoBytes)), EndianType.BigEndian);
break;
}
case 2://LZ4
@ -206,8 +205,7 @@ namespace Unity_Studio
var compressedBytes = b_Stream.ReadBytes(compressedSize);
switch (flag & 0x3F)
{
default:
case 0://None
default://None
{
assetsDataStream.Write(compressedBytes, 0, compressedSize);
break;
@ -217,7 +215,7 @@ namespace Unity_Studio
var uncompressedBytes = new byte[uncompressedSize];
using (var mstream = new MemoryStream(compressedBytes))
{
var decoder = SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(mstream, uncompressedSize);
var decoder = SevenZipHelper.StreamDecompress(mstream, uncompressedSize);
decoder.Read(uncompressedBytes, 0, uncompressedSize);
decoder.Dispose();
}

View File

@ -20,115 +20,115 @@ namespace Unity_Studio
public EndianStream(Stream stream, EndianType endian) : base(stream) { }
public long Position { get { return base.BaseStream.Position; } set { base.BaseStream.Position = value; } }
public long Position { get { return BaseStream.Position; } set { BaseStream.Position = value; } }
public override short ReadInt16()
{
if (endian == EndianType.BigEndian)
{
a16 = base.ReadBytes(2);
a16 = ReadBytes(2);
Array.Reverse(a16);
return BitConverter.ToInt16(a16, 0);
}
else return base.ReadInt16();
return base.ReadInt16();
}
public override int ReadInt32()
{
if (endian == EndianType.BigEndian)
{
a32 = base.ReadBytes(4);
a32 = ReadBytes(4);
Array.Reverse(a32);
return BitConverter.ToInt32(a32, 0);
}
else return base.ReadInt32();
return base.ReadInt32();
}
public override long ReadInt64()
{
if (endian == EndianType.BigEndian)
{
a64 = base.ReadBytes(8);
a64 = ReadBytes(8);
Array.Reverse(a64);
return BitConverter.ToInt64(a64, 0);
}
else return base.ReadInt64();
return base.ReadInt64();
}
public override ushort ReadUInt16()
{
if (endian == EndianType.BigEndian)
{
a16 = base.ReadBytes(2);
a16 = ReadBytes(2);
Array.Reverse(a16);
return BitConverter.ToUInt16(a16, 0);
}
else return base.ReadUInt16();
return base.ReadUInt16();
}
public override uint ReadUInt32()
{
if (endian == EndianType.BigEndian)
{
a32 = base.ReadBytes(4);
a32 = ReadBytes(4);
Array.Reverse(a32);
return BitConverter.ToUInt32(a32, 0);
}
else return base.ReadUInt32();
return base.ReadUInt32();
}
public override ulong ReadUInt64()
{
if (endian == EndianType.BigEndian)
{
a64 = base.ReadBytes(8);
a64 = ReadBytes(8);
Array.Reverse(a64);
return BitConverter.ToUInt64(a64, 0);
}
else return base.ReadUInt64();
return base.ReadUInt64();
}
public override float ReadSingle()
{
if (endian == EndianType.BigEndian)
{
a32 = base.ReadBytes(4);
a32 = ReadBytes(4);
Array.Reverse(a32);
return BitConverter.ToSingle(a32, 0);
}
else return base.ReadSingle();
return base.ReadSingle();
}
public override double ReadDouble()
{
if (endian == EndianType.BigEndian)
{
a64 = base.ReadBytes(8);
a64 = ReadBytes(8);
Array.Reverse(a64);
return BitConverter.ToUInt64(a64, 0);
}
else return base.ReadDouble();
return base.ReadDouble();
}
public string ReadASCII(int length)
{
return Encoding.ASCII.GetString(base.ReadBytes(length));
return Encoding.ASCII.GetString(ReadBytes(length));
}
public void AlignStream(int alignment)
{
long pos = base.BaseStream.Position;
long pos = BaseStream.Position;
//long padding = alignment - pos + (pos / alignment) * alignment;
//if (padding != alignment) { base.BaseStream.Position += padding; }
if ((pos % alignment) != 0) { base.BaseStream.Position += alignment - (pos % alignment); }
if ((pos % alignment) != 0) { BaseStream.Position += alignment - (pos % alignment); }
}
public string ReadAlignedString(int length)
{
if (length > 0 && length < (base.BaseStream.Length - base.BaseStream.Position))//crude failsafe
if (length > 0 && length < (BaseStream.Length - BaseStream.Position))//crude failsafe
{
byte[] stringData = new byte[length];
base.Read(stringData, 0, length);
Read(stringData, 0, length);
var result = Encoding.UTF8.GetString(stringData); //must verify strange characters in PS3
/*string result = "";
@ -142,7 +142,7 @@ namespace Unity_Studio
AlignStream(4);
return result;
}
else { return ""; }
return "";
}
public string ReadStringToNull()

View File

@ -9,16 +9,12 @@ namespace Lz4
{
public class Lz4DecoderStream : Stream
{
public Lz4DecoderStream()
public Lz4DecoderStream(Stream input, long inputLength = long.MaxValue)
{
Reset(input, inputLength);
}
public Lz4DecoderStream( Stream input, long inputLength = long.MaxValue )
{
Reset( input, inputLength );
}
public void Reset( Stream input, long inputLength = long.MaxValue )
public void Reset(Stream input, long inputLength = long.MaxValue)
{
this.inputLength = inputLength;
this.input = input;
@ -37,7 +33,7 @@ namespace Lz4
public override void Close()
{
this.input = null;
input = null;
}
private long inputLength;
@ -76,15 +72,15 @@ namespace Lz4
private int litLen, matLen, matDst;
public override int Read( byte[] buffer, int offset, int count )
public override int Read(byte[] buffer, int offset, int count)
{
#if CHECK_ARGS
if( buffer == null )
throw new ArgumentNullException( "buffer" );
if( offset < 0 || count < 0 || buffer.Length - count < offset )
if (buffer == null)
throw new ArgumentNullException("buffer");
if (offset < 0 || count < 0 || buffer.Length - count < offset)
throw new ArgumentOutOfRangeException();
if( input == null )
if (input == null)
throw new InvalidOperationException();
#endif
int nRead, nToRead = count;
@ -102,7 +98,7 @@ namespace Lz4
var inBufPos = this.inBufPos;
var inBufEnd = this.inBufEnd;
#endif
switch( phase )
switch (phase)
{
case DecodePhase.ReadToken:
goto readToken;
@ -125,7 +121,7 @@ namespace Lz4
readToken:
int tok;
if( inBufPos < inBufEnd )
if (inBufPos < inBufEnd)
{
tok = decBuf[inBufPos++];
}
@ -141,7 +137,7 @@ namespace Lz4
inBufEnd = this.inBufEnd;
#endif
#if CHECK_EOF
if( tok == -1 )
if (tok == -1)
goto finish;
#endif
}
@ -149,7 +145,7 @@ namespace Lz4
litLen = tok >> 4;
matLen = (tok & 0xF) + 4;
switch( litLen )
switch (litLen)
{
case 0:
phase = DecodePhase.ReadOffset;
@ -166,7 +162,7 @@ namespace Lz4
readExLiteralLength:
int exLitLen;
if( inBufPos < inBufEnd )
if (inBufPos < inBufEnd)
{
exLitLen = decBuf[inBufPos++];
}
@ -182,13 +178,13 @@ namespace Lz4
#endif
#if CHECK_EOF
if( exLitLen == -1 )
if (exLitLen == -1)
goto finish;
#endif
}
litLen += exLitLen;
if( exLitLen == 255 )
if (exLitLen == 255)
goto readExLiteralLength;
phase = DecodePhase.CopyLiteral;
@ -196,13 +192,13 @@ namespace Lz4
copyLiteral:
int nReadLit = litLen < nToRead ? litLen : nToRead;
if( nReadLit != 0 )
if (nReadLit != 0)
{
if( inBufPos + nReadLit <= inBufEnd )
if (inBufPos + nReadLit <= inBufEnd)
{
int ofs = offset;
for( int c = nReadLit; c-- != 0; )
for (int c = nReadLit; c-- != 0;)
buffer[ofs++] = decBuf[inBufPos++];
nRead = nReadLit;
@ -212,13 +208,13 @@ namespace Lz4
#if LOCAL_SHADOW
this.inBufPos = inBufPos;
#endif
nRead = ReadCore( buffer, offset, nReadLit );
nRead = ReadCore(buffer, offset, nReadLit);
#if LOCAL_SHADOW
inBufPos = this.inBufPos;
inBufEnd = this.inBufEnd;
#endif
#if CHECK_EOF
if( nRead == 0 )
if (nRead == 0)
goto finish;
#endif
}
@ -228,18 +224,18 @@ namespace Lz4
litLen -= nRead;
if( litLen != 0 )
if (litLen != 0)
goto copyLiteral;
}
if( nToRead == 0 )
if (nToRead == 0)
goto finish;
phase = DecodePhase.ReadOffset;
goto readOffset;
readOffset:
if( inBufPos + 1 < inBufEnd )
if (inBufPos + 1 < inBufEnd)
{
matDst = (decBuf[inBufPos + 1] << 8) | decBuf[inBufPos];
inBufPos += 2;
@ -255,12 +251,12 @@ namespace Lz4
inBufEnd = this.inBufEnd;
#endif
#if CHECK_EOF
if( matDst == -1 )
if (matDst == -1)
goto finish;
#endif
}
if( matLen == 15 + 4 )
if (matLen == 15 + 4)
{
phase = DecodePhase.ReadExMatchLength;
goto readExMatchLength;
@ -273,7 +269,7 @@ namespace Lz4
readExMatchLength:
int exMatLen;
if( inBufPos < inBufEnd )
if (inBufPos < inBufEnd)
{
exMatLen = decBuf[inBufPos++];
}
@ -288,13 +284,13 @@ namespace Lz4
inBufEnd = this.inBufEnd;
#endif
#if CHECK_EOF
if( exMatLen == -1 )
if (exMatLen == -1)
goto finish;
#endif
}
matLen += exMatLen;
if( exMatLen == 255 )
if (exMatLen == 255)
goto readExMatchLength;
phase = DecodePhase.CopyMatch;
@ -302,21 +298,21 @@ namespace Lz4
copyMatch:
int nCpyMat = matLen < nToRead ? matLen : nToRead;
if( nCpyMat != 0 )
if (nCpyMat != 0)
{
nRead = count - nToRead;
int bufDst = matDst - nRead;
if( bufDst > 0 )
if (bufDst > 0)
{
//offset is fairly far back, we need to pull from the buffer
int bufSrc = decodeBufferPos - bufDst;
if( bufSrc < 0 )
if (bufSrc < 0)
bufSrc += DecBufLen;
int bufCnt = bufDst < nCpyMat ? bufDst : nCpyMat;
for( int c = bufCnt; c-- != 0; )
for (int c = bufCnt; c-- != 0;)
buffer[offset++] = decBuf[bufSrc++ & DecBufMask];
}
else
@ -325,14 +321,14 @@ namespace Lz4
}
int sOfs = offset - matDst;
for( int i = bufDst; i < nCpyMat; i++ )
for (int i = bufDst; i < nCpyMat; i++)
buffer[offset++] = buffer[sOfs++];
nToRead -= nCpyMat;
matLen -= nCpyMat;
}
if( nToRead == 0 )
if (nToRead == 0)
goto finish;
phase = DecodePhase.ReadToken;
@ -344,16 +340,16 @@ namespace Lz4
int nToBuf = nRead < DecBufLen ? nRead : DecBufLen;
int repPos = offset - nToBuf;
if( nToBuf == DecBufLen )
if (nToBuf == DecBufLen)
{
Buffer.BlockCopy( buffer, repPos, decBuf, 0, DecBufLen );
Buffer.BlockCopy(buffer, repPos, decBuf, 0, DecBufLen);
decodeBufferPos = 0;
}
else
{
int decPos = decodeBufferPos;
while( nToBuf-- != 0 )
while (nToBuf-- != 0)
decBuf[decPos++ & DecBufMask] = buffer[repPos++];
decodeBufferPos = decPos & DecBufMask;
@ -370,13 +366,13 @@ namespace Lz4
{
var buf = decodeBuffer;
if( inBufPos == inBufEnd )
if (inBufPos == inBufEnd)
{
int nRead = input.Read( buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength );
int nRead = input.Read(buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength);
#if CHECK_EOF
if( nRead == 0 )
if (nRead == 0)
return -1;
#endif
@ -393,13 +389,13 @@ namespace Lz4
{
var buf = decodeBuffer;
if( inBufPos == inBufEnd )
if (inBufPos == inBufEnd)
{
int nRead = input.Read( buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength );
int nRead = input.Read(buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength);
#if CHECK_EOF
if( nRead == 0 )
if (nRead == 0)
return -1;
#endif
@ -409,15 +405,15 @@ namespace Lz4
inBufEnd = DecBufLen + nRead;
}
if( inBufEnd - inBufPos == 1 )
if (inBufEnd - inBufPos == 1)
{
buf[DecBufLen] = buf[inBufPos];
int nRead = input.Read( buf, DecBufLen + 1,
InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength );
int nRead = input.Read(buf, DecBufLen + 1,
InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength);
#if CHECK_EOF
if( nRead == 0 )
if (nRead == 0)
{
inBufPos = DecBufLen;
inBufEnd = DecBufLen + 1;
@ -438,7 +434,7 @@ namespace Lz4
return ret;
}
private int ReadCore( byte[] buffer, int offset, int count )
private int ReadCore(byte[] buffer, int offset, int count)
{
int nToRead = count;
@ -446,31 +442,31 @@ namespace Lz4
int inBufLen = inBufEnd - inBufPos;
int fromBuf = nToRead < inBufLen ? nToRead : inBufLen;
if( fromBuf != 0 )
if (fromBuf != 0)
{
var bufPos = inBufPos;
for( int c = fromBuf; c-- != 0; )
for (int c = fromBuf; c-- != 0;)
buffer[offset++] = buf[bufPos++];
inBufPos = bufPos;
nToRead -= fromBuf;
}
if( nToRead != 0 )
if (nToRead != 0)
{
int nRead;
if( nToRead >= InBufLen )
if (nToRead >= InBufLen)
{
nRead = input.Read( buffer, offset,
nToRead < inputLength ? nToRead : (int)inputLength );
nRead = input.Read(buffer, offset,
nToRead < inputLength ? nToRead : (int)inputLength);
nToRead -= nRead;
}
else
{
nRead = input.Read( buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength );
nRead = input.Read(buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength);
inBufPos = DecBufLen;
inBufEnd = DecBufLen + nRead;
@ -479,7 +475,7 @@ namespace Lz4
var bufPos = inBufPos;
for( int c = fromBuf; c-- != 0; )
for (int c = fromBuf; c-- != 0;)
buffer[offset++] = buf[bufPos++];
inBufPos = bufPos;
@ -494,20 +490,11 @@ namespace Lz4
#region Stream internals
public override bool CanRead
{
get { return true; }
}
public override bool CanRead => true;
public override bool CanSeek
{
get { return false; }
}
public override bool CanSeek => false;
public override bool CanWrite
{
get { return false; }
}
public override bool CanWrite => false;
public override void Flush()
{
@ -524,17 +511,17 @@ namespace Lz4
set { throw new NotSupportedException(); }
}
public override long Seek( long offset, SeekOrigin origin )
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
public override void SetLength( long value )
public override void SetLength(long value)
{
throw new NotSupportedException();
}
public override void Write( byte[] buffer, int offset, int count )
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
}

View File

@ -1105,10 +1105,6 @@ namespace Unity_Studio
}
}
}
else
{
//bool stop = true;
}
}
MeshPD.uniqueID = keepID;
@ -1653,7 +1649,8 @@ namespace Unity_Studio
public static bool ExportAudioClip(AssetPreloadData asset, string exportFilename, string exportFileextension)
{
var oldextension = exportFileextension;
if ((bool)Properties.Settings.Default["convertfsb"] && exportFileextension == ".fsb")
var convertfsb = (bool)Properties.Settings.Default["convertfsb"];
if (convertfsb && exportFileextension == ".fsb")
{
exportFileextension = ".wav";
}
@ -1661,7 +1658,7 @@ namespace Unity_Studio
if (ExportFileExists(exportFullname))
return false;
var m_AudioClip = new AudioClip(asset, true);
if ((bool)Properties.Settings.Default["convertfsb"] && oldextension == ".fsb")
if (convertfsb && oldextension == ".fsb")
{
FMOD.System system;
FMOD.Sound sound;
@ -1769,10 +1766,10 @@ namespace Unity_Studio
{
count = 4;
}
var vertices = new ManagedFbx.Vector3[m_Mesh.m_VertexCount];
var vertices = new Vector3[m_Mesh.m_VertexCount];
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
{
vertices[v] = new ManagedFbx.Vector3(
vertices[v] = new Vector3(
m_Mesh.m_Vertices[v * count],
m_Mesh.m_Vertices[v * count + 1],
m_Mesh.m_Vertices[v * count + 2]);
@ -1801,10 +1798,10 @@ namespace Unity_Studio
count = 4;
}
var normals = new ManagedFbx.Vector3[m_Mesh.m_VertexCount];
var normals = new Vector3[m_Mesh.m_VertexCount];
for (int n = 0; n < m_Mesh.m_VertexCount; n++)
{
normals[n] = new ManagedFbx.Vector3(
normals[n] = new Vector3(
m_Mesh.m_Normals[n * count],
m_Mesh.m_Normals[n * count + 1],
m_Mesh.m_Normals[n * count + 2]);
@ -1815,20 +1812,20 @@ namespace Unity_Studio
#region Colors
if (m_Mesh.m_Colors == null)
{
var colors = new ManagedFbx.Colour[m_Mesh.m_VertexCount];
var colors = new Colour[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
colors[c] = new ManagedFbx.Colour(
colors[c] = new Colour(
0.5f, 0.5f, 0.5f, 1.0f);
}
mesh.VertexColours = colors;
}
else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3)
{
var colors = new ManagedFbx.Colour[m_Mesh.m_VertexCount];
var colors = new Colour[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
colors[c] = new ManagedFbx.Colour(
colors[c] = new Colour(
m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2],
@ -1838,10 +1835,10 @@ namespace Unity_Studio
}
else
{
var colors = new ManagedFbx.Colour[m_Mesh.m_VertexCount];
var colors = new Colour[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
colors[c] = new ManagedFbx.Colour(
colors[c] = new Colour(
m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2],
@ -1853,19 +1850,19 @@ namespace Unity_Studio
#region UV
if (m_Mesh.m_UV1 != null && m_Mesh.m_UV1.Length == m_Mesh.m_VertexCount * 2)
{
var uv = new ManagedFbx.Vector2[m_Mesh.m_VertexCount];
var uv = new Vector2[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
uv[c] = new ManagedFbx.Vector2(m_Mesh.m_UV1[c * 2], m_Mesh.m_UV1[c * 2 + 1]);
uv[c] = new Vector2(m_Mesh.m_UV1[c * 2], m_Mesh.m_UV1[c * 2 + 1]);
}
mesh.TextureCoords = uv;
}
else if (m_Mesh.m_UV2 != null && m_Mesh.m_UV2.Length == m_Mesh.m_VertexCount * 2)
{
var uv = new ManagedFbx.Vector2[m_Mesh.m_VertexCount];
var uv = new Vector2[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
uv[c] = new ManagedFbx.Vector2(m_Mesh.m_UV2[c * 2], m_Mesh.m_UV2[c * 2 + 1]);
uv[c] = new Vector2(m_Mesh.m_UV2[c * 2], m_Mesh.m_UV2[c * 2 + 1]);
}
mesh.TextureCoords = uv;
}

View File

@ -49,9 +49,9 @@ namespace Unity_Studio
int vboColors;
int vboViewMatrix;
int eboElements;
OpenTK.Vector3[] vertexData;
OpenTK.Vector3[] normalData;
OpenTK.Vector4[] colorData;
Vector3[] vertexData;
Vector3[] normalData;
Vector4[] colorData;
Matrix4[] viewMatrixData;
int[] indiceData;
bool wireFrameView;
@ -73,7 +73,7 @@ namespace Unity_Studio
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
private void loadFile_Click(object sender, System.EventArgs e)
private void loadFile_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
@ -118,7 +118,7 @@ namespace Unity_Studio
}
}
private void loadFolder_Click(object sender, System.EventArgs e)
private void loadFolder_Click(object sender, EventArgs e)
{
/*FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
@ -274,11 +274,11 @@ namespace Unity_Studio
{
if (productName != "")
{
this.Text = "Unity Studio - " + productName + " - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
Text = "Unity Studio - " + productName + " - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
}
else if (assetsfileList.Count > 0)
{
this.Text = "Unity Studio - no productName - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
Text = "Unity Studio - no productName - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
}
if (!dontLoadAssetsMenuItem.Checked)
{
@ -596,7 +596,7 @@ namespace Unity_Studio
if (treeSearch.Text == " Search ")
{
treeSearch.Text = "";
treeSearch.ForeColor = System.Drawing.SystemColors.WindowText;
treeSearch.ForeColor = SystemColors.WindowText;
}
}
@ -605,7 +605,7 @@ namespace Unity_Studio
if (treeSearch.Text == "")
{
treeSearch.Text = " Search ";
treeSearch.ForeColor = System.Drawing.SystemColors.GrayText;
treeSearch.ForeColor = SystemColors.GrayText;
}
}
@ -694,7 +694,7 @@ namespace Unity_Studio
if (listSearch.Text == " Filter ")
{
listSearch.Text = "";
listSearch.ForeColor = System.Drawing.SystemColors.WindowText;
listSearch.ForeColor = SystemColors.WindowText;
enableFiltering = true;
}
}
@ -705,7 +705,7 @@ namespace Unity_Studio
{
enableFiltering = false;
listSearch.Text = " Filter ";
listSearch.ForeColor = System.Drawing.SystemColors.GrayText;
listSearch.ForeColor = SystemColors.GrayText;
}
}
@ -716,7 +716,7 @@ namespace Unity_Studio
assetListView.BeginUpdate();
assetListView.SelectedIndices.Clear();
//visibleListAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.StartsWith(ListSearch.Text, System.StringComparison.CurrentCultureIgnoreCase));
visibleAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.IndexOf(listSearch.Text, System.StringComparison.CurrentCultureIgnoreCase) >= 0);
visibleAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.IndexOf(listSearch.Text, StringComparison.CurrentCultureIgnoreCase) >= 0);
assetListView.VirtualListSize = visibleAssets.Count;
assetListView.EndUpdate();
}
@ -742,7 +742,7 @@ namespace Unity_Studio
{
int xdiff = reverseSort ? b.Text.CompareTo(a.Text) : a.Text.CompareTo(b.Text);
if (xdiff != 0) return xdiff;
else return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Size.CompareTo(b.Size);
return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Size.CompareTo(b.Size);
});
break;
case 1:
@ -750,7 +750,7 @@ namespace Unity_Studio
{
int xdiff = reverseSort ? b.TypeString.CompareTo(a.TypeString) : a.TypeString.CompareTo(b.TypeString);
if (xdiff != 0) return xdiff;
else return secondSortColumn == 2 ? a.Size.CompareTo(b.Size) : a.Text.CompareTo(b.Text);
return secondSortColumn == 2 ? a.Size.CompareTo(b.Size) : a.Text.CompareTo(b.Text);
});
break;
case 2:
@ -758,7 +758,7 @@ namespace Unity_Studio
{
int xdiff = reverseSort ? b.Size.CompareTo(a.Size) : a.Size.CompareTo(b.Size);
if (xdiff != 0) return xdiff;
else return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Text.CompareTo(b.Text);
return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Text.CompareTo(b.Text);
});
break;
}
@ -771,7 +771,7 @@ namespace Unity_Studio
private void selectAsset(object sender, ListViewItemSelectionChangedEventArgs e)
{
previewPanel.BackgroundImage = Properties.Resources.preview;
previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
previewPanel.BackgroundImageLayout = ImageLayout.Center;
assetInfoLabel.Visible = false;
assetInfoLabel.Text = null;
textPreviewBox.Visible = false;
@ -975,10 +975,10 @@ namespace Unity_Studio
{
count = 4;
}
vertexData = new OpenTK.Vector3[m_Mesh.m_VertexCount];
vertexData = new Vector3[m_Mesh.m_VertexCount];
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
{
vertexData[v] = new OpenTK.Vector3(
vertexData[v] = new Vector3(
m_Mesh.m_Vertices[v * count],
m_Mesh.m_Vertices[v * count + 1],
m_Mesh.m_Vertices[v * count + 2]);
@ -1005,10 +1005,10 @@ namespace Unity_Studio
count = 4;
}
normalData = new OpenTK.Vector3[m_Mesh.m_VertexCount];
normalData = new Vector3[m_Mesh.m_VertexCount];
for (int n = 0; n < m_Mesh.m_VertexCount; n++)
{
normalData[n] = new OpenTK.Vector3(
normalData[n] = new Vector3(
m_Mesh.m_Normals[n * count],
m_Mesh.m_Normals[n * count + 1],
m_Mesh.m_Normals[n * count + 2]);
@ -1018,19 +1018,19 @@ namespace Unity_Studio
#region Colors
if (m_Mesh.m_Colors == null)
{
colorData = new OpenTK.Vector4[m_Mesh.m_VertexCount];
colorData = new Vector4[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
colorData[c] = new OpenTK.Vector4(
colorData[c] = new Vector4(
0.5f, 0.5f, 0.5f, 1.0f);
}
}
else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3)
{
colorData = new OpenTK.Vector4[m_Mesh.m_VertexCount];
colorData = new Vector4[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
colorData[c] = new OpenTK.Vector4(
colorData[c] = new Vector4(
m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2],
@ -1039,10 +1039,10 @@ namespace Unity_Studio
}
else
{
colorData = new OpenTK.Vector4[m_Mesh.m_VertexCount];
colorData = new Vector4[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{
colorData[c] = new OpenTK.Vector4(
colorData[c] = new Vector4(
m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2],
@ -1375,7 +1375,7 @@ namespace Unity_Studio
//Environment.Exit(-1);
return true;
}
else { return false; }
return false;
}
private void all3DObjectssplitToolStripMenuItem_Click(object sender, EventArgs e)
@ -1734,24 +1734,24 @@ namespace Unity_Studio
GL.DeleteShader(address);
}
private void createVBO(out int vboAddress, OpenTK.Vector3[] data, int address)
private void createVBO(out int vboAddress, Vector3[] data, int address)
{
GL.GenBuffers(1, out vboAddress);
GL.BindBuffer(BufferTarget.ArrayBuffer, vboAddress);
GL.BufferData<OpenTK.Vector3>(BufferTarget.ArrayBuffer,
(IntPtr)(data.Length * OpenTK.Vector3.SizeInBytes),
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
(IntPtr)(data.Length * Vector3.SizeInBytes),
data,
BufferUsageHint.StaticDraw);
GL.VertexAttribPointer(address, 3, VertexAttribPointerType.Float, false, 0, 0);
GL.EnableVertexAttribArray(address);
}
private void createVBO(out int vboAddress, OpenTK.Vector4[] data, int address)
private void createVBO(out int vboAddress, Vector4[] data, int address)
{
GL.GenBuffers(1, out vboAddress);
GL.BindBuffer(BufferTarget.ArrayBuffer, vboAddress);
GL.BufferData<OpenTK.Vector4>(BufferTarget.ArrayBuffer,
(IntPtr)(data.Length * OpenTK.Vector4.SizeInBytes),
GL.BufferData<Vector4>(BufferTarget.ArrayBuffer,
(IntPtr)(data.Length * Vector4.SizeInBytes),
data,
BufferUsageHint.StaticDraw);
GL.VertexAttribPointer(address, 4, VertexAttribPointerType.Float, false, 0, 0);
@ -1823,7 +1823,7 @@ namespace Unity_Studio
Properties.Settings.Default["displayInfo"] = displayAssetInfoMenuItem.Checked;
Properties.Settings.Default.Save();*/
base.Text = "Unity Studio";
Text = "Unity Studio";
unityFiles.Clear();
assetsfileList.Clear();
@ -1841,7 +1841,7 @@ namespace Unity_Studio
classesListView.Groups.Clear();
previewPanel.BackgroundImage = Properties.Resources.preview;
previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
previewPanel.BackgroundImageLayout = ImageLayout.Center;
assetInfoLabel.Visible = false;
assetInfoLabel.Text = null;
textPreviewBox.Visible = false;

View File

@ -1,56 +0,0 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7-Zip Copyright (C) 1999-2015 Igor Pavlov.
Licenses for files are:
1) 7z.dll: GNU LGPL + unRAR restriction
2) All other files: GNU LGPL
The GNU LGPL + unRAR restriction means that you must follow both
GNU LGPL rules and unRAR restriction rules.
Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
unRAR restriction
-----------------
The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.
The license for original unRAR code has the following restriction:
The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.
--
Igor Pavlov