“对象”不包含“ layerCount”的定义

时间:2019-02-16 20:43:04

标签: unity3d photon

更新统一后,我遇到了问题 资产/ Photon Unity网络/编辑器/ PhotonNetwork /视图/PhotonAnimatorViewEditor.cs(83,57):错误CS1061:类型为object' does not contain a definition for layerCount',找不到扩展方法layerCount' of type object'。您是否缺少装配参考?

    private int GetLayerCount()
{
    #if UNITY_5 || UNITY_5_0 || UNITY_2017
    return (this.m_Controller == null) ? 0 : this.m_Controller.layers.Length;
    #else
    return (m_Controller == null) ? 0 : this.m_Controller.layerCount;
    #endif
}

任何可解决此错误的帮助。

非常感谢

1 个答案:

答案 0 :(得分:2)

我猜您已更新为Unity2018.x。该代码无法编译的原因是因为Unity 2018等所有预处理器均为false。

我建议也从统一资产商店更新光子,因为它们应支持Unity 2018。

但是,如果您想自己修复它:快速修复方法是添加UNITY_2018

private int GetLayerCount()
{
    #if UNITY_5 || UNITY_5_0 || UNITY_2017 || UNITY_2018
    return (this.m_Controller == null) ? 0 : this.m_Controller.layers.Length;
    #else
    return (m_Controller == null) ? 0 : this.m_Controller.layerCount;
    #endif
}

或者因为您不再需要Unity 4及更低版本的行而删除

private int GetLayerCount()
{
    return (this.m_Controller == null) ? 0 : this.m_Controller.layers.Length;
}