Example #1
0
    public new void OnGUI()
    {
        base.OnGUI();

        if (show)
        {
            float informationWindowWidth = Screen.width / 5f;
            float contentHeight          = calculateContentHeight(informationWindowWidth);    // TODO - calculate precise information height
            windowRect = new Rect(0, 0, informationWindowWidth, Screen.height);
            Rect viewRect = new Rect(0, 0, Screen.width / 5f + 10, contentHeight);

            GUI.Box(windowRect, "", windowStyle);

            using (GUI.ScrollViewScope scrollScope = new GUI.ScrollViewScope(windowRect, scrollPosition, viewRect, SCROLLBAR_NOT_VISIBLE, VERTICAL_SCROLLBAR_VISIBLE)) {
                scrollPosition = scrollScope.scrollPosition;

                float y = 0;
                foreach (KeyValuePair <string, object> infoRow in information)
                {
                    printKeyValuePair(infoRow, ref y, informationWindowWidth);
                }
                if (GUI.Button(new Rect(informationWindowWidth - 35f, 5f, 20f, 20f), "X"))
                {
                    hideInformation();
                }
                // TODO - If we should keep this, make some text/image
                if (informationObject != null && informationObject.GetType() == typeof(InformationVehicle) && !informationObject.GetComponent <Vehicle>().destroying)
                {
                    if (GUI.Button(new Rect(informationWindowWidth - 35f, 35f, 20f, 20f), ""))
                    {
                        switchCamera();
                    }
                }

                if (follow && informationObject != null && informationObject.gameObject != null)
                {
                    scrollToInformationBase(informationObject);
                }
            }
        }
    }