how to make/use ScriptableObject?

I’ve been trying to solve a mans Question Learned I cannot help him any longer but out of curiosity I went looking in link @meat5000 provided and I found something I’ve never saw ScriptableObject before

A class you can derive from if you want to create objects that don’t need to be attached to game objects. - am what? how do I make 1 if it is not attached to non GameObject, IF I manage 1 how do I access it?

  • This Answer Says he can make 2.35M Scriptable Objects before Unity Crashes
  • also I’ve been looking through this
  • and this it has a code in it and I don’t understand more than 40% of it

also I’ve been asking my self:

  • How to create 1?
  • how to keep track of ScriptableObjects?
  • how to access them?
  • where could I see each scriptable Object in hierarchy?
  • IF it’s made and it has MeshRender attached where will it render it? if it has not got Transform attached?

this Question is made purely out of curiosity.

I guess the idea is to have an object that is not a component. So it is in memory like any object but not on any GameObject. Meaning you won’t see it in the Inspector nor in the Scene list.

You create one like this:

public class NewBehaviourScript : ScriptableObject {
int a = 10;

public int A{
	get{return a;}
}
}

and you use like this:

public class Trial : MonoBehaviour {
NewBehaviourScript newGuy;

void Start () 
{
	newGuy = (NewBehaviourScript)ScriptableObject.CreateInstance(typeof(NewBehaviourScript));
	print(newGuy.A);
}

}

You keep track of it via the reference you assign it to. Just like basic programming.
It is just a storage class for values and methods, I don’t think it is meant to have a mesh. It does not seem to have any update so you would have to update via your own call.

If you look at the inheritance hierarchy it has nothing to do with the whole MonoBehaviour apart from being an Object.

So, it is just for storing info and helpers.

My point of view.

EDIT: it then makes sense to be able to create millions of them since they are just taking space in memory but no resources, no update call, no Unity maintainance, only GC when needed.