Search Unity

Calling static methods whilst attached to Unity

Discussion in 'Scripting' started by Andyman35uk, May 26, 2017.

  1. Andyman35uk

    Andyman35uk

    Joined:
    Jan 15, 2017
    Posts:
    3
    Hi All,

    I have a controller class which exposes a series of static methods to enable interaction with a UWP application. At the moment I'm developing the Unity part of my project so I need to be able to debug the Unity elements. If I play my project from Visual Studio through 'Attach to Unity and Play' is there a way of interactively calling static methods of my controller class?

    I've tried using the Visual Studio Immediate window but that gives the error 'The expression cannot be evaluated while in run mode.'.

    Does anyone know if it is possible to call static methods from an interactive session while the game is in Play?

    Cheers,
    Andy.
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    You could just create a button in a ongui method in a monobehavior file which calls your static function when pressed.
     
  3. Andyman35uk

    Andyman35uk

    Joined:
    Jan 15, 2017
    Posts:
    3
    So simple I can't believe I didn't think of that. Perfect. Thank you.

    Andy.