Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

WorldUnmanaged.GetUnsafeSystemRef

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public ref T GetUnsafeSystemRef(SystemHandle id);

Parameters

Parameter Description
id The system handle

Returns

T A reference to the concrete ISystem compatible instance for this system

Description

Resolves the system handle to a reference to its underlying system instantiation.

This system reference is not guaranteed to be safe to use. If the system or world is destroyed then the reference becomes invalid and will likely lead to corrupted program state if used.

Generally, instead of public member data, prefer using component data for system level data that needs to be shared between systems or externally to them. This defines a data protocol for the system which is separated from the system functionality.

Private member data which is only used internally to the system is recommended.

GetUnsafeSystemRef, though provided as a backdoor to system instance data, is not recommended for usage in production or any non-throwaway code, as it - encourages coupling of data and functionality
- couples data to the system type with no direct path to decouple
- does not provide lifetime or thread safety guarantees for data
- does not provide lifetime or thread safety guarantees for system access through the returned ref