i use this code:
GameObject.Find(“something”);
there’s a way to use it with audiosource, transform or texture?
something like:
AudioSource.Find(“something”);
or
Transform.Find(“something”);
or
Texture.Find(“something”);
i use this code:
GameObject.Find(“something”);
there’s a way to use it with audiosource, transform or texture?
something like:
AudioSource.Find(“something”);
or
Transform.Find(“something”);
or
Texture.Find(“something”);
It does not work that way, If you want to find components, you need to find the gameobject that has that specific component like the GUItexture,audiosource etc… then get the component with “GetComponent”
and then you can do stuff with it, you only find the objects that hold components, not the components themselves. (sorry for mentioning component so much)
Here is an example:
var Player: GameObject;
function Update(){
Player.FindWithTag (“YourObjectTag”); //Find with a tag
Player.getComponent (Component you
need); //Get the component needed}
To find transform you can use this: “Transform.Find”
If you want more info, type Find in the unity script reference.
Happy coding.