Search Unity

Mega Book - Easily create working 3D books Comics

Discussion in 'Assets and Asset Store' started by SpookyCat, May 19, 2014.

  1. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Another question.

    Is there a way to get a trigger just before objects dissapear, so i can have a script triggered to scale them down ?

    I suppose i could go into your code where it checks for the position to trigger the object dissapearence and do a check at 90% of that and expose a flag variable. Where should i look for that in the code ?

    Thanks,

    I am constantly getting more and more amazing results, i have scripted a gradual scale when objects appear and is really sweet :), the dissapearence is a bit more tricky i guess.
     
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    I will add a system to send a message to each attached object saying how 'visible' each object.
     
  3. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    There is a new version in the Asset Store that has support for sending messages to attached Objects. In the page objects inspector you will see a Message toggle box, check that for any object you wish to receive a message then the system will send out a 'BookVisiblity' message for any visible object with a float param between 0 and 1 for current visibility of that object. So you just need to have a public void BookVisiblity(float visi) method on any script attached to your object to get the message, there is an example script MegaBookVisible.cs script included in the system.
     
  4. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Thanks a lot for the quick addition, i will implement it asap :)

    BTW, what is the best way to update my current installation of the pack ? If i download and simply run the package i will replace only the files that changed i guess ? Or should i do a clean install and re-insert my additions ?

    EDIT: I will probably need to open to a new project, make the folder structure like in my project and export first, then import the pack, probably this will work and replace the right files and put them in the right spot
     
  5. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    If you get it from the Asset Store then it should only update the files that are new or have changed.
     
  6. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Ok, i will try that

    I have a custom directory structure, that is why i was asking, just in case it tries to put the new files in another directory
     
  7. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    Nice idea.
    But isn't this "Bat-Thing" going too far already? o_O
    How many Mega-Stuff are out there? haha
     
  8. GSJP

    GSJP

    Joined:
    Jun 12, 2014
    Posts:
    3
    If only it has a build in serializer like a bookmark manager, it'll be perfect!
     
  9. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Could you elaborate more on what is meant by a bookmark manager?
     
  10. GSJP

    GSJP

    Joined:
    Jun 12, 2014
    Posts:
    3
    A menu to let user bookmark pages for later reference.
     
  11. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    That would be very easy for someone to add, just need a Dictionary for a bookmark string to a page value, an untested example is below, and you would just add whatever GUI you like to and call the AddBookMark, RemoveBookMark and GetBookMark methods.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class BookMark : MonoBehaviour
    5. {
    6.    public MegaBookBuilder book;
    7.  
    8.    public Dictionary<string, float>   bookmarks = new Dictionary<string, float>();
    9.  
    10.    public void AddBookMark(string name, float page)
    11.    {
    12.      bookmarks.Add(name, page);
    13.    }
    14.  
    15.    public void RemoveBookMark(string name)
    16.    {
    17.      bookmarks.Remove(name);
    18.    }
    19.  
    20.    public void GetBookmark(string name)
    21.    {
    22.      if ( bookmarks.ContainsKey(name) )
    23.        book.page = bookmarks[name];
    24.    }
    25. }
     
  12. GSJP

    GSJP

    Joined:
    Jun 12, 2014
    Posts:
    3
    Yes, we can do it easily, but the thing is, if i wanted to go the DIY route i would have did everything from the ground up.

    What I have learn in using addons is to try not to mess with it the best i could.
    In times like updates, the time to debug is much more than the convenience.
     
  13. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    I think the thing SpookyCat is pointing out is that you are going to have to write your own GUI code somewhere along the line to allow the user to create book marks and select them and the code above shows that once a book mark is selected the only code that is needed to get the book to turn to that page is the line book.page = bookmarks[name]; so there really isn't much need to add it to the book system.
     
  14. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Very cool asset.

    I've been wanting to get a well supported package that supports the creation of a 3D popup book. Something like the Dynamic 3D book kit on the asset store.

    Question: Can I make something like the 3D book kit using this package? If yes, how easy can it be done? A little video would be great.

    Cheers.
     
  15. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Submitted a small update to the Asset Store that fixes the warnings that show up when importing MegaBook into a 4.5 project.
     
  16. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Submitted a new version to the Asset Store which brings a new feature of being able to add hard front and back covers to your books, there is a new section at the bottom of the Book Builder inspector that opens up the cover options and you can select the objects to use for the front and back covers, as well as alter the angle the covers turn through and define the pivot location. When Tony (the Artist brother) is back I will do a video showing the system in use but until then the demo scene book has hard covers on so you can try it out. You can off course point the system at a bone transforms if you happen to have a skinned book cover, which would allow you to have nice look at the cover hinges for example.

    hardcovers.jpg

    Changes in v1.11
    • Removed Debug script from object in test scene.
    • Added beta of hard front and back cover system for your books.
     
  17. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Amazing addition, thanks :)
     
  18. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Another update to MegaBooks has been submitted to the Asset Store, this brings the beta of the Dynamic Mesh system which is designed to allow you to add mesh data to each page as it is built, the main use for this would be to add text to the pages but could be used to add any kind of mesh data to the front and backs of pages. The mesh data is combined into the page mesh so that it will deform along with the page as it turns. You have control over scaling, position and rotation of the data as it is combined.

    As there are quite a few different text systems out there we added a component called MegaBookDynamicMesh to the system so you would add that component to an object in the scene, the component contains a few methods that the book builder will call as it builds each page mesh, you just need to return the vertex, uv and tri data you want to be added to the page and the materials to use. The demo book in the scene as a simple example where a cube mesh is added to each page.

    Changes in v1.13
    • Removed a debug line.
    • Added beta of system to allow any mesh data to be added to each page as it is built, for example adding text to the page.
    • MegaBookDynamicMesh component added, use this class to provide the mesh data the book builder asks for.
    • Added simple example of dynam mesh to the demo scene book. Docs and video coming.
     
  19. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    That is fantastic news, I got excited yesterday to see that you added hard covers to the system, and was wondering how long it would be until the ability to add text to pages came along, only had to wait a day :) And it seems not only text can add any kind of mesh per page. Will have to have a play but thanks again for your constant efforts in adding new features to all your systems, been really spoilt in the last week with virtually all your systems getting updates and new features.
     
  20. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Another update, this brings some improvements and fixes to the dynamic mesh system that allows you to add text or any other custom mesh to each page. I have also included an example script on how to make use of the free Typogenic text system. Typogenic makes use of signed distance fields so the text is smooth no matter how close you get. If you use another text rendering system then you can adapt the example script as you need.

    Below is a grab showing the text on the page that is being turned and below that another image zoomed in a little on the text to show its still sharp. The script that passes the data to and from the book builder is also below, and you can see it is a few simple methods that return vertex and tri data and material info, and a method that is called to build the mesh data per page, so with Typogenic there is a RebuildMesh method to call and you just pass in the string of text.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4.  
    5. public class TypogenicMesh : MegaBookDynamicMesh
    6. {
    7.    TypogenicText     typo;
    8.    public List<string>   text = new List<string>();
    9.  
    10.    public override int GetNumMaterials(int page, bool front)
    11.    {
    12.      return renderer.sharedMaterials.Length;
    13.    }
    14.  
    15.    public override Material GetMaterial(int page, bool front, int i)
    16.    {
    17.      return renderer.sharedMaterials[i];
    18.    }
    19.  
    20.    public override void BuildMesh(int page, bool front)
    21.    {
    22.      if ( !typo )
    23.      {
    24.        typo = gameObject.GetComponent<TypogenicText>();
    25.        mesh = typo.m_Mesh;
    26.      }
    27.  
    28.      int index = page * 2;
    29.      if ( !front )
    30.        index++;
    31.  
    32.      if ( index < text.Count )
    33.      {
    34.        typo.Text = text[index];
    35.        typo.RebuildMesh();
    36.        mesh = typo.m_Mesh;
    37.      }
    38.    }
    39.  
    40.    public override Vector3[] GetVertices(int page, bool front)
    41.    {
    42.      if ( mesh )
    43.        return mesh.vertices;
    44.  
    45.      return new Vector3[0];
    46.    }
    47.  
    48.    public override Vector2[] GetUVs(int page, bool front)
    49.    {
    50.      if ( mesh )
    51.        return mesh.uv;
    52.  
    53.      return new Vector2[0];
    54.    }
    55.  
    56.    public override int[] GetTris(int page, bool front, int m)
    57.    {
    58.      if ( mesh )
    59.        return mesh.GetTriangles(m);
    60.  
    61.      return new int[0];
    62.    }
    63. }
    64.  
    megabooktext2.jpg megabooktext3.jpg

    Changes in v1.14
    • Improvements to the Dynamic mesh system.
    • Example dynamic mesh script for using Typogenic to add text to book pages
     
  21. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Very cool, thanks for the cool new features :), the text one is great to have. Can we use any font with it ?
     
  22. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    You can use any font you like its up to whatever text system you use but I doubt there is a text system which doesnt allow you to choose a font.
     
  23. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Nice, thanks
     
  24. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Just got a copy of TextMesh Pro and it to works just great with MegaBook so you can add some very fancy looking text to your books now.
    TMPro1.jpg
     
  25. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Great you added a Text system.
    Thanks to your link and Typogenic I could add a Typogenictext Object but sure I need a tutorial to insert in the book !?!
    Thanks for the hard cover system too.
    6R
     
  26. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    I will be doing a video showing how to do it very soon, and be adding the docs to the website, the system is still in beta though and just need to test it with a couple more systems to make sure it does all that is needed before I finialize the system. The demo book in the asset has dynamic text, so you can check that out, you basically just need to select the Text object in your scene in the Dynamic params in the Bool Builder inspector. And that text object should have the script above attached. The script should return any mesh data when it is asked, so in the simple example above there is a list of strings which holds the text for each page, and when asked the script gets the text mesh rebuilt and returns the vertex and tri data to the book builder.

    Using a script means the user can have complete control over the mesh built per page, so you could have different fonts, sizes, multiple text objects, custom meshes etc per page just as long as you return the right info when asked. But the example script above is probably the simplest way for most users.
     
  27. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    Very nice to see this level of cross asset support, I hope that all your work is well appreciated by the Unity community at large.
     
  28. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    I have replaced the "Dynam Control" by a "New Typogenic Text" like on your screenshot in the Dynam Mesh parameters after I have added the MegaBookDynamicMesh to it. But It doesn't work for me !?!
    If I disabled your dynam control (for testing) on the first page for example it is disabled for all pages !?!
    I think I will wait for your tutorial... :)
    Don't forget to show us with more than one Text Object (how to insert several different texts on different pages and how to enable/disable them on the pages to have a different text on each one...

    For my project I'm using Megafiers + MeagBook...
    6R
     
  29. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Quick update, added an example script to be able to use Text Mesh Pro for adding text to your pages, also added in vertex color support to the book builder so that text or any mesh you add per page can have vertex color info as well so you can have multi colored text etc. Will being the docs and tutorial video for the dynamic mesh system in the coming days.

    Changes in v1.15
    • Added support for vertex color to book builder which will allow multi colored text to be used etc
    • Added support for getting vertex colors in the dynamic mesh system.
    • Added example script for using Text Mesh Pro for adding text to pages.
     
  30. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Can the text be dynamically changed while in game ?

    Would be very cool for dynamic menus directly implemented on the book pages
     
  31. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    I will be adding methods to the Book API to allow for changes to be made at runtime.
     
  32. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Quick grab showing the new vertex color support in MegaBook which allows you to add color to your text (if the text system you are using supports it). In this example Text Mesh Pro is being used which allows for text to easily be colored and various other options such as sizing and italic.
    megabooktext6.jpg
     
  33. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Great, thanks :)
     
  34. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    That's a mighty nice looking book there :)

    The justified text looks nice as well along the spine of the book.
     
  35. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Did a slightly more complex example for the dynamic mesh system in the book builder, this example allows you to use multiple objects per page to define the content, so in this example there are multiple text objects per page and a textured object. So you now have complete control over the layout and content of each page. Again in this example the text mesh is generated from the Text Mesh Pro system.
    megabooktext7a.jpg
     
  36. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Just a quick note, seems I messed something up in the shader for the text in the grab above, and grab and scaling of image hasn't helped, grab below shows the text is very crisp when zoomed in.
    megabooktext8.jpg
     
  37. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    I hope we can use Typogenic Text too because it's free. TextMeshPro is very expensive...

    Great to see we can add textures too.
    Very interesting if we don't have to make "page textures" out of Unity with texts and graphics.
    6R
     
  38. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    You can use anything that is a mesh, I just used TMPro as it does do a very nice job of handling text, but anything that uses a meshfilter can be used to build page content for your books.
     
  39. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    New version in the AssetStore, this fixes a bug if you used the page hole mesh option where the uvs were wrong on the back of the page. Also removes the error if you are compiling for WP8 or other platforms that do not support threading. And finally adds the helper script to be able to add any meshes to a page, be it multiple meshes, multiple material meshes etc so you can do complex text layouts with images as well.

    Changes in v1.16
    • Fixed bug with page hole meshes having wrong back uvs
    • Fixed error about threading method missing when building for platforms that do not support threading.
    • Added example script for adding any mesh items as content for pages, MBComplexPage.cs
     
  40. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
  41. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
  42. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Keeps getting better and better Phillipe :) Those two assets work well together.
     
  43. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Thanks...
    Yes, I'm learning little by little how to use them. And the results are very motivating.
    6R
     
  44. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Finally got around to creating a video to show how to use the Dynamic Mesh system to add complex mesh data as content for your books. The system allows you to add any number of meshes for each page of your book, the system will combine all the meshes and add them to the page so that it will turn correctly etc. The system also support multiple materials and vertex colors.
     
  45. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Very nice addition :)

    Is it possible to assing any gameobject or only planar things ?

    Also does it instantiate and destroy the content at each page turn, or enable/disable one instance ?
     
  46. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Very nice addition.
    I would like to add hyperlinks to the text that points to another page. For example, when the user clicks on the hyperlinks, the book flips to the target page. Is this something that can be done?
     
  47. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
  48. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Have a few more questions:

    1. Performance on Mobile?
    2. Does anyone know how well the demo book performs on an Iphone 4?
    3. How many draw calls per page?
    4. How does it perform with text/graphics/3D content ?
     
  49. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Is this the same as the book in MegaFilers? The MegaFilers one had the bug with floating point accuracy due to the pagecount, which was never fixed.
     
  50. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    No ! It's much better and especially made for 3D books. This plugin is fantastic and so easy to use. All is ready to use. Simply add your textures or 3D models/2D sprites.
    6R