public void Start() { if (existingTags.Count == 0) { BinaryCardLoader cardLoader = new BinaryCardLoader(); LoadCardCallback loadCardCallback = LoadExistingTag; cardLoader.LoadCardsAsync(loadCardCallback); } }
public void LoadCards() { ClearAllCards(); if (loadCardCallback == null) { loadCardCallback = LoadCard; } Debug.Log($"Loading cards with {loadCardCallback}"); cardLoader.LoadCardsAsync(loadCardCallback); }
public void LoadCardsAsync(LoadCardCallback callback) { string folderPath = FOLDER_NAME; string[] filePaths = Directory.GetFiles(folderPath, "*" + FILE_EXTENSION, SearchOption.AllDirectories); List <CardData> cards = new List <CardData>(); foreach (string dataPath in filePaths) { CardData cardData = LoadCardData(dataPath); if (cardData != null) { cards.Add(cardData); string dirName = Path.GetDirectoryName(dataPath); byte[] imageBytes = File.ReadAllBytes(Path.Combine(dirName, cardData.GetID() + IMAGE_FORMAT)); cardData.ArtTexture = new Texture2D(300, 300, TextureFormat.RGBA32, false, false); cardData.ArtTexture.LoadImage(imageBytes, false); cardData.ArtTexture.Apply(); callback(cardData); } } }
public void Start() { loadCardCallback = LoadCard; }