Hi, really new to unity and c# here but learning quite a bit from tutorials, ive just got stuck on 1 little bit here and i cant seem to find a proper desription. ive made a scrollview window (included a picture of my results
[34131-scrollable+window.jpg|34131]
and its scrolling through the value instead of waiting for the value to change (basically ive got a health script which works fine when a mob does damage) but i was trying to make a small combat log style window but it doesnt seem to wait for a change in value, i’ve put a line in the wrong place so im hoping someone could just point me in the right direction.
thanks for any help on this (syntax is a killer for me, so difficult to pick up)
using UnityEngine;
using System.Collections;
public class combat_log : MonoBehaviour {
public Vector2 scrollPosition = Vector2.zero;
public string longString = System.Convert.ToString(playerhp.curhp);
void LateUpdate ()
{
ammendlog(0);
}
void OnGUI()
{
GUI.Box (new Rect (Screen.width - 798, Screen.height - 125, 352, 123), "");
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
GUILayout.BeginArea (new Rect (Screen.width - 798, Screen.height - 125, 352, 123));
scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (350), GUILayout.Height (121));
scrollPosition.y = Mathf.Infinity;
GUILayout.Label (longString);
GUILayout.EndScrollView ();
GUILayout.EndArea ();
}
public void ammendlog(float adj)
{
longString += "
" + " Current Health : " + System.Convert.ToString (playerhp.curhp);
}
}