Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TheIronHobo · Jul 21, 2013 at 06:30 AM · texttextfieldlabeladventure

Text Adventure: Moving text field?

Hello, I am the creator of a very unique text adventure. I am purchased an asset called Tidy Text Adventures and I love what it has to offer for my game. However it is necessary that I modify it to fit my needs. So far I've changed the font type and the font color placement etc. But each time I type a command in the text field and press enter, the text field moves down a space eventually obscuring itself from view. I have scoured the UI file in hopes to find what is causing this but to no avail. Can someone help me find what needs changing/ commenting out to stop this from happening? Thanks bunches -- TheIronHobo

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class TTA_UI : MonoBehaviour {
     
     public TextAsset textAsset;
     TTA_World world;
         
     //We put all of our styles in this skin (custom styles)
     //And we reference them by their output type name
     public GUISkin UIskin;
     
     public GUIStyle GetStyleForOutputType(TTA_OutputType outputType){
         
         return UIskin.GetStyle(outputType.ToString());
                 
     }
     
     void Awake(){
         
         SetUIState(TTA_UIState.Title);
         
     }
     
     //And these are the three functions that will handle the unusual requests
     void NewGame(){
         SetUIState(TTA_UIState.NewGame);
     }
     
     void QuitGame(){
         SetUIState(TTA_UIState.Quit);
     }
     
     void HandleVictory(){
         SetUIState(TTA_UIState.Victory);
     }
     
     
     string input = "";
     List<TTA_OutputEntry> output = new List<TTA_OutputEntry>();
     bool keyDown = false;
     
     enum TTA_UIState{
         
         Title,
         Game,
         NewGame,
         Victory,
         Quit
         
     }
     
     TTA_UIState uiState;
     
     void SetUIState(TTA_UIState uiState){
         
         this.uiState = uiState;
         
         switch(uiState){
             
             case TTA_UIState.Title:{
                 
                 //Load!
                 if(TTA_Utilities.HasWorldSave(textAsset.name)){
                     world = TTA_Utilities.LoadSavedWorld(textAsset.name);
                 }
                 else{
                     world = TTA_Utilities.WorldFromString(textAsset.text);
                 }
                 
                 //Important! We really want to do this
                 TTA_InputTranslation.InitializeTranslation(NewGame,QuitGame,HandleVictory);
                 
                 output = TTA_InputTranslation.GetTitleStatus(world);    
                 break;
             }
             case TTA_UIState.Game:{
                 output = TTA_InputTranslation.GetBeginningStatus(world);
                 break;
             }
             case TTA_UIState.NewGame:{
                 break;
             }
             case TTA_UIState.Quit:{
                 break;
             }
             case TTA_UIState.Victory:{
                 break;
             }
             
         }
     }
     
     void OnGUI(){
         
         GUILayout.BeginArea(new Rect(320, 100, 600, 600));
         
         GUILayout.BeginVertical();
         
         GUI.color = Color.black;
         
         GUI.skin = UIskin;
         
         GUILayout.Space(20.0f);
         
         GUILayout.BeginHorizontal();
         
         GUILayout.Space (20.0f);
         
         GUILayout.BeginVertical();
         
         switch(uiState){
             
             case TTA_UIState.Title:{
                 DrawGameDisplay();
                 break;
             }
             case TTA_UIState.Game:{
             
                 GUI.FocusControl ("TEXT");
             
                 DrawGameDisplay();
                 break;
             }
             case TTA_UIState.NewGame:{
                 DrawNewGame();
                 break;
             }
             case TTA_UIState.Quit:{
                 DrawQuit();
                 break;
             }
             case TTA_UIState.Victory:{
                 DrawGameDisplay();
                 break;
             }
             
         }
         
         GUILayout.EndVertical();
         
         GUILayout.Space (5.0f);
         
         GUILayout.EndHorizontal();
         
         GUILayout.Space(900.0f);
                 
         GUILayout.EndVertical();
         
         GUILayout.EndArea();
         
     }
     
     void DrawNewGame(){
         
         GUILayout.FlexibleSpace();
         
         GUILayout.Box(world.language.newGameWarning,GetStyleForOutputType(TTA_OutputType.New_Game));
         
         GUILayout.FlexibleSpace();
         
         GUILayout.BeginHorizontal();
         
         GUILayout.FlexibleSpace();
         
         Color c = GUI.backgroundColor;
         
         GUI.backgroundColor = Color.black;
         
         if(GUILayout.Button("Yes")){
             //New game
             //We'll need to reload
             TTA_Utilities.ClearSave(textAsset.name);
             SetUIState(TTA_UIState.Title);
         }
         
         GUI.backgroundColor = Color.black;
         
         if(GUILayout.Button("No")){
             SetUIState(TTA_UIState.Game);
         }
         
         GUI.backgroundColor = c;
         
         GUILayout.FlexibleSpace();
         
         GUILayout.EndHorizontal();
         
         GUILayout.FlexibleSpace();
         
     }
     
     void DrawQuit(){
         
         GUILayout.FlexibleSpace();
         
         GUILayout.Box(world.language.quitMessage,GetStyleForOutputType(TTA_OutputType.Quit));
         
         
         GUILayout.BeginHorizontal();
         
         GUILayout.FlexibleSpace();
         
         Color c = GUI.backgroundColor;
         
         GUI.backgroundColor = Color.black;
         
         if(GUILayout.Button("Yes")){
             //Quit the game. 
             //What does that even mean? Nothing
             SetUIState(TTA_UIState.Title);
         }
         
         GUI.backgroundColor = Color.black;
         
         if(GUILayout.Button("No")){
             SetUIState(TTA_UIState.Game);
         }
         
         GUI.backgroundColor = c;
         
         GUILayout.FlexibleSpace();
         
         GUILayout.EndHorizontal();
         
         GUILayout.FlexibleSpace();
         
     }
     
     void DrawGameDisplay(){
                         
         
         
         for(int i = 0; i < output.Count; i++){
             
             if(i > 0){
                 
                 if(output[i].outputType == output[i].outputType){
                     GUILayout.Label("");
                 }
                 
             }
             
             GUILayout.Label(output[i].entry,GetStyleForOutputType(output[i].outputType));
             
         }
         
 
         
         
         
         
         
         
         
         if(uiState == TTA_UIState.Game){
         
             GUILayout.Space(15.0f);
             
             GUILayout.BeginHorizontal();
             
             GUI.SetNextControlName("TEXT");
             
             input = GUILayout.TextField(input,GUILayout.ExpandWidth(true));
             
             if(GUILayout.Button("Go", GUILayout.ExpandWidth(false))){
                 
                 
                 HandleInput(input);
                                 
                 input = "";
                 
             }
             
             GUILayout.EndHorizontal();
                 
         }
         
         
         
         
         
         
         
         
         if(uiState == TTA_UIState.Victory){
             
             GUILayout.Space(15.0f);
             
             GUILayout.BeginHorizontal();
             
             if(GUILayout.Button("Quit")){
                 //Quit
                 TTA_Utilities.ClearSave(textAsset.name);
                 SetUIState(TTA_UIState.Title);
             }
             
             GUILayout.FlexibleSpace();
             
             if(GUILayout.Button("New")){
                 //Restart
                 TTA_Utilities.ClearSave(textAsset.name);
                 SetUIState(TTA_UIState.Title);
             }
             
             GUILayout.EndHorizontal();
             
             GUILayout.Space(15.0f);
             
         }
         
         if(Event.current.type == EventType.keyDown ||
             Event.current.type == EventType.KeyDown){
         
             if(!keyDown){
                 
                 if(uiState == TTA_UIState.Title){
                     SetUIState(TTA_UIState.Game);
                 }
                 else if(uiState == TTA_UIState.Victory){
                     //Do nothing
                 }
                 else{
                     HandleInput(input);
                 }
                 
                 input = "";
             }
             
             keyDown = true;
                     
             
             
         }
         
         if(Event.current.type == EventType.KeyUp ||
             Event.current.type == EventType.keyUp){
                 
             
             keyDown = false;
                 
                         
         }
         
     }
     
     void HandleInput(string input){
         
         if(string.IsNullOrEmpty(input)){
             return;
         }
         
         //This is all here so that I can plainly lay out the process through which the 
         //logic flows in order to apply your language
         //
         //I figure this is probably one of the most common things that people will want to tweak,
         //So I've exposed the working components here (instead of summing it up in a single "DrawGame" function)
         
         //We'll convert it into a basic sentence
         List<TTA_Word> sentence = TTA_InputTranslation.ProcessInput(input,world);
         
         //And then we'll filter that sentence into valid things
         sentence = TTA_InputTranslation.FilterInput(sentence,world);
         
         //And then we'll turn it into something we can use
         TTA_InputResult result = TTA_InputTranslation.TranslateSentence(sentence,world);
         
         //And now that that is done, we'll get something to actually draw.
         //At the culmination of this, we will 
         output = TTA_InputTranslation.ProcessInputResult(result,output,world);
                     
         //Just a nice little function to strip the empty results and replace them with [None] (it's easier for debugging)
         FilterOutput();
     }
     
     void FilterOutput(){
                 
         for(int i = 0; i < output.Count; i++){
             
             if(string.IsNullOrEmpty(output[i].entry)){
                 output[i].entry = "[None]";
             }
             
         }
         
     }
     
 }
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheIronHobo · Jul 21, 2013 at 07:17 AM 0
Share

I may have found the problem in a seperate file altogether

avatar image TheIronHobo · Jul 21, 2013 at 07:24 AM 0
Share

nvm. I have no idea now

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TheIronHobo · Jul 21, 2013 at 08:05 AM

For the very small number of you that might find this useful the way to not make it scroll is to comment out

 case TTA_CommandType.None:{
             
                 currentState.Add(new TTA_OutputEntry(world.language.GetGeneralFailureMessage(),TTA_OutputType.Failure));
             
                 break;
             }




from the input translation file. Finally I can get some rest...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to changes font, color & size of the text in textfield? 2 Answers

Textfield doubt, multiplayer purpose... 2 Answers

TextField text component not updating 2 Answers

Unity GUI text displaying as noise 1 Answer

how to put the name of a car ??? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges