Why is NetworKserver.Spawn() creating a Spawn button in NetworkIdentity?

Why is NetworKserver.Spawn() creating a Spawn button in NetworkIdentity?

When I try to spawn a new obj by using a method like:

[Command]
void CmdSpawn {
    NetworkServer.Spawn(newGameObject);
}

A “spawn”-button is created in network identity and the object I am trying to spawn does not appear local nor on other clients before i click the “spawn”-button in the network identity.

How can I make the object spawn directly without having to click the “spawn”-button?

You need to Instantiate the object first before you can spawn it, try the below:

[Command]
void CmdSpawn
{
	GameObject NewObject = (GameObject)Instantiate (newGameObject, transform.position, transform.rotation);
	NetworkServer.Spawn(NewObject);
}

Same issue here… This line of code is giving me errors…

it says: Attribute command is not valid on this deceleration type. it is only valid on method declarations

or on the CmdSpawn it says:

property or indexes must have at least one accessor / cannot have void type