# -*- coding: UTF-8 -*-
# This is an example how to call VNGE code from C# plugins

from extplugins import CallPrivateStatic, GetPrivateStatic

def start(game):
    """:type game: vngameengine.VNNeoController"""

    # getting MainEngine internal field from Unity.Console.dll Program class with Reflection
    # this need to be properly converted to C#
    import clr
    clr.AddReference('Unity.Console')
    from Unity.Console import Program
    mainEngine = CallPrivateStatic(Program,"get_MainEngine",[])

    # run some python code through main engine
    code = "from vngameengine import vnge_game\nvnge_game.show_blocking_message_time('hi')"
    # vnge_game will contain main VNGE object
    # you can also import other modules and run them

    mainEngine.CreateScriptSourceFromString(code).Compile().Execute()

    # if it fail to run, try use this code with SourceCodeKind option
    #mainEngine.CreateScriptSourceFromString(code, SourceCodeKind.File).Compile().Execute();

