Safe Cross-Scene References – Like Drag & Drop, But Between Scenes!

Overview

The Cross-Scene Reference Package provides a convenient way to reference Unity objects across multiple scenes. By using a generic component-based system, it allows developers to create cross-scene references for any Component, such as Transform, Rigidbody, or Collider.

Features

  • 🎯 Seamless Cross-Scene Object References: Reference objects between scenes directly.
  • 🔄 Persistent Data Management: Handles references between loaded scenes without issues.
  • 🧩 Simple API: Easy-to-use methods to get/set references.
  • ⚙️ Generic Cross-Scene Object References: Use a generic approach to reference any Component type across scenes (e.g., Transform, Rigidbody).
  • 🗃️ Serialization Support: Automatically handles the serialization of references across scenes.
  • 🛡️ Type Safety: Ensures references are strongly typed at compile time.

Key Components

  • CrossSceneReference<T>: A generic class used to reference components of type T (e.g., Transform, Rigidbody) across scenes.
  • CrossSceneReferenceId: A monobehaviour script that uses a global unique guid to identify the object which is a combination of m_LocalIdentfierInFile and the scene path.

Best Practices

  • Use Type Safety: Always specify the correct component type when using CrossSceneReference<T> to avoid runtime errors.
  • 🔁 Avoid Circular Dependencies: Ensure that objects referencing each other are not in a loop.
  • 📂 Scene Loading Order: Manage scene loading carefully to ensure references are available when needed.

FAQ

  • A: No, CrossSceneReference<T> is constrained to Component types only.Q: Can I reference non-Component types?
  • A: The system will return null. Handle this scenario to avoid null reference exceptions.Q: What happens if the referenced object isn't loaded?
  • A: No, only active and loaded scenes can be referenced.Q: Can I reference objects from unloaded scenes?

Support

For additional support, visit our support page or contact us via email. contact@kabreetgames.com