public static T CreateAsset(string _assetPath) { string[] _pathComponents = _assetPath.Split('/'); string _parentFolderPath = _pathComponents[0]; int _pIter = 0; while (++_pIter < (_pathComponents.Length - 1)) { string _currentFolderPath = _parentFolderPath + "/" + _pathComponents[_pIter]; if (!AssetsUtility.FolderExists(_currentFolderPath)) { AssetDatabase.CreateFolder(_parentFolderPath, _pathComponents[_pIter]); } // Update parent folder reference _parentFolderPath = _currentFolderPath; } // Ask Unity to import changes AssetDatabase.Refresh(); // Create the asset T _newAsset = ScriptableObject.CreateInstance <T>(); AssetDatabase.CreateAsset(_newAsset, AssetDatabase.GenerateUniqueAssetPath(_assetPath)); // Save the changes (_newAsset as AdvancedScriptableObject <T>).Save(); return(_newAsset); }
private static bool DecompressValidation() { string _selectedFilePath = AssetsUtility.GUIDToAssetAbsolutePath(Selection.assetGUIDs[0]); string _fileExtension = Path.GetExtension(_selectedFilePath); return(_fileExtension.Equals(".gz")); }
private static void Decompress() { string _zippedFilePath = AssetsUtility.GUIDToAssetAbsolutePath(Selection.assetGUIDs[0]); FileInfo _fileInfo = new FileInfo(_zippedFilePath); DecompressToDirectory(_zippedFilePath, _fileInfo.Directory.FullName, (string _outputMessage) => { Console.WriteLine(_outputMessage); }); }
private static bool CompressValidation() { string[] _guids = Selection.assetGUIDs; if (_guids.Length <= 0) { return(false); } return(Directory.Exists(AssetsUtility.GUIDToAssetAbsolutePath(_guids[0]))); }
private static void Decompress() { #if IO_UNSUPPORTED_PLATFORM Debug.LogWarning("[Zip] Not supported."); #else string _zippedFilePath = AssetsUtility.GUIDToAssetAbsolutePath(Selection.assetGUIDs[0]); FileInfo _fileInfo = new FileInfo(_zippedFilePath); DecompressToDirectory(_zippedFilePath, _fileInfo.Directory.FullName, (string _outputMessage) => { Console.WriteLine(_outputMessage); }); #endif }
public static T GetAsset(string _assetName) { #if !UNITY_EDITOR if (assetGroupFolderName == null) { return(Resources.Load <T>(_assetName)); } else { return(Resources.Load <T>(string.Format("{0}/{1}", assetGroupFolderName, _assetName))); } #else string _assetSavedAtPath = string.Format("{0}/{1}.asset", kRelativePathToAssetsGroup, _assetName); T _scriptableObject = AssetDatabase.LoadAssetAtPath(_assetSavedAtPath, typeof(T)) as T; if (_scriptableObject == null) { // Need to create folder "Assets/Resources", if it doesnt exist if (!AssetsUtility.FolderExists(kRelativePathToResources)) { AssetDatabase.CreateFolder(kAssetsFolderName, kResourcesFolderName); } // Need to create folder "Assets/Resources/Group", if it doesnt exist if (!AssetsUtility.FolderExists(kRelativePathToAssetsGroup)) { AssetDatabase.CreateFolder(kRelativePathToResources, assetGroupFolderName); } // Refresh AssetDatabase.Refresh(); // Create asset T _newAsset = ScriptableObject.CreateInstance <T>(); AssetDatabase.CreateAsset(_newAsset, AssetDatabase.GenerateUniqueAssetPath(_assetSavedAtPath)); // Save (_newAsset as AdvancedScriptableObject <T>).Save(); // Assign reference of newly created asset _scriptableObject = _newAsset; } return(_scriptableObject); #endif }
private static bool DecompressValidation() { string[] _guids = Selection.assetGUIDs; if (_guids.Length <= 0) { return(false); } string _selectedFilePath = AssetsUtility.GUIDToAssetAbsolutePath(_guids[0]); string _fileExtension = Path.GetExtension(_selectedFilePath); if (_fileExtension == null) { return(false); } return(_fileExtension.Equals(".gz")); }
private static void Compress() { string _curSelectedFolder = AssetsUtility.GUIDToAssetAbsolutePath(Selection.assetGUIDs[0]); // Generate output file path if (Directory.Exists(_curSelectedFolder)) { DirectoryInfo _curDirectoryInfo = new DirectoryInfo(_curSelectedFolder); // Set info string _compressedFileName = _curDirectoryInfo.Name + ".gz"; string _parentDirectoryPath = _curDirectoryInfo.Parent.FullName; // Output file name string _outputFileAbsolutePath = Path.Combine(_parentDirectoryPath, _compressedFileName); // Now compress the file CompressDirectory(_curSelectedFolder, _outputFileAbsolutePath, (string _outputMessage) => { Debug.Log(_outputMessage); }); } }