anonymous-dev
anonymous-dev

Reputation: 3499

Unity3d c# - Variable visible in inspector but not for other classes

Is it possible in Unity3d to make a variable visible in the inspector but not to other classes. I want the variable to be private to other classes but it still needs to be set in the inspector.

Upvotes: 1

Views: 88

Answers (1)

Keiwan
Keiwan

Reputation: 8251

Yes, you can achieve this using SerializeField:

For C#:

[SerializeField] private Type name;

For JavaScript:

@SerializeField
private var name : Type;

Looks like Unity even has a short video tutorial on this topic.

Upvotes: 2

Related Questions