'How to set a game object from hierarchy to a prefab. unity

I have a script called audiomananger that is a scriptable object, I need to put a slider onto it so when I change the slider value so does the volume but I cant drag the slider from hierarchy to the prefab thing, any help appreciated. Thanks. enter image description here



Solution 1:[1]

You can not reference a gameObject at scene inside scriptable object, because it is irrational and ignores class independence. For example, when you copy / paste a Scribtable Object asset file from the project to outside, there is no way to find it reference, so they are not using as Asset Bundle. The use of a Scribtable Object is to store date and themselves are used as a reference rather than a reference receiver. For this you must use the MonoBehavior class in the Prefab.

MonoBehavior: Special unity class Which support runtime events and can store as instances, Instances of this class can retrieve data within a scene or project But the storage of data in the body of the class is limited.

Prefab: Can store asset data and MonoBehaviour's inside their body, Perfab does not belong to a specific game object or mono behavior and can be referenced from other game objects as long as they are part of their themselves, parent or child's.

Scribtable Object: This class is used to store data and handle them during project, can be cloned and prevent data from being copied. It is divisible, but the data is stored equally in all references, so it is better to use it in storing public information such as settings or profile. As mentioned above, reference to the scene is not a condition of the class.

Pure C# Class: These classes are also in C # and can be part of data. Although it is not configurable outside of code but very useful for summarizing programming phase.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1