I have this little AR-Unityapp for Android and i try to play a video with a button. But the button should not be on the screen ( canvas ) it should be in the scene ( understandable? ). So i made a 3d plane which simply starts the video with a pointer down event but it won´t work. I know that its possible to make this but i have no idea how some help would be helpful ( xP ).
use a world canvas:
Create a canvas and set its "render mode" to "world". In that canvas you can put your button, give it a 3D location as you would with your plane, but you can use normal UI functionalities, such as buttons, instead of implementing click detections your self.
If you want to trigger a Pointer Down event just follow the steps below
Attach the below Script to that Plane as below
using UnityEngine; using UnityEngine.EventSystems; public class Plane : MonoBehaviour,IPointerDownHandler { public void OnPointerDown(PointerEventData eventData) { Debug.Log("CALLED"); } }
This Method will be called on Pointer Down on the required plane. As Seen in the above code we are using IPointerDownHandler
interface of UnityEngine.EventSystems
I am sure this will clear your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.