Okay I have two or more scripts in separate objects that do the same.
(Complex checking inventory system checking if the clicked Button has item in it)
What I need to do is make one static function containing that huge code.
And now my problem is:
void myFunction(script scriptName, int i)
{
if(script.inventorySlot[i] == texture_apple) //texture apple is assigned texture
{
just do something;
}
}
So you see my problem is that multiple scripts needs to pass themselves or other scripts into myFunction() as script parameter.
How to do that?
This doesn`t work as well
void myFunction(gameObject Object, int i)
{
if (Object.GetComponent() != null)
target = Object.GetComponent();
if (Object.GetComponent() != null)
target = Object.GetComponent();
if(target.inventorySlot[i] == texture_apple) //texture apple is assigned texture
{
just do something;
}
}
↧