m-y
June 15, 2014, 12:18am
1
Hello
i have script
i use it inside another script
i can use it when the cube in the scene
but when i make the cube as prefab
it is not able to use it
can i know what is the solution /.?
that is the code
i am using in the
( Hela Cube )
var HealthScript : HealthBar1 ;
Prefabs cannot link to instanced GameObjects because they are not guaranteed to be there.
You will need to link it in the instanced prefab (after you add it to the scene) or assign it via script, likely in the Awake function.
m-y
June 15, 2014, 12:34am
3
how i can write code like that ?
it is first time to me ? !
m-y
June 15, 2014, 12:34am
4
how i can link to to instanced prefab ?
It would be what you did in the first image, linking it in the scene.
m-y
June 15, 2014, 1:11am
6
can u say it clear
i can’t get what u mean ?
HealthScript = targetObject.GetComponent(HealthBar1);
You would have to acquire the targetObject to do this.