C# and prefabs

Sorry, I’ve been searching the forums and can’t find an answer to this. When using Javascript, if I have a “global” variable in the script, that variable is accessible as a property from the editor, and I can assign a prefab to later be instantiated. Like so:

var effect : GameObject;

function play_effect() {
    Instantiate(effect, ...);
}

However, I can’t seem to get this to work in C#. Is there any way I can do this? I’ve tried static member variables, namespace enclosures, you name it. I’m assuming there’s something simple I need to do, but there’s just a lack of C# tutorials out there.

Thanks! :slight_smile:

Jeff M.

Do you have the variable labeled as public? The inspector won’t pick up variables that aren’t public:

public GameObject effect;

I believe I covered this in the programming tutorials:
http://www.unifycommunity.com/wiki/index.php?title=Programming_Chapter_2#Scope_Modifiers

PS: Technically the variable in JavaScript isn’t global, it’s just a member variable.

Thanks! I knew it would be simple enough. And, yes, I know about the JS variable not being global (hence putting it in “quotes”). :wink:

Thank you, again.

Jeff M.

Searching on google for C# info and tutorials can help you a lot too btw. So there are a lot of C# tutorials actually :wink:

Here is a useful one off the top of my head: About US | Award-Winning Software Development Company

-Jeremy