0

I've created a simple script for application to exit. But I see that MonoBehaviour class which I derived from and Application class (for calling Application.exit() method) are not reachable.

Seems like Visual Studio doesn't know anything about those classes. I've opened my script by double-clicking on it from Unity.

Am I doing something wrong?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ExitScript : MonoBehaviour <- displayed as just text, not the actual class
{
     public void exit()
     {
         Application.quit(); <- can go inside of Application class like it's just text
     }
}
user2620644
  • 521
  • 1
  • 12
  • 25

1 Answers1

0

According to the docs It is Application.Quit() with a capital Q. Since its a Unity method it will always start with a capital. In C# Methods, Classes, and properties are all written LikeThis. While variables are written likeThis. I would also rename you exit method to Exit.

If your MonoBehaviour is not highlighted as a class it would appear that you may have issues with Unity's integration into Visual Studio. Do you have the plugin installed and configured?

Hexagon789
  • 315
  • 2
  • 4
  • 16
  • `Since its a method it will always start with a capital` ... You can handle it however you like it .. but that's the naming convention yes ;) – derHugo May 25 '19 at 16:28
  • @derHugo well since Unity follows C#'s naming conventions all of their methods will always start with a capital. Good catch ill update my answer. :) – Hexagon789 May 25 '19 at 16:33