private void SetSelectedStateIfSelected(AssetFileInfoEx info, PGProperty prop) { if (info.index == selectedId) { prop.description = "SELECTEDCOMPONENT"; } }
private void LoadComponentData(PGProperty root, AssetTypeValueField baseField, AssetFileInfoEx info, int index, int size) { string className = AssetHelper.FindAssetClassByID(helper.classFile, info.curFileType) .name.GetString(helper.classFile); AssetTypeValueField targetBaseField = baseField; if (className == "MonoBehaviour") { if (AssetUtils.AllDependenciesLoaded(helper, inst)) { className += $" ({GetClassName(helper, inst, targetBaseField)})"; string managedPath = Path.Combine(Path.GetDirectoryName(inst.path), "Managed"); if (Directory.Exists(managedPath)) { targetBaseField = helper.GetMonoBaseFieldCached(inst, info, managedPath); } } else if (!firstTimeMBMessage) { firstTimeMBMessage = true; MessageBox.Show("Can't display MonoBehaviour data until dependencies are loaded", "Assets View"); } } string category = new string('\t', size - index) + className; PopulateDataGrid(targetBaseField, root, info, category); }
private void SetSelectedStateIfSelected(AssetFileInfoEx info, PGProperty prop) { //Console.WriteLine($"{info.index} == {selectedComponentIndex}"); if (info.index == selectedComponentIndex) { prop.description = "SELECTEDCOMPONENT"; } }
private void RecursiveTreeLoad(AssetTypeValueField atvf, PGProperty node, AssetFileInfoEx info, string category, int depth) { if (atvf.childrenCount == 0) { return; } foreach (AssetTypeValueField atvfc in atvf.pChildren) { if (atvfc == null) { return; } object value = ""; EnumValueTypes evt; if (atvfc.GetValue() != null) { evt = atvfc.GetValue().GetValueType(); if (evt != EnumValueTypes.ValueType_None) { if (1 <= (int)evt && (int)evt <= 12) { value = atvfc.GetValue().AsString(); PGProperty prop = new PGProperty(atvfc.GetName(), value); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); RecursiveTreeLoad(atvfc, prop, info, category, depth + 1); } else if (evt == EnumValueTypes.ValueType_Array || evt == EnumValueTypes.ValueType_ByteArray) { PGProperty childProps = new PGProperty("child", null, $"[size: {atvfc.childrenCount}]"); PGProperty prop = new PGProperty(atvfc.GetName(), childProps, $"[size: {atvfc.childrenCount}]"); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); RecursiveTreeLoad(atvfc, childProps, info, category, depth + 1); } } } else { PGProperty childProps = new PGProperty("child"); PGProperty prop = new PGProperty(atvfc.GetName(), childProps); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); RecursiveTreeLoad(atvfc, childProps, info, category, depth + 1); } } }
private PGProperty LoadGameObjectData(AssetTypeValueField field) { PGProperty root = new PGProperty("root"); AssetTypeValueField components = field.Get("m_Component").Get("Array"); int componentSize = (int)components.GetValue().AsArray().size; for (int i = 0; i < componentSize; i++) { AssetTypeValueField componentPtr = components[(uint)i].Get("component"); AssetsManager.AssetExternal ext = helper.GetExtAsset(inst, componentPtr); LoadComponentData(root, ext.instance.GetBaseField(), ext.info, i, componentSize); } return(root); }
private void LoadComponentData(PGProperty root, AssetTypeValueField baseField, AssetFileInfoEx info, int index, int size) { string className = AssetHelper.FindAssetClassByID(helper.classFile, info.curFileType) .name.GetString(helper.classFile); AssetTypeValueField targetBaseField = baseField; if (className == "MonoBehaviour") { className += $" ({GetClassName(helper, inst, targetBaseField)})"; string managedPath = Path.Combine(Path.GetDirectoryName(inst.path), "Managed"); if (Directory.Exists(managedPath)) { targetBaseField = helper.GetMonoBaseFieldCached(inst, info, managedPath); } } string category = new string('\t', size - index) + className; PopulateDataGrid(targetBaseField, root, info, category); }
private void GetSelectedNodeData() { if (goTree.Nodes.Count > 0) { object nodeTag = null; if (goTree.SelectedNode != null) { nodeTag = goTree.SelectedNode.Tag; } if (nodeTag is AssetTypeValueField) { PGProperty dataRoot = LoadGameObjectData((AssetTypeValueField)nodeTag); valueGrid.SelectedObject = dataRoot; if (selectedComponentIndex != ulong.MaxValue) { GridItem gi = valueGrid.EnumerateAllItems().FirstOrDefault(i => i.PropertyDescriptor != null && i.PropertyDescriptor.Description == "SELECTEDCOMPONENT"); if (gi != null) { valueGrid.Focus(); gi.Select(); } } } else { if (componentInfo == null) { valueGrid.SelectedObject = null; } else { PGProperty root = new PGProperty("root"); LoadComponentData(root, baseField, componentInfo, 0, 1); valueGrid.SelectedObject = root; } } } }
private PGProperty LoadGameObjectData(AssetTypeValueField field) { PGProperty root = new PGProperty("root"); AssetTypeValueField components = field.Get("m_Component").Get("Array"); int componentSize = components.GetValue().AsArray().size; for (int i = 0; i < componentSize; i++) { AssetTypeValueField componentPtr = components[i].GetLastChild(); if (ModifierKeys == Keys.Shift) { AssetExternal ext = helper.GetExtAsset(inst, componentPtr); if (ext.instance != null) { LoadComponentData(root, ext.instance.GetBaseField(), ext.info, i, componentSize); } } else { try { AssetExternal ext = helper.GetExtAsset(inst, componentPtr); if (ext.instance != null) { LoadComponentData(root, ext.instance.GetBaseField(), ext.info, i, componentSize); } } catch { if (loadedWithErrors == false) { loadedWithErrors = true; MessageBox.Show("A component failed to load. (tell nes or hold shift to throw)"); } } } } return(root); }
private void GetSelectedNodeData() { if (goTree.Nodes.Count > 0) { object nodeTag = null; if (goTree.SelectedNode != null) { nodeTag = goTree.SelectedNode.Tag; } if (nodeTag is AssetExternal ext) { AssetTypeValueField baseField = ext.instance.GetBaseField(); string typeName = baseField.templateField.type; if (typeName == "GameObject") { PGProperty dataRoot = LoadGameObjectData(baseField); valueGrid.SelectedObject = dataRoot; GridItem possibleComponent = valueGrid.EnumerateAllItems().FirstOrDefault(i => i.PropertyDescriptor != null && i.PropertyDescriptor.Description == "SELECTEDCOMPONENT"); if (possibleComponent != null) { valueGrid.Focus(); possibleComponent.Select(); } } else { PGProperty root = new PGProperty("root"); LoadComponentData(root, ext.instance.GetBaseField(), ext.info, 0, 0); valueGrid.SelectedObject = root; } } } }
private void PopulateDataGrid(AssetTypeValueField atvf, PGProperty node, AssetFileInfoEx info, string category, bool arrayChildren = false) { if (atvf.childrenCount == 0) { return; } string arraySingular = string.Empty; if (arrayChildren && atvf.childrenCount > 0) { arraySingular = plurServ.Singularize(atvf.children[0].templateField.name); } for (int i = 0; i < atvf.childrenCount; i++) { AssetTypeValueField atvfc = atvf.children[i]; if (atvfc == null) { return; } string key; if (!arrayChildren) { key = atvfc.GetName(); } else { key = $"{arraySingular}[{i}]"; } EnumValueTypes evt; if (atvfc.GetValue() != null) { evt = atvfc.GetValue().GetValueType(); if (evt != EnumValueTypes.None) { if (1 <= (int)evt && (int)evt <= 12) { string value = atvfc.GetValue().AsString(); PGProperty prop = new PGProperty(key, value); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); PopulateDataGrid(atvfc, prop, info, category); } else if (evt == EnumValueTypes.Array || evt == EnumValueTypes.ByteArray) { PGProperty childProps = new PGProperty("child", null, $"[size: {atvfc.childrenCount}]"); PGProperty prop = new PGProperty(key, childProps, $"[size: {atvfc.childrenCount}]"); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); PopulateDataGrid(atvfc, childProps, info, category, true); } } } else { PGProperty childProps; if (atvfc.childrenCount == 2) { AssetTypeValueField fileId = atvfc.children[0]; AssetTypeValueField pathId = atvfc.children[1]; string fileIdName = fileId.templateField.name; string fileIdType = fileId.templateField.type; string pathIdName = pathId.templateField.name; string pathIdType = pathId.templateField.type; if (fileIdName == "m_FileID" && fileIdType == "int" && pathIdName == "m_PathID" && pathIdType == "SInt64") { int fileIdValue = fileId.GetValue().AsInt(); long pathIdValue = pathId.GetValue().AsInt64(); childProps = new PGProperty("child", "", $"[fileid: {fileIdValue}, pathid: {pathIdValue}]"); } else { childProps = new PGProperty("child", ""); } } else { childProps = new PGProperty("child", ""); } PGProperty prop = new PGProperty(key, childProps); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); PopulateDataGrid(atvfc, childProps, info, category); } } }
private void RecursiveTreeLoad(AssetTypeValueField atvf, PGProperty node, AssetFileInfoEx info, string category, int depth) { if (atvf.childrenCount == 0) { return; } foreach (AssetTypeValueField atvfc in atvf.children) { if (atvfc == null) { return; } EnumValueTypes evt; if (atvfc.GetValue() != null) { evt = atvfc.GetValue().GetValueType(); if (evt != EnumValueTypes.ValueType_None) { if (1 <= (int)evt && (int)evt <= 12) { string value = atvfc.GetValue().AsString(); PGProperty prop = new PGProperty(atvfc.GetName(), value); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); RecursiveTreeLoad(atvfc, prop, info, category, depth + 1); } else if (evt == EnumValueTypes.ValueType_Array || evt == EnumValueTypes.ValueType_ByteArray) { PGProperty childProps = new PGProperty("child", null, $"[size: {atvfc.childrenCount}]"); PGProperty prop = new PGProperty(atvfc.GetName(), childProps, $"[size: {atvfc.childrenCount}]"); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); RecursiveTreeLoad(atvfc, childProps, info, category, depth + 1); } } } else { PGProperty childProps; if (atvfc.childrenCount == 2) { AssetTypeValueField fileId = atvfc.children[0]; AssetTypeValueField pathId = atvfc.children[1]; string fileIdName = fileId.templateField.name; string fileIdType = fileId.templateField.type; string pathIdName = pathId.templateField.name; string pathIdType = pathId.templateField.type; if (fileIdName == "m_FileID" && fileIdType == "int" && pathIdName == "m_PathID" && pathIdType == "SInt64") { int fileIdValue = fileId.GetValue().AsInt(); long pathIdValue = pathId.GetValue().AsInt64(); childProps = new PGProperty("child", "", $"[fileid: {fileIdValue}, pathid: {pathIdValue}]"); } else { childProps = new PGProperty("child", ""); } } else { childProps = new PGProperty("child", ""); } PGProperty prop = new PGProperty(atvfc.GetName(), childProps); prop.category = category; SetSelectedStateIfSelected(info, prop); node.Add(prop); RecursiveTreeLoad(atvfc, childProps, info, category, depth + 1); } } }