command_terminal icon indicating copy to clipboard operation
command_terminal copied to clipboard

Static methods not called if asset is in the /Plugins/ folder

Open Saucy opened this issue 6 years ago • 2 comments

Hello!

I'm having trouble having static methods appear in the help-command, or being able to run at all if I have Command Terminal-folder in the /Plugins/ folder. Command Terminal works if it is outside the /Plugins/ folder.

My code:

using CommandTerminal;

public static class DebugTestCommand {
  [RegisterCommand(Help = "Outputs message")]
  static void CommandHello (CommandArg[] args) {
    Terminal.Log("Hello world!");
  }
}

Saucy avatar Aug 10 '18 18:08 Saucy

Hi!

The Plugins folder compiles to a separate assembly. Right now the RegisterCommand attribute only works in the main assembly (source).

Try registering the command manually using Terminal.Shell.AddCommand.

I'll look into supporting separate assemblies.

stillwwater avatar Aug 11 '18 13:08 stillwwater

I've fixed this issue in my fork of Command Terminal. @stillwwater, if you want to do this it's very simple. On line 35 of CommandShell.cs, do this:

foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) {
                foreach (var type in assembly.GetTypes()) {

instead of this:

foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) {

JimmyCushnie avatar Nov 11 '18 12:11 JimmyCushnie