Exemplo n.º 1
0
        /// <summary>
        /// Called every frame to enable rendering of GUI items
        /// to the screeen
        /// </summary>
        public static void Render()
        {
            if (!mIsEnabled)
            {
                return;
            }

            GUIStyle lStyle = new GUIStyle();

            lStyle.alignment        = TextAnchor.UpperLeft;
            lStyle.normal.textColor = Color.white;
            lStyle.fontSize         = mFontSize;

            //GUI.color = Color.white;
            GUI.contentColor    = mForeColor;
            GUI.backgroundColor = Color.green;

            // Write out the lines of text
            for (int i = 0; i < mLineIndex; i++)
            {
                LogText lLine = mLines[i];

                mLineRect.x      = lLine.X;
                mLineRect.y      = lLine.Y;
                mLineRect.width  = 900;
                mLineRect.height = mLineHeight;

                GUI.Label(mLineRect, lLine.Text, lStyle);
            }
        }
Exemplo n.º 2
0
		/// <summary>
		/// Returns an element back to the pool.
		/// </summary>
		/// <param name="rEdge"></param>
		public static void Release(LogText rInstance)
		{
			if (rInstance == null) { return; }

			// Make it available to others.
			sPool.Release(rInstance);
		}
Exemplo n.º 3
0
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static void Release(LogText rInstance)
        {
            if (rInstance == null)
            {
                return;
            }

            // Make it available to others.
            sPool.Release(rInstance);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Pulls an object from the pool.
        /// </summary>
        /// <returns></returns>
        public static LogText Allocate(string rText, int rX, int rY)
        {
            // Grab the next available object
            LogText lInstance = sPool.Allocate();

            // Set values
            lInstance.Text = rText;
            lInstance.X    = rX;
            lInstance.Y    = rY;

            return(lInstance);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Pulls an object from the pool.
        /// </summary>
        /// <returns></returns>
        public static LogText Allocate()
        {
            // Grab the next available object
            LogText lInstance = sPool.Allocate();

            // Set values
            lInstance.Text = "";
            lInstance.X    = 0;
            lInstance.Y    = 0;

            return(lInstance);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Static constructor
        /// </summary>
        static Log()
        {
            if (mLines == null)
            {
                mLines = new LogText[mLineCount];
            }
            for (int i = 0; i < mLines.Length; i++)
            {
                LogText lLine = new LogText();
                lLine.X    = 10;
                lLine.Y    = i * mLineHeight;
                lLine.Text = "";

                mLines[i] = lLine;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Called by the co-routine after rendering happens
        /// so that we can clean up our objects
        /// </summary>
        public static void Clear()
        {
            for (int i = 0; i < mLineIndex; i++)
            {
                LogText.Release(mLines[i]);
            }

            mLineIndex = 0;

            // Flush the external log if needed
#if USE_FILE_IO
            if (mWriter != null)
            {
                mWriter.Flush();
            }
#endif
        }
Exemplo n.º 8
0
        /// <summary>
        /// Writes text to the screen
        /// </summary>
        /// <param name="rText">Text to write</param>
        /// <param name="rX">X start of left character</param>
        /// <param name="rY">Y start of the left character</param>
        public static void ScreenWrite(string rText, int rX, int rY)
        {
            if (!mIsEnabled)
            {
                return;
            }

            if (mPrefixTime)
            {
                rText = String.Format("[{0:f4}] {1}", System.DateTime.Now.ToLongTimeString(), rText);
            }

            LogText lLine = LogText.Allocate(rText, rX, rY);

            mLines[mLineIndex % Log.LOG_TEXT_COUNT] = lLine;

            mLineIndex++;
            if (mLineIndex >= Log.LOG_TEXT_COUNT)
            {
                mLineIndex = Log.LOG_TEXT_COUNT - 1;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Writes text to the screen
        /// </summary>
        /// <param name="rText">Text to write</param>
        /// <param name="rX">X start of left character</param>
        /// <param name="rY">Y start of the left character</param>
        public static void ScreenWrite(string rText, int rX, int rY)
        {
            if (!mIsEnabled)
            {
                return;
            }

            if (mPrefixTime)
            {
                rText = String.Format("[{0:f4}] {1}", Time.realtimeSinceStartup, rText);
            }

            int lLineIndex = rY / mLineHeight;

            if (lLineIndex < mLines.Length)
            {
                if (mLines[lLineIndex] == null)
                {
                    LogText lLine = new LogText();
                    lLine.X    = rX;
                    lLine.Y    = lLineIndex * mLineHeight;
                    lLine.Text = rText;

                    mLines[lLineIndex] = lLine;
                }
                else
                {
                    mLines[lLineIndex].Text = rText;
                }
            }

            mLineIndex++;
            if (mLineIndex >= mLineCount)
            {
                mLineIndex = mLineCount - 1;
            }
        }