- Home /
This question was
closed Jul 03, 2013 at 01:26 AM by
robertbu for the following reason:
Multiple technical questions.
How do i make my chat window save messages and be a scrolling GUI
Ok so i just made a 3d text over my character and when you type a message it pops up over their head. Now what i want to do is have that message logged in the ui we have preset on the screen as well as have the gui have a scroller so i can see old messages. All my code is working but here is what I have as of right now.
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(GUITexture))]
public class ChatWindowPlacement : MonoBehaviour {
public GUIStyle style;
private GUITexture Image;
private int Screen_width;
private int Screen_height;
public string stringToEdit = "";
public TextMesh speechBubble;
void Start () {
Screen_width = Screen.width;
Screen_height = Screen.height;
Image = guiTexture;
Image.pixelInset = new Rect (Screen_width / 100, Screen_height / 100, Image.pixelInset.width, Image.pixelInset.height);
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
stringToEdit = GUI.TextField(new Rect(Screen.width /60f,Screen.height / 1.05f, 300,20),stringToEdit,25);
if(Input.GetKeyDown(KeyCode.Return))
{
speechBubble.text = stringToEdit;
}
if(GUI.Button( new Rect(Image.pixelInset.x + Image.pixelInset.width / 1.1f, Screen_height - Image.pixelInset.y - Image.pixelInset.height + Image.pixelInset.height/ 20, Image.pixelInset.width / 15, Image.pixelInset.height / 10) , "", style) ){
Debug.Log("Closing Chat");
gameObject.SetActive(false);
}
}
}
Comment
There are multiple technical issues here. You need to focus your questions on a single specific technical issue. And it helps to show you've done your homework about the issue.