- Home /
Question by
ardizzle · Mar 28, 2013 at 07:51 AM ·
instantiatetext
How to Instantiate an editable text field
Hey im trying to make a program that makes a list of projects but I can't figure out how to make a editable text field that i can Instantiate over and over. This is what I have gotten to. Any ideas?
#pragma strict
// Inspector Variables
var numberOfProjects : int = 1; // Number of projects you have
var projectSelecterXPos : float; // X postions for all project selecter buttons
var projectSelecterYStartPos : float; // the starting y position that the NewProject function is based on
var projectSelecterGap : float; // the gap between your project selecter buttons
var projectNameList : String = "Project Name List "; // name of the box that hold your projects
var projectSelecterButton : Transform; // needed to make copys of text box
// Private Variables
private var projectManagerArray = Array(numberOfProjects); // may be needed later. not used yet
private var numberOfProjectsHolder : int = 0; // needed to hold a number for NewProject function
function Start ()
{
guiText.transform.position = Vector3(projectSelecterXPos,projectSelecterYStartPos,0);
guiText.text = projectNameList;
}
function Update ()
{
NewProject();
}
function NewProject()
{
if(numberOfProjects>numberOfProjectsHolder)
{
var projectSelecterYPos = Array(numberOfProjects);
var x = projectSelecterYPos.length;
Instantiate(projectSelecterButton,Vector3(projectSelecterXPos,projectSelecterYStartPos - x * projectSelecterGap, 0), Quaternion.identity);
numberOfProjectsHolder++;
}
}
Comment
Your answer
Follow this Question
Related Questions
Prefabs not visible in webplayer? (read from .txt file) 1 Answer
Changing the text of an instantiated game object 4 Answers
Why can't I drag text into public text in the inspector when instantiated? 1 Answer
trouble instantiating ui text 1 Answer
cachedTextGenerator not working with instantiated canvas 1 Answer