当从 python 调用时,c# 需要额外的参数(.net with ironpython)
c# wants extra Argument when called from python (.net with ironpython)
我在 c# 中有这个(游戏对象来自 unity3d)
namespace DLLTest
{
public class buttong : MonoBehaviour
{
public GameObject BButtn([ParamDictionary] IDictionary kwargs)
这在 python 初始化中:
engine.Runtime.LoadAssembly(System.Reflection.Assembly.GetAssembly(typeof(DLLTest.buttong)));
Python 中的这个:
from DLLTest.buttong import BButtn
def BButton(**kwargs):
BButtn(kwargs)
而且我不断得到
TypeError: expected buttong, got dict
当我从 c# 调用它时它只需要字典(我认为),但是从 python 它需要 2 个参数一个 buttong 类型,我想知道为什么以及如何提供一个 buttong 类型。
你的方法 BButtn 不是静态的。所以你需要用 buttong 的实例来调用它(或者让它成为静态的)
尝试做
from DLLTest import buttong
def BButton(**kwargs):
b= buttong()
b.BButtn(kwargs)
我在 c# 中有这个(游戏对象来自 unity3d)
namespace DLLTest
{
public class buttong : MonoBehaviour
{
public GameObject BButtn([ParamDictionary] IDictionary kwargs)
这在 python 初始化中:
engine.Runtime.LoadAssembly(System.Reflection.Assembly.GetAssembly(typeof(DLLTest.buttong)));
Python 中的这个:
from DLLTest.buttong import BButtn
def BButton(**kwargs):
BButtn(kwargs)
而且我不断得到
TypeError: expected buttong, got dict
当我从 c# 调用它时它只需要字典(我认为),但是从 python 它需要 2 个参数一个 buttong 类型,我想知道为什么以及如何提供一个 buttong 类型。
你的方法 BButtn 不是静态的。所以你需要用 buttong 的实例来调用它(或者让它成为静态的)
尝试做
from DLLTest import buttong
def BButton(**kwargs):
b= buttong()
b.BButtn(kwargs)