原文地址:https://support.unity3d.com/hc/en-us/articles/206193836-What-is-CS1061-
症状
当尝试进入Play模式时,我得到了如下的错误:
error CS1061: Type `__’ does not contain a definition for `__’ and no extension method `__’ of type `__’ could be found (are you missing a using directive or an assembly reference?)
原因
当你尝试调用一个不存的方法或者访问一个不存的成员时,就会引发CS1061号错误。
下面的例子演示了尝试在Class1类型的对象上调用SayGoodbye方法。正如我们所见的那样类型Class1并没含有SayGoodbye的定义。
本例子的错误信息如下:
error CS1061: Type `Class1’ does not contain a definition for `SayGoodbye’ and no extension method `SayGoodbye’ of type `Class1’ could be found (are you missing a using directive or an assembly reference?)
解决方案
你需要确保方法和类成员存在,并且从正确的位置访问它们,才能解决CS1061错误。