Beispiel #1
0
        private void DrawDragSpace()
        {
            EditorGUILayout.LabelField("请将脚本文件拖到下边区域");
            var sfxPathRect = EditorGUILayout.GetControlRect(GUILayout.Height(100));

            GUI.Box(sfxPathRect, string.Empty);
            // EditorGUILayout.LabelField(string.Empty, GUILayout.Height(185));
            if (Event.current.type == EventType.DragUpdated && sfxPathRect.Contains(Event.current.mousePosition))
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
            }
            if (Event.current.type == EventType.DragPerform && sfxPathRect.Contains(Event.current.mousePosition))
            {
                string path = null;
                if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
                {
                    path = DragAndDrop.paths[0];
                }
                if (DragAndDrop.objectReferences != null && DragAndDrop.objectReferences.Length > 0)
                {
                    if (path != null && path.EndsWith(".cs") || path.EndsWith(".lua"))
                    {
                        focusFileName = DragAndDrop.objectReferences[0].name;
                        focusFilePath = path;
                    }
                }
                if (focusFileName.IsNullOrEmpty())
                {
                    Log.W("Incorrect file");
                    ShowNotification(new GUIContent("Incorrect file (Nonconforming .cs or .lua)"));
                }
                else
                {
                    if (path.EndsWith(".cs"))
                    {
                        focusFileType = QEType.CSharp;
                        if (GetFocusFileType(focusFileName) == null)
                        {
                            var msg = "File Name : <color=#FF0000>{0}</color>\nmake sure .cs file is correct (name same as TypeName)";
                            Log.W(string.Format(msg, focusFileName));
                            ShowNotification(new GUIContent(string.Format("Incorrect  {0}", focusFileName)));
                            ClearFocusFile();
                        }
                    }
                    if (path.EndsWith(".lua"))
                    {
                        focusFileType = QEType.Lua;
                    }
                }
            }
        }
Beispiel #2
0
 private void ClearFocusFile(string errorMsg = null)
 {
     if (!errorMsg.IsNullOrEmpty())
     {
         Log.W(errorMsg);
         ShowNotification(new GUIContent(errorMsg));
     }
     focusFileName = string.Empty;
     focusFilePath = string.Empty;
     focusFileType = QEType.None;
                 #if LUA_KIT
     luaVeiwer.ClearLuaState();
                 #endif
 }