Photon Fusion 1.1.2

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

More...

Inherits Attribute.

Public Member Functions

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

Properties

string OnChanged [get, set]
 Signature for the callback is: More...
 
OnChangedTargets OnChangedTargets [get, set]
 Which targets should receive the OnChanged callback. More...
 
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...
 

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() [1/2]

Default constructor for NetworkedAttribute

◆ NetworkedAttribute() [2/2]

NetworkedAttribute ( string  group)

Group constructor

Parameters
groupThe interest group this property belongs to

Property Documentation

◆ Default

string Default
getset

Name of the field that holds the default value for this networked property.

◆ Group

string Group
getset

Interest group for this property

◆ OnChanged

string OnChanged
getset

Signature for the callback is:

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

◆ OnChangedTargets

Which targets should receive the OnChanged callback.