I’m attempting to create a drag-able console window. I’ve created a Window, then inside of it created a scroll view with a TextArea. Then I end the scroll view and add a Input Textfield below.
However, when text fills the textarea the scrollbars do not appear.
When the Scroll area is outside of a window it does appear.
Anyone know why the Scrollbars are not appearing inside of a GUI.window?
using UnityEngine;
using System.Collections;
public class ShellTester : MonoBehaviour {
public GUISkin thisSkin = null;
public float returnRate = .5F;
public const int inputSize = 20;
public int maxInputChars = 60;
private string textAreaString = "V_Shell [Version 2.3.5] \n"+"Copyright (c) 2013 Grimm Corporation. All rights reserved.";
private string inputText = ">";
private float nextFire = 0.0F;
private Vector2 scrolLVector = new Vector2(0,0);
private bool scrollToBottom = false;
private Rect windowRect = new Rect(0,0,Screen.width*.5f,Screen.height*.5f);
void OnGUI(){
windowRect = GUILayout.Window (0,windowRect, updateV_SHELL, "V_SHELL");
}//END OnGUI
void updateV_SHELL(int windowID)
{
GUI.skin = thisSkin;
GUIStyle bt = thisSkin.GetStyle("");
scrolLVector = GUILayout.BeginScrollView(scrolLVector, GUILayout.Width((Screen.width)), GUILayout.Height((Screen.height*.6f) - 28f) );
GUILayout.TextArea(textAreaString, GUILayout.Height((Screen.height*.5f)-inputSize*2f));
if(scrollToBottom == true)
{
GUIContent gc = new GUIContent(textAreaString);
scrolLVector.y = bt.CalcHeight(gc,((Screen.height*.5f) - 28))- ((Screen.height*.5f) - 37);
scrollToBottom = false;
}
GUILayout.EndScrollView();
inputText = GUILayout.TextField(inputText); //GUI.TextField( new Rect(0, (Screen.height*.5f) - inputSize, (Screen.width*.5f), (Screen.height*.5f)),inputText,maxInputChars);
if(Event.current.keyCode == KeyCode.Return Time.time > nextFire)
{
nextFire=Time.time+returnRate;
textAreaString = textAreaString + "\n" + inputText;
inputText = ">";
scrollToBottom = true;
}
GUI.DragWindow(new Rect(0,0,Screen.width,Screen.height));