Get Unity to read in objects name without the need to hard code
Posted
by
N0xus
on Game Development
See other posts from Game Development
or by N0xus
Published on 2013-05-31T11:48:08Z
Indexed on
2013/07/03
17:20 UTC
Read the original article
Hit count: 477
I'm trying to get away from having to hard code in the names of objects I want my code to use.
For example, I'm use to do it this way:
TextAsset test = new TextAsset();
test = (TextAsset)Resources.Load("test.txt", typeof(TextAsset));
What I want to know, is there a way to have so that when I drag my test.txt file onto my object in Unity, my code automatically gets the name of that object?
I'm wanting to do this so once I write the code, I don't need to back in and change it should I wish re-use it.
© Game Development or respective owner