1-我已将YapLan()函数分配给“关闭”(按钮)KapanLan。
2-如果是服务器的所有者,则按钮将关闭自身并关闭客户端。 (没问题)
3-单击客户端时,出现标题中提到的错误。
Trying to send command for object without authority.
UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String)
Test:CallCmdYapLan()
Test:YapLan() (at Assets/Scripts/Test.cs:17)
UnityEngine.EventSystems.EventSystem:Update()
using UnityEngine.Networking;
using UnityEngine.UI;
#pragma warning disable CS0618
public class Test : NetworkBehaviour
{
public Button KapanLan;
public void YapLan()
{
if (isServer)
{
RpcYapLan();
}
else
{
CmdYapLan();
}
}
[Command]
public void CmdYapLan()
{
RpcYapLan();
}
[ClientRpc]
public void RpcYapLan()
{
KapanLan.interactable = false;
}
}
#pragma warning restore CS0618