Log in or register to post comments

Text over parts of model when looking at it

August 9, 2019 - 4:23am #1

Hi,

I'm building this for android, I want to be able to look at certain parts of the model and text appears and disappears once looking away from it. I know my current script is for a mouse how do I set it as the ARCamera?

Please see below my current script which I have applied to a part of the model using text within UI.

 

Any advice would be greatly appreciated :)

 

using UnityEngine;

using UnityEngine.UI;

using System.Collections;

public class displayUIcam : MonoBehaviour

{

    public string myString;

    public Text myText;

    public float fadeTime;

    public bool displayInfo;

    // Use this for initialization

    void Start()

    {

        myText = GameObject.Find("Text").GetComponent<Text>();

        myText.color = Color.clear;

        //Screen.showCursor = false;

        //Screen.lockCursor = true;

    }

    // Update is called once per frame

    void Update()

    {

        FadeText();

        /*if (Input.GetKeyDown (KeyCode.Escape))

        

                {

                        Screen.lockCursor = false;

                        

                }

                */



    }

    void OnMouseOver()

    {

        displayInfo = true;

    }

 

    void OnMouseExit()

    {

        displayInfo = false;

    }



    void FadeText()

    {



        if (displayInfo)

        {

            myText.text = myString;

            myText.color = Color.Lerp(myText.color, Color.black, fadeTime * Time.deltaTime);

        }

        else

        {

            myText.color = Color.Lerp(myText.color, Color.clear, fadeTime * Time.deltaTime);

        }

 



    }

 

}

Log in or register to post comments