private static EanFile ReadInfoFromFile(string path) { if (!File.Exists(path)) { Debug.LogError("wrong ean file path!" + path); return(null); } FileStream fs = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(fs); EanFile ean = new EanFile(); ean.Load(br, fs); fs.Close(); return(ean); }
public void BuildFromFile(string path, int index, float uvTime, Texture mainTex) { if (!File.Exists(path)) { Debug.LogError("wrong ean file path!"); return; } FileStream fs = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(fs); EanFile ean = new EanFile(); ean.Load(br, fs); fs.Close(); EanAnimation eanim = ean.Anims[index]; frames = new Vector2[eanim.TotalCount]; UVDimensions = new Vector2[eanim.TotalCount]; int cols = eanim.TileCount; int rows = (eanim.TotalCount + cols - 1) / cols; int cellCount = 0; int tWidth = mainTex.width; int tHeight = mainTex.height; //Vector2 Oft = new Vector2((float)eanim.MipWidth / tWidth, (float)eanim.MipHeight / tHeight); for (int row = 0; row < rows; ++row) { for (int col = 0; col < cols && cellCount < eanim.TotalCount; ++col) { Vector2 cellSize = Vector2.zero; cellSize.x = (float)eanim.Frames[cellCount].Width / tWidth; cellSize.y = (float)eanim.Frames[cellCount].Height / tHeight; frames[cellCount].x = (float)eanim.Frames[cellCount].X / tWidth; frames[cellCount].y = 1f - (float)eanim.Frames[cellCount].Y / tHeight; UVDimensions[cellCount] = cellSize; UVDimensions[cellCount].y = -UVDimensions[cellCount].y; ++cellCount; } } }
public void BuildFromFile(string path, int index, float uvTime, Texture mainTex) { if (!File.Exists(path)) { Debug.LogError("wrong ean file path!"); return; } FileStream fileStream = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(fileStream); EanFile eanFile = new EanFile(); eanFile.Load(br, fileStream); fileStream.Close(); EanAnimation eanAnimation = eanFile.Anims[index]; frames = new Vector2[eanAnimation.TotalCount]; UVDimensions = new Vector2[eanAnimation.TotalCount]; int tileCount = eanAnimation.TileCount; int num = (eanAnimation.TotalCount + tileCount - 1) / tileCount; int num2 = 0; int width = mainTex.width; int height = mainTex.height; for (int i = 0; i < num; i++) { for (int j = 0; j < tileCount; j++) { if (num2 >= eanAnimation.TotalCount) { break; } Vector2 zero = Vector2.zero; zero.x = (float)(int)eanAnimation.Frames[num2].Width / (float)width; zero.y = (float)(int)eanAnimation.Frames[num2].Height / (float)height; frames[num2].x = (float)(int)eanAnimation.Frames[num2].X / (float)width; frames[num2].y = 1f - (float)(int)eanAnimation.Frames[num2].Y / (float)height; UVDimensions[num2] = zero; UVDimensions[num2].y = 0f - UVDimensions[num2].y; num2++; } } }
public void BuildFromFile(string path, int index, float uvTime, Texture mainTex) { if (!File.Exists(path)) { Debug.LogError("wrong ean file path!"); } else { FileStream input = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(input); EanFile file = new EanFile(); file.Load(br, input); input.Close(); EanAnimation animation = file.Anims[index]; this.frames = new Vector2[animation.TotalCount]; this.UVDimensions = new Vector2[animation.TotalCount]; int tileCount = animation.TileCount; int num2 = ((animation.TotalCount + tileCount) - 1) / tileCount; int num3 = 0; int width = mainTex.width; int height = mainTex.height; for (int i = 0; i < num2; i++) { for (int j = 0; j < tileCount; j++) { if (num3 >= animation.TotalCount) { break; } Vector2 zero = Vector2.zero; zero.x = ((float)animation.Frames[num3].Width) / ((float)width); zero.y = ((float)animation.Frames[num3].Height) / ((float)height); this.frames[num3].x = ((float)animation.Frames[num3].X) / ((float)width); this.frames[num3].y = 1f - (((float)animation.Frames[num3].Y) / ((float)height)); this.UVDimensions[num3] = zero; this.UVDimensions[num3].y = -this.UVDimensions[num3].y; num3++; } } } }
public void BuildFromFile(string path, int index, float uvTime, Texture mainTex) { if (!File.Exists(path)) { Debug.LogError("wrong ean file path!"); } else { var input = new FileStream(path, FileMode.Open); var br = new BinaryReader(input); var file = new EanFile(); file.Load(br, input); input.Close(); var animation = file.Anims[index]; frames = new Vector2[animation.TotalCount]; UVDimensions = new Vector2[animation.TotalCount]; int tileCount = animation.TileCount; var num2 = (animation.TotalCount + tileCount - 1) / tileCount; var num3 = 0; var width = mainTex.width; var height = mainTex.height; for (var i = 0; i < num2; i++) { for (var j = 0; j < tileCount && num3 < animation.TotalCount; j++) { var zero = Vector2.zero; zero.x = animation.Frames[num3].Width / (float)width; zero.y = animation.Frames[num3].Height / (float)height; frames[num3].x = animation.Frames[num3].X / (float)width; frames[num3].y = 1f - animation.Frames[num3].Y / (float)height; UVDimensions[num3] = zero; UVDimensions[num3].y = -UVDimensions[num3].y; num3++; } } } }
public void BuildFromFile(string path,int index, float uvTime, Texture mainTex) { if (!File.Exists(path)) { Debug.LogError("wrong ean file path!"); return; } FileStream fs = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(fs); EanFile ean = new EanFile(); ean.Load(br, fs); fs.Close(); EanAnimation eanim = ean.Anims[index]; frames = new Vector2[eanim.TotalCount]; UVDimensions = new Vector2[eanim.TotalCount]; int cols = eanim.TileCount; int rows = (eanim.TotalCount + cols - 1) / cols; int cellCount = 0; int tWidth = mainTex.width ; int tHeight = mainTex.height; //Vector2 Oft = new Vector2((float)eanim.MipWidth / tWidth, (float)eanim.MipHeight / tHeight); for (int row = 0; row < rows; ++row) { for (int col = 0; col < cols && cellCount < eanim.TotalCount; ++col) { Vector2 cellSize = Vector2.zero; cellSize.x = (float)eanim.Frames[cellCount].Width / tWidth; cellSize.y = (float)eanim.Frames[cellCount].Height / tHeight; frames[cellCount].x = (float)eanim.Frames[cellCount].X / tWidth; frames[cellCount].y = 1f - (float)eanim.Frames[cellCount].Y / tHeight; UVDimensions[cellCount] = cellSize; UVDimensions[cellCount].y = -UVDimensions[cellCount].y; ++cellCount; } } }