Photon Fusion 2.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
SceneRef Struct Reference

Scene reference struct. Can be used to reference a scene by index or by path. More...

Inherits INetworkStruct, and IEquatable< SceneRef >.

Public Member Functions

override bool Equals (object obj)
 Determines whether the specified object is equal to the current SceneRef.
 
bool Equals (SceneRef other)
 Determines whether the specified SceneRef is equal to the current SceneRef.
 
override int GetHashCode ()
 Serves as the default hash function.
 
bool IsPath (string path)
 Checks if the SceneRef corresponds to a specific path.
 
override string ToString ()
 Returns a string that represents the current SceneRef.
 
string ToString (bool brackets, bool prefix)
 Returns a string that represents the current SceneRef, with optional formatting.
 

Static Public Member Functions

static SceneRef FromIndex (int index)
 Creates a SceneRef from an index.
 
static SceneRef FromPath (string path)
 Creates a scene ref from a path. The most common use case for this method is when using Unity's addressable scenes. The path is hashed (31 bit), so on rare occasion there may be a hash collision. In such case consider renaming a scene or construct your own hash and use FromRaw. To check if a scene ref is was created for a specific path, use IsPath.
 
static SceneRef FromRaw (uint rawValue)
 Creates a SceneRef from a raw value.
 
static bool operator!= (SceneRef a, SceneRef b)
 Returns true if the values are not equal.
 
static bool operator== (SceneRef a, SceneRef b)
 Returns true if the values are equal.
 

Public Attributes

uint RawValue
 The raw value of the SceneRef. This can represent either an index or a path hash, depending on the flag.
 

Static Public Attributes

const uint FLAG_ADDRESSABLE = 1u << 31
 A constant representing the flag for addressable scenes.
 
const int SIZE = 4
 The size of the SceneRef structure in bytes.
 

Properties

int AsIndex [get]
 Returns lower 32 bits as an index.
 
uint AsPathHash [get]
 Gets the path hash of the SceneRef.
 
bool IsIndex [get]
 Returns true if this scene ref is an index.
 
bool IsValid [get]
 If this scene index is valid.
 
static SceneRef None [get]
 None scene.
 

Detailed Description

Scene reference struct. Can be used to reference a scene by index or by path.

Member Function Documentation

◆ Equals() [1/2]

override bool Equals ( object  obj)

Determines whether the specified object is equal to the current SceneRef.

Parameters
objThe object to compare with the current SceneRef.
Returns
true if the specified object is equal to the current SceneRef; otherwise, false.

◆ Equals() [2/2]

bool Equals ( SceneRef  other)

Determines whether the specified SceneRef is equal to the current SceneRef.

Parameters
otherThe SceneRef to compare with the current SceneRef.
Returns
true if the specified SceneRef is equal to the current SceneRef; otherwise, false.

◆ FromIndex()

static SceneRef FromIndex ( int  index)
static

Creates a SceneRef from an index.

Parameters
indexThe index to create the SceneRef from.
Returns
A SceneRef that represents the index.
Exceptions
ArgumentOutOfRangeExceptionThrown when the index is less than 0 or equal to int.MaxValue.

◆ FromPath()

static SceneRef FromPath ( string  path)
static

Creates a scene ref from a path. The most common use case for this method is when using Unity's addressable scenes. The path is hashed (31 bit), so on rare occasion there may be a hash collision. In such case consider renaming a scene or construct your own hash and use FromRaw. To check if a scene ref is was created for a specific path, use IsPath.

Parameters
pathThe path to create the SceneRef from.
Returns
A SceneRef that represents the path.

◆ FromRaw()

static SceneRef FromRaw ( uint  rawValue)
static

Creates a SceneRef from a raw value.

Parameters
rawValueThe raw value to create the SceneRef from.
Returns
A SceneRef that represents the raw value.

◆ GetHashCode()

override int GetHashCode ( )

Serves as the default hash function.

Returns
A hash code for the current SceneRef.

◆ IsPath()

bool IsPath ( string  path)

Checks if the SceneRef corresponds to a specific path.

Parameters
pathThe path to check.
Returns
true if the SceneRef corresponds to the path; otherwise, false.

◆ operator!=()

static bool operator!= ( SceneRef  a,
SceneRef  b 
)
static

Returns true if the values are not equal.

Parameters
aSceneRef a
bSceneRef b
Returns
true if the values are not equal; otherwise, false.

◆ operator==()

static bool operator== ( SceneRef  a,
SceneRef  b 
)
static

Returns true if the values are equal.

Parameters
aSceneRef a
bSceneRef b
Returns
true if the values are equal; otherwise, false.

◆ ToString() [1/2]

override string ToString ( )

Returns a string that represents the current SceneRef.

Returns
A string that represents the current SceneRef.

◆ ToString() [2/2]

string ToString ( bool  brackets,
bool  prefix 
)

Returns a string that represents the current SceneRef, with optional formatting.

Parameters
bracketsIf true, the string will be enclosed in brackets.
prefixIf true, the string will be prefixed with "Scene:".
Returns
A string that represents the current SceneRef, formatted according to the provided parameters.

Property Documentation

◆ AsPathHash

uint AsPathHash
get

Gets the path hash of the SceneRef.

Exceptions
InvalidOperationExceptionThrown when the SceneRef is an index, not a path.