Hey there, first time using scriptable objects and have randomly encountered an issue that I can’t seem to nail down.
There are no errors in the console and no script rewriting the values. Here is what is happening.
- Create instances of the scriptable object below in the editor
- Populate all fields
- Hit play in the editor
- Multiple scriptable objects lose their
itemIconanditemIconBackgroundsprite references - Hit play again to stop in the editor
- Scriptable object variable valuable still missing
I thought the benefit of scriptable objects was that the data would persist on these individual instances? Is there something I have set up incorrectly? Is this a bug I should submit?
I’ve tried recreating the objects, changing names, etc with no luck. All scripts that interact with these only reference them, never attempt to modify them.
Here is the scriptable object class. Using Unity 2020.3.3f1.
using UnityEngine;
[CreateAssetMenu(fileName = "Ruby Terminal Item", menuName = "Ruby Terminal Item", order = 0)]
public class UmokTerminalItem : ScriptableObject
{
[SerializeField]
private bool itemActiveInStore = false;
[SerializeField]
private string itemDisplayName = "Skin Name";
[Space(30, order =4)]
[SerializeField]
private string itemName = "skin_name";
[Space(30, order = 8)]
[SerializeField]
[TextArea(4,4)]
private string itemDescription = "";
[Space(30, order =12)]
[SerializeField]
private int UCCost = 50;
[Space(30, order =14)]
[Header("Icon that will display in the store")]
[SerializeField]
private Sprite itemIcon;
[SerializeField]
[Header("Background only used for weapons")]
private Sprite itemIconBackground;
public enum terminalItemTypes
{
skin,
gun,
modifier,
weaponskin
};
[Header("Terminal Item Type", order = 15)]
[SerializeField]
private terminalItemTypes terminalItemType = terminalItemTypes.skin;
[Space(30, order = 16)]
[Header("Weapon Skin Color. Only use if this is a weapon skin color", order = 17)]
[SerializeField]
private Color32 weaponSkinColor = new Color32(255, 255, 255, 255);
[SerializeField]
private Color32 weaponSkinColorSecondary = new Color32(255, 255, 255, 255);
[Space(30, order = 18)]
[SerializeField]
private Color32 iconCoreColor = new Color32(255, 255, 255, 255);
[SerializeField]
private Color32 iconBgColor= new Color32(255, 255, 255, 255);
[SerializeField]
private UmokTerminalItem linkedWeaponSkin;
public bool IsActive { get { return itemActiveInStore; } }
public string DisplayName { get { return itemDisplayName; } }
public string ItemID { get { return itemName; } }
public string Description { get { return itemDescription; } }
public int Cost { get { return UCCost; } }
public Sprite ItemIcon { get { return itemIcon; } }
public Sprite ItemIconBackground { get { return itemIconBackground; } }
public terminalItemTypes Type { get { return terminalItemType; } }
public Color32 WeaponSkinColor { get { return weaponSkinColor; } }
public Color32 WeaponSkinColorSecondary { get { return weaponSkinColorSecondary; } }
public Color32 IconCoreColor { get { return iconCoreColor; } }
public Color32 IconBackgroundColor { get { return iconBgColor; } }
public UmokTerminalItem LinkedWeaponSkin { get { return linkedWeaponSkin; } }
}