- Home /
Drag and Drop error
OK, I am doing a C# script about dragging objects from the files to a box(drag and drop files), but the problem is that when I copy this script and save it I get 2 erros saying me:
Assets/Standard Assets/File.cs(5,47): error CS0246: The type or namespace name `DragEventArgs' could not be found. Are you missing a using directive or an assembly reference?
So I don't know what exactly is saying(I dont know what is the error) so I decide to investigate and I found I have to put System.Windows.Forms;(but I am not sure if is that) but I save it and gives me an error that that word dosent exist. Here is the script I copy:
using UnityEngine; using System.Collections; using System; public class File : MonoBehaviour { private void textBox1_DragEnter(object sender,DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; }
private void textBox1_DragDrop(object sender,DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var objPaths = (string[])(e.Data.GetData(DataFormats.FileDrop)); if (objPaths != null && objPaths.Length > 0 && File.Exists(objPaths[0])) { MessageBox.Show(string.Format("Filename: {0}", objPaths[0])); using (TextReader tr = new StreamReader(objPaths[0])) textBox1.Text = tr.ReadToEnd(); } } } }
So please could some one point me in the right direction of I need to do to solve this problem.
Thanks.. In advance.
Answer by _Petroz · Jan 14, 2011 at 04:49 AM
That does not really look like Unity code. A google search for DragEventArgs turned up this: http://msdn.microsoft.com/en-us/library/system.windows.forms.drageventargs.aspx?PHPSESSID=ev0v34i8u80gkmn37sd8r65363
That seems to indicate that the class is in the System.Windows.Forms namespace.
Answer by tylo · Jan 14, 2011 at 03:19 AM
I'm not certain, but you may need to have
using UnityEditor;
good point but is not that I added and the error still there :(