Search Results for

    Show / Hide Table of Contents

    VehicleTextData Usage Guide

    中文 | English

    Run this command at the repository root to replay the examples through the local Unity MCP. The command also captures screenshots in both languages.

    python Docs/Manual/manual/tools/tutorials.py run vehicle-text-data --capture
    
    Click to expand MCP actionsClick to collapse MCP actions

    Prepare the teaching sample. The recipe provides ${variables}.

    {
      "variables": {
        "asset": "${fixture}/Tutorial_VehicleTextData.asset",
        "sharedGun": "${fixture}/Tutorial_SharedGunData.asset",
        "vehicleData": "${fixture}/Tutorial_VehicleData.asset"
      },
      "calls": [
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:UnityEditor.AssetDatabase/CreateFolder",
            "args": [
              "${fixtureParent}",
              "${folder}"
            ]
          },
          "expect": {
            "regex": "\\(String\\) [a-f0-9]{32}"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:UnityEditor.AssetDatabase/CopyAsset",
            "args": [
              "Packages/com.shanghaiwindy.coreresources/BuiltInVehicles/PatriotRadar/BuiltIn-Patriot-Radar_VehicleTextData.asset",
              "${asset}"
            ]
          },
          "expect": {
            "contains": "True"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:UnityEditor.AssetDatabase/CopyAsset",
            "args": [
              "Packages/com.shanghaiwindy.coreresources/BuiltInVehicles/PatriotRadar/BuiltIn-Patriot-Radar-SharedGun.asset",
              "${sharedGun}"
            ]
          },
          "expect": {
            "contains": "True"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:UnityEditor.AssetDatabase/AssetPathToGUID",
            "args": [
              "${asset}"
            ]
          },
          "capture": {
            "editorGuid": {
              "regex": "\\(String\\) ([a-f0-9]{32})"
            }
          }
        },
        {
          "tool": "inspect_set",
          "arguments": {
            "path": "asset:${asset}/AssetName",
            "value": "TutorialTank"
          },
          "expect": {
            "contains": "OK:"
          }
        },
        {
          "tool": "inspect_set",
          "arguments": {
            "path": "asset:${asset}/editorAssetGuid",
            "value": "${editorGuid}"
          },
          "expect": {
            "contains": "OK:"
          }
        },
        {
          "tool": "inspect_set",
          "arguments": {
            "path": "asset:${asset}/sharedGunData",
            "value": "@asset:${sharedGun}"
          },
          "expect": {
            "contains": "OK:"
          }
        },
        {
          "tool": "inspect_set",
          "arguments": {
            "path": "asset:${sharedGun}/tankFireParameter/fireSpread/aimTime",
            "value": "2"
          },
          "expect": {
            "contains": "OK:"
          }
        },
        {
          "tool": "inspect_set",
          "arguments": {
            "path": "asset:${sharedGun}/tankFireParameter/fireSpread/dispersion",
            "value": "0.35"
          },
          "expect": {
            "contains": "OK:"
          }
        }
      ]
    }
    

    VehicleTextData is the ScriptableObject that holds a vehicle's configuration. This page covers selecting the asset, locating fields, entering values and checking the result in the Unity Inspector.

    1. Select the asset

    1. In the Project window, select the .asset whose main type is VehicleTextData. Its create menu is A Panzer War - 装甲纷争/G Ground Vehicle - 地面载具/Base - 载具配置/Vehicle Configuration - 载具配置参数. If you create a new asset, assign it to vehicleTextData on the target VehicleData. The pictures use a separate teaching sample named Tutorial_VehicleTextData; select the actual vehicle asset you are authoring in your project.
    2. Check that AssetName (shown as Default Asset Name. Do not modify it!) and editorAssetGuid (shown as Asset GUID) belong to the target vehicle. Both are read-only and cannot be edited here.
    3. editorAssetGuid is the Unity authoring-asset GUID, not the queue vehicleGuid. The queue vehicle ID comes from VehicleInfo.GetLoadGUID(). The two are different and must not be substituted for each other.

    Select the teaching asset and check its default name and asset GUID

    Click to expand MCP actionsClick to collapse MCP actions

    CreateAsset is the asset-creation equivalent; assigning a live object with inspect_set is the reference-slot equivalent. The sample is assigned to a separate VehicleData. Read-only identifiers are queried only.

    [
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.AssetDatabase/CreateAsset",
          "args": [
            "@static:UnityEngine.ScriptableObject/CreateInstance(ShanghaiWindy.Core.VehicleTextData)",
            "${fixture}/Tutorial_NewVehicleTextData.asset"
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.AssetDatabase/CreateAsset",
          "args": [
            "@static:UnityEngine.ScriptableObject/CreateInstance(ShanghaiWindy.Core.VehicleData)",
            "${vehicleData}"
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect_set",
        "arguments": {
          "path": "asset:${vehicleData}/vehicleTextData",
          "value": "@asset:${asset}"
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect_set",
        "arguments": {
          "path": "static:UnityEditor.Selection/activeObject",
          "value": "@asset:${asset}"
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/AssetName"
        },
        "expect": {
          "contains": "TutorialTank"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/editorAssetGuid"
        },
        "expect": {
          "contains": "${editorGuid}"
        }
      }
    ]
    

    2. Set HP and view range

    1. Expand PSParameter. It is under the Base BoxGroup and is labelled Player State Params.
    2. Inside PSParameter, find PSParameter.Health under the Camera Control group; it is labelled HP. The code default is 1200, and this example also uses the teaching value 1200.
    3. In the same PSParameter, find PSParameter.viewRange under the Sight group; it is labelled View Range. The allowed range is 220–5000, the code default is 220, and this example uses the teaching value 600.
    4. Save the asset, then reselect it and confirm HP and View Range were written to the target asset rather than another one.

    HP=1200 and viewRange=600 are teaching values only, not official balance guidance.

    Expand Player State Params; set HP to 1200 and View Range to 600

    Click to expand MCP actionsClick to collapse MCP actions

    Paths use real code field names and remain stable across UI languages. Asset writes save the asset; reselect and read back the values to verify.

    [
      {
        "tool": "inspect_set",
        "arguments": {
          "path": "asset:${asset}/PSParameter/Health",
          "value": "1200"
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect_set",
        "arguments": {
          "path": "asset:${asset}/PSParameter/viewRange",
          "value": "600"
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.AssetDatabase/SaveAssets",
          "args": []
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect_set",
        "arguments": {
          "path": "static:UnityEditor.Selection/activeObject",
          "value": "null"
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect_set",
        "arguments": {
          "path": "static:UnityEditor.Selection/activeObject",
          "value": "@asset:${asset}"
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/PSParameter/Health"
        },
        "expect": {
          "contains": "1200"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/PSParameter/viewRange"
        },
        "expect": {
          "contains": "600"
        }
      }
    ]
    

    3. Advanced groups

    Select the relevant Mobility, Fire, Turret or Multi-Turret tab before locating a field below. The Misc group is below the tabs.

    Field Inspector group and label Visibility and read behavior
    sharedGunData Shared Gun Data (Fire) Always shown; when set, GetTankFireParam() returns its tankFireParameter.
    TFParameter Tank Fire Params (Fire) Shown only when sharedGunData is empty; GetTankFireParam() then returns it.
    sharedTurretData Shared Turret Data (Turret) Always shown; when set, GetTurretParam() returns its turretParameter.
    MTParameter Turret Params (Turret) Shown only when sharedTurretData is empty; GetTurretParam() then returns it.
    PTCParameter Track Params (Mobility) Shown only when GetGroundType() returns TrackController, i.e. IsTrackController() is true.
    MechParameter Mech Params (Mobility) Enable isMech for the mech controller. Configure turn response, walking effects, and flight.
    CarControllerParameter Car Params (Mobility) Older data still appears here. The current GetGroundType() ignores this field. Follow the wheel setup guide for a wheeled vehicle.
    MultiFireSystemData Old Multi-Turret (Deprecated) Legacy multi-turret list; do not add it to new vehicles.
    simpleVehicleFireSystemParameters New Multi-Turret Current multi-turret list; each element is a SimpleVehicleFireSystemParameter.
    vehicleSelfExplosionParams Self Explosion Params (Misc) An array of VehicleSelfExplosionTextParameter; fill it element by element.

    PTCParameter visibility follows the order inside GetGroundType(): isStationary → Stationary, MechParameter.isMech → MechController, LuaVehicleControllerParameter.isLua → Lua, ShipControllerParameter.isShip → Ship, and only the remaining case returns TrackController. A tracked model does not by itself guarantee the field.

    sharedGunData and sharedTurretData are shared references: when several vehicles point to the same asset, edits affect every referencing vehicle; use TFParameter or MTParameter only when no shared reference is assigned. The teaching sample keeps a sharedGunData reference, so TFParameter is hidden there; this does not affect the HP and View Range steps above.

    Configure movement, firing, the turret, and self-destruction

    • For tracks, configure power and forward and reverse speed under Mobility. Assign TankWheelCollider and Track Data before setting up the suspension. Wheels · Track suspension
    • Under Fire, choose the shells, ammo capacity, reload time, and firing sound. Set muzzle velocity on the selected shell asset. The gun parameters control recoil scale and dispersion. Use a shared gun asset when several vehicles need the same gun settings.
    • Under Turret, set the traverse range, barrel elevation speed, and maximum elevation and depression. For a new secondary weapon, use simpleVehicleFireSystemParameters in the multi-turret tab to bind model nodes and independent firing data. For existing vehicles, see the legacy paths and offsets.
    • To configure an in-game self-destruct effect, add an entry under vehicleSelfExplosionParams in the miscellaneous settings. Assign the model's explosionPath and put a SelfExplodeBullet in explosionParam.explosionData. The asset provides range and damage, and the script determines when the effect fires.
    Click to expand MCP actionsClick to collapse MCP actions

    MCP paths locate advanced data and visibility conditions directly. The capture window cannot yet select Odin tabs automatically; Codex must add that capability before a tutorial needs such a capture. This group does not alter advanced settings.

    [
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/sharedGunData"
        },
        "expect": {
          "contains": "SharedGunData"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/noSharedGunData"
        },
        "expect": {
          "contains": "False"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/noSharedTurretData"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "asset:${asset}/GetTankFireParam",
          "args": []
        },
        "expect": {
          "contains": "TankFireParameter"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "asset:${asset}/GetTurretParam",
          "args": []
        },
        "expect": {
          "contains": "TurretParameter"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "asset:${asset}/GetGroundType",
          "args": []
        },
        "expect": {
          "contains": "TrackController"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/PTCParameter"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/MultiFireSystemData"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/simpleVehicleFireSystemParameters"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/vehicleSelfExplosionParams"
        }
      },
      {
        "expect": {
          "contains": "(Single)"
        },
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/MechParameter/timeToFullyTurn"
        }
      },
      {
        "expect": {
          "contains": "(Boolean)"
        },
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/CarControllerParameter/isCar"
        }
      },
      {
        "expect": {
          "regex": "Count=|\\(VehicleSelfExplosionTextParameter"
        },
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/vehicleSelfExplosionParams"
        }
      }
    ]
    

    4. Check

    1. Confirm AssetName and editorAssetGuid are unchanged and HP and View Range were written to the target asset.
    2. An Inspector screenshot proves only field positions and labels, not runtime behavior; confirm actual behavior with a check in game.
    3. If you later adjust advanced parameters, check the visibility conditions in the table above first, then look for the field in its group.
    Click to expand MCP actionsClick to collapse MCP actions

    This recipe verifies the asset reference, identifiers and persisted fields. The sample has no complete driveable model, so gameplay is not verified. A successful capture is not a runtime pass.

    [
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${vehicleData}/vehicleTextData/name"
        },
        "expect": {
          "contains": "Tutorial_VehicleTextData"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/AssetName"
        },
        "expect": {
          "contains": "TutorialTank"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/editorAssetGuid"
        },
        "expect": {
          "contains": "${editorGuid}"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/PSParameter/Health"
        },
        "expect": {
          "contains": "1200"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "asset:${asset}/PSParameter/viewRange"
        },
        "expect": {
          "contains": "600"
        }
      }
    ]
    
    In this article
    Back to top Panzer War Document