Пример #1
0
    public string fetchAppVersion()
    {
        string appVersion = "";

        try
        {
            AssetsFile assetsFile = new AssetsFile(finder.location + "/resources.assets", new EndianStream(File.OpenRead(finder.location + "/resources.assets"), EndianType.BigEndian));

            foreach (var asset in assetsFile.preloadTable.Values)
            {
                if (asset.Type2 == 49) //TextAsset
                {
                    Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
                    if (asset.Text.Equals("_version"))
                    {
                        m_TextAsset = new Unity_Studio.TextAsset(asset, true);
                        appVersion  = System.Text.Encoding.UTF8.GetString(m_TextAsset.m_Script);
                    }
                }
            }

            if (appVersion.IndexOf("#") != -1)
            {
                appVersion = appVersion.Substring(0, appVersion.IndexOf("#"));
            }
        }
        catch (System.Exception) { }

        return(appVersion);
    }
Пример #2
0
    // Save text to file
    private void ExportText(Unity_Studio.AssetPreloadData asset)
    {
        Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
        Directory.CreateDirectory(ContentData.ContentPath());
        Directory.CreateDirectory(ContentData.ContentPath() + gameType);
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg");
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg/text");
        string fileCandidate = ContentData.ContentPath() + gameType + "/ffg/text/" + asset.Text;
        string fileName      = fileCandidate + asset.extension;

        m_TextAsset = new Unity_Studio.TextAsset(asset, true);
        // This should apend a postfix to the name to avoid collisions, but as we import multiple times
        // This is broken
        while (File.Exists(fileName))
        {
            return;// Fixme;
        }

        // Write to disk
        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            // Pass the Deobfuscate key to decrypt
            writer.Write(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            writer.Close();
        }

        // Run monster data extration tool if in dev
        if (Application.isEditor && asset.Text.Equals("Localization"))
        {
            if (finder is MoMFinder)
            {
                ExtractDataTool.MoM(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            }
        }
    }
Пример #3
0
        // Determine FFG app version
        public string FetchAppVersion()
        {
            string appVersion = "";

            try
            {
                if (importData.platform == Platform.Android)
                {
                    return(finder.ExtractObbVersion());
                }
                string resourcesAssets = Path.Combine(finder.location, "resources.assets");
                if (!File.Exists(resourcesAssets))
                {
                    ValkyrieDebug.Log("Could not find main assets file: " + resourcesAssets);
                    return(appVersion);
                }

                // We assume that the version asset is in resources.assets
                using (var fs = File.OpenRead(resourcesAssets))
                {
                    using (var endianStream = new EndianStream(fs, EndianType.BigEndian))
                    {
                        var assetsFile = new AssetsFile(resourcesAssets, endianStream);

                        // Look through all listed assets
                        foreach (var asset in assetsFile.preloadTable.Values)
                        {
                            // Check all text assets
                            if (asset.Type2 != 49) //TextAsset
                            {
                                continue;
                            }
                            // Load as text
                            var textAsset = new Unity_Studio.TextAsset(asset, false);
                            // Check if called _version
                            if (asset.Text.Equals("_version"))
                            {
                                // Read asset content
                                textAsset = new Unity_Studio.TextAsset(asset, true);
                                // Extract version
                                appVersion = System.Text.Encoding.UTF8.GetString(textAsset.m_Script);
                                break;
                            }
                        }
                    }
                }

                // Trim content from #
                if (appVersion.IndexOf("#") != -1)
                {
                    appVersion = appVersion.Substring(0, appVersion.IndexOf("#"));
                }
            }
            catch (Exception ex)
            {
                ValkyrieDebug.Log("fetchAppVersion caused " + ex.GetType().Name + ": " + ex.Message + " " + ex.StackTrace);
            }

            return(appVersion);
        }
Пример #4
0
    private void ExportText(Unity_Studio.AssetPreloadData asset)
    {
        Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
        Directory.CreateDirectory(ContentData.ContentPath());
        Directory.CreateDirectory(ContentData.ContentPath() + gameType);
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg");
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg/text");
        string fileCandidate = ContentData.ContentPath() + gameType + "/ffg/text/" + asset.Text;
        string fileName      = fileCandidate + asset.extension;

        m_TextAsset = new Unity_Studio.TextAsset(asset, true);
        while (File.Exists(fileName))
        {
            return;// Fixme;
        }

        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            writer.Write(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            writer.Close();
        }

        // Run monster data extration tool if in dev
        if (Application.isEditor && asset.Text.Equals("Localization"))
        {
            if (finder is MoMFinder)
            {
                ExtractDataTool.MoM(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            }
        }
    }
Пример #5
0
        // Save text to file
        private void ExportText(Unity_Studio.AssetPreloadData asset)
        {
            Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
            Directory.CreateDirectory(contentPath);
            Directory.CreateDirectory(contentPath + "/text");
            string fileCandidate = contentPath + "/text/" + asset.Text;
            string fileName      = fileCandidate + asset.extension;

            m_TextAsset = new Unity_Studio.TextAsset(asset, true);
            // This should apend a postfix to the name to avoid collisions, but as we import multiple times
            // This is broken
            while (File.Exists(fileName))
            {
                return;// Fixme;
            }

            // Write to disk
            using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
            {
                // Pass the Deobfuscate key to decrypt
                writer.Write(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
                writer.Close();
            }

            // Need to trim new lines from old D2E format
            if (asset.Text.Equals("Localization"))
            {
                string[]      locFix      = File.ReadAllLines(fileName);
                List <string> locOut      = new List <string>();
                string        currentLine = "";
                for (int i = 0; i < locFix.Length; i++)
                {
                    if (locFix[i].Split('\"').Length % 2 == 0)
                    {
                        if (currentLine.Length == 0)
                        {
                            currentLine = locFix[i];
                        }
                        else
                        {
                            locOut.Add(currentLine + "\\n" + locFix[i]);
                            currentLine = "";
                        }
                    }
                    else
                    {
                        if (currentLine.Length == 0)
                        {
                            locOut.Add(locFix[i]);
                        }
                        else
                        {
                            currentLine += "\\n" + locFix[i];
                        }
                    }
                }
                File.WriteAllLines(fileName, locOut.ToArray());
            }
        }
Пример #6
0
        // Save text to file
        private void ExportText(Unity_Studio.AssetPreloadData asset)
        {
            if (asset == null)
            {
                throw new ArgumentNullException("asset");
            }
            var    textAsset = new Unity_Studio.TextAsset(asset, false);
            string textPath  = Path.Combine(contentPath, "text");

            Directory.CreateDirectory(textPath);
            string fileCandidate = Path.Combine(textPath, asset.Text);

            textAsset = new Unity_Studio.TextAsset(asset, true);

            // This should apends a postfix to the name to avoid collisions
            string fileName = GetAvailableFileName(fileCandidate, asset.extension);

            // Write to disk, pass the Deobfuscate key to decrypt
            File.WriteAllBytes(fileName, textAsset.Deobfuscate(finder.ObfuscateKey()));

            // Need to trim new lines from old D2E format
            if (asset.Text.Equals("Localization"))
            {
                string[] locFix      = File.ReadAllLines(fileName);
                var      locOut      = new List <string>();
                string   currentLine = "";
                for (int i = 0; i < locFix.Length; i++)
                {
                    if (locFix[i].Split('\"').Length % 2 == 0)
                    {
                        if (currentLine.Length == 0)
                        {
                            currentLine = locFix[i];
                        }
                        else
                        {
                            locOut.Add(currentLine + "\\n" + locFix[i]);
                            currentLine = "";
                        }
                    }
                    else
                    {
                        if (currentLine.Length == 0)
                        {
                            locOut.Add(locFix[i]);
                        }
                        else
                        {
                            currentLine += "\\n" + locFix[i];
                        }
                    }
                }
                File.WriteAllLines(fileName, locOut.ToArray());
            }
        }
Пример #7
0
        // Determine FFG app version
        public string fetchAppVersion()
        {
            string appVersion = "";

            if (!File.Exists(finder.location + "/resources.assets"))
            {
                ValkyrieDebug.Log("Could not find main assets file: " + finder.location + "/resources.assets");
            }
            try
            {
                // We assume that the version asset is in resources.assets
                AssetsFile assetsFile = new AssetsFile(finder.location + "/resources.assets", new EndianStream(File.OpenRead(finder.location + "/resources.assets"), EndianType.BigEndian));

                // Look through all listed assets
                foreach (var asset in assetsFile.preloadTable.Values)
                {
                    // Check all text assets
                    if (asset.Type2 == 49) //TextAsset
                    {
                        // Load as text
                        Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
                        // Check if called _version
                        if (asset.Text.Equals("_version"))
                        {
                            // Read asset content
                            m_TextAsset = new Unity_Studio.TextAsset(asset, true);
                            // Extract version
                            appVersion = System.Text.Encoding.UTF8.GetString(m_TextAsset.m_Script);
                        }
                    }
                }

                // Trim content from #
                if (appVersion.IndexOf("#") != -1)
                {
                    appVersion = appVersion.Substring(0, appVersion.IndexOf("#"));
                }
            }
            catch (System.Exception) { }

            return(appVersion);
        }
Пример #8
0
    private void ExportText(Unity_Studio.AssetPreloadData asset)
    {
        Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
        Directory.CreateDirectory(ContentData.ContentPath());
        Directory.CreateDirectory(ContentData.ContentPath() + gameType);
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg");
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg/text");
        string fileCandidate = ContentData.ContentPath() + gameType + "/ffg/text/" + asset.Text;
        string fileName      = fileCandidate + asset.extension;

        m_TextAsset = new Unity_Studio.TextAsset(asset, true);
        while (File.Exists(fileName))
        {
            return;// Fixme;
        }

        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            writer.Write(m_TextAsset.m_Script);
            writer.Close();
        }
    }
Пример #9
0
        private void BuildAssetStrucutres()
        {
            #region first loop - read asset data & create list
            if (!dontLoadAssetsMenuItem.Checked)
            {
                assetListView.BeginUpdate();
                progressBar1.Value = 0;
                progressBar1.Maximum = totalAssetCount;

                string fileIDfmt = "D" + assetsfileList.Count.ToString().Length.ToString();

                foreach (var assetsFile in assetsfileList)
                {
                    StatusStripUpdate("Building asset list from " + Path.GetFileName(assetsFile.filePath));

                    var a_Stream = assetsFile.a_Stream;
                    var fileGen = assetsFile.fileGen;
                    //var m_version = assetsFile.m_version;
                    var version = assetsFile.version;
                    string fileID = assetsfileList.IndexOf(assetsFile).ToString(fileIDfmt);

                    //ListViewGroup assetGroup = new ListViewGroup(Path.GetFileName(assetsFile.filePath));


                    foreach (var asset in assetsFile.preloadTable.Values)
                    {
                        asset.uniqueID = fileID + asset.uniqueID;
                        a_Stream.Position = asset.Offset;

                        switch (asset.Type2)
                        {
                            case 1: //GameObject
                                {
                                    GameObject m_GameObject = new GameObject(asset);
                                    assetsFile.GameObjectList.Add(asset.m_PathID, m_GameObject);
                                    totalTreeNodes++;
                                    break;
                                }
                            case 4: //Transform
                                {
                                    Transform m_Transform = new Transform(asset);
                                    assetsFile.TransformList.Add(asset.m_PathID, m_Transform);
                                    break;
                                }
                            case 224: //RectTransform
                                {
                                    RectTransform m_Rect = new RectTransform(asset);
                                    assetsFile.TransformList.Add(asset.m_PathID, m_Rect.m_Transform);
                                    break;
                                }
                            //case 21: //Material
                            case 28: //Texture2D
                                {
                                    Texture2D m_Texture2D = new Texture2D(asset, false);

                                    asset.Text = m_Texture2D.m_Name;
                                    asset.exportSize = 128 + m_Texture2D.image_data_size;

                                    #region Get Info Text
                                    asset.InfoText = "Width: " + m_Texture2D.m_Width.ToString() + "\nHeight: " + m_Texture2D.m_Height.ToString() + "\nFormat: ";

                                    switch (m_Texture2D.m_TextureFormat)
                                    {
                                        case 1: asset.InfoText += "Alpha8"; break;
                                        case 2: asset.InfoText += "ARGB 4.4.4.4"; break;
                                        case 3: asset.InfoText += "BGR 8.8.8"; break;
                                        case 4: asset.InfoText += "GRAB 8.8.8.8"; break;
                                        case 5: asset.InfoText += "BGRA 8.8.8.8"; break;
                                        case 7: asset.InfoText += "RGB 5.6.5"; break;
                                        case 10: asset.InfoText += "RGB DXT1"; break;
                                        case 12: asset.InfoText += "ARGB DXT5"; break;
                                        case 13: asset.InfoText += "RGBA 4.4.4.4"; break;
                                        case 30: asset.InfoText += "PVRTC_RGB2"; asset.exportSize -= 76; break;
                                        case 31: asset.InfoText += "PVRTC_RGBA2"; asset.exportSize -= 76; break;
                                        case 32: asset.InfoText += "PVRTC_RGB4"; asset.exportSize = 52; break;
                                        case 33: asset.InfoText += "PVRTC_RGBA4"; asset.exportSize -= 76; break;
                                        case 34: asset.InfoText += "ETC_RGB4"; asset.exportSize -= 76; break;
                                        default: asset.InfoText += "unknown"; asset.exportSize -= 128; break;
                                    }

                                    switch (m_Texture2D.m_FilterMode)
                                    {
                                        case 0: asset.InfoText += "\nFilter Mode: Point "; break;
                                        case 1: asset.InfoText += "\nFilter Mode: Bilinear "; break;
                                        case 2: asset.InfoText += "\nFilter Mode: Trilinear "; break;

                                    }

                                    asset.InfoText += "\nAnisotropic level: " + m_Texture2D.m_Aniso.ToString() + "\nMip map bias: " + m_Texture2D.m_MipBias.ToString();

                                    switch (m_Texture2D.m_WrapMode)
                                    {
                                        case 0: asset.InfoText += "\nWrap mode: Repeat"; break;
                                        case 1: asset.InfoText += "\nWrap mode: Clamp"; break;
                                    }
                                    #endregion

                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 49: //TextAsset
                                {
                                    TextAsset m_TextAsset = new TextAsset(asset, false);

                                    asset.Text = m_TextAsset.m_Name;
                                    asset.exportSize = m_TextAsset.exportSize;
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 83: //AudioClip
                                {
                                    AudioClip m_AudioClip = new AudioClip(asset, false);

                                    asset.Text = m_AudioClip.m_Name;
                                    asset.exportSize = (int)m_AudioClip.m_Size;
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 48: //Shader
                            case 89: //CubeMap
                            case 128: //Font
                                {
                                    asset.Text = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 129: //PlayerSettings
                                {
                                    PlayerSettings plSet = new PlayerSettings(asset);
                                    productName = plSet.productName;
                                    base.Text = "Unity Studio - " + productName + " - " + assetsFile.m_Version + " - " + assetsFile.platformStr;
                                    break;
                                }

                        }

                        if (asset.Text == "") { asset.Text = asset.TypeString + " #" + asset.uniqueID; }
                        asset.SubItems.AddRange(new string[] { asset.TypeString, asset.exportSize.ToString() });

                        progressBar1.PerformStep();
                    }

                    exportableAssets.AddRange(assetsFile.exportableAssets);
                    //if (assetGroup.Items.Count > 0) { listView1.Groups.Add(assetGroup); }
                }

                if (base.Text == "Unity Studio" && assetsfileList.Count > 0)
                {
                    base.Text = "Unity Studio - no productName - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
                }

                visibleAssets = exportableAssets;
                assetListView.VirtualListSize = visibleAssets.Count;

                //will only work if ListView is visible
                resizeAssetListColumns();

                assetListView.EndUpdate();
                progressBar1.Value = 0;
            }
            #endregion

            #region second loop - build tree structure
            if (!dontBuildHierarchyMenuItem.Checked)
            {
                sceneTreeView.BeginUpdate();
                progressBar1.Value = 0;
                progressBar1.Maximum = totalTreeNodes;

                foreach (var assetsFile in assetsfileList)
                {
                    StatusStripUpdate("Building tree structure from " + Path.GetFileName(assetsFile.filePath));
                    GameObject fileNode = new GameObject(null);
                    fileNode.Text = Path.GetFileName(assetsFile.filePath);
                    fileNode.m_Name = "RootNode";

                    foreach (var m_GameObject in assetsFile.GameObjectList.Values)
                    {
                        var parentNode = fileNode;

                        Transform m_Transform;
                        if (assetsfileList.TryGetTransform(m_GameObject.m_Transform, out m_Transform))
                        {
                            Transform m_Father;
                            if (assetsfileList.TryGetTransform(m_Transform.m_Father, out m_Father))
                            {
                                //GameObject Parent;
                                if (assetsfileList.TryGetGameObject(m_Father.m_GameObject, out parentNode))
                                {
                                    //parentNode = Parent;
                                }
                            }
                        }

                        parentNode.Nodes.Add(m_GameObject);
                        progressBar1.PerformStep();
                    }


                    if (fileNode.Nodes.Count == 0) { fileNode.Text += " (no children)"; }
                    sceneTreeView.Nodes.Add(fileNode);
                }
                sceneTreeView.EndUpdate();
                progressBar1.Value = 0;

                if (File.Exists(mainPath + "\\materials.json"))
                {
                    string matLine = "";
                    using (StreamReader reader = File.OpenText(mainPath + "\\materials.json"))
                    { matLine = reader.ReadToEnd(); }

                    jsonMats = new JavaScriptSerializer().Deserialize<Dictionary<string, Dictionary<string, string>>>(matLine);
                    //var jsonMats = new JavaScriptSerializer().DeserializeObject(matLine);
                }
            }
            #endregion

            #region build list of class strucutres
            if (buildClassStructuresMenuItem.Checked)
            {
                //group class structures by versionv
                foreach (var assetsFile in assetsfileList)
                {
                    SortedDictionary<int, ClassStrStruct> curVer;
                    if (AllClassStructures.TryGetValue(assetsFile.m_Version, out curVer))
                    {
                        foreach (var uClass in assetsFile.ClassStructures)
                        {
                            curVer[uClass.Key] = uClass.Value;
                        }
                    }
                    else { AllClassStructures.Add(assetsFile.m_Version, assetsFile.ClassStructures); }
                }

                classesListView.BeginUpdate();
                foreach (var version in AllClassStructures)
                {
                    ListViewGroup versionGroup = new ListViewGroup(version.Key);
                    classesListView.Groups.Add(versionGroup);

                    foreach (var uclass in version.Value)
                    {
                        uclass.Value.Group = versionGroup;
                        classesListView.Items.Add(uclass.Value);
                    }
                }
                classesListView.EndUpdate();
            }
            #endregion

            StatusStripUpdate("Finished loading " + assetsfileList.Count.ToString() + " files with " + (assetListView.Items.Count + sceneTreeView.Nodes.Count).ToString() + " exportable assets.");
            
            progressBar1.Value = 0;
            treeSearch.Select();
            TexEnv dsd = new TexEnv();
        }
Пример #10
0
        private int ExportAsset(AssetPreloadData asset, string exportPath)
        {
            int exportCount = 0;
            
            switch (asset.Type2)
            {
                #region Texture2D
                case 28: //Texture2D
                    {
                        Texture2D m_Texture2D = new Texture2D(asset, true);
                        
                        string texPath = exportPath + "\\" + asset.Text;
                        if (uniqueNames.Checked) { texPath += " #" + asset.uniqueID; }
                        if (m_Texture2D.m_TextureFormat < 30) { texPath += ".dds"; }
                        else if (m_Texture2D.m_TextureFormat < 35) { texPath += ".pvr"; }
                        else { texPath += "_" + m_Texture2D.m_Width.ToString() + "x" + m_Texture2D.m_Height.ToString() + "." + m_Texture2D.m_TextureFormat.ToString() + ".tex"; }

                        if (File.Exists(texPath))
                        {
                            StatusStripUpdate("Texture file " + Path.GetFileName(texPath) + " already exists");
                        }
                        else
                        {
                            StatusStripUpdate("Exporting Texture2D: " + Path.GetFileName(texPath));
                            exportCount += 1;

                            switch (m_Texture2D.m_TextureFormat)
                            {
                                case 1: //Alpha8
                                case 2: //A4R4G4B4
                                case 3: //B8G8R8 //confirmed on X360, iOS //PS3 unsure
                                case 4: //G8R8A8B8 //confirmed on X360, iOS
                                case 5: //B8G8R8A8 //confirmed on X360, PS3, Web, iOS
                                case 7: //R5G6B5 //confirmed switched on X360; confirmed on iOS
                                case 10: //DXT1
                                case 12: //DXT5
                                case 13: //R4G4B4A4, iOS (only?)
                                    WriteDDS(texPath, m_Texture2D);
                                    break;
                                case 30: //PVRTC_RGB2
                                case 31: //PVRTC_RGBA2
                                case 32: //PVRTC_RGB4
                                case 33: //PVRTC_RGBA4
                                case 34: //ETC_RGB4
                                    WritePVR(texPath, m_Texture2D);
                                    break;
                                default:
                                    {
                                        using (BinaryWriter writer = new BinaryWriter(File.Open(texPath, FileMode.Create)))
                                        {
                                            writer.Write(m_Texture2D.image_data);
                                            writer.Close();
                                        }
                                        break;
                                    }
                            }
                        }
                        break;
                    }
                #endregion
                #region AudioClip
                case 83: //AudioClip
                    {
                        AudioClip m_AudioClip = new AudioClip(asset, true);
                        
                        string audPath = exportPath + "\\" + asset.Text;
                        if (uniqueNames.Checked) { audPath += " #" + asset.uniqueID; }
                        audPath += m_AudioClip.extension;

                        if (File.Exists(audPath))
                        {
                            StatusStripUpdate("Audio file " + Path.GetFileName(audPath) + " already exists");
                        }
                        else
                        {
                            StatusStripUpdate("Exporting AudioClip: " + Path.GetFileName(audPath));
                            exportCount += 1;
                            
                            using (BinaryWriter writer = new BinaryWriter(File.Open(audPath, FileMode.Create)))
                            {
                                writer.Write(m_AudioClip.m_AudioData);
                                writer.Close();
                            }

                        }
                        break;
                    }
                #endregion
                #region Shader & TextAsset
                case 48: //Shader
                case 49: //TextAsset
                    {
                        TextAsset m_TextAsset = new TextAsset(asset, true);

                        string textAssetPath = exportPath + "\\" + asset.Text;
                        if (uniqueNames.Checked) { textAssetPath += " #" + asset.uniqueID; }
                        textAssetPath += m_TextAsset.extension;

                        if (File.Exists(textAssetPath))
                        {
                            StatusStripUpdate("TextAsset file " + Path.GetFileName(textAssetPath) + " already exists");
                        }
                        else
                        {
                            StatusStripUpdate("Exporting TextAsset: " + Path.GetFileName(textAssetPath));
                            exportCount += 1;

                            using (BinaryWriter writer = new BinaryWriter(File.Open(textAssetPath, FileMode.Create)))
                            {
                                writer.Write(m_TextAsset.m_Script);
                                writer.Close();
                            }
                        }
                        break;
                    }
                #endregion
                #region Font
                case 128: //Font
                    {
                        unityFont m_Font = new unityFont(asset);

                        if (m_Font.m_FontData != null)
                        {
                            string fontPath = exportPath + "\\" + asset.Text;
                            if (uniqueNames.Checked) { fontPath += " #" + asset.uniqueID; }
                            fontPath += m_Font.extension;

                            if (File.Exists(fontPath))
                            {
                                StatusStripUpdate("Font file " + Path.GetFileName(fontPath) + " already exists");
                            }
                            else
                            {
                                StatusStripUpdate("Exporting Font: " + Path.GetFileName(fontPath));

                                using (BinaryWriter writer = new BinaryWriter(File.Open(fontPath, FileMode.Create)))
                                {
                                    writer.Write(m_Font.m_FontData);
                                    writer.Close();
                                }

                                exportCount += 1;
                            }
                        }
                        break;
                    }
                #endregion
                /*default:
                    {
                        string assetPath = exportPath + "\\" + asset.Name + "." + asset.TypeString;
                        byte[] assetData = new byte[asset.Size];
                        Stream.Read(assetData, 0, asset.Size);
                        using (BinaryWriter writer = new BinaryWriter(File.Open(assetPath, FileMode.Create)))
                        {
                            writer.Write(assetData);
                            writer.Close();
                        }
                        exportCount += 1;
                        break;
                    }*/
            }
            return exportCount;
        }
Пример #11
0
        private void PreviewAsset(AssetPreloadData asset)
        {
            switch (asset.Type2)
            {
                #region Texture2D
                case 28: //Texture2D
                    {
                        Texture2D m_Texture2D = new Texture2D(asset, true);
                        
                        if (m_Texture2D.m_TextureFormat < 30)
                        {
                            byte[] imageBuffer = new byte[128 + m_Texture2D.image_data_size];

                            imageBuffer[0] = 0x44;
                            imageBuffer[1] = 0x44;
                            imageBuffer[2] = 0x53;
                            imageBuffer[3] = 0x20;
                            imageBuffer[4] = 0x7c;
                            
                            BitConverter.GetBytes(m_Texture2D.dwFlags).CopyTo(imageBuffer, 8);
                            BitConverter.GetBytes(m_Texture2D.m_Height).CopyTo(imageBuffer, 12);
                            BitConverter.GetBytes(m_Texture2D.m_Width).CopyTo(imageBuffer, 16);
                            BitConverter.GetBytes(m_Texture2D.dwPitchOrLinearSize).CopyTo(imageBuffer, 20);
                            BitConverter.GetBytes(m_Texture2D.dwMipMapCount).CopyTo(imageBuffer, 28);
                            BitConverter.GetBytes(m_Texture2D.dwSize).CopyTo(imageBuffer, 76);
                            BitConverter.GetBytes(m_Texture2D.dwFlags2).CopyTo(imageBuffer, 80);
                            BitConverter.GetBytes(m_Texture2D.dwFourCC).CopyTo(imageBuffer, 84);
                            BitConverter.GetBytes(m_Texture2D.dwRGBBitCount).CopyTo(imageBuffer, 88);
                            BitConverter.GetBytes(m_Texture2D.dwRBitMask).CopyTo(imageBuffer, 92);
                            BitConverter.GetBytes(m_Texture2D.dwGBitMask).CopyTo(imageBuffer, 96);
                            BitConverter.GetBytes(m_Texture2D.dwBBitMask).CopyTo(imageBuffer, 100);
                            BitConverter.GetBytes(m_Texture2D.dwABitMask).CopyTo(imageBuffer, 104);
                            BitConverter.GetBytes(m_Texture2D.dwCaps).CopyTo(imageBuffer, 108);
                            BitConverter.GetBytes(m_Texture2D.dwCaps2).CopyTo(imageBuffer, 112);
                            
                            m_Texture2D.image_data.CopyTo(imageBuffer, 128);

                            imageTexture = DDSDataToBMP(imageBuffer);
                            imageTexture.RotateFlip(RotateFlipType.RotateNoneFlipY);
                            previewPanel.BackgroundImage = imageTexture;
                            previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
                        }
                        else { StatusStripUpdate("Unsupported image for preview. Try to export."); }
                        break;
                    }
                #endregion
                #region AudioClip
                case 83: //AudioClip
                    {
                        AudioClip m_AudioClip = new AudioClip(asset, true);

                        //MemoryStream memoryStream = new MemoryStream(m_AudioData, true);
                        //System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer(memoryStream);
                        //soundPlayer.Play();

                        FMOD.RESULT result;
                        FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
                        
                        exinfo.cbsize = Marshal.SizeOf(exinfo);
                        exinfo.length = (uint)m_AudioClip.m_Size;

                        result = system.createSound(m_AudioClip.m_AudioData, (FMOD.MODE.OPENMEMORY | loopMode), ref exinfo, out sound);
                        if (ERRCHECK(result)) { break; }

                        result = sound.getLength(out FMODlenms, FMOD.TIMEUNIT.MS);
                        if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE))
                        {
                            if (ERRCHECK(result)) { break; }
                        }

                        result = system.playSound(sound, null, false, out channel);
                        if (ERRCHECK(result)) { break; }

                        timer.Start();
                        FMODstatusLabel.Text = "Playing";
                        FMODpanel.Visible = true;

                        //result = channel.getChannelGroup(out channelGroup);
                        //if (ERRCHECK(result)) { break; }

                        result = channel.getFrequency(out FMODfrequency);
                        ERRCHECK(result);

                        FMODinfoLabel.Text = FMODfrequency.ToString() + " Hz";
                        break;
                    }
                #endregion
                #region Shader & TextAsset
                case 48:
                case 49:
                    {
                        TextAsset m_TextAsset = new TextAsset(asset, true);
                        
                        string m_Script_Text = UnicodeEncoding.UTF8.GetString(m_TextAsset.m_Script);
                        m_Script_Text = Regex.Replace(m_Script_Text, "(?<!\r)\n", "\r\n");
                        textPreviewBox.Text = m_Script_Text;
                        textPreviewBox.Visible = true;

                        break;
                    }
                #endregion
                #region Font
                case 128: //Font
                    {
                        unityFont m_Font = new unityFont(asset);
                        
                        if (m_Font.extension != ".otf" && m_Font.m_FontData != null)
                        {
                            IntPtr data = Marshal.AllocCoTaskMem(m_Font.m_FontData.Length);
                            Marshal.Copy(m_Font.m_FontData, 0, data, m_Font.m_FontData.Length);

                            System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                            // We HAVE to do this to register the font to the system (Weird .NET bug !)
                            uint cFonts = 0;
                            AddFontMemResourceEx(data, (uint)m_Font.m_FontData.Length, IntPtr.Zero, ref cFonts);

                            pfc.AddMemoryFont(data, m_Font.m_FontData.Length);
                            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(data);

                            //textPreviewBox.Font = new Font(pfc.Families[0], 16, FontStyle.Regular);
                            //textPreviewBox.Text = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ\r\n1234567890.:,;'\"(!?)+-*/=\r\nThe quick brown fox jumps over the lazy dog. 1234567890";
                            fontPreviewBox.SelectionStart = 0;
                            fontPreviewBox.SelectionLength = 80;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 16, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 81;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 12, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 138;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 18, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 195;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 24, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 252;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 36, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 309;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 48, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 366;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 60, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 423;
                            fontPreviewBox.SelectionLength = 55;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 72, FontStyle.Regular);
                            fontPreviewBox.Visible = true;
                        }
                        else { StatusStripUpdate("Unsupported font for preview. Try to export."); }

                        break;
                    }
                #endregion
            }
        }
Пример #12
0
        private void BuildAssetStrucutres()
        {
            #region first loop - read asset data & create list
            if (!dontLoadAssetsMenuItem.Checked)
            {
                assetListView.BeginUpdate();
                progressBar1.Value = 0;
                progressBar1.Maximum = totalAssetCount;

                string fileIDfmt = "D" + assetsfileList.Count.ToString().Length.ToString();

                foreach (var assetsFile in assetsfileList)
                {
                    StatusStripUpdate("Building asset list from " + Path.GetFileName(assetsFile.filePath));

                    string fileID = assetsfileList.IndexOf(assetsFile).ToString(fileIDfmt);

                    //ListViewGroup assetGroup = new ListViewGroup(Path.GetFileName(assetsFile.filePath));


                    foreach (var asset in assetsFile.preloadTable.Values)
                    {
                        asset.uniqueID = fileID + asset.uniqueID;

                        switch (asset.Type2)
                        {
                            case 1: //GameObject
                                {
                                    GameObject m_GameObject = new GameObject(asset);
                                    assetsFile.GameObjectList.Add(asset.m_PathID, m_GameObject);
                                    totalTreeNodes++;
                                    break;
                                }
                            case 4: //Transform
                                {
                                    Transform m_Transform = new Transform(asset);
                                    assetsFile.TransformList.Add(asset.m_PathID, m_Transform);
                                    break;
                                }
                            case 224: //RectTransform
                                {
                                    RectTransform m_Rect = new RectTransform(asset);
                                    assetsFile.TransformList.Add(asset.m_PathID, m_Rect.m_Transform);
                                    break;
                                }
                            //case 21: //Material
                            case 28: //Texture2D
                                {
                                    Texture2D m_Texture2D = new Texture2D(asset, false);
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 48: //Shader
                            case 49: //TextAsset
                                {
                                    TextAsset m_TextAsset = new TextAsset(asset, false);
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 83: //AudioClip
                                {
                                    AudioClip m_AudioClip = new AudioClip(asset, false);
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            //case 89: //CubeMap
                            case 128: //Font
                                {
                                    unityFont m_Font = new unityFont(asset, false);
                                    assetsFile.exportableAssets.Add(asset);
                                    break;
                                }
                            case 129: //PlayerSettings
                                {
                                    PlayerSettings plSet = new PlayerSettings(asset);
                                    productName = plSet.productName;
                                    base.Text = "Unity Studio - " + productName + " - " + assetsFile.m_Version + " - " + assetsFile.platformStr;
                                    break;
                                }
                            case 0:
                                break;

                        }

                        progressBar1.PerformStep();
                    }

                    exportableAssets.AddRange(assetsFile.exportableAssets);
                    //if (assetGroup.Items.Count > 0) { listView1.Groups.Add(assetGroup); }
                }

                if (base.Text == "Unity Studio" && assetsfileList.Count > 0)
                {
                    base.Text = "Unity Studio - no productName - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
                }

                visibleAssets = exportableAssets;
                assetListView.VirtualListSize = visibleAssets.Count;

                //will only work if ListView is visible
                resizeAssetListColumns();

                assetListView.EndUpdate();
                progressBar1.Value = 0;
            }
            #endregion

            #region second loop - build tree structure
            if (!dontBuildHierarchyMenuItem.Checked)
            {
                sceneTreeView.BeginUpdate();
                progressBar1.Value = 0;
                progressBar1.Maximum = totalTreeNodes;

                foreach (var assetsFile in assetsfileList)
                {
                    StatusStripUpdate("Building tree structure from " + Path.GetFileName(assetsFile.filePath));
                    GameObject fileNode = new GameObject(null);
                    fileNode.Text = Path.GetFileName(assetsFile.filePath);
                    fileNode.m_Name = "RootNode";

                    foreach (var m_GameObject in assetsFile.GameObjectList.Values)
                    {
                        var parentNode = fileNode;

                        Transform m_Transform;
                        if (assetsfileList.TryGetTransform(m_GameObject.m_Transform, out m_Transform))
                        {
                            Transform m_Father;
                            if (assetsfileList.TryGetTransform(m_Transform.m_Father, out m_Father))
                            {
                                //GameObject Parent;
                                if (assetsfileList.TryGetGameObject(m_Father.m_GameObject, out parentNode))
                                {
                                    //parentNode = Parent;
                                }
                            }
                        }

                        parentNode.Nodes.Add(m_GameObject);
                        progressBar1.PerformStep();
                    }


                    if (fileNode.Nodes.Count == 0) { fileNode.Text += " (no children)"; }
                    sceneTreeView.Nodes.Add(fileNode);
                }
                sceneTreeView.EndUpdate();
                progressBar1.Value = 0;

                if (File.Exists(mainPath + "\\materials.json"))
                {
                    string matLine = "";
                    using (StreamReader reader = File.OpenText(mainPath + "\\materials.json"))
                    { matLine = reader.ReadToEnd(); }

                    jsonMats = new JavaScriptSerializer().Deserialize<Dictionary<string, Dictionary<string, string>>>(matLine);
                    //var jsonMats = new JavaScriptSerializer().DeserializeObject(matLine);
                }
            }
            #endregion

            #region build list of class strucutres
            if (buildClassStructuresMenuItem.Checked)
            {
                //group class structures by versionv
                foreach (var assetsFile in assetsfileList)
                {
                    SortedDictionary<int, ClassStrStruct> curVer;
                    if (AllClassStructures.TryGetValue(assetsFile.m_Version, out curVer))
                    {
                        foreach (var uClass in assetsFile.ClassStructures)
                        {
                            curVer[uClass.Key] = uClass.Value;
                        }
                    }
                    else { AllClassStructures.Add(assetsFile.m_Version, assetsFile.ClassStructures); }
                }

                classesListView.BeginUpdate();
                foreach (var version in AllClassStructures)
                {
                    ListViewGroup versionGroup = new ListViewGroup(version.Key);
                    classesListView.Groups.Add(versionGroup);

                    foreach (var uclass in version.Value)
                    {
                        uclass.Value.Group = versionGroup;
                        classesListView.Items.Add(uclass.Value);
                    }
                }
                classesListView.EndUpdate();
            }
            #endregion

            StatusStripUpdate("Finished loading " + assetsfileList.Count.ToString() + " files with " + (assetListView.Items.Count + sceneTreeView.Nodes.Count).ToString() + " exportable assets.");
            
            progressBar1.Value = 0;
            treeSearch.Select();
            
            saveFolderDialog1.InitialDirectory = mainPath;
        }
Пример #13
0
 private void ExportText(TextAsset m_TextAsset, string exportFilename)
 {
     using (BinaryWriter writer = new BinaryWriter(File.Open(exportFilename, FileMode.Create)))
     {
         writer.Write(m_TextAsset.m_Script);
         writer.Close();
     }
 }
Пример #14
0
        private void ExportAssets_Click(object sender, EventArgs e)
        {
            if (exportableAssets.Count > 0 && saveFolderDialog1.ShowDialog() == DialogResult.OK)
            {
                var savePath = saveFolderDialog1.FileName;
                if (Path.GetFileName(savePath) == "Select folder or write folder name to create")
                { savePath = Path.GetDirectoryName(saveFolderDialog1.FileName); }

                bool exportAll = ((ToolStripItem)sender).Name == "exportAllAssetsMenuItem";
                bool exportFiltered = ((ToolStripItem)sender).Name == "exportFilteredAssetsMenuItem";
                bool exportSelected = ((ToolStripItem)sender).Name == "exportSelectedAssetsMenuItem";

                int toExport = 0;
                int exportedCount = 0;

                //looping assetsFiles will optimize HDD access
                //but will also have a small performance impact when exporting only a couple of selected assets
                foreach (var assetsFile in assetsfileList)
                {
                    string exportpath = savePath + "\\";
                    if (assetGroupOptions.SelectedIndex == 1) { exportpath += Path.GetFileNameWithoutExtension(assetsFile.filePath) + "_export\\"; }

                    foreach (var asset in assetsFile.exportableAssets)
                    {
                        if (exportAll ||
                            visibleAssets.Exists(x => x.uniqueID == asset.uniqueID) && (exportFiltered || 
                                                                                        exportSelected && asset.Index >= 0 && assetListView.SelectedIndices.Contains(asset.Index)))
                        {
                            toExport++;
                            if (assetGroupOptions.SelectedIndex == 0) { exportpath = savePath + "\\" + asset.TypeString + "\\"; }

                            //AudioClip and Texture2D extensions are set when the list is built
                            //so their overwrite tests can be done without loading them again

                            switch (asset.Type2)
                            {
                                case 28:
                                    if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
                                    { ExportTexture(new Texture2D(asset, true), exportpath + asset.Text + asset.extension); exportedCount++; }
                                    break;
                                case 83:
                                    if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
                                    { ExportAudioClip(new AudioClip(asset, true), exportpath + asset.Text + asset.extension); exportedCount++; }
                                    break;
                                case 48:
                                    if (!ExportFileExists(exportpath + asset.Text + ".txt", asset.TypeString))
                                    { ExportText(new TextAsset(asset, true), exportpath + asset.Text + ".txt"); exportedCount++; }
                                    break;
                                case 49:
                                    TextAsset m_TextAsset = new TextAsset(asset, true);
                                    if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
                                    { ExportText(m_TextAsset, exportpath + asset.Text + asset.extension); exportedCount++; }
                                    break;
                                case 128:
                                    unityFont m_Font = new unityFont(asset, true);
                                    if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
                                    { ExportFont(m_Font, exportpath + asset.Text + asset.extension); exportedCount++; }
                                    break;
                            }
                        }
                    }
                }

                string statusText = "";
                switch (exportedCount)
                {
                    case 0:
                        statusText = "Nothing exported.";
                        break;
                    case 1:
                        statusText = toolStripStatusLabel1.Text + " finished.";
                        break;
                    default:
                        statusText = "Finished exporting " + exportedCount.ToString() + " assets.";
                        break;
                }
                
                if (toExport > exportedCount) { statusText += " " + (toExport - exportedCount).ToString() + " assets skipped (not extractable or files already exist)"; }

                StatusStripUpdate(statusText);

                if (openAfterExport.Checked && exportedCount > 0) { System.Diagnostics.Process.Start(savePath); }
            }
            else
            {
                StatusStripUpdate("No exportable assets loaded");
            }
        }
Пример #15
0
        private void BuildAssetStrucutres()
        {
            #region first loop - read asset data & create list
            StatusStripUpdate("Building asset list...");
            assetListView.BeginUpdate();

            string fileIDfmt = "D" + assetsfileList.Count.ToString().Length.ToString();

            foreach (var assetsFile in assetsfileList)
            {
                var a_Stream = assetsFile.a_Stream;
                var fileGen = assetsFile.fileGen;
                //var m_version = assetsFile.m_version;
                var version = assetsFile.version;
                string fileID = "1" + assetsfileList.IndexOf(assetsFile).ToString(fileIDfmt);

                //ListViewGroup assetGroup = new ListViewGroup(Path.GetFileName(assetsFile.filePath));

                foreach (var asset in assetsFile.preloadTable.Values)
                {
                    asset.uniqueID = fileID + asset.uniqueID;
                    a_Stream.Position = asset.Offset;

                    switch (asset.Type2)
                    {
                        case 1: //GameObject
                            {
                                GameObject m_GameObject = new GameObject(asset);

                                //asset.Text = m_GameObject.m_Name;
                                asset.specificIndex = assetsFile.GameObjectList.Count;
                                assetsFile.GameObjectList.Add(m_GameObject);
                                break;
                            }
                        case 4: //Transform
                            {
                                Transform m_Transform = new Transform(asset);

                                asset.specificIndex = assetsFile.TransformList.Count;
                                assetsFile.TransformList.Add(m_Transform);
                                break;
                            }
                        case 224: //RectTransform
                            {
                                RectTransform m_Rect = new RectTransform(asset);

                                asset.specificIndex = assetsFile.TransformList.Count;
                                assetsFile.TransformList.Add(m_Rect.m_Transform);
                                break;
                            }
                        //case 21: //Material
                        case 28: //Texture2D
                            {
                                Texture2D m_Texture2D = new Texture2D(asset, false);

                                asset.Text = m_Texture2D.m_Name;
                                asset.exportSize = 128 + m_Texture2D.image_data_size;

                                #region Get Info Text
                                asset.InfoText = "Width: " + m_Texture2D.m_Width.ToString() + "\nHeight: " + m_Texture2D.m_Height.ToString() + "\nFormat: ";

                                switch (m_Texture2D.m_TextureFormat)
                                {
                                    case 1: asset.InfoText += "Alpha8"; break;
                                    case 2: asset.InfoText += "ARGB 4.4.4.4"; break;
                                    case 3: asset.InfoText += "BGR 8.8.8"; break;
                                    case 4: asset.InfoText += "GRAB 8.8.8.8"; break;
                                    case 5: asset.InfoText += "BGRA 8.8.8.8"; break;
                                    case 7: asset.InfoText += "RGB 5.6.5"; break;
                                    case 10: asset.InfoText += "RGB DXT1"; break;
                                    case 12: asset.InfoText += "ARGB DXT5"; break;
                                    case 13: asset.InfoText += "RGBA 4.4.4.4"; break;
                                    case 30: asset.InfoText += "PVRTC_RGB2"; asset.exportSize -= 76; break;
                                    case 31: asset.InfoText += "PVRTC_RGBA2"; asset.exportSize -= 76; break;
                                    case 32: asset.InfoText += "PVRTC_RGB4"; asset.exportSize = 52; break;
                                    case 33: asset.InfoText += "PVRTC_RGBA4"; asset.exportSize -= 76; break;
                                    case 34: asset.InfoText += "ETC_RGB4"; asset.exportSize -= 76; break;
                                    default: asset.InfoText += "unknown"; asset.exportSize -= 128; break;
                                }

                                switch (m_Texture2D.m_FilterMode)
                                {
                                    case 0: asset.InfoText += "\nFilter Mode: Point "; break;
                                    case 1: asset.InfoText += "\nFilter Mode: Bilinear "; break;
                                    case 2: asset.InfoText += "\nFilter Mode: Trilinear "; break;

                                }

                                asset.InfoText += "\nAnisotropic level: " + m_Texture2D.m_Aniso.ToString() + "\nMip map bias: " + m_Texture2D.m_MipBias.ToString();

                                switch (m_Texture2D.m_WrapMode)
                                {
                                    case 0: asset.InfoText += "\nWrap mode: Repeat"; break;
                                    case 1: asset.InfoText += "\nWrap mode: Clamp"; break;
                                }
                                #endregion

                                assetsFile.exportableAssets.Add(asset);
                                break;
                            }
                        case 49: //TextAsset
                            {
                                TextAsset m_TextAsset = new TextAsset(asset, false);

                                asset.Text = m_TextAsset.m_Name;
                                asset.exportSize = m_TextAsset.exportSize;
                                assetsFile.exportableAssets.Add(asset);
                                break;
                            }
                        case 83: //AudioClip
                            {
                                AudioClip m_AudioClip = new AudioClip(asset, false);

                                asset.Text = m_AudioClip.m_Name;
                                asset.exportSize = (int)m_AudioClip.m_Size;
                                assetsFile.exportableAssets.Add(asset);
                                break;
                            }
                        case 48: //Shader
                        case 89: //CubeMap
                        case 128: //Font
                            {
                                asset.Text = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
                                assetsFile.exportableAssets.Add(asset);
                                break;
                            }
                        case 129: //PlayerSettings
                            {
                                PlayerSettings plSet = new PlayerSettings(asset);
                                productName = plSet.productName;
                                base.Text = "Unity Studio - " + productName + " - " + assetsFile.m_Version ;
                                break;
                            }

                    }

                    if (asset.Text == "") { asset.Text = asset.TypeString + " #" + asset.uniqueID; }
                    asset.SubItems.AddRange(new string[] { asset.TypeString, asset.exportSize.ToString() });
                }

                exportableAssets.AddRange(assetsFile.exportableAssets);
                //if (assetGroup.Items.Count > 0) { listView1.Groups.Add(assetGroup); }
            }

            visibleAssets = exportableAssets;
            assetListView.VirtualListSize = visibleAssets.Count;

            assetListView.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
            assetListView.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.ColumnContent);
            resizeNameColumn();

            assetListView.EndUpdate();
            #endregion

            #region second loop - build tree structure
            StatusStripUpdate("Building tree structure...");
            sceneTreeView.BeginUpdate();
            foreach (var assetsFile in assetsfileList)
            {
                GameObject fileNode = new GameObject(null);
                fileNode.Text = Path.GetFileName(assetsFile.filePath);

                foreach (var m_GameObject in assetsFile.GameObjectList)
                {
                    var parentNode = fileNode;

                    Transform m_Transform;
                    if (assetsfileList.TryGetTransform(m_GameObject.m_Transform, out m_Transform))
                    {
                        Transform m_Father;
                        if (assetsfileList.TryGetTransform(m_Transform.m_Father, out m_Father))
                        {
                            //GameObject Parent;
                            if (assetsfileList.TryGetGameObject(m_Father.m_GameObject, out parentNode))
                            {
                                //parentNode = Parent;
                            }
                        }
                    }

                    parentNode.Nodes.Add(m_GameObject);
                }

                if (fileNode.Nodes.Count == 0) { fileNode.Text += " (no children)"; }
                sceneTreeView.Nodes.Add(fileNode);
            }
            sceneTreeView.EndUpdate();
            #endregion

            if (File.Exists(mainPath + "\\materials.json"))
            {
                string matLine = "";
                using (StreamReader reader = File.OpenText(mainPath + "\\materials.json"))
                { matLine = reader.ReadToEnd(); }

                jsonMats = new JavaScriptSerializer().Deserialize<Dictionary<string, Dictionary<string, string>>>(matLine);
                //var jsonMats = new JavaScriptSerializer().DeserializeObject(matLine);
            }

            StatusStripUpdate("Finished loading " + assetsfileList.Count.ToString() + " files with " + (assetListView.Items.Count + sceneTreeView.Nodes.Count).ToString() + " exportable assets.");

            progressBar1.Value = 0;
            treeSearch.Select();
            TexEnv dsd = new TexEnv();
        }