GetComponent and setting it to active.?? HELP :)

Good day everyone…newbie here…i am having a hard time on what to do in my project…
i am creating a guess a word game… my problem is…i cant figure out how to show “letters” in a cube. only one letter by cube…
i cant figure out how Script should be…this is my script…
please let me know what to do…

function FixedUpdate(){
	if(Input.GetKeyDown("a")){
	print("letter A");
	box1.gameObject.SetActive(true);
        letterA.gameObject.SetActive(true);
	//audio.Play();
	}
	else if (Input.GetKeyDown("b")||(Input.GetKeyDown("c"))){
       letterB.gameObject.SetActive(false);
        letterC.gameObject.SetActive(false);
	print("No Letter");

	//audio.Play();
	}

this script is save in box1(cube)…I dont know how to Script GetComponent and SetActive(false) if there is no Letter (i.e “b” , “c”) =(

for example…if Word= “hello”

box1=active
box2=active…box5=active
(because it is 5 letters in the Word)

the porblem is…everytime i “h” and “e”
in one box there is two letter…they are not separted…>.< I cant figure it out…please do help me…thanks in advance!

Do i understand right, that u want each typed in Letters to appear as a Box?
Like that:
[E] [L] [L] [O]

yes…dou you have an idea Aeronaut?? i will post a image…


please help me…thanks

Hello paul___ . What are you using to display your letters 3d mesh, gui, or materials ?

3D…from A-Z, I just make it children to my Box1 and then duplicate it then rename it to Box2…

Wow i think this is a very Complicated way.

I suggest u to use a Prefab:

Create Empty GameObject
Parent the Cube
Parent the TextMesh

If it looks like u want it, create a Prefab of it.

Then make one Script:

using UnityEngine;
using System.Collections;

public class LetterBoxHandler : MonoBehaviour {
    public GameObject textCube;
    public string SearchedWort;

    private int currentPosition = 0;
    private string lastPressedKey;
    private char[] searchedLetters;

    void Start()
    {
        searchedLetters = SearchedWort.ToUpper().ToCharArray(); //ToUpper maybe?
    }

	void Update ()
    {
        if (Input.anyKeyDown)
        {
            if (searchedLetters[currentPosition].ToString() == lastPressedKey)
            {
                GameObject cube = Instantiate(textCube, new Vector3(currentPosition * 1.1f, 0, 0), Quaternion.identity) as GameObject;
                cube.GetComponentInChildren<TextMesh>().text = lastPressedKey;
                currentPosition++;
            }
        }
	}

    void OnGUI()
    {
        Event e = Event.current;

        if (e.isKey  e.keyCode != KeyCode.None)
        {
            lastPressedKey = e.keyCode.ToString().ToUpper();
        }
    }
}

This should do it…

that script will disable last pressed key?? sorry im not familiarize with Cscript…
I already Parent them before i post in this forum

No. How u want the scene to look like after Initial? Do u want Boxes with all Letters overlapping and then remove the Letters pressed on Keyboard?

i want my boxes one letter per box [E] [L] [L] [O]…just like that…i just cant figure it out how will I make it on script without them overlapping.

do you have skype sir?

No. I don’t use Skype anymore, sorry.

You have your GameObject/Transform with a TextMesh on it, to change the Text of that TextMesh component u use:

cube.GetComponentInChildren().text = “YourKeyHere”;