# Error CS0234 and CS0236 in Unity

I'm trying to make a simple button perform an action when pressed. Initially I was using vscode, but as I couldn't solve the problem, I switched to visual studio 2017. For some reason the error persists.

The button has been removed from this link:

https://www.c-sharpcorner.com/article/unity-change-scene-on-button-click-using-c-sharp-scripts-in-unity/

Button code (internet sketch):

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

public class SceneChanger: MonoBehaviour {
public void Scene1() {
}
public void Scene2() {
}
public void Scene3() {
}
}


Button code (my code):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Windows.Forms;

public class botaoJogar : MonoBehaviour
{
public Button btn_Jogar;

void Start()
{
Button btn = btn_Jogar.GetComponent<Button>();
}

{
Debug.Log("You have clicked the button!");
}
}


Image of the construction in unity:

Before, I was able to solve the CS0236 error using the answers from this link:

https://stackoverflow.com/questions/2883505/the-type-or-namespace-name-button-could-not-be-found-are-you-missing-a-using

The answer says to add the line using System.Windows.Forms; to the button code, but for some reason, now in visual studio, this error doesn't go away.

Errors:

Assets\botajogar.cs(4,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

Assets\botajogar.cs(8,12): error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)

Some community links, which I accessed:

https://stackoverflow.com/questions/2883505/the-type-or-namespace-name-button-could-not-be-found-are-you-missing-a-using

https://stackoverflow.com/questions/47412796/system-windows-forms-assembly-reference-in-vs-code

https://stackoverflow.com/questions/46582847/creating-a-windows-forms-application-in-c-sharp-using-dotnet-new

https://stackoverflow.com/questions/40562192/windows-form-application-on-visual-studio-code

https://stackoverflow.com/questions/48496542/forms-does-not-exist-in-the-namespace-system-windows

https://docs.microsoft.com/pt-br/dotnet/csharp/language-reference/compiler-messages/cs0246

I don't know what to do anymore, I feel like I tried to do everything I could, but windows forms simply don't work. Visual studio 2017 has no bugs, just unity.

Installation I did in visual studio 2017:

Nothing in the script you've shown references "Button", so you've either shown us the wrong code, or you've linked a misleading Q&A page/quoted a misleading error unrelated to the root problem.

You do not want to use a Windows Forms button in Unity, because you are not building a Windows Forms application. You're building a Unity game.

You more likely want to use a Unity UI button. That's found in the UnityEngine.UI namespace, as a quick search of the Unity documentation will tell you.

Try using UnityEngine.UI; if you want to reference UI components like buttons.

• I edited the question, added my code and showed an image of the construction in Unity. I will try to do what you said. Sep 18 at 23:54
• Thanks. I made a terrible mistake, confused the unity button with the windows forms button. I could not solve this "problem" ever. Should I delete this question? Or do you think she might be useful to someone? Sep 19 at 0:13
• I don't think it's harmful to leave this question here. Sep 19 at 0:18