Answers for "how to clear console through script unity"

C#
5

how to clear console through script unity

using System.Reflection; //make sure you add this!
using UnityEngine;


void Update()
{
  	if (Input.GetKey("space"))
    {
      	ClearLog() //when you call this function it will clear the console
    }
}


public void ClearLog() //you can copy/paste this code to the bottom of your script
{
    var assembly = Assembly.GetAssembly(typeof(UnityEditor.Editor));
    var type = assembly.GetType("UnityEditor.LogEntries");
    var method = type.GetMethod("Clear");
    method.Invoke(new object(), null);
}
Posted by: Guest on June-27-2020

Code answers related to "how to clear console through script unity"

C# Answers by Framework

Browse Popular Code Answers by Language