Industry links | Danish game productions | Contact | Latest threads |
Google Translate |

| Main forum | Site Content | Jobs | Showcase | Development | Offtopic |


| Event Calender |

Username:   Password:   Log me on automatically each visit  





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Kan man lave et GUI.Textfield med 2 eller 3 linjer tekst?
PostPosted: 14 Apr 2012, 08:42 
Offline
Level 1 - Speck of dust

Joined: 26 Dec 2011, 10:49
Posts: 11
Unitys forum er nede, så nu forsøger jeg mig med at spørge her :-)

Er det muligt at lave et tekstfelt, brugeren kan redigere med mere end en linje?

Code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CreateGoal : MonoBehaviour {
   
   //int PrintLabelYPosition = 200;
   bool showList = false;
      
   public List<string> stringList = new List<string>();
       public string stringToEdit = "Write which goal you completed here";
   
    void OnGUI()
   {
      stringToEdit = GUI.TextField(new Rect(10, 130, 220, 42), stringToEdit, 100);
      
      //Button for adding a new string to the list
      if (GUI.Button(new Rect(10, 180, 210, 21), "Complete goal"))
      {
         stringList.Add(stringToEdit);
      }
      
      //Button for printing out the list to the console
      //if (GUI.Button(new Rect(10, 210, 210, 21), "Debug List to console"))
      //{
      //   DebugList();   
      //}
      
      //Button for printing out the strings in the list to the screen   
      if (GUI.Button(new Rect(10, 240, 210, 21), "Print list to screen"))
      {
              showList = !showList;
      }

      if (showList == true)
         PrintList();
    }
   
   //Function that prints out the strings in the list to the console
   void DebugList()
   {
      foreach(string s in stringList)
      {
         Debug.Log(s);   
      }
   }
      
      //Function that prints out the strings in the list to the screen
   void PrintList()
   {
      int PrintLabelYPosition = 260;
        foreach(string s in stringList)
      {
         GUI.Label(new Rect(10, PrintLabelYPosition, 500, 20), s);   

             PrintLabelYPosition = PrintLabelYPosition + 20;

        }
   }
   
}


Top
 Profile  
 
 Post subject: Re: Kan man lave et GUI.Textfield med 2 eller 3 linjer tekst
PostPosted: 14 Apr 2012, 10:55 
Offline
Level 12 - Master of the dark arts

Joined: 16 Mar 2011, 18:28
Posts: 128
http://unity3d.com/support/documentatio ... tArea.html

MÃ¥ske den der?

/T

_________________
Full Control
Makers of Smack Boxing, Smack Hockey, Monster Ball, Electrocute, Touch Wars, Tactical Soldier - Undead Rising, Frontline Tactics, Space Hulk


Top
 Profile  
 
 Post subject: Re: Kan man lave et GUI.Textfield med 2 eller 3 linjer tekst
PostPosted: 14 Apr 2012, 11:03 
Offline
Level 1 - Speck of dust

Joined: 26 Dec 2011, 10:49
Posts: 11
Fantastisk! Mange tak. Det er ikke sidste gang, jeg spørger efter hjælp her :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

cron
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.