# Project JSON Representation for LLM Analysis

This document outlines the structure and schema of the JSON files generated to represent the Unity project in a machine-readable format. The primary goal of this JSON-ification is to allow Large Language Models (LLMs) to better understand, analyze, and process the project's structure, assets, and dependencies.

## 1. Project Data Export (`ProjectDataExport`)

This directory contains a JSON representation of the Unity project's assets. Each asset file (e.g., `.unity`, `.prefab`, `.asset`, `.meta`) is converted into a corresponding `.json` file. These JSON files are structured as an array of objects, where each object corresponds to a document in Unity's YAML text serialization format.

### General Asset Schema

Most generated JSON files follow this basic structure:

```json
[
  {
    "type_id": "...",
    "anchor_id": "...",
    "data": {
      "ObjectType": {
        "property1": "value1",
        "property2": { ... }
      }
    }
  },
  ...
]
```

-   **`type_id`**: A string representing Unity's internal class ID for the object type (e.g., "1" for `GameObject`, "4" for `Transform`, "114" for `MonoBehaviour`).
-   **`anchor_id`**: A string representing the unique anchor or `fileID` for this object within the asset file. This ID is used to create references between objects.
-   **`data`**: An object containing the serialized data. The key is the object's type (e.g., `GameObject`, `RenderSettings`), and the value contains its properties.

### Specific File Schemas

#### Scene (`.unity`) or Prefab (`.prefab`)

Scene and Prefab files are converted into a JSON array that describes their GameObjects, components, and settings.

**Example Schema (`SampleScene.unity.json`):**
```json
[
  {
    "type_id": "104",
    "anchor_id": "2",
    "data": {
      "RenderSettings": { ... }
    }
  },
  {
    "type_id": "1",
    "anchor_id": "330585543",
    "data": {
      "GameObject": {
        "m_Name": "Main Camera",
        "m_Component": [
          { "component": { "fileID": "330585546" } },
          { "component": { "fileID": "330585545" } }
        ],
        ...
      }
    }
  },
  {
    "type_id": "4",
    "anchor_id": "330585546",
    "data": {
      "Transform": {
        "m_GameObject": { "fileID": "330585543" },
        "m_LocalPosition": { "x": 0, "y": 1, "z": -10 },
        ...
      }
    }
  },
  {
    "type_id": "20",
    "anchor_id": "330585545",
    "data": {
      "Camera": {
        "m_GameObject": { "fileID": "330585543" },
        ...
      }
    }
  }
]
```
-   The array contains definitions for scene-wide settings (like `RenderSettings`, `LightmapSettings`) and all GameObjects and their components.
-   A `GameObject` is defined with its properties and a list of its components. The components are referenced by their `fileID` (which corresponds to an `anchor_id` of another object in the file).
-   Each `Component` (e.g., `Transform`, `Camera`, `MonoBehaviour`) has a reference back to its parent `GameObject` via a `m_GameObject` field containing the `fileID`.

#### Project Settings (`.asset`)

Project settings files (like `AudioManager.asset`) are also converted into a JSON array.

**Example Schema (`AudioManager.asset.json`):**
```json
[
  {
    "type_id": "11",
    "anchor_id": "1",
    "data": {
      "AudioManager": {
        "m_Volume": 1,
        "Rolloff Scale": 1,
        ...
      }
    }
  }
]
```
-   This structure is simpler, usually containing one object that defines the settings for a specific manager.

#### Meta File (`.meta`)

A `.meta` file's JSON representation contains the asset's `guid` and importer settings. It has a slightly different structure, without the `type_id` and `anchor_id`.

**Example Schema (`SampleScene.unity.meta.json`):**
```json
[
  {
    "data": {
      "fileFormatVersion": 2,
      "guid": "99c9720ab356a0642a771bea13969a05",
      "DefaultImporter": {
        "externalObjects": {},
        "userData": null,
        "assetBundleName": null,
        "assetBundleVariant": null
      }
    }
  }
]
```
-   **`guid`**: The unique identifier for the asset in the Unity project. This is crucial for tracking dependencies.
-   **`DefaultImporter`** (or a specific importer type): Contains the settings for how the associated asset is imported into Unity.

---

## 2. Dependency Cache (`DependencyCache`)

This directory contains JSON files that map out the dependency graph of the entire project. A dependency file is generated for every asset type, providing a complete picture of how assets reference each other.

This cache is built by analyzing every asset in the project and recording all the other assets it depends on.

### Schema Overview

The dependency information is stored in a JSON file where each key is the GUID of an asset. The value is an object containing lists of dependency and referencer GUIDs. The GUID can be used to look up in the Project Exported Data to find the exact attributes of the asset.

**Schema:**
```json
{
  "AssetTypeIndex": 4,
  "JsonData": "{\"Guid\":\"0a0f5a0711f844690b4fa78f78c922f5\",\"DependencyGuids\":[]}"
}
```
- **`AssetTypeIndex`**: The internal type of unity asset.
- *`0`*: Script
- *`1`*: Prefab
- *`2`*: Scene
- *`3`*: ScriptableObject
- *`4`*: Every other asset type
- **`JsonData`**: A JSON object containing the following fields:
  - **`Guid`**: The GUID of the asset.
  - **`DependencyGuids`**: The GUIDs of all assets that this asset depends on.