Skip to content

Commit

Permalink
small object variable debug/consistency changes
Browse files Browse the repository at this point in the history
  • Loading branch information
theradest1 committed Apr 14, 2024
1 parent 2f60b31 commit f16e911
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
19 changes: 12 additions & 7 deletions Assets/UM2/Object Sync/UM2_Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ public class UM2_Object : MonoBehaviourUM2
public bool destroyWhenCreatorLeaves = false;

public object getNetworkVariableValue(string name){
return UM2_Variables.getNetworkVariable(name, objectID).getValue();
}

public NetworkVariable_Client getNetworkVariable(string name){
return UM2_Variables.getNetworkVariable(name, objectID);
return this.getNetworkVariable(name).getValue();
}

public void setNetworkVariableValue(string name, object value){
UM2_Variables.getNetworkVariable(name, objectID).setValue(value);
this.getNetworkVariable(name).setValue(value);
}

public void addToNetworkVariableValue(string name, object valueToAdd){
UM2_Variables.getNetworkVariable(name, objectID).addToValue(valueToAdd);
this.getNetworkVariable(name).addToValue(valueToAdd);
}

public NetworkVariable_Client getNetworkVariable(string name){
if(objectID == -1){
Debug.LogWarning("Cannot get network variable since object doesn't have a variable yet\njust wait for a bit before getting it (or ignore)");
return null;
}

return UM2_Variables.getNetworkVariable(name, objectID);
}

private void Start()
Expand Down
11 changes: 8 additions & 3 deletions Assets/UM2/Object Sync/UM2_Prefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ public class UM2_Prefab : MonoBehaviourUM2


public object getNetworkVariableValue(string name){
return UM2_Variables.getNetworkVariable(name, objectID).getValue();
return this.getNetworkVariable(name).getValue();
}

public void setNetworkVariableValue(string name, object value){
UM2_Variables.getNetworkVariable(name, objectID).setValue(value);
this.getNetworkVariable(name).setValue(value);
}

public void addToNetworkVariableValue(string name, object valueToAdd){
UM2_Variables.getNetworkVariable(name, objectID).addToValue(valueToAdd);
this.getNetworkVariable(name).addToValue(valueToAdd);
}

public NetworkVariable_Client getNetworkVariable(string name){
if(objectID == -1){
Debug.LogWarning("Cannot get network variable since object doesn't have a variable yet\njust wait for a bit before getting it (or ignore)");
return null;
}

return UM2_Variables.getNetworkVariable(name, objectID);
}

Expand Down

0 comments on commit f16e911

Please sign in to comment.