I want to have classic class in C#, like class Something() { bla bla bla } and then in any script type Something myObject = new Something;
One thing I did is making a new script but it starts with:
using UnityEngine;
using System.Collections;
public class Something: MonoBehaviour
is this mandatory for all Unity3d classes?
Also, when I put Something myObject = new Something it says in the console “You are trying to create a MonoBehaviour using the ‘new’ keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor()”
Of course you can create your own classes. And since 5.0 structs!
Unity does not allow you to create MonoBehaviour, you must use AddComponent as it is said in the console.
When you create a C# script from Unity, Unity will look at (On Windows) C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt
It is the template of all new C# script. It just a placeholder, you can do what you want in it, hell yeah!
public class Something: MonoBehaviour {…}
Means your class Something inherit from MonoBehaviour. If you want to make a simple class, just remove the inheritance by writing public class Something {...}!
Remember : to have a class being a component to add to GameObjects, you need it to inherit from MonoBehaviour !