[5.4] value = x.name as setter, alternative?

Greetings, in my project I have an abstract class that doesn’t inherit MonoBehaviour. In this class I have 2-3 fields with their respective property getters/setters, similar to the one below:

[SerializeField()]
protected string _iconID;
public Sprite icon
{
	get
	{
		return ItemDatabase.instance.FindIcon(_id, _iconID);
	}
	set
	{
		_iconID = value.name;
	}
}

For memory’s sake, I am not storing the Sprite or GameObject itself in the field, but a string representing it’s name. Using that I call a method in my ItemDatabase that will return that object as needed. Now I’ve read about the coming changes and I’m trying the beta now, and my question would be:

Am I doing this correctly? Should I store the GameObject/Sprite/Texture itself instead of a string representing the name/ID in the Database? The project is still young and I can still do changes without screwing up everything. Thanks for your help :slight_smile:

Wow, I think you may be overkilling it. Also, a reference to a GameObject or Sprite takes only 4 bytes. But a string requires at least as many bytes as it’s length, so you’re likely adding memory, not saving it. You’d be much better off storing a direct reference.

Also, what ‘coming changes’ are you referring to?