Hello,
Is it possible to add a Sprite of a Scriptable Object in Unity to the Sprite Renderer Component?
public class SOInventoryItemData : ScriptableObject
{
public Sprite Icon;
}
This Should go here automatically if i add the ScriptableObject:
Best regards,
Basti
Ok i Found the solution you need to address the OnInspectorGUI Event like this
[CustomEditor(typeof(TrCollectItemInWorld))]
public class TrCollectItemInWorldEditor : Editor
{
TrCollectItemInWorld Script;
GameObject ScriptObject;
void OnEnable()
{
this.Script = (TrCollectItemInWorld)target;
this.ScriptObject = Script.gameObject;
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
SpriteRenderer CurrentSpriteRenderer = ScriptObject.GetComponent();
if (CurrentSpriteRenderer != null)
{
CurrentSpriteRenderer.sprite = this.Script.ItemToCollect.Icon;
}
}
}
: