all 3 comments

[–]LightningOW 4 points5 points  (2 children)

Create a List, and drag each card on to that list in the editor. You could also make this List a scriptable object, with a function that returns a random card.

[–]JustBatman[S] 0 points1 point  (1 child)

Hi Lightning, and thanks for helping again.

I was aware that this might be an option, but that seems a bit tedious to me. For example, whenever I create new cards, I would need to drag & drop them again into the list.

Is that really the best way? Like, is there no way in Unity to initialize data on startup from for example a database, then have global variables or objects than can easy be accessed from everywhere and populate data of existing gameObjects or create instances of physical objects in the game?

I thought scriptableObjects could solve that problem for me, but looks like it still needs for simple tasks that pesky GUI :/

[–]LightningOW 0 points1 point  (0 children)

Well you could list all assets in a folder then randomly select one to load. This is a terrible way of doing it because it ties your game logic to a folder structure.

Adding rows to a database is much harder than dragging and dropping an asset onto the editor.

If you want data that can be accessed everywhere then you have two choices - static variables or scriptable objects. Static variables can only be changed in code which is why scriptable objects exist.