Scene reference struct. Can be used to reference a scene by index or by path.
More...
Inherits INetworkStruct, and IEquatable< SceneRef >.
|
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 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.
|
|
|
uint | RawValue |
| The raw value of the SceneRef. This can represent either an index or a path hash, depending on the flag.
|
|
|
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.
|
|
|
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.
|
|
Scene reference struct. Can be used to reference a scene by index or by path.
◆ Equals() [1/2]
override bool Equals |
( |
object |
obj | ) |
|
Determines whether the specified object is equal to the current SceneRef.
- Parameters
-
obj | The object to compare with the current SceneRef. |
- Returns
- true if the specified object is equal to the current SceneRef; otherwise, false.
◆ Equals() [2/2]
Determines whether the specified SceneRef is equal to the current SceneRef.
- Parameters
-
other | The SceneRef to compare with the current SceneRef. |
- Returns
- true if the specified SceneRef is equal to the current SceneRef; otherwise, false.
◆ FromIndex()
Creates a SceneRef from an index.
- Parameters
-
index | The index to create the SceneRef from. |
- Returns
- A SceneRef that represents the index.
- Exceptions
-
ArgumentOutOfRangeException | Thrown when the index is less than 0 or equal to int.MaxValue. |
◆ FromPath()
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
-
path | The 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
-
rawValue | The 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
-
- Returns
- true if the SceneRef corresponds to the path; otherwise, false.
◆ operator!=()
Returns true if the values are not equal.
- Parameters
-
- Returns
- true if the values are not equal; otherwise, false.
◆ operator==()
Returns true if the values are equal.
- Parameters
-
- 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
-
brackets | If true, the string will be enclosed in brackets. |
prefix | If true, the string will be prefixed with "Scene:". |
- Returns
- A string that represents the current SceneRef, formatted according to the provided parameters.
◆ AsPathHash
Gets the path hash of the SceneRef.
- Exceptions
-
InvalidOperationException | Thrown when the SceneRef is an index, not a path. |