private void FollowBtn_Click(object sender, EventArgs e)
        {
            valueGrid.Focus();
            GridItem item = valueGrid.SelectedGridItem;

            if (item.Label == "m_FileID" || item.Label == "m_PathID")
            {
                int  fileId = -1;
                long pathId = -1;
                foreach (GridItem gi in item.Parent.EnumerateAllItems())
                {
                    if (gi.Label == "m_FileID")
                    {
                        fileId = int.Parse((string)gi.Value);
                    }
                    if (gi.Label == "m_PathID")
                    {
                        pathId = long.Parse((string)gi.Value);
                    }
                }
                if (fileId == 0 && pathId == 0)
                {
                    MessageBox.Show("Cannot open null reference", "Assets View");
                    return;
                }
                else if (fileId == -1 || pathId == -1)
                {
                    MessageBox.Show("Could not find other id, is this really a pptr?", "Assets View");
                    return;
                }
                AssetExternal    ext  = helper.GetExtAsset(inst, fileId, pathId, true);
                GameObjectViewer view = new GameObjectViewer(helper, ext.file, ext.info.index);
                view.Show();
            }
        }
Example #2
0
        public void OpenAsset(long id)
        {
            GameObjectViewer view = new GameObjectViewer(helper, currentFile, id);

            view.Show();
            view.FormClosed += GameObjectViewer_FormClosed;
        }
Example #3
0
        public void OpenAsset(long id)
        {
            ClassDatabaseFile  classFile  = helper.classFile;
            AssetsFileInstance correctAti = currentFile;
            AssetFileInfoEx    info       = correctAti.table.GetAssetInfo(id);
            //todo this won't work for assets with typetrees
            ClassDatabaseType classType = AssetHelper.FindAssetClassByID(classFile, info.curFileType);
            string            typeName  = classType.name.GetString(classFile);
            bool hasGameobjectField     = classType.fields.Any(f => f.fieldName.GetString(classFile) == "m_GameObject");
            bool parentPointerNull      = false;

            if (typeName != "GameObject" && hasGameobjectField)
            {
                //get gameobject parent
                AssetTypeValueField componentBaseField = helper.GetATI(correctAti.file, info).GetBaseField();
                AssetFileInfoEx     newInfo            = helper.GetExtAsset(correctAti, componentBaseField["m_GameObject"], true).info;
                if (newInfo != null && newInfo.index != 0)
                {
                    info = newInfo;
                }
                else
                {
                    parentPointerNull = true;
                }
            }
            if ((typeName == "GameObject" || hasGameobjectField) && !parentPointerNull)
            {
                AssetTypeValueField baseField = helper.GetATI(correctAti.file, info).GetBaseField();

                AssetTypeValueField transformPtr = baseField["m_Component"]["Array"][0]["component"];
                AssetTypeValueField transform    = helper.GetExtAsset(correctAti, transformPtr).instance.GetBaseField();
                baseField = GetRootTransform(helper, currentFile, transform);
                AssetTypeValueField gameObjectPtr = baseField["m_GameObject"];
                AssetTypeValueField gameObject    = helper.GetExtAsset(correctAti, gameObjectPtr).instance.GetBaseField();
                GameObjectViewer    view          = new GameObjectViewer(helper, correctAti, gameObject, info.index, id);
                view.Show();
            }
            else
            {
                AssetTypeValueField baseField = helper.GetATI(correctAti.file, info).GetBaseField();
                GameObjectViewer    view      = new GameObjectViewer(helper, correctAti, baseField, info);
                view.Show();
            }
        }
Example #4
0
        private void assetList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (assetList.SelectedCells.Count > 0)
            {
                var    selRow   = assetList.SelectedRows[0];
                string typeName = (string)selRow.Cells[2].Value;
                if (typeName == "Folder")
                {
                    string dirName = (string)selRow.Cells[1].Value;
                    ChangeDirectory(dirName);
                }
                else
                {
                    ClassDatabaseFile  classFile  = helper.classFile;
                    AssetsFileInstance correctAti = currentFile;
                    ClassDatabaseType  classType  = AssetHelper.FindAssetClassByName(classFile, typeName);
                    if (currentFile.name == "globalgamemanagers")
                    {
                        int rsrcIndex = helper.files.FindIndex(f => f.name == "resources.assets");
                        if (rsrcIndex != -1)
                        {
                            correctAti = helper.files[rsrcIndex];
                        }
                        else
                        {
                            string rsrcPath = Path.Combine(Path.GetDirectoryName(currentFile.path), "resources.assets");
                            correctAti = helper.LoadAssetsFile(rsrcPath, false);
                            UpdateDependencies();
                        }
                        if (typeName == "")
                        {
                            return;
                        }
                    }
                    AssetFileInfoEx info = correctAti.table.getAssetInfo((ulong)selRow.Cells[3].Value);
                    bool            hasGameobjectField = classType.fields.Any(f => f.fieldName.GetString(classFile) == "m_GameObject");
                    bool            parentPointerNull  = false;
                    if (typeName != "GameObject" && hasGameobjectField)
                    {
                        //get gameobject parent
                        AssetTypeValueField componentBaseField = helper.GetATI(correctAti.file, info).GetBaseField();
                        AssetFileInfoEx     newInfo            = helper.GetExtAsset(correctAti, componentBaseField["m_GameObject"], true).info;
                        if (newInfo != null && newInfo.index != 0)
                        {
                            info = newInfo;
                        }
                        else
                        {
                            parentPointerNull = true;
                        }
                    }
                    if ((typeName == "GameObject" || hasGameobjectField) && !parentPointerNull)
                    {
                        AssetTypeValueField baseField = helper.GetATI(correctAti.file, info).GetBaseField();

                        AssetTypeValueField transformPtr = baseField["m_Component"]["Array"][0]["component"];
                        AssetTypeValueField transform    = helper.GetExtAsset(correctAti, transformPtr).instance.GetBaseField();
                        baseField = GetRootTransform(helper, currentFile, transform);
                        AssetTypeValueField gameObjectPtr = baseField["m_GameObject"];
                        AssetTypeValueField gameObject    = helper.GetExtAsset(correctAti, gameObjectPtr).instance.GetBaseField();
                        GameObjectViewer    view          = new GameObjectViewer(helper, correctAti, gameObject, info.index, (ulong)selRow.Cells[3].Value);
                        view.Show();
                    }
                    else
                    {
                        AssetTypeValueField baseField = helper.GetATI(correctAti.file, info).GetBaseField();
                        GameObjectViewer    view      = new GameObjectViewer(helper, correctAti, baseField, info);
                        view.Show();
                    }
                }
            }
        }