I have a MonoBehaviour derived class attached to a GameObject. Let’s call it “ExampleMB”.
Within the Awake() event of ExampleMB I instance a ScriptableObject derived class. Lets call it “ExampleSO”.
ExampleSO contains a large number of properties of different ValueTypes (int, float, etc…).
Within the set{} portion of these properties I want to be able to call an RPC. The ExampleSO class holds a reference to the ExampleMB class. Therefore SENDING the RPC is no problem: exampleMB.networkView.RPC(parameters here). However, the receiving [RPC] tagged method is also within ExampleSO. This causes the problem.
An obvious answer is the have the receiving [RPC] tagged method be WITHIN ExampleMB, then point to ExampleMB’s reference to ExampleSO.
My question is: Is there any way to receive the RPC within ExampleSO without needing an [RPC] tagged method within ExampleMB that points to ExampleSO?
Heres some example code:
public class ExampleMB : MonoBehaviour
{
ExampleSO exampleSO;
void Awake()
{
exampleSO = ScriptableObject.CreateInstance<ExampleSO>();
exampleSO.Initialize(this);
}
}
public class ExampleSO : ScriptableObject
{
ExampleMB exampleMB;
int exampleProperty;
int ExampleProperty
{
get { return exampleProperty; }
set
{
exampleProperty = value;
exampleMB.networkView.RPC("UpdateExampleProperty", RPCMode.All, exampleProperty);
}
}
public void Initialize(ExampleMB exampleMB)
{
this.exampleMB = exampleMB;
}
[RPC]
void UpdateExampleProperty(int value)
{
exampleProperty = value;
}
}