- Home /
Question by
BrentonStumpf · Nov 13, 2018 at 03:28 AM ·
scriptableobjectscriptable objectserializeserializefield
How to serialize scripts in Unity?
I have a gameobject that I want to have a different script depending on what is loaded to the gameobject. I was creating a scriptable object decide which script is added but when I try to add the script it does not show. How would I make scripts serializable so I can add them to a sriptable object?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "New Card", menuName = "Card")]
public class CardType : ScriptableObject {
public Component cardScript;
public int cardModifyer;
}
Comment
Best Answer
Answer by BrentonStumpf · Nov 15, 2018 at 09:50 PM
Figured out what I was doing wrong. I created a script that will have the scriptable object on it and that script will spawn the script as a compnenet that will then reference stuff on the scriptable object.