|
Post by jiottolo on Dec 4, 2019 18:19:38 GMT
Hello!
I'm planning to buy this asset and I'm wondering if it can be used together with bookmarks coming outside of the book (even when the book is closed or the bookmark) .
The general idea would be to have them clickable to navigate the book. Is that possible? Also they should follow the page they are connected to, so they would move with the page animation.
I look forward to hearing from you!
Jo.
|
|
|
Post by echo17 on Dec 4, 2019 21:49:58 GMT
Hmm, that is an interesting question. You could have the bookmark mesh follow one of the turning page's bones. But since the turning pages are reused / recycled you'd have to add some logic to determine if the bookmark should be following a page turn animation or just lying still. Unfortunately, this functionality does not come packaged with the plugin, but if you are a savvy programmer, you could probably come up with something.
Here is some code that is included with the plugin to allow objects to follow an animation's bone transform. This is used in Demo #2 to have some metal corner pieces follow the cover bones of the book:
using UnityEngine;
/// <summary> /// Makes an object act like a child of another object. /// This is useful because we can have objects follow the book's /// transforms and not disappear when the animated book is /// set inactive, switching to a static standin /// </summary> public class MimicChild : MonoBehaviour { private Vector3 parentInitialPosition; private Quaternion parentInitialRotation; private Vector3 childInitialPosition; private Quaternion childInitialRotation; private Matrix4x4 parentMatrix;
public Transform parentTransform;
void Start() { parentInitialPosition = parentTransform.position; parentInitialRotation = parentTransform.rotation;
childInitialPosition = transform.position; childInitialRotation = transform.rotation;
childInitialPosition = DivideVectors(Quaternion.Inverse(parentTransform.rotation) * (childInitialPosition - parentInitialPosition), parentTransform.lossyScale); }
void LateUpdate() { parentMatrix = Matrix4x4.TRS(parentTransform.position, parentTransform.rotation, parentTransform.lossyScale); transform.position = parentMatrix.MultiplyPoint3x4(childInitialPosition); transform.rotation = (parentTransform.rotation * Quaternion.Inverse(parentInitialRotation)) * childInitialRotation; }
Vector3 DivideVectors(Vector3 num, Vector3 den) { return new Vector3(num.x / den.x, num.y / den.y, num.z / den.z); } }
|
|
|
Post by jiottolo on Dec 5, 2019 0:01:27 GMT
Hey! Thanks for the quick response. I went ahead and bought the asset, I might need some support but I'm willing to put a bit of my own work to get the bookmarks to work with it. Let's see how it goes!
|
|
|
Post by jiottolo on Dec 8, 2019 22:36:19 GMT
Hello! I have started trying to implement my old book into your asset, following your suggestion of using the MimicChild script. It seems to work fine but several times the mimic children get stuck in the air (see attached image). Have you ever encountered that? To be precise: I have no errors in the console and I made no changes, just tried to open the book back and forth and the bits fly... What should I do to fix that?
|
|
|
Post by echo17 on Dec 9, 2019 15:16:58 GMT
I'm not sure what would be causing that. Is this from Demo #2? I have not seen this happen with that demo before.
|
|
|
Post by jiottolo on Dec 10, 2019 11:40:32 GMT
It happened here and there and now it stopped, maybe it was just something on my side.
Anyway, I have another question: is it possible to add clickable buttons inside a page? I am either a sprite with an onlick event or, even better, an actual UI button (with world space canvas). Would it be possible?
|
|
|
Post by jiottolo on Dec 10, 2019 21:21:06 GMT
P.S. I actually noticed that it's possible to get it to work in World Space but there seems to be a bit of an offset with the clickable areas. Is it because of the cameras setup?
|
|
|
Post by echo17 on Dec 11, 2019 11:36:03 GMT
Without seeing your specific setup, it would be difficult to tell what would be causing the offset. If you want to send me your project to look over, please see this FAQ: link
|
|
|
Post by jiottolo on Dec 11, 2019 15:00:03 GMT
This happens with the provided demo too. Here is how you can construct it: - Open 'Demo 02' scene - Pick a page (let's say "PageView_Front") - Create a UI button object (a Canvas object will be created automatically) - Set Canvas > Render Mode to "World Space" and select the "Camera" of the chosen PageView - Resize and move the canvas + button to be visible by "Camera" * Make sure the "Canvas" object has a "Graphic Raycaster" and no Blocking Objects/Mask selected * Also make sure the "Canvas" Layer is selected in "Camera" layer mask (or just select 'Everything') * To make the test more clear, I suggest to set some bold colors to the 'Highlighted Color' and 'Pressed Color' of "Button" - Start scene - Notice that the hovering/clicking boundaries of the button are offset (if you at first don't think the button is clickable, just keep moving the mouse around the whole window, you should find the right spot). P.S. For this test I tried using a page on the right-hand side and it seemed to have a much larger offset than one placed on the left. Perhaps it can help? Let me know
|
|
|
Post by jiottolo on Dec 16, 2019 17:31:01 GMT
Heya! Did you manage to reproduce the problem with those step?
|
|
|
Post by echo17 on Dec 16, 2019 17:41:00 GMT
|
|