|
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");
(comments are locked)
|
|
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:
To find transform you can use this: "Transform.Find" If you want more info, type Find in the unity script reference. Happy coding.
(comments are locked)
|

ok, i find a way for transform:
GameObject.Find("something").transform;
i'm waiting for audiosource and texture
An audio source is attached to a GameObject, so you can just search for that GO.
ok,but if i try to find the gameobject that is audiosource..
InvalidCastException: Cannot cast from source type to destination type.
First you need to find the GameObject. Then get that GO's Component AudioSource
Mind posting the line(s) you are getting error(s) from, then we can explain whats wrong and how to remedy
I do not need the audiosource object, but the object itself.
i've this script
var AudioObject:AudioSource;
function OnTriggerEnter(collision: Collider){
}
i want to change with another script the var AudioObject.