Skip to content

Commit 000f535

Browse files
author
Andrew Eiche
committed
Modified readme and added link to HTML root director in reader
1 parent 9b08b71 commit 000f535

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
# UnityEPubReader
2-
EPub reader for Unity3d
2+
ePub reader for Unity3d
3+
4+
### What is this? Why would somebody make this?
5+
This is an ePub reader for the Unity 3D game engine. What is ePub? It is a format for ebooks, and you can read more about the standard [here](http://idpf.org/epub). It can read the book and provide the HTML for each chapter. It currently supports "Linear" books.
6+
7+
**Why?**
8+
9+
Well I thought it would be funny to have ebooks available in the Unity Engine, so I made this library. Maybe someone will find it useful someday, maybe not...
10+
11+
## Notes
12+
First, this library *does not* render ebooks. It is merely a parser to provide you the data which you could write a renderer for.
13+
14+
Since ePub is a compressed format the library uses UnityZip and your ``` Application.temporaryCachePath``` to store the uncompressed book. In production it's important to check that there is enough free space on the device before opening a book.
15+
16+
Also, this library will unpack the entire HTML of the book to memory (but not anything the HTML links to e.g. images). This is done for speed and ease of access. For most books this will only be a few KB to a few MB at most. Again, be sure that your app can handle having the book text in memory. Feel free to modify the code if you want to stream the HTML at runtime.## Usage
17+
It's pretty simple. Load the book via the constructor and you should be all set.
18+
19+
Example:
20+
21+
```csharp
22+
var epub = new UEPubReader ("Assets/Books/austen-pride-and-prejudice-illustrations.epub");
23+
```
24+
25+
## Thanks
26+
Special thanks to the [UnityZip Library](https://github.com/tsubaki/UnityZip)!

UnityEPubReader/Assets/Scripts/UEPubReader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace UEPub{
1111
public class UEPubReader {
1212

1313
public string epubFolderLocation { get; private set; }
14+
public string htmlRoot { get; private set; }
1415
public UEPubMetadata metadata { get; private set; }
1516

1617
public List<string> chapters;
@@ -86,8 +87,10 @@ private void ReadChapters (string opfFile, XmlDocument doc, XmlNamespaceManager
8687
var toc = spine.Select (x => bookItems [x]).ToList ();
8788
chapters = new List<string> ();
8889

90+
htmlRoot = Path.GetDirectoryName (opfFile) + "/";
91+
8992
foreach (string s in toc) {
90-
StreamReader sr = new StreamReader (Path.GetDirectoryName (opfFile) + "/" + s);
93+
StreamReader sr = new StreamReader(htmlRoot + s);
9194
chapters.Add (sr.ReadToEnd ());
9295
sr.Close ();
9396
}

0 commit comments

Comments
 (0)