Click here to Skip to main content
15,794,275 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm a beginner learning from youtube. I followed the tutorial code exactly but got this error.
error CS1002: ; expected

my code:
    Debug.Log("Unable to find main camera");

It says the error is at the period between the camera and the main. I don't know how to resolve

What I have tried:

-removing the ".main" portion
-place semicolons after the statement
Updated 5-Jul-23 18:58pm
Graeme_Grant 5-Jul-23 22:33pm    
There is not enough code here to see why. It could be missing earlier in the method to cause the error.
Sandeep Mewara 6-Jul-23 0:06am    
If you share the entire code, probably it would be easier to share. Right now, somwehere you are missing a semicolon.

1 solution

We can't tell - it's likely to be something just above the code fragment you show that is causing the error, and we can't see that. This may help: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^]

BTW: do yourself a favour and don't learn how to code from YouTube: I'm sure there are good tutorials out there, but most are created by people who don;t know how to teach, don't know how to make a video, and often don't know how to code either. Remember that Youtube is about money: likes and subscribes are currency!

Go on a course, or get a book - Adison Wesley, Wrox, and MS Press all do good ones - and follow it from start to finish doing all the exercises. You will get a much better result than watching youtube!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900