Skip to main content

Network Properties Sync

Description

The NetworkPropertiesSync component will provide properties for the NetworkGameObject. Such as the object's health, level, name, etc.

Properties

NameTypeDescription
GetHealthInt Currententity health value
GetObjectLevelIntCurrent entity level value
GetObjectNameStringCurrent entity name value
GetCustomPropertiesStringCurrent entity custom properties value

Events

Register a callback event for listen the value change.

public Action<float, NetworkIdentity> HealthSyncedCallback;
public Action<int, NetworkIdentity> ObjectLevelSyncedCallback;
public Action<string, NetworkIdentity> ObjectNameSyncedCallback;
public Action<string, NetworkIdentity> CustomPropertiesSyncedCallback;

Methods

CmdSubtractHealth

Description

Change entity health value. You can register for Health value change events to listen for value changes.

public void CmdSubtractHealth(int _newValue,NetworkIdentity _sender)

Parameters

ConnectionTypeDescription
_newValueIntThe value of health to be subtracted
_senderNetworkIdentityThe sender of the operation. e.g. Player attack to enemy, the sender is player

CmdAddHealth

public void CmdAddHealth(int _newValue,NetworkIdentity _sender)

Description

Change entity health value and sync to all user.

Parameters

ConnectionTypeDescription
_newValueIntThe value of health to be subtracted
_senderNetworkIdentityThe sender of the operation. e.g. Player attack to enemy, the sender is player

Event

Developer can register for Health value change event to listen for value changes.

public Action<float, NetworkIdentity> HealthSyncedCallback;

Example

Getcomponent<NetworkPropertiesSync>().HealthSyncedCallback += (_health,_sender)=>{
//TODO: YOUR Logic code here
}

CmdLevelUp

public void CmdLevelUp(int _additionLevel,NetworkIdentity _sender)

Description

Change entity level value and sync to all user.

Parameters

ConnectionTypeDescription
_additionLevelIntThe value of level to be up
_senderNetworkIdentityThe sender of the operation. e.g. Player attack to enemy, the sender is player

Event

Developer can register for Level value change event to listen for value changes.

public Action<float, NetworkIdentity> ObjectLevelSyncedCallback;

Example

Getcomponent<NetworkPropertiesSync>().ObjectLevelSyncedCallback += (_level_,_sender)=>{
//TODO: YOUR Logic code here
}

CmdDegradeLevel

public void CmdDegradeLevel(int _level, NetworkIdentity _sender)

Description

Change the entity level value. You can register Level value change events to listen for value changes.

Parameters

ConnectionTypeDescription
_levelIntThe value of level to be degrade
_senderNetworkIdentityThe sender of the operation. e.g. Player attack to enemy, the sender is player

Event

Developer can register for Level value change event to listen for value changes.

public Action<float, NetworkIdentity> ObjectLevelSyncedCallback;

Example

Getcomponent<NetworkPropertiesSync>().ObjectLevelSyncedCallback += (_level_,_sender)=>{
//TODO: YOUR Logic code here
}

CmdSetObjectName

public void CmdSetObjectName(string _name,NetworkIdentity _sender)

Description

Name your gameobject and sync to all user.

Parameters

ConnectionTypeDescription
_namestringThe value of name to set.
_senderNetworkIdentityThe sender of the operation. e.g. Player attack to enemy, the sender is player

Event

Developer can register for name value change event to listen for value changes.

public Action<float, NetworkIdentity> ObjectNameSyncedCallback;

Example

Getcomponent<NetworkPropertiesSync>().ObjectNameSyncedCallback += (_name_,_sender)=>{
//TODO: YOUR Logic code here
}

CmdUpdateCustomProperties

public void CmdUpdateCustomProperties(string _customProperties,NetworkIdentity _sender)

Description

In addition to the above Properties, additional Properties can be added and sync to all user.

Parameters

ConnectionTypeDescription
_customPropertiesIntIncoming custom properties value
_senderNetworkIdentityThe sender of the operation

Event

Developer can register for custom data change event to listen for value changes.

public Action<string, NetworkIdentity> CustomPropertiesSyncedCallback;

Example

Getcomponent<NetworkPropertiesSync>().CustomPropertiesSyncedCallback += (_customdata,_sender)=>{
//TODO: YOUR Logic code here
}