#Alovon Unity Problem (Button Hiding)
1 messages · Page 1 of 1 (latest)
So where do you call this function
Well how can you call on a function from another script inside another script
as that is the only way to "Call" it based on how Unity sees it atm
What?
I don't even know what you're talking about. Drag what in where?
I just want to know where you are calling this function
I don't see anywhere to call the function in the way you are asking
that is the problem
as the other functions here just "work"
without specific calls inside themsleves
I am not giving you anywhere to call it. I haven't done that yet because I can't until I know where you are calling it currently
Nowhere
at least nothing that I can see
Okay, so there's why it's not doing anything
When do you want to call it
That is inside the PlayerController script
and is the "GameEnd" state more or less
Okay, so you want to call this function inside of SetCountText?
If I could, yeah
Then do so
yeah problem is it won't let me call the function like I can the value of count
Because the function is defined in another class ?
Yeah, which is the hangup here
I can't call the function within itself seemingly if I set it to inactive by default
So you need a reference to a instance of Button controller
You need to reference the ButtonController
You have to tell it which ButtonController you want to use
Still learning Unity Scripting, so how do I acess instances of scripts?
Usually by making a public field and dragging it in
You define a public ButtonController buttCintroller; at the top
Then drag the button cont component in there and then you can go buttController.MyCoolMethod()
Digi send him the referincing 101 video
Im on my phone and cant
A few basic ways to get references in Unity.
Directly-
GetComponent 0:38
/GetComponentInChildren
/GetComponentInParent
Public Variable- 3:00
Find- 5:01
Find 5:39 (by name)
FindWithTag 6:14 (by tag)
FindObjectOfType 6:51 (by component)
Interaction- 7:15
OnCollisionEnter
/OnTriggerEnter
Does this object have a Button component on it
it itself is a button, but should I just switch it to GameObject?
the button is the object that the ButtonController script should be influencing
If you just want it to activate the object this script is on get rid of that variable entirely and just call SetActive on its own gameObject
No no
You need to reference ButtonController
Inside Player something
So you can button controllers method
From player
It looks like it is
Oh wait, it's getting the ButtonController from itself
is this the same object?
Its private and he is trying to get button controller fro the player
Watch the video
About public fields
Not just the first thing you see
yeah that video has all the elements tied to the same object
the tank one
the UI Count, TankFlash.etc are all tied to the Tank Object
I'm trying to make the actions of one object influence another
that isn't onColide like with the cubes that incriment points
Did you watch the second section of the video
With the ammo display
There's even a handy little infographic in case reading is too hard
Yeah that's more or less what I am doing for the text
it just won't work with the button
Why not
Do you have a script named ButtonManager?
So no
GameObject is not a component.
Also is ButtonController on the object you want to activate?
yes the script is on the button itself
Then why do you have an entire variable to just refer to itself
Why does the variable WinButton exist at all