Search Results for

    Show / Hide Table of Contents

    Migrate an Old Project to the New Mod SDK Project

    中文 | English

    Run this command at the repository root to replay the examples through the local Unity MCP.

    python Docs/Manual/manual/tools/tutorials.py run migrate-old-project
    
    Click to expand MCP actionsClick to collapse MCP actions

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

    {
      "variables": {
        "sourceAssetDir": "${fixture}/.migration/legacy/Assets/MyMod",
        "backupAssetDir": "${fixture}/.migration/backup/Assets/MyMod",
        "targetAssetDir": "${fixture}/.migration/fresh/Assets/MyMod"
      },
      "calls": [
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:UnityEditor.AssetDatabase/CreateFolder",
            "args": [
              "${fixtureParent}",
              "${folder}"
            ]
          },
          "expect": {
            "contains": "(String)"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:System.IO.Directory/CreateDirectory",
            "args": [
              "${fixture}/.migration/legacy/Assets/MyMod"
            ]
          },
          "expect": {
            "contains": "DirectoryInfo"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:System.IO.Directory/CreateDirectory",
            "args": [
              "${fixture}/.migration/backup/Assets"
            ]
          },
          "expect": {
            "contains": "DirectoryInfo"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:System.IO.Directory/CreateDirectory",
            "args": [
              "${fixture}/.migration/fresh/Assets"
            ]
          },
          "expect": {
            "contains": "DirectoryInfo"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:System.IO.File/WriteAllText",
            "args": [
              "${sourceAssetDir}/Example.lua",
              "return { name = \"Migration example\" }\n"
            ]
          },
          "expect": {
            "contains": "OK:"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:System.IO.File/WriteAllText",
            "args": [
              "${sourceAssetDir}/Example.lua.meta",
              "fileFormatVersion: 2\nguid: 8164f16a6ac0458b9dd5a79639ccb845\n"
            ]
          },
          "expect": {
            "contains": "OK:"
          }
        },
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:System.IO.File/WriteAllText",
            "args": [
              "${sourceAssetDir}.meta",
              "fileFormatVersion: 2\nguid: 95f38d6822b44d6ab0dcacb51e81752e\nfolderAsset: yes\n"
            ]
          },
          "expect": {
            "contains": "OK:"
          }
        }
      ]
    }
    

    Extract the complete SDK into a new directory, then bring over your own assets and their .meta files.

    1. Back up the old project and open the new one

    Copy the whole old project or keep a repository snapshot. Download the named Panzer-War-Mod-SDK-sdk-*.zip asset from the GitHub release and extract it into a new directory, keeping UnityProject and Packages next to each other. Follow project setup to open UnityProject in the Unity version it declares, then wait for import and compilation.

    2. Copy your assets

    Copy your own Assets subfolders into the new UnityProject/Assets. Keep relative paths and the .meta files for assets and folders. Include your mod package and build-pipeline assets under Assets/ModManager, then check their linked objects and package GUID. Keep the Packages and examples supplied by the new SDK. Re-enter personal settings such as your Steam game directory in the new project.

    Click to expand MCP actionsClick to collapse MCP actions

    Copy and back up a scratch subtree, then read the asset and both asset and folder GUIDs back.

    [
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.FileUtil/CopyFileOrDirectory",
          "args": [
            "${sourceAssetDir}",
            "${backupAssetDir}"
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.FileUtil/CopyFileOrDirectory",
          "args": [
            "${sourceAssetDir}.meta",
            "${backupAssetDir}.meta"
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.FileUtil/CopyFileOrDirectory",
          "args": [
            "${sourceAssetDir}",
            "${targetAssetDir}"
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:UnityEditor.FileUtil/CopyFileOrDirectory",
          "args": [
            "${sourceAssetDir}.meta",
            "${targetAssetDir}.meta"
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/ReadAllText",
          "args": [
            "${targetAssetDir}/Example.lua"
          ]
        },
        "expect": {
          "contains": "return { name = \"Migration example\" }"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/ReadAllText",
          "args": [
            "${targetAssetDir}/Example.lua.meta"
          ]
        },
        "expect": {
          "contains": "guid: 8164f16a6ac0458b9dd5a79639ccb845"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/ReadAllText",
          "args": [
            "${targetAssetDir}.meta"
          ]
        },
        "expect": {
          "contains": "guid: 95f38d6822b44d6ab0dcacb51e81752e"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/ReadAllText",
          "args": [
            "${sourceAssetDir}/Example.lua.meta"
          ]
        },
        "expect": {
          "contains": "guid: 8164f16a6ac0458b9dd5a79639ccb845"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/ReadAllText",
          "args": [
            "${backupAssetDir}/Example.lua.meta"
          ]
        },
        "expect": {
          "contains": "guid: 8164f16a6ac0458b9dd5a79639ccb845"
        }
      }
    ]
    

    3. Check references and rebuild

    Open the migrated prefabs and configuration and check for missing scripts, materials, shaders and dependencies. Follow the platform build guide to build and test each target. Keep the old project until the new one passes these checks.

    Click to expand MCP actionsClick to collapse MCP actions

    Check the connected Editor. Verify references, compilation and packages in the new project separately.

    [
      {
        "tool": "editor_status",
        "arguments": {},
        "expect": {
          "contains": "\"scriptCompilationFailed\": false"
        }
      },
      {
        "tool": "logs",
        "arguments": {
          "count": 10
        }
      }
    ]
    

    Early releases used Runtime-Supports to identify old projects and upgraded them by replacing MiddleLibLayer in place. The mod tools changelog describes that layout.

    In this article
    Back to top Panzer War Document