You can add the following attribute at the beginning of your script class:
[RequireComponent (typeof (NetworkView))]
This will ensure that whenever your script is added to a GameObject, a NetworkView component will also be added to that GameObject. Or you can just manually add the NetworkView component yourself. If you're only using it for RPC, you can set the Observed to none and change the State Synchronization to Off.
Once you're sure a NetworkView is attached to the same GameObject as your script, you can either use the built in shortcut of this.networkview
(which will automatically retrieve the NetworkView attached to the same GameObject), or you can use this.GetComponent<NetworkView>()
to get the NetworkView component attached to the current GameObject.
Either way, you'll be retrieving the same NetworkView, and utilizing it for its RPC functionality.
Your desired strategy of calling the method: Table_Manager.networkview.rpc("Table_Manager",RPCMode.All,25);
will not work. In this case you'd be treating Table_Manager
like a static class. In which case, you wouldn't have access to instance variables like networkview
. You can however make some kind of GameManager object in your scene. Attach your Table_Manager
script to it, then create a static function like the following:
static void GetScore() {
GameObject.Find("GameManger").GetComponent<Table_Manager>().
networkview.RPC("Table_Manager",RPCMode.All,25);
}
I'm not really sure what GetScore
is supposed to do, or why it's trying to call a Table_Manager
method on all the clients, but the above is how you'd write that.