Search Unity

Question error CS1038 #endregion directive expected, how to fix?

Discussion in 'Editor & General Support' started by JustAGoodChair, Dec 6, 2022.

  1. JustAGoodChair

    JustAGoodChair

    Joined:
    Dec 5, 2022
    Posts:
    13
    Hi, I've currently came across an error CS1038 and I've searched on YouTube and not found a single fix for this error and I'm new to c# and unity and not got a single clue to fix at first i thought i just needed to add a ; to the end but i guess not

    upload_2022-12-6_17-20-7.png
    it's on my very last line right after the } for namespace
     
  2. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    497
    We would need you to post your code for us to really help. But it sound like you have
    #region
    in your code but no corresponding
    #endregion
     
  3. JustAGoodChair

    JustAGoodChair

    Joined:
    Dec 5, 2022
    Posts:
    13
    upload_2022-12-6_17-31-7.png
    upload_2022-12-6_17-31-28.png
     
  4. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    497
    Please do not post screenshots of code. Use code tags, like the forum guidelines says to use.
    However, your problem is exactly what I said.
    You have
    #region
    but no
    #endregion
    . Regions are just like curly brackets, if you open with { you need to close with }, so when you open with #region you need to close with #endregion.
    That defines what gets included in the collapsible code region.
     
  5. JustAGoodChair

    JustAGoodChair

    Joined:
    Dec 5, 2022
    Posts:
    13
    hey I've now got a error CS0116 any idea how to fix it?
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    Again, please do learn to fix your own typos... it's easy, as I posted in the other thread you started:

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.
     
  7. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    497
    Can you give us more than just the error code please? The code is the least helpful thing. There is a full error message, and usually also the line and character number where the issue is - it is the numbers inside the () of the error message.