private void AddFile(string path) { if (string.IsNullOrEmpty(path)) { return; } string objectTypeName = Regex.Replace(Path.GetFileNameWithoutExtension(path), "([A-ZА-Я])", " $1"); string fileName = ObjectBuildHelper.ConvertToNiceName(objectTypeName).Trim(); CreateObjectModel model = new CreateObjectModel() { Path = path, ObjectName = fileName .Replace(" ", "") .Replace("(", "") .Replace(")", "") .Replace("-", ""), LocalizedName = fileName, LocalizedNameRU = fileName, IsGrabbable = true, IsPhysicsOn = true }; _modelsList.Add(model); }
static void Init() { var window = GetWindow <CreateObjectWindow>(true, "Create object", true); window.minSize = MinWindowSize; window.maxSize = MaxWindowSize; window.Show(); _existingObjectNames = ObjectBuildHelper.GetExistingObjectsNames(); if (Selection.activeGameObject != null) { _gameObject = Selection.activeGameObject; string objectTypeName = Regex.Replace(_gameObject.name, "([A-ZА-Я])", " $1"); objectTypeName = ObjectBuildHelper.ConvertToNiceName(objectTypeName).Trim(); _objectClassName = objectTypeName .Replace(" ", "") .Replace("(", "") .Replace(")", "") .Replace("-", ""); _localizedName = objectTypeName; _localizedNameRU = objectTypeName; } AuthorSettings.Initialize(); _authorName = AuthorSettings.Name; _authorEmail = AuthorSettings.Email; _authorUrl = AuthorSettings.Url; _scrollPosition = Vector2.zero; }
private void AddFolder(string path) { DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] files = dirInfo.GetFiles(); foreach (FileInfo file in files) { string ext = file.Extension.Replace(".", ""); if (!AvailableFileFormats.Any(x => string.Equals(x, ext, StringComparison.OrdinalIgnoreCase))) { continue; } string objectTypeName = Regex.Replace(file.Name, "([A-ZА-Я])", " $1"); string fileName = ObjectBuildHelper.ConvertToNiceName(Path.GetFileNameWithoutExtension(objectTypeName)).Trim(); CreateObjectModel model = new CreateObjectModel() { Path = file.FullName, ObjectName = fileName .Replace(" ", "") .Replace("(", "") .Replace(")", "") .Replace("-", ""), LocalizedName = fileName, LocalizedNameRU = fileName, IsGrabbable = true, IsPhysicsOn = true }; //Will prevent .meta files from getting into the import window if (!Regex.IsMatch(file.FullName, @".+\.meta$")) { _modelsList.Add(model); } } }