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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

An object reference is required to access non-static member

Discussion in 'Scripting' started by jsull1, May 18, 2018.

  1. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Can anyone explain to me in human words why this script isn’t working?
     

    Attached Files:

  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Because it's not Unity related.

    But if you just want to know your error. An instance of a class is required to access a non-static member. You need a variable to access through that variable something that is not declared as static.
     
  3. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    It’s for a unity game, I’m just trying it on a phone application while I’m at work, would like work on Monodevelop??
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Updated my post to try to make it more understandable.
    No, it wouldn't. but you wouldn't have a static Main in a Unity script. Nor would you have Console.WQriteLine stuff normally either. If you aren't sure about static, you probably wouldn't use it normally.
     
  5. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,874
    You really need to go follow some of the tutorials on the website here. Just using monodevelop wont magically make this non unity standard app run in unity. That just is not how engines, compilers, linkers etc work.
     
  6. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Okay I’ll go check out some more tutorials, I’m just trying to experiment with c# on my phone, I didn’t know it’d be different
     
  7. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Are there any apps out there that I can practice with, that would be helpful for me learn c# for unity??
     
  8. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,383
  9. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Okay sweet, these tutorials are much better than what I’ve been using