public void addNewEntry(Texture2D texture, string assetPath) { string name = assetPath.Substring(assetPath.LastIndexOf('/') + 1); Rect rect = new Rect(0, 0, texture.width, texture.height); UFTAtlasEntry uftAtlasEntry = UFTAtlasEntry.CreateInstance <UFTAtlasEntry>(); uftAtlasEntry.assetPath = assetPath; uftAtlasEntry.textureName = name; uftAtlasEntry.canvasRect = rect; uftAtlasEntry.texture = texture; uftAtlasEntry.uftAtlas = this; atlasEntries.Add(uftAtlasEntry); if (UFTAtlasEditorEventManager.onAddNewEntry != null) { UFTAtlasEditorEventManager.onAddNewEntry(uftAtlasEntry); } sendEventAtlasChanged(); }
public void readPropertiesFromMetadata(UFTAtlasMetadata atlasMetadata) { atlasWidth = (UFTAtlasSize)atlasMetadata.texture.width; atlasHeight = (UFTAtlasSize)atlasMetadata.texture.height; List <UFTAtlasEntry> entries = new List <UFTAtlasEntry>(); foreach (UFTAtlasEntryMetadata meta in atlasMetadata.entries) { UFTAtlasEntry entry = UFTAtlasEntry.CreateInstance <UFTAtlasEntry>(); try{ entry.readPropertiesFromMetadata(meta); entry.uftAtlas = this; entries.Add(entry); }catch (TextureDoesNotExistsException e) { Debug.LogWarning("texture " + e.texturePath + " does not exists exception"); } } this.atlasEntries = entries; this.atlasName = atlasMetadata.atlasName; }