How to set SyncVarAttribute.hook?
I just found out about this hook in the SyncVar attribute. From reading about custom attributes most of them define those in brackets or the constructor.
My question is how and where this can be set so Unity will use the string for a method? I mean creating an instance and setting the hook in that instance would require some code to execute this, right? Or is the best way to just create your own Class with a constructor that does just that? defining the string in the constructor?
Answer by Pratap-Dafedar · Jun 21, 2016 at 02:30 PM
[SyncVar(hook = "OnMyName")]
public string playerName = "";
public void OnMyName(string newName)
{
playerName = newName;
nameInput.text = playerName;
}
Your answer
Follow this Question
Related Questions
With a custom attribute & drawer, how do I allow multiple attributes? 0 Answers
Copy constructor not copying referenced class 1 Answer
Passing in objects to class constructor 0 Answers
error CS0119: I declared the variable, but it is saying I need to declare it. 1 Answer
Hitting Serialization depth, need a better way to access parent class 1 Answer