Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Making of a InfoPanel for a AR Weather Application for mobile.

Discussion in 'AR/VR (XR) Discussion' started by vedantgirkar32, Jun 11, 2020.

  1. vedantgirkar32


    May 28, 2020
    I'm trying to make an AR app for mobile which uses a house model to along with various assets like rain, snow, etc prefabs to portray the current weather. I need to make a panel along the side of the model to show details like the temperature, humidity, and precipitation index. This panel is not a part of the UI but the part of the 3D AR Model. So I need to be able to change the content of this panel every day. I make a prefab of a 3D - Object -> TextMeshPro and I tried to change its text by creating a cube and a sphere below it and when you tap on it, it should change the text of the prefab to either 1 or 2 respectively just for experimentation purposes. but it stayed strong to what it was by default.
    I have included my code below:

    Code (CSharp):
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.UI;
    7. public class Place : MonoBehaviour
    8. {
    10.     public Transform SpawnLoc;
    11.     public GameObject SpawnObject;
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    18.     }
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         if(Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
    24.         {
    25.             RaycastHit hit;
    26.             Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
    28.             if(Physics.Raycast(ray, out hit, 100.0f))
    29.             {
    30.                 if( == "Cube")
    31.                 {
    32.                     Text TextObj = GameObject.Find("SpawnObject").GetComponent<Text>();
    33.                     TextObj.text = "1";
    34.                     Instantiate(SpawnObject, SpawnLoc.position, SpawnLoc.rotation);
    37.                 }
    38.             }
    39.         }
    40.     }
    41. }
    The SpawnObject is the prefab of the TextMeshPro.

    Does anybody have any ideas about how to fix this?

    Thank You.