- Home /
inspector isnt showing scripts
i have little problem with unity
Iam new to unity so it could be obvious. As you can see in the picture i cant see or change the variables in the script even though they are public. Please Help.
Thank you in advance
Without your script code we can't deter$$anonymous$$e what's wrong.
ok first thanks for trying to help me, here is a script
using UnityEngine; using System.Collections;
public class CameraControl : $$anonymous$$onoBehaviour {
Transform Target;
double Distance = -10;
double lift = 1.5;
// Update is called once per frame
void Update () {
transform.position = Target.position;
}
}
but in unity its showing only this :
P.s. when i first instaled unity it was normal so it might be setting or something and i tried reinstalling it
Answer by vexe · May 10, 2014 at 06:31 PM
That's because your variables are non public (private) To make a field visible in the inspector, it has to play nice with Unity's serialization. So you either do:
public Transform Target;
public double Distance = -10;
public double lift = 1.5;
But it's a bad habit to make all fields public, unless you know what you're doing. However; making them private will tell unity not to serialize them unless you markup with [SerializeField], so:
[SerializeField]
private Transform Target;
[SerializeField]
private double Distance = -10;
[SerializeField]
private double lift = 1.5;
Keep in mind, something being visible in the inspector is a side effect to serialization. Which means, if something doesn't serialize, it won't show up in the inspector.
Edit: as suggested above by @JasperFlick, use floats instead of doubles.
Answer by Jasper-Flick · May 10, 2014 at 06:29 PM
Your variables aren't public. You have specified no access modifier, which means they are internal (should be private) by default. Explicitly declare them as public. Also, better use float instead of double, as floats are used everywhere in Unity while doubles aren't.
Beat me to it :P - +1 For mentioning floats, I had that in $$anonymous$$d but forgot to.
Except that this is wrong, they are not internal by default or they would be accessible from any other scripts in the project, they are private by default.
Thanks for the correction, edited. Top level types are internal by default, the rest private.