I have Player prefab with script Player
Also I have GameController prefab with script TouchMove. This is TouchMove code:
public class TouchMove{
[SerializeField] Player player;
.....
}
So TouchMove has player object as a component, which I attach through unity inspector. TouchMove script is responsible for player movement. That is why it neads the player object.
Also I have a lot of scenes and each one contains GameController and Player objects. When I modify the GameController or Player components I wanted the all game objects at the all scenes to be updated. That is why I decided to create prefabs: GameController prefab and Player prefab.
In inspector I added Player prefab to GameController prefab because TouchMove of GameController requares player object.
But after it when I run the game the player script gets not active. I mean that I get unable to move player in the game. (the player script gets not working) This problem solves if I attach Player to GameController as just game objects (not the prefabs or without prefabs)
So, my questions:
- why player scripts gets not working if I attach it with prefabs and it works if I attach just as game objects (without prefabs)
- Is it possible to link two prefabs in the way I described?