Skip to content

Instantly share code, notes, and snippets.

@Noxalus
Created July 28, 2020 14:19
Show Gist options
  • Save Noxalus/85283a270b528f26104c3a02ff115fb4 to your computer and use it in GitHub Desktop.
Save Noxalus/85283a270b528f26104c3a02ff115fb4 to your computer and use it in GitHub Desktop.
Unity Modding

Code / Logic

  • How to load new scripts?
    • Compile MOD project DLL and load the Assembly during runtime in the original project (done by ModTool)
  • How to ensure the loaded code is secure?
    • Using Mono.Cecil (an official Unity package exists for that), we can limit the access to certain methods/APIs (done by ModTool)
  • How to use the original project code? (inherit from an existing classes, use existing components, etc...)
    • Export the project DLL (and its dependencies) in an .unitypackage file to import in the MOD project (done by ModTool)
    • TODO: Original project code should be under an assembly definition file and the needed DLL referenced by the ASMDEF should be included in the .unitypackage?
  • How to make sure the Unity settings for the MOD corresponds to the one of the original project?
    • Export project settings files in the .unitypackage: DynamicsManager.asset, InputManager.asset, Physics2DSettings.asset, TagManager.asset, etc... (done by ModTool)
      • TODO: Handle URP + package.json
      • TODO+: Export a demo scene to easily test new features added by the MOD
  • How to update existing UI?
    • We use JSON files to describe our UI, the idea would be to merge all MODs JSON files and to load the final JSON file when the game is loaded

Assets

  • How to load new assets?
    • ModTool uses AssetBundles to pack prefabs (with related assets) and provide an API to access to prefabs
      • Problem: We can't easily export assets that are not referenced by a prefab (TextAsset for instance)
      • Possible solution: use Addressable Assets loading the content catalog from the Mod project

Saving/Loading game state

  • How to save/load MOD content?
    • Possible answer here
  • What happen when we disable a MOD and we load a game state containing this MOD contents?
    • Just ignore entity not known?

Localization

  • Using com.unity.localization package, how can we localize contents from a MOD project?
    • Like for the Addressable Assets, we should be able to load localization tables from the MOD project

AI Planner

  • Can we extends the behaviour of agent in a MOD project using AI planner?
    • Don't know...

How to handle multiple MODs conflicts?

  • Make sure the MOD name is unique
  • Force use of namespaces (using the mod name) for the code to isolate the code
  • Naming rule for assets?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment