Exemplo n.º 1
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;
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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();
        }