Acessing public functions/variables from another script, SAME object + prefabs

Hey guys!

I’m having a minor issue. I have three scripts in a prefab and I want them to call functions from others. (Everything is happening inside SAME gameobject).

Let’s say, I want to call from script A some function/variable inside script B/C. I’m getting a little confused, because every thread I look is about calling functions of scripts on different gameobjects. Am I missing some easy things? (And please, remember that everything is happening inside a prefab) :slight_smile:

And another question, if anyone has a minute to spare:
I want for my program to hold 150 different cards, each with it’s own effects, power, health and so on. I tried to solve this with prefabs, but now I don’t know which is the “correct” way of using prefabs. Do I need to make a prefab for every single card (150 different prefabs) or I can make only 2 prefabs (for example one for creatures, one for spells (they will be “blank”)) and when I create a card I just add blank prefab card and immeditly fill the card with correct variables and PICTURE! (Is there any way to set a picture to blank card? So to have picture stored somewhere else and while you fill the card with text and variables, you also put picture inside?).

I hope you understand what I’m asking :slight_smile: My English is not perfect :confused:

Oh, I figured out the first thing about calling scripts :slight_smile:

Anyone mind answering me the second question about prefabs and 150 cards? :smile:

Personally i would create a Card-‘info-template’ (ScriptableObject asset) which stores values, graphics and sounds to define the cards and a Card class (a blank card) which, when a card is used, is loaded with the infos from a specific template asset.

This metheod doesn’t use prefabs?

i think it would be practical to make the blank card a prefab.

Great, thanks :slight_smile:

ScriptableObject asset must be bought?

No :slight_smile:
This should help Introduction to Scriptable Objects - Unity Learn
Unity - Scripting API: ScriptableObject