how to assign new Object to public member variable for editor?

Hi., I am trying to assign a new object to a member variable so it is accessible in the editor however whatever I try shows it as unassigned. Example:

public class SomeComponent : MonoBehaviour
{
public someObject = new SomeObject();
}

someObject in the editor says “None (Some Object)”.

I have also tried assigning someObject in Awake but that does not seem to work either.

Thanks for the help!

In order for a reference to appear in the inspector, it has to be serializable. You may simply need to mark your SomeObject class as [System.Serializable]. Check out Unity serialization part 1: How it works and examples | Sometimes I Code for some info about serialization.

Thanks - I did try that but it still does not work, but the more I think about it I dont think I can do this since a “new” object would never serialize properly - I am pretty new to Unity but if I am understanding correctly I will need to build a Prefab of this object and assign it that way so the system can properly store/retrieve its values into the underlying Asset DB.

Thanks for the response!

hm… moments later I am thinking a Prefab is not correct either since the class I want to use derives from UnityEngine.Object and a Prefab would require a full MonoBehaviour and these classes are mostly just data structures with some minimal logic.