Photon Fusion 2.0.3

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. More...
 
bool Equals (SceneRef other)
 Determines whether the specified SceneRef is equal to the current SceneRef. More...
 
override int GetHashCode ()
 Serves as the default hash function. More...
 
bool IsPath (string path)
 Checks if the SceneRef corresponds to a specific path. More...
 
override string ToString ()
 Returns a string that represents the current SceneRef. More...
 
string ToString (bool brackets, bool prefix)
 Returns a string that represents the current SceneRef, with optional formatting. More...
 

Static Public Member Functions

static SceneRef FromIndex (int index)
 Creates a SceneRef from an index. More...
 
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. More...
 
static SceneRef FromRaw (uint rawValue)
 Creates a SceneRef from a raw value. More...
 
static bool operator!= (SceneRef a, SceneRef b)
 Returns true if the values are not equal. More...
 
static bool operator== (SceneRef a, SceneRef b)
 Returns true if the values are equal. More...
 
static SceneRef Parse (string str)
 Parses a SceneRef from a string. More...
 

Public Attributes

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

Static Public Attributes

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

Properties

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

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.

◆ Parse()

static SceneRef Parse ( string  str)
static

Parses a SceneRef from a string.

Parameters
str
Returns

◆ 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.

Member Data Documentation

◆ FLAG_ADDRESSABLE

const uint FLAG_ADDRESSABLE = 1u << 31
static

A constant representing the flag for addressable scenes.

◆ RawValue

uint RawValue

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

◆ SIZE

const int SIZE = 4
static

The size of the SceneRef structure in bytes.

Property Documentation

◆ AsIndex

int AsIndex
get

Returns lower 32 bits as an index.

◆ AsPathHash

uint AsPathHash
get

Gets the path hash of the SceneRef.

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

◆ IsIndex

bool IsIndex
get

Returns true if this scene ref is an index.

◆ IsValid

bool IsValid
get

If this scene index is valid

◆ None

SceneRef None
staticget

None scene