public void OpenAssetFileInAseprite(DefaultAsset asset) { var assetPath = AssetDatabase.GetAssetPath(asset); var name = Path.GetFileNameWithoutExtension(assetPath); AsepriteImporter.OpenFileInAseprite(_asepritePath, GetBasePath(assetPath), name); }
// parses a JSON file and creates the raw data for ImportedAnimationSheet from it private ImportedAnimationSheet CreateAnimationSheetFromJSON(string basePath, string name, PreviousImportSettings previousImportSettings) { string textAssetFilename = GetJSONAssetFilename(basePath, name); TextAsset textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(textAssetFilename); if (textAsset != null) { JSONObject jsonObject = JSONObject.Parse(textAsset.ToString()); ImportedAnimationSheet animationSheet = AsepriteImporter.GetAnimationInfo(jsonObject); if (animationSheet == null) { return(null); } animationSheet.previousImportSettings = previousImportSettings; animationSheet.name = name; animationSheet.basePath = basePath; animationSheet.SetNonLoopingAnimations(sharedData.animationNamesThatDoNotLoop); // delete JSON file afterwards AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(textAsset)); return(animationSheet); } else { Debug.LogWarning("Problem with JSON file: " + textAssetFilename); } return(null); }
public ImportedAnimationSheet ImportSpritesAndAnimationSheet(string assetPath, string additionalCommandLineArguments = null) { if (assetPath == null) { return(null); } if (sharedData == null) { LoadUserConfig(); } string fileName = Path.GetFileName(assetPath); string assetName = Path.GetFileNameWithoutExtension(fileName); string basePath = GetBasePath(assetPath); // we analyze import settings on existing files PreviousImportSettings previousAnimationInfo = CollectPreviousImportSettings(basePath, assetName); if (AsepriteImporter.CreateSpriteAtlasAndMetaFile(_asepritePath, additionalCommandLineArguments, basePath, fileName, assetName, _sharedData.saveSpritesToSubfolder)) { AssetDatabase.Refresh(); return(ImportJSONAndCreateSprites(basePath, assetName, previousAnimationInfo)); } return(null); }
private ImportedAnimationInfo ImportJSONAndCreateAnimations(string basePath, string name) { string imagePath = basePath; if (_saveSpritesToSubfolder) { imagePath += "/Sprites"; } string imageAssetFilename = imagePath + "/" + name + ".png"; string textAssetFilename = imagePath + "/" + name + ".json"; TextAsset textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(textAssetFilename); if (textAsset != null) { // parse the JSON file JSONObject jsonObject = JSONObject.Parse(textAsset.ToString()); ImportedAnimationInfo animationInfo = AsepriteImporter.GetAnimationInfo(jsonObject); if (animationInfo == null) { return(null); } animationInfo.basePath = basePath; animationInfo.name = name; animationInfo.nonLoopingAnimations = _animationNamesThatDoNotLoop; // delete JSON file afterwards AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(textAsset)); CreateSprites(animationInfo, imageAssetFilename); CreateAnimations(animationInfo, imageAssetFilename); return(animationInfo); } else { Debug.LogWarning("Problem with JSON file: " + textAssetFilename); } return(null); }
public ImportedAnimationInfo CreateAnimationsForAssetFile(string assetPath) { if (!IsValidAsset(assetPath)) { return(null); } string fileName = Path.GetFileName(assetPath); string assetName = Path.GetFileNameWithoutExtension(fileName); string basePath = GetBasePath(assetPath); // we analyze import settings on existing files PreviousImportSettings previousAnimationInfo = CollectPreviousImportSettings(basePath, assetName); if (AsepriteImporter.CreateSpriteAtlasAndMetaFile(_asepritePath, basePath, fileName, assetName, _sharedData.saveSpritesToSubfolder)) { AssetDatabase.Refresh(); return(ImportJSONAndCreateAnimations(basePath, assetName, previousAnimationInfo)); } return(null); }
private ImportedAnimationInfo CreateAnimationsForAssetFile(DefaultAsset droppedAsset) { string path = AssetDatabase.GetAssetPath(droppedAsset); string name = Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(droppedAsset)); string lastPart = "/" + name + ".ase"; // check if this is an ASE file (HACK!) if (!path.Contains(lastPart)) { return(null); } path = path.Replace(lastPart, ""); if (AsepriteImporter.CreateSpriteAtlasAndMetaFile(_asepritePath, path, name, _saveSpritesToSubfolder)) { AssetDatabase.Refresh(); return(ImportJSONAndCreateAnimations(path, name)); } return(null); }