- Home /
Gameobject variable on C#
Just a really quick question over how I would write a gameobject place holder in C#. I am pretty much only java but for this certain small project I am using c# just to experiment. Anyway so in JS my variable looks like this. Camera1 : GameObject; So how would I convert that so it works in C#?
Answer by The Kracken · Dec 07, 2013 at 01:32 AM
GameObject Camera1;
stick public before it if you want to assign in the editor.
Alright it worked but it lead to another error, so how would I properly make a boolean in C#. $$anonymous$$y current code is Camera1 = false;
To check if the camera exists or is assigned use:
if(Camera1 != null)
Ok, but how would I set it to be active or inactive? With my current code it says it "cannot convert type 'bool' to Unityengine.GameObject"
Ahh ok every game object has an enabled property. So if(Camera1.enabled) would work for you.
Your answer
Follow this Question
Related Questions
Create a guitexture When clicked on 3d text? 0 Answers
js to C# converstion Problem 3 Answers
.js to C# conversion 4 Answers
Can you Help me about how to get the variable of Java Script to C# script? 2 Answers
Convert js to C# Serializer problem 1 Answer