Question by
powerproc_chris · Sep 10, 2017 at 09:57 AM ·
assetsscriptableobjectbuildpipelineassign-variable
How do you assign the value of a ScriptableObject (from asset) to a component variable?
Context
I'm working on a custom build pipeline and I need to make modifications to a component's field, which is a ScriptableObject. This is not to instantiate a ScriptableObject at runtime. This is to change the value as you would by dragging and dropping an asset onto the component's field or going through the object picker and selecting the asset from the Assets tab.
Example:
class Foo : ScriptableObject
{
public int someRandomInt;
}
------
class Bar : MonoBehaviour
{
public Foo foo;
}
In assets:
Assets/
--Prefabs/
----Foo1.asset (ScriptableObjects have .asset extension)
----Foo2.asset
How do you assign Foo1.asset's data, or Foo2.asset's data, to Bar.foo?
This one has been stumping me for quite a while. Thanks for your help!
Comment