https://github.com/instance-id/so-persistent-reference
Scene Object / ScriptableObject persistent references
https://github.com/instance-id/so-persistent-reference
Last synced: 7 months ago
JSON representation
Scene Object / ScriptableObject persistent references
- Host: GitHub
- URL: https://github.com/instance-id/so-persistent-reference
- Owner: instance-id
- License: mit
- Created: 2020-08-29T23:36:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-02T18:55:52.000Z (about 5 years ago)
- Last Synced: 2025-04-06T05:09:25.684Z (7 months ago)
- Language: C#
- Size: 310 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scene Object / ScriptableObject persistent references
This project provides an example of taking scene objects in the hierarchy and creating a persistent reference within ScriptableObjects through code, or by dragging them into the interface. The references will be maintained through Domain Reloads, Entering PlayMode, and closing Unity completely.
---

# Example Instructions
An example scene is located in Asset/instance.id/SOReference/Example/BindingExample.unity
1. To use the example, click on the Reference Manager. In the ObjectHandler component select one or more "TypeData" items from the list, or manually drag GameObjects from the scene into the "Object Reference List".
##### (The TypeData component is used as a tag to demonstrate locating and selecting different component types via code and creating a persistent reference to them within ScriptableObjects. There is a ScriptableObject for each "TypeData" class that uses dropdown to select an identifier that matches it to one of the TypeData classes in order to act as different storage containers for the references based on the Scene Objects assigned type.

2. Press the "Bind Object" button

3. The Scene Objects should now be seen in the above "Reference Manager" Component under the "Referenced Scene Objects" Foldout.

4. You can also, under the "Referenced ScriptableObjects foldout, select the ScriptableObject which is of the same TypeData that you selected earlier and then see the Scene Objects added to the ScriptableObject. You should now be able to save the scene, enter playmode, close Unity, etc, and those references will persist.


---
