hey i have a sidebar for a networked car game which gets information from each car like name, player, current lap. When i disable the script in game it goes up by about 30-50 FPS. any help on how to speed this up would be cool
using UnityEngine;
using System.Collections;
public class VehicleGUI : MonoBehaviour
{
public GUISkin aGUISkin;
private int maxVehiclesInRace = 8;
private GameObject[] vehicleInRace;
private VehicleCurrentRaceStats[] vehicleInRaceStats;
private Rect guiRect;
private float fltScrollerValue = 0.5f;
void Awake()
{
guiRect = new Rect(0, 100, 200, 400);
vehicleInRace = new GameObject[maxVehiclesInRace];
vehicleInRaceStats = new VehicleCurrentRaceStats[vehicleInRace.Length];
}
void OnGUI()
{
GUI.skin = aGUISkin;
guiRect = GUI.Window(0, guiRect, Sidebar, "RACE SATS", GUI.skin.GetStyle("window"));
}
void Sidebar(int windowID)
{
GUILayout.BeginVertical();
GUILayout.Label("VEHICLES");
GUILayout.Space(8);
GUILayout.TextArea("PLACE - race position" + "\nNAME " + vehicleInRaceStats[0].racerName + "\nVEHICLE " + vehicleInRaceStats[0].tag + "\nCURRENT LAP " + vehicleInRaceStats[0].currentLap);
//Scrollbars
//fltScrollerValue = GUILayout.VerticalScrollbar(fltScrollerValue, 0.1f, 0.0f, 1.1f, GUILayout.Height(90));
GUILayout.EndVertical();
}
void AddCarToArray(GameObject vehicleToAdd)
{
for (int i = 0; i <= vehicleInRace.Length; i++)
{
if (vehicleInRace[i] == null)
{
vehicleInRace[0] = vehicleToAdd;
vehicleInRaceStats[0] = vehicleInRace[0].GetComponentInChildren<VehicleCurrentRaceStats>();
}
}
}
}