How to expose variables

So I’m working on a project with a large enough scale that I have a dedicated level designer. He wants access to all of the variables I can give him but he cannot read code.

I know with Javascript you can expose variables but almost all of my code is in C# due to use of plugins. How can I expose variables in C#?

Thanks!

Hi TimeIsAParallax,

All you have to do is include the word public in front of your variable.

So something like:

public int myInt;

Hope this helps,
Nathan

Oops! my bad I should have been more clear with my question. Is there a way to expose variables in C# scripts to the Inspector in Unity? Basically he wants control on things like rates and some values in AI.

Thanks!

Hi timeisaparallax,

Here is probably a better piece of code showing this:

The variable myInt will be exposed to the inspector :slight_smile:

public class MyCoolCSharpClass : MonoBehaviour
{
     public int myInt;

     ........ Other functions, variables, etc...
}

Hope this helps,
Nathan

wow my bad again. You had it the first time I just was looking at my scripts in the Inspector instead of my scripts attached as components on my game objects.

Thanks Nathan for all your patience and help with someone getting used to Unity.

No problemo. I’m glad to help where I can :slight_smile:

I’ve been getting used to the whole C# thing lately myself and I have to say I like JScript a lot better, haha… darn plugins :slight_smile:

Good luck with everything timeisaparallax!