Schemes.ID: Difference between revisions
Tayfunwiki (talk | contribs) (Created page with "== <code>ID</code> Property in Scheme Class == === Overview === The <code>ID</code> property in the Scheme class represents a unique identifier for each scheme instance in the game. === Property Definition === <syntaxhighlight lang="c#"> [field: SerializeField] public string ID { get; private set; } </syntaxhighlight> === Description === * Attribute: <code>[field: SerializeField]</code> - This attribute allows the <code>ID</code> field to be serialized by Unity, enab...") |
Tayfunwiki (talk | contribs) No edit summary |
||
Line 26: | Line 26: | ||
=== Example of Usage === | === Example of Usage === | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public class | public class SchemeInteractionManager : MonoBehaviour { | ||
void Start() { | void Start() { | ||
Scheme | // Iterate through all active schemes of the player and log their ID's | ||
foreach (Scheme scheme in IM.Player.Schemes) { | |||
Debug.Log($" | Debug.Log($"Scheme ID: {scheme.ID}"); | ||
} | } | ||
} | } | ||
Line 38: | Line 38: | ||
==== Description: ==== | ==== Description: ==== | ||
* | * In the <code>Start</code> method of the <code>SchemeInteractionManager</code> class, the example demonstrates iterating through all active schemes associated with the player and logging each scheme's id. | ||
=== Remarks === | === Remarks === |
Revision as of 17:30, 4 January 2024
ID
Property in Scheme Class
Overview
The ID
property in the Scheme class represents a unique identifier for each scheme instance in the game.
Property Definition
[field: SerializeField]
public string ID { get; private set; }
Description
- Attribute:
[field: SerializeField]
- This attribute allows theID
field to be serialized by Unity, enabling it to be set and viewed in the Unity Editor. - Type:
string
- Accessibility: The property is publicly accessible for getting its value but is privately settable, meaning it can only be modified internally within the class or its methods.
Functionality
- The
ID
serves as a unique identifier for schemes, ensuring that each scheme instance can be distinctly recognized and referenced. - It is particularly important for managing and tracking different schemes in the game, especially when dealing with multiple instances and types of schemes.
Usage
This property is used to access the unique identifier of a scheme. It's crucial in scenarios where specific schemes need to be identified, compared, or tracked throughout the gameplay.
Example of Usage
public class SchemeInteractionManager : MonoBehaviour {
void Start() {
// Iterate through all active schemes of the player and log their ID's
foreach (Scheme scheme in IM.Player.Schemes) {
Debug.Log($"Scheme ID: {scheme.ID}");
}
}
}
Description:
- In the
Start
method of theSchemeInteractionManager
class, the example demonstrates iterating through all active schemes associated with the player and logging each scheme's id.
Remarks
- The
ID
property is a critical aspect of the Scheme class, providing a means to uniquely identify each scheme instance. - Proper management of scheme IDs is essential for the integrity of game logic, particularly in complex systems involving multiple schemes and interactions.