Beispiel #1
0
 public void Initialize(VC_Log log)
 {
     Log        = log;
     Input      = log.Input;
     StackTrace = log.StackTrace;
     Count      = 1;
 }
Beispiel #2
0
        private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
        {
            VC_Log log = new VC_Log(LogTypes.Error, "Unity log callback" + string.Format("Undefined log type: {0}!", type.ToString()));

            switch (type)
            {
            case LogType.Assert:
                log = new VC_Log(LogTypes.Exception, condition + " : stackTrace: " + stackTrace);
                break;

            case LogType.Error:
                log = new VC_Log(LogTypes.Error, condition + " : stackTrace: " + stackTrace);
                break;

            case LogType.Exception:
                log = new VC_Log(LogTypes.Exception, condition + " : stackTrace: " + stackTrace);
                break;

            case LogType.Log:
                log = new VC_Log(LogTypes.Log, condition + " : stackTrace: " + stackTrace);
                break;

            case LogType.Warning:
                log = new VC_Log(LogTypes.Warning, condition + " : stackTrace: " + stackTrace);
                break;
            }
            VConsole.Log(log);
        }
Beispiel #3
0
 public static void OnLogAdded(VC_Log log)
 {
     if (logAdded != null)
     {
         logAdded(log);
     }
 }
Beispiel #4
0
 public static void Log(VC_Log log)
 {
     if (onCommandRecive != null)
     {
         onCommandRecive(log);
     }
 }
Beispiel #5
0
        void OnLogAdded(VC_Log log)
        {
            VC_LogItem instance;

            //Increase the Instance count
            if (logDictionary.ContainsKey(log))
            {
                instance        = logDictionary[log];
                instance.Count += 1;
            }
            else
            {
                //Create a New Instance
                if (transform.childCount < maxInstance)
                {
                    instance = GameObject.Instantiate(logItemPrefab);
                    instance.Initialize(log);
                    instance.transform.SetParent(transform, false);
                    instance.transform.SetAsLastSibling();

                    CacheLogItem(log, instance);

                    instance.BackgroundColor = instance.transform.GetSiblingIndex() % 2 != 0 ? logDefaultColor : logAlternateColor;
                }
                else
                {
                    //Remove the top
                    GameObject firstChild = transform.GetChild(0).gameObject;
                    instance = firstChild.GetComponent <VC_LogItem>();
                    RemoveCache(instance);
                    CacheLogItem(log, instance);

                    //Reset the Log Item
                    instance.Initialize(log);
                    instance.transform.SetAsLastSibling();
                    logDictionary.Add(log, instance);
                    instance.BackgroundColor = instance.transform.GetSiblingIndex() % 2 != 0 ? logDefaultColor : logAlternateColor;
                }

                if (gameObject.activeInHierarchy)
                {
                    if (scrollbar)
                    {
                        scrollbar.value = 0;
                    }
                }
            }
        }
Beispiel #6
0
        //private IEnumerator MoveScrollbarNextFrame()
        //{
        //    // Updating all canvases can produce frame drops if there is too much to draw. If you remove this, the scrollbar won't snap at the bottom when a new log is added.
        //    Canvas.ForceUpdateCanvases();
        //    yield return null;
        //    _scrollbar.value = 0;
        //}


        void CacheLogItem(VC_Log log, VC_LogItem instance)
        {
            logDictionary.Add(log, instance);

            if (log.Type == LogTypes.Error)
            {
                instance.Icon          = new Color(0.9607843f, 0.2538381f, 0.0588235f);
                instance.typeText.text = "Error";
                activeError.Add(instance);
            }
            else if (log.Type == LogTypes.Warning)
            {
                instance.Icon          = new Color(0.9622642f, 0.7508726f, 0.05900679f);
                instance.typeText.text = "Warning";
                activeWarning.Add(instance);
            }
            else if (log.Type == LogTypes.Log)
            {
                instance.Icon          = new Color(0.6911268f, 0.8204549f, 0.8773585f);
                instance.typeText.text = "Log";
                activeLogs.Add(instance);
            }
        }