why can not I put something on the scene in a prefab?
I just can not drag something that's on the scene to the prefab. I'm trying to drag a Panel into a script that should get this Panel.
why can not I put something on the scene in a prefab?
public class ScriptP : MonoBehaviour {
public FixedTouchField TouchField;
void Start()
{
}
// Update is called once per frame
void Update()
{
var fps = GetComponent<RigidbodyFirstPersonController>();
fps.mouseLook.LookAxis = TouchField.TouchDist;
}
}
how can I "Drag panel to script as soon as I start the game"?
I am now adapting the script to multiplayer so I need to put the panel in the prefab of the player
Answer by tormentoarmagedoom · Sep 17, 2018 at 11:23 AM
Good day.
As i see you know, If you declare a public variable y ou can assign the value or object from the scene via inspector.
But they need to be the same type. If you declare a Camera variable, you can only atach objects with a camera component. If you declare a Canvas variable, you can only attach a object with a canvas component.
I'm not sure what is a FixedTouchField (i supose is something about mobile inputs) So its not something you can assign, its not an object or a component. What you expect to assign in this variable?
You can always declare a GameObject variable (so can attach any gameobject) and via code reach the compoenent you want from taht object.
Good bye!
Your answer
![](https://koobas.hobune.stream/wayback/20220612174731im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Photon doesn't Spawn Player 0 Answers
cant acces script bool on serialize view 0 Answers
Photon team assignment 1 Answer
PHOTON FindFriends (222) not allowed on current server (GameServer) 0 Answers