- Home /
String Assets?
Okay, I have a very unusual situation.
I have a script that display objective on screen. I just changed a parameter in that script, so that instead of taking in a GUIText it takes in a String. It makes it easier on the developer, as he does not need to create an object for all of objective tooltips.
However, there is a few objective types that will have same description in instances of dozens scripts. I know that it is possible to store GUIText in the assets folder and objecti-point to it... but is it possible to store a String in assets folder and object-point to it?
If I used enums instead, how do I make it so that when ENUM is '.CUSTOM', the inspector adds additional field to be filled by the developer?
Answer by karljj1 · Dec 10, 2013 at 06:01 PM
You could store strings in the assets folder by creating a gameobject and adding a MonoiBeahviour with your string as a field. Then save the GameObject as a prefab.Reference the prefab to get the string at runtime. You could also create a custom class that can be saved as an Asset using CreateAsset and reference that at runtime. http://docs.unity3d.com/Documentation/ScriptReference/AssetDatabase.CreateAsset.html
If you want to to customise the inspector so it shows a text field when they select custom a Property Drawer would be ideal: http://docs.unity3d.com/Documentation/ScriptReference/PropertyDrawer.html
Your answer
Follow this Question
Related Questions
Cast the result of an enum as a string 3 Answers
Converting enum to string ? 1 Answer
How do you get the results from an enum in a different script 1 Answer
String to enum 2 Answers