Class OnValueSyncedAttribute
Specifies a method to be called when the value of a synced field/property changes. This method will be called only for instances whose HasStateAuthority evaluates to false. CoherenceSync.isSimulated).
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field)]
public class OnValueSyncedAttribute : Attribute
- Inheritance
-
OnValueSyncedAttribute
Remarks
The callback method must meet the following conditions:
* Be 'public'
* Be defined in the same component as the field/property
* Have exactly two parameters
* Type of both parameters must match the type of field/property on which this attribute was applied
Example of a method signature for a field of type 'int': 'public void OnMyValueSynced(int oldValue, int newValue)'
Constructors
OnValueSyncedAttribute(string)
public OnValueSyncedAttribute(string callback)
Parameters
callback
string
Fields
Callback
Name of the method to be called when value changes. We strongly recommend using the 'nameof()' operator to avoid typing errors (e.g. '[OnValueSyncedAttribute(nameof(OnMyValueSynced)]' ).
public readonly string Callback
Field Value
Properties
SuppressNotBoundError
If true, fields (or properties) marked with this attribute, but not marked as synced, won't generate any error logs.
public bool SuppressNotBoundError { get; set; }
Property Value
SuppressParamOrderError
If true, callbacks with parameter names suggesting invalid order won't generate any error logs.
public bool SuppressParamOrderError { get; set; }