“Script file name does not match the name of the class defined in script”
In the first time, I successfully dragged the C# script to my object, but “C# Help, Script file name does not match the name of the class defined in script” appeared in the debug box while running.Then when I tried dragging again, the error box popped.
My class name and the script name are identical.BTW I’m using c# to try SerialPorts
Here is the code:
using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.IO.Ports;
namespace System.IO.Ports
{
public class mySerial : MonoBehaviour {
SerialPort sp;
// Use this for initialization
void Start () {
sp = new SerialPort ();
}
// Update is called once per frame
void Update () {
print(sp.PortName);
}
}
}