Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Singleton Problems

Discussion in 'Scripting' started by Krispinyoo98, Feb 6, 2020.

  1. Krispinyoo98

    Krispinyoo98

    Joined:
    Feb 6, 2020
    Posts:
    3
    Hello good, I comment, while I was doing my game I created some Singleton, but trying to use them in other scripts gave me an error.

    error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,151
    Show your script with the error and the error line, while I know what the error means we can't exactly tell you where it is if we don't see the code.

    And use code tags.
     
  3. Krispinyoo98

    Krispinyoo98

    Joined:
    Feb 6, 2020
    Posts:
    3
    Sorry, i will use it.
     

    Attached Files:

  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,151
    Still not helpful, but you can clearly see a red line under part of your script. I'm guessing KillPlayer is a method, which means you need to add the () after it.

    Code (CSharp):
    1. Player.sharedInstance.KillPlayer();
     
    Krispinyoo98 likes this.
  5. Krispinyoo98

    Krispinyoo98

    Joined:
    Feb 6, 2020
    Posts:
    3
    It was that. I was going crazy, really thank you very much and i'm sorry for providing you so little information.