Search Unity

In Unity Arkit,how to show a text in UnityARHitTestExample scene until a vertical plane is found?

Discussion in 'AR' started by zyonneo, Sep 13, 2018.

  1. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
    I am trying to show a text say "Scan for a surface" until it scans a plane surface.Once the device detects a plane surface the message should disappear and add another text.Where should I write code for this purpose.I found two instances where prefab plane is initialised ,one in UnityARGeneratePlane.cs and UnityARUtility.cs .I added a Gameobject as Text in UnityARGeneratePlane.cs and used setactive to true and false to show and hide the text.It is showing when i used it in the start method.How to hide the text is where i struggle.Where to use the code to hide the text when a plane is detected?Is it in UnityARGeneratePlane.cs or UnityARUtility.cs.
     
    yjcnbnbnb200 likes this.
  2. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    Hi @zyonneo ,

    You would just have a GameObject with a script that does something like this:

    Code (CSharp):
    1. public class MyClass : MonoBehaviour
    2. {
    3.     // Use this for initialization
    4.     void Start()
    5.     {
    6.         Debug.Log("waiting for first anchor");
    7.         UnityARSessionNativeInterface.ARAnchorAddedEvent += AddAnchor;
    8.     }
    9.  
    10.     void AddAnchor(ARPlaneAnchor arPlaneAnchor)
    11.     {
    12.         Debug.Log("added first anchor");
    13.         UnityARSessionNativeInterface.ARAnchorAddedEvent -= AddAnchor;
    14.     }
    15. }
    16.  

    Todd
     
    robenu likes this.