小编Dar*_*rkT的帖子

“组件”不包含“启用”的定义并且没有扩展方法“启用”

我正在尝试禁用和禁用Component存储在List. 当我尝试这样做时,我收到以下错误:

“组件”不包含“已启用”的定义,并且找不到接受“组件”类型的第一个参数的扩展方法“已启用”(您是否缺少 using 指令或程序集引用?)

我也试过

 components[4].SetActive(false);
Run Code Online (Sandbox Code Playgroud)

并得到类似的错误

public List<Component> components;
...
components = new List<Component>();
components.Add(player.GetComponent<_2dxFX_HSV1>());
components.Add(player.GetComponent<_2dxFX_HSV2>());
components.Add(player.GetComponent<_2dxFX_HSV3>());
components.Add(player.GetComponent<_2dxFX_HSV4>());
components.Add(player.GetComponent<_2dxFX_Negative>());
components.Add(player.GetComponent<_2dxFX_Lightning>());
components.Add(player.GetComponent<_2dxFX_MetalFX>());
components.Add(player.GetComponent<_2dxFX_Pixel8bitsC64>());
components.Add(player.GetComponent<_2dxFX_GoldFX>());
components.Add(player.GetComponent<_2dxFX_Waterfall>());
components.Add(player.GetComponent<_2dxFX_Hologram>());
components.Add(player.GetComponent<_2dxFX_PlasmaRainbow>());

components[4].enabled = false;
Run Code Online (Sandbox Code Playgroud)

如何禁用Component列表中的类型?

c# arrays list unity-game-engine

3
推荐指数
1
解决办法
2585
查看次数

标签 统计

arrays ×1

c# ×1

list ×1

unity-game-engine ×1