Exemple #1
0
        private void DrawValueFor(FieldDescription field, BytesAndOffset bytesAndOffset)
        {
            var typeDescription = _unpackedCrawl.typeDescriptions[field.typeIndex];

            switch (typeDescription.name)
            {
            case "System.Int32":
                GUILayout.Label(_primitiveValueReader.ReadInt32(bytesAndOffset).ToString());
                break;

            case "System.Int64":
                GUILayout.Label(_primitiveValueReader.ReadInt64(bytesAndOffset).ToString());
                break;

            case "System.UInt32":
                GUILayout.Label(_primitiveValueReader.ReadUInt32(bytesAndOffset).ToString());
                break;

            case "System.UInt64":
                GUILayout.Label(_primitiveValueReader.ReadUInt64(bytesAndOffset).ToString());
                break;

            case "System.Int16":
                GUILayout.Label(_primitiveValueReader.ReadInt16(bytesAndOffset).ToString());
                break;

            case "System.UInt16":
                GUILayout.Label(_primitiveValueReader.ReadUInt16(bytesAndOffset).ToString());
                break;

            case "System.Byte":
                GUILayout.Label(_primitiveValueReader.ReadByte(bytesAndOffset).ToString());
                break;

            case "System.SByte":
                GUILayout.Label(_primitiveValueReader.ReadSByte(bytesAndOffset).ToString());
                break;

            case "System.Char":
                GUILayout.Label(_primitiveValueReader.ReadChar(bytesAndOffset).ToString());
                break;

            case "System.Boolean":
                GUILayout.Label(_primitiveValueReader.ReadBool(bytesAndOffset).ToString());
                break;

            case "System.Single":
                GUILayout.Label(_primitiveValueReader.ReadSingle(bytesAndOffset).ToString());
                break;

            case "System.Double":
                GUILayout.Label(_primitiveValueReader.ReadDouble(bytesAndOffset).ToString());
                break;

            case "System.IntPtr":
                GUILayout.Label(_primitiveValueReader.ReadPointer(bytesAndOffset).ToString("X"));
                break;

            default:

                if (!typeDescription.isValueType)
                {
                    ThingInMemory item = GetThingAt(bytesAndOffset.ReadPointer());
                    if (item == null)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        GUILayout.Button("Null");
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        DrawLinks(new ThingInMemory[] { item });
                    }
                }
                else
                {
                    DrawFields(typeDescription, bytesAndOffset);
                }
                break;
            }
        }
Exemple #2
0
        private void DrawValueFor(FieldDescription field, BytesAndOffset bytesAndOffset)
        {
            var typeDescription = _unpackedCrawl.typeDescriptions[field.typeIndex];

            try
            {
                switch (typeDescription.name)
                {
                case "System.Int32":
                    GUILayout.Label(_primitiveValueReader.ReadInt32(bytesAndOffset).ToString());
                    break;

                case "System.Int64":
                    GUILayout.Label(_primitiveValueReader.ReadInt64(bytesAndOffset).ToString());
                    break;

                case "System.UInt32":
                    GUILayout.Label(_primitiveValueReader.ReadUInt32(bytesAndOffset).ToString());
                    break;

                case "System.UInt64":
                    GUILayout.Label(_primitiveValueReader.ReadUInt64(bytesAndOffset).ToString());
                    break;

                case "System.Int16":
                    GUILayout.Label(_primitiveValueReader.ReadInt16(bytesAndOffset).ToString());
                    break;

                case "System.UInt16":
                    GUILayout.Label(_primitiveValueReader.ReadUInt16(bytesAndOffset).ToString());
                    break;

                case "System.Byte":
                    GUILayout.Label(_primitiveValueReader.ReadByte(bytesAndOffset).ToString());
                    break;

                case "System.SByte":
                    GUILayout.Label(_primitiveValueReader.ReadSByte(bytesAndOffset).ToString());
                    break;

                case "System.Char":
                    GUILayout.Label(_primitiveValueReader.ReadChar(bytesAndOffset).ToString());
                    break;

                case "System.Boolean":
                    GUILayout.Label(_primitiveValueReader.ReadBool(bytesAndOffset).ToString());
                    break;

                case "System.Single":
                    GUILayout.Label(_primitiveValueReader.ReadSingle(bytesAndOffset).ToString());
                    break;

                case "System.Double":
                    GUILayout.Label(_primitiveValueReader.ReadDouble(bytesAndOffset).ToString());
                    break;

                case "System.IntPtr":
                    GUILayout.Label(_primitiveValueReader.ReadPointer(bytesAndOffset).ToString("X"));
                    break;

                default:
                    if (!typeDescription.isValueType)
                    {
                        ThingInMemory item = GetThingAt(bytesAndOffset.ReadPointer());
                        if (item == null)
                        {
                            EditorGUI.BeginDisabledGroup(true);
                            GUILayout.Button("Null");
                            EditorGUI.EndDisabledGroup();
                        }
                        else
                        {
                            DrawLinks(new ThingInMemory[] { item });
                        }
                    }
                    else
                    {
                        DrawFields(typeDescription, bytesAndOffset);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                GUILayout.Label(string.Format("<bad_entry> type: {0}, len: {1}, offset: {2}, ex: {3}", typeDescription.name, bytesAndOffset.bytes.Length, bytesAndOffset.offset, ex.GetType().Name));
                Debug.LogFormat("<bad_entry> type: {0}, len: {1}, offset: {2}, ex: {3}", typeDescription.name, bytesAndOffset.bytes.Length, bytesAndOffset.offset, ex.GetType().Name);
            }
        }