`object'不包含`layerCount'的定义

问题描述 投票:0回答:1

更新统一后,我面临问题Assets / Photon Unity Networking / Editor / PhotonNetwork / Views / PhotonAnimatorViewEditor.cs(83,57):错误CS1061:输入object' does not contain a definition forlayerCount'并且找不到扩展方法layerCount' of typeobject'。你错过了装配参考吗?

    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
}

任何帮助来解决此错误。

提前致谢

unity3d photon
1个回答
2
投票

我猜你已经更新到Unity 2018.x.代码无法编译的原因是因为UNITY_2017等所有预处理器对于Unity 2018都是错误的。

我建议从Unity资产商店更新光子,因为它们应该支持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;
}
© www.soinside.com 2019 - 2024. All rights reserved.