Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Can I disable Debug.Logerror messages in editor mode ?

$
0
0
I have an editor script(ProviderManager) that is trying to destroy all the components(except some) attached to a gameobject. Few of these components have "RequireComponent" attribute on them so destroying the components that are "required" by other components results in error from Unity. However to avoid this I am running this function in recursion so that the component that cannot be destroyed now will get destroyed later in next iteration. The function works perfectly as I'd want it to work but the issue is Unity prints error messages in console when component destruction is not possible. I want a way to hide these error messages when running this function since I take care of these errors and I don't want them to appear in console. private void RemoveAllComponents() { int length = GetComponents().Length; if (length<= 3) { return; } foreach (var comp in GetComponents()) { //Don't remove the Transform and SturfeeXRSession component if (!(comp is Transform) && !(comp is SturfeeXRSession)) { //Don't remove this script if (!(comp is ProviderManager)) { Debug.Log(" Destroying " + comp.ToString()); Debug.unityLogger.logEnabled = false; DestroyImmediate(comp); // prints error message in console Debug.unityLogger.logEnabled = true; } } } RemoveAllComponents(); } ![alt text][1] [1]: /storage/temp/167378-screen-shot-2020-09-11-at-10910-pm.png

Viewing all articles
Browse latest Browse all 2891

Trending Articles