Inherits Attribute.
Public Member Functions | |
NetworkedAttribute () | |
Default constructor for NetworkedAttribute More... | |
NetworkedAttribute (string group) | |
Group constructor More... | |
Properties | |
string | Default [get, set] |
Name of the field that holds the default value for this networked property. More... | |
string | Group [get, set] |
Interest group for this property More... | |
string | OnChanged [get, set] |
Signature for the callback is: More... | |
OnChangedTargets | OnChangedTargets [get, set] |
Which targets should receive the OnChanged callback. More... | |
Flags a property of NetworkBehaviour for network state synchronization. The property should have empty get and set defines, which will automatically be replaced with networking code via IL Weaving. OnChanged can be assigned with the name of a method in the same NetworkBehaviour. The named method will get called whenever this property value has been changed by the State Authority. | [Networked(OnChanged = nameof(MyCallbackMethod)]
| public int MyProperty { get; set; } | | protected static void MyCallbackMethod(Changed<ChangedCallbackParent> changed) { | changed.LoadNew(); | var newval = changed.Behaviour.MyProperty; | changed.LoadOld(); | var oldval = changed.Behaviour.MyProperty; | Debug.Log($"Changed from {oldval} to {newval}"); | }
Inside of INetworkStruct, do not use AutoProperties (get; set;), as these will introduce managed types into the struct, which are not allowed. Instead use '=> default'. | [Networked]
| public string StringProp { get => default; set { } }
Default constructor for NetworkedAttribute
NetworkedAttribute | ( | string | group | ) |
Group constructor
group | The interest group this property belongs to |
|
getset |
Name of the field that holds the default value for this networked property.
|
getset |
Interest group for this property
|
getset |
Signature for the callback is:
static void OnChanged(Changed<MyClass> changed){}
|
getset |
Which targets should receive the OnChanged callback.