|
Post by squareeyes on Nov 14, 2022 22:15:11 GMT
Hello how do i make an object appear when im on a certain page? I want to make a sphere thats clickable when im on page 6 for example.
|
|
|
Post by echo17 on Nov 15, 2022 11:49:39 GMT
You will need a few elements set up for this to work. First, you'll need a collision object that hovers over the book's surface. This will capture any user interaction, like clicks of a mouse or touches of a finger. You can then use the information about that collision to cast a physics ray into a scene where your sphere exists. If that ray collides with the sphere, you can capture that information. The scene with the sphere will be rendered to a render texture instead of the screen so it will have its own camera for that. That render texture will be used in the page material of the book. Check out Demo #2 included with the plugin, specifically the table of contents page. Each section of the table of contents is just a cube collider in a scene that is being rendered to a texture for that page material. You can see the touch pad collision object in the scene: In the Touchpad.cs script, you can see the various methods that are used to capture where on the touchpad the user interaction is occurring. In the DetectTouchUp method, the hit point of the page is determined, then touchUpDetected callback is invoked if it is a page hit. That is sent back to the Demo02.cs script since that is where the callback is attached. In Demo02.cs the TouchPadTouchUpDetected is called if the touchpad received a hit on the page. If the book is open, it will call RayCast on the appropriate pageView. PageView_02.cs script inherits the PageView.cs script, calling the RayCast method to determine if anything in the PageView's sub-scene is hit, like a table of contents collider (or a sphere collider in your case). In the scene, the PageView_02 object contains the scene where the table of contents objects are. This is where you would put your sphere in your page scene. It's a lot to try to explain in a post, so going through the Demo scene and the scripts used in the demo would be your best tutorial. I would start by adding a sphere to the table of contents sub-scene. Choose one of the chapter objects as an example. Be sure you set your Layer on the sphere as the same layer for the chapter object. That ensures it is collideable and will register as a hit.
|
|
|
Post by squareeyes on Nov 18, 2022 21:10:38 GMT
This is very helpful thank you! im going to try to reuse one of those table of contents objects and change it to the button i need on the page i want. maybe that will work?
|
|
|
Post by squareeyes on Nov 18, 2022 21:16:41 GMT
How can i tell unity if i am on a certain page? I can just use the buttons instead and move them on the screen when im on a certain page.
I could make a script like if on current page = 6 Button active
|
|
|
Post by echo17 on Nov 19, 2022 10:45:45 GMT
Each page is a different material, so the button on page 6 would only be visible when you are on page 6, no need to modify its visibility.
|
|