SceneTeleporterDictionary - jimdroberts/FishMMO GitHub Wiki
Serializable dictionary mapping string keys to scene teleporter details. Used to store and retrieve teleporter destinations and settings for scenes.
- Use this class to store mappings from teleporter names (string) to
SceneTeleporterDetails
objects. - Ensure
SceneTeleporterDetails
is properly defined and serializable. - Integrate this dictionary into your scene or game manager as needed.
// Example 1: Creating and populating a SceneTeleporterDictionary
SceneTeleporterDictionary teleporterDict = new SceneTeleporterDictionary();
teleporterDict["Start"] = new SceneTeleporterDetails {
ToScene = "MainTown",
ToPosition = new Vector3(0, 0, 0),
ToRotation = Quaternion.identity
};
// Example 2: Retrieving a teleporter destination
if (teleporterDict.TryGetValue("Start", out SceneTeleporterDetails details)) {
// Use details.ToScene, details.ToPosition, details.ToRotation
}
- Use clear, unique string keys for each teleporter to avoid conflicts.
- Always check for key existence before accessing dictionary values.
- Ensure all
SceneTeleporterDetails
entries are valid and initialized before use. - Leverage the inherited methods from
SerializableDictionary
for safe access and manipulation.