Log in or register to post comments

How can I connect the 3D model into my Script

Unity Editor
November 23, 2022 - 8:20pm #1

Hello! I'm just a newbie so please bare with me. How can I call the object that show to my image target to my script? I create a script using a csv file that contains the information of the instruments (Name of the Instrument, Description, etc.).

Below you can see the my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;

public class ReadData : MonoBehaviour
{
public TextAsset textAssetData;

private string Instrument;
private string Text;
public TextMeshProUGUI Name;
public TextMeshProUGUI Description;
public TextMeshProUGUI Dos;
public TextMeshProUGUI Uses;

// Start is called before the first frame update
void Start()
{
Instrument = "Mayo Table";
}

// Update is called once per frame
void Update()
{
Text = Instrument;
string[] data = textAssetData.text.Split(new string[] { ";", "\n" }, System.StringSplitOptions.None);

for (int i = 0; i {
if (Text == data[i])
{
Name.text = data[i];
Description.text = data[i + 1];
Dos.text = data[i + 2];
Uses.text = data[i + 3];
}
}
}
}

As you can see that the Instrument is equal to the variable that I put manually. What I want to happen is the Instrument is equal to the object that display.

Platform: 
Log in or register to post comments