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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

public class NewBehaviourScript : MonoBehaviour?

Discussion in 'Scripting' started by Deleted User, Dec 8, 2015.

  1. Deleted User

    Deleted User

    Guest

    public class NewBehaviourScript : MonoBehaviour

    Can I delete MonoBehaviour part out of my scripts and use just straight C# Language to program my scripts to use with unity engine?
     
  2. Deleted User

    Deleted User

    Guest

    Answered My own question by playing around. The answer is no you can't. You have to have :MonoBehaviour in your class to be able to use the script in unity engine.
     
  3. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    This isn't entirely true. You can remove MonoBehaviour, but not if you want to utilize anything that exists inside MonoBehaviour, nor if you want to be able to attach the script to a GameObject.
     
    Deleted User and Zaladur like this.
  4. Deleted User

    Deleted User

    Guest

    Ok that make sense. So what is the point in using visual studio 2015 community environment instead of the mono development environment then?
     
  5. 3zzerland

    3zzerland

    Joined:
    Oct 31, 2014
    Posts:
    42
    There are advantages to both. You don't have to use either, however. This comes more to preference than anything else. For example, I use Script Inspector 3 (can be found on the Asset Store).
     
    Deleted User and DRRosen3 like this.
  6. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,796
    Buy yourself a copy of Resharper for Visual Studio, learn all the keyboard shortcuts and you will see a HUGE DIFFERENCE in your productivity and will never consider any other editor again.
     
    Deleted User likes this.
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    MonoBehaviour has nothing to do with MonoDevelop. MonoDevelop has nothing to do with the Mono runtime. The Mono runtime has nothing to do with MonoBehaviour. Just like the language called JavaScript by Unity has nothing to do with the language called JavaScript used on the web. And neither have anything to do with the language called Java used for applications. Computer programmers in general have a habit of just grabbing whatever word is lying around, and not checking if anybody else is using the word.

    The class that attaches directly to GameObjects is called MonoBehaviour. Anything that attaches to a GameObject must be a MonoBehaviour. On the other hand anything that doesn't attach to a GameObject shouldn't be a MonoBehaviour.
     
    Deleted User likes this.
  8. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    Because the ": MonoBehaviour" has nothing to do with the IDE you use. And has entirely to do with what class type you want to inherit from.

    MonoBehaviour is the type that custom component inherit from, so to attach to a GameObject as a component, you need to inherit from MonoBehaviour (or subclass there of).

    The IDE is about the development environment you feel more comfortable in. MonoDevelop is a free open source product that works on Windows, Mac OSX, and Linux.

    Visual Studio on the other hand isn't exactly free, and only works on Windows. Before VS2015, the free version (Visual Studio Express) didn't support plugins, so getting the debugger to connect to Unity and to synchronize required a paid version. Now with VS2015 Community Edition, a free version exists that supports plugins, and Microsoft bought up a company that made the "Unity Tools for Visual Studio" plugin as well:
    https://www.visualstudio.com/en-us/features/unitytools-vs.aspx

    With this, Visual Studio has become a viable option for users looking for free dev tools.

    And it's a much more mature development environment than MonoDevelop... of course this doesn't necessarily make it objectively better, as that's a subjective opinion. Both Visual Studio and MonoDevelop have their quarks, and some may prefer one over the other.

    But at the end of the day they both work as an IDE to develop code against the .net/mono frameworks with C#.
     
    Deleted User likes this.