debug engine

by ◕小莫◕·v1.2·Updated 2022-09-23

调试引擎

Screenshots 1 screenshots

About this mod Machine translation

Taiwu scroll script debugging engine

Source code:

Main functions

Taiwu Painting Scroll has officially supported Mod. I think the shortcoming is that script debugging is inconvenient, so I wrote this debugging engine to debug scripts.

To facilitate mod developers to debug their own scripts

How to use

  • Extract "ScriptEngine" into the "Mod" folder of the game directory
  • After entering the game, find "Mod Selection"
  • Enable "Taiwu Painting Scroll Script Debugger" and then apply
  • Place your scripts in the "Mod/scirpts" folder
  • Pressing F6 will automatically reload the scripts in the folder

main

To use ScriptEngine to debug scripts, you need to add a `main` class to your script and inherit the `MonoBehaviour` class. Since you inherit the `MonoBehaviour` class, all event functions of MonoBehaviour can be used, such as `Start` `Update` `OnGUI` `OnDisable` and so on.

example

```csharp

using System;

using HarmonyLib;

using UnityEngine;

namespace ScriptTrainer

{

public class main: MonoBehaviour

{

void Start()

{

// Do something on startup

Debug.Log("ScriptTrainer Start");

}

void OnDisable()

{

// Script to do something when uninstalling

Debug.Log("ScriptTrainer OnDisable Uninstall");

}

void Update()

{

// Do something every frame

if (Input.GetKeyDown(KeyCode.F9))

{

Debug.Log("You pressed the F9 key");

}

}

}

}

```

The following is the method called by the game

```csharp

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using TaiwuModdingLib.Core.Plugin;

using UnityEngine;

using HarmonyLib;

using Object = UnityEngine.Object;

namespace ScriptTrainer

{

[PluginConfig("ScriptTrainer", "Xiao Mo", "1.0.0")]

public class ScriptTrainer: TaiwuRemakePlugin

{

private static GameObject gameObject;

public override void Dispose()

{

//// Destroy

Object.Destroy(gameObject);

Debug.Log("ScriptTrainer destroyed");

}

public override void Initialize()

{

// Called when loading

//Create an empty object

gameObject = new GameObject($"taiwu.ScriptTrainer{DateTime.Now.Ticks}");

// Mount the main class to gameObject

//The game will automatically call the Start and Update methods

gameObject.AddComponent();

Debug.Log("ScriptTrainer initialization completed");

}

}

}

```

The `public class ScriptTrainer: TaiwuRemakePlugin` here is the type called by the game when used as a Mod. This is used by the game. Remember to add it, otherwise the game will not read your script.

And `public class main: MonoBehaviour` is a class used for debugging the engine. As for why we do this, you will understand after looking at the source code. I want to simulate the game loading Mod to debug the script, but no matter how much I try, I can't achieve the effect I want, so I can only do this. It is a little troublesome. If you have a better method, you are welcome to push your modified code.

Principle

  • Create an empty `GameObject`,
  • Use `AddComponent` to mount classes that inherit `MonoBehaviour` to `GameObject`
  • After mounting, the game will call all event functions of it (MonoBehaviour) for you
  • This method applies to all Unity games,

Update log:

v1.2

-Fixed the problem of dependencies being occupied

v1.1

  • Now you can load the dependency l, just put the dependency dll into the scirpts folder

v1.0

  • Initial release

Install & use Install: follow the bundled instructions

  1. Unzip the archive from playbuff and read the bundled readme / instructions first.
  2. There is no universal mod manager for this game: some mods replace game files directly, some go into a game-specific Mods folder, and some need a game-specific community loader or tool first — follow the bundled readme.
  3. Place the files exactly as the readme says; mods with listed dependencies need those installed too.
  4. Launch the game to confirm it loaded; some games require enabling mods in settings or an in-game mod menu.

Install locations vary a lot between games and mods — the bundled readme is the most reliable guide.

File & checksum

Filename
太吾绘卷 脚本调试引擎
File size
55.5 KiB