GUI Update

I have a gui script here that displays the hull of a selected target from the selected targets pref file but the gui window does not update till I click off and back on to the target which does update the window…

Check this out…
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Hud : MonoBehaviour
	public GUISkin SensorHud;
	//private string textstring = "Hello";
	private float Shiphull;
	void Update ()
		var script = GameObject.Find("aaMain Camera").GetComponent<SelectTarget>();
		Shiphull = script.Shiphull;
	private void OnGUI()
	{ = SensorHud;
		//print the window based on center of screen, centering rects based on top corner, so divide screen w and h by 2
		//and subtract half of the w and height
		Rect windowSize = new Rect(Screen.width - 300,Screen.height - 250,300,250);
		windowSize = GUI.Window(1, windowSize, MyWindow, "");
	private void MyWindow(int id)
		GUILayout.Label ("Sensor Analysis",GUILayout.Width(649));
			var script = GameObject.Find("aaMain Camera").GetComponent<SelectTarget>();
			if(script.gui == "yes")
				GUILayout.Label ("Shipname: " + script.Shipname);
				GUILayout.Label ("Shiphull: " + Shiphull);
				if(script.gui == "no")
					GUILayout.Label ("Shipname: N/A");
					GUILayout.Label ("Shiphull: N/A");
			//GUI.TextField(new Rect(11,40,400,200),textstring);

What’s wrong here, shouldn’t the window be updating every frame?

In your SelectTarget script, you only update the ShipHull when a target it selected. Since your window gets its info from there, then it also only updates only when you select the target.

If you want it to update every frame, you also need to update it every frim in the SelectTarget script.