Photon Fusion 1.1.9

Public Member Functions | Properties | List of all members
NetworkedAttribute Class Reference

Inherits Attribute.

Public Member Functions

 NetworkedAttribute ()
 Default constructor for NetworkedAttribute.
 
 NetworkedAttribute (string group)
 Group constructor.
 

Properties

string Default [get, set]
 Name of the field that holds the default value for this networked property.
 
string Group [get, set]
 Interest group for this property.
 
string OnChanged [get, set]
 Signature for the callback is:
 
OnChangedTargets OnChangedTargets [get, set]
 Which targets should receive the OnChanged callback.
 

Detailed Description

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 { } }

Constructor & Destructor Documentation

◆ NetworkedAttribute()

NetworkedAttribute ( string  group)

Group constructor.

Parameters
groupThe interest group this property belongs to

Property Documentation

◆ OnChanged

string OnChanged
getset

Signature for the callback is:

static void OnChanged(Changed<MyClass> changed){}