Esempio n. 1
0
        private void OnGUI()
        {
            if (_dataRowCreateTypes == null || _dataRowCreateTypes.Length == 0)
            {
                EditorGUILayout.HelpBox($"没有找到数据行创建类型的实现,请增加{typeof(IDataRowCreate).AssemblyQualifiedName}的实现", MessageType.Warning);

                return;
            }

            _selectIndex   = EditorGUILayout.Popup(new GUIContent("DataRowType:"), _selectIndex, _dataRowCreateTypes);
            _extensionName = EditorGUILayout.TextField("Extension:", _extensionName);
            if (GUILayout.Button("Create", GUILayout.Height(50)))
            {
                if (_selectIndex < 0)
                {
                    Debug.LogError("创建失败,没有选择需要创建的DataRow");
                    return;
                }
                var folderPath = EditorUtility.OpenFolderPanel("保存路径", _folder, "");

                if (string.IsNullOrEmpty(folderPath))
                {
                    Debug.LogWarning("创建失败,取消了创建");
                    return;
                }

                EditorPrefs.SetString(_createTableRowKey, folderPath);

                System.Type createType = Utility.Assembly.GetType(_dataRowCreateTypes[_selectIndex]);
                var         create     = (IDataRowCreate)Activator.CreateInstance(createType);
                var         fileName   = _getFileName(create);
                File.WriteAllText(Path.Combine(folderPath, $"{fileName}.{_extensionName}"), create.Create());
                AssetDatabase.Refresh();
                OpenFolder.Execute(folderPath);
            }
        }
Esempio n. 2
0
 public static void OpenFolderDataPath()
 {
     OpenFolder.Execute(ProtoFilesPath);
 }