Search Unity

Other Can you guys help me.

Discussion in 'Scripting' started by parasalolkolamang, Nov 23, 2022.

  1. parasalolkolamang

    parasalolkolamang

    Joined:
    Nov 23, 2022
    Posts:
    1
    I create a script that can read and display the data to my scene, using the csv file. In this script, the Instrument is equal to the string that I put manually which is the "Mayo Table". Is it possible that instead putting it manually, make the instrument equal to the prefab that detect in vuforia?

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.SceneManagement;
    6. using TMPro;
    7.  
    8. public class ReadData : MonoBehaviour
    9. {
    10.     public TextAsset textAssetData;
    11.  
    12.     private string Instrument;
    13.     private string Text;
    14.     public TextMeshProUGUI Name;
    15.     public TextMeshProUGUI Description;
    16.     public TextMeshProUGUI Dos;
    17.     public TextMeshProUGUI Uses;
    18.  
    19.     // Start is called before the first frame update
    20.     void Start()
    21.     {
    22.         Instrument = "Mayo Table";
    23.     }
    24.  
    25.  
    26.     // Update is called once per frame
    27.     void Update()
    28.     {
    29.         Text = Instrument;
    30.         string[] data = textAssetData.text.Split(new string[] { ";", "\n" }, System.StringSplitOptions.None);
    31.  
    32.         for (int i = 0; i < data.Length; i++)
    33.         {
    34.             if (Text == data[i])
    35.             {
    36.                 Name.text = data[i];
    37.                 Description.text = data[i + 1];
    38.                 Dos.text = data[i + 2];
    39.                 Uses.text = data[i + 3];
    40.             }
    41.         }
    42.     }
    43. }
    44.  
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,009
    To quote the code of conduct:
     
    MaskedMouse likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,747
    Everything is possible.

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    You may edit your post above.

    The purpose of this forum is to assist people who are ready to learn by doing, and who are unafraid to get their hands dirty learning how to code, particularly in the context of Unity3D.

    This assumes you have at least written and studied some code and have run into some kind of issue.

    If you haven't even started yet, go check out some Youtube videos for whatever game design you have in mind. There are already many examples of the individual parts and concepts involved, as there is nothing truly new under the sun.

    If you just want someone to do it for you, you need go to one of these places:

    https://forum.unity.com/forums/commercial-job-offering.49/

    https://forum.unity.com/forums/non-commercial-collaboration.17/

    https://livehelp.unity.com/?keywords=&page=1&searchTypes=lessons
     
    parasalolkolamang likes this.