output message to Unity Console - Debug.Log() v.s. Debug.LogWarning() v.s. Debug.LogError() v.s. print()

 output message to Unity Console - Debug.Log() v.s. Debug.LogWarning() v.s. Debug.LogError() v.s. print()

usage and description:

1.Debug.Log(string message)
The message will be printed in Unity Console. You can see it in Unity Console with General mode.

2.Debug.LogWarning(string message)
The message was considered as a warning. Then the message will be printed in Unity Console.
You can see it in Unity Console with Warning mode.
When you see it you will see a warning figure(similar to a yellow triangle).

3.Debug.LogError(string message)
The message was considered as a Error. Then the message will be printed in Unity Console.
You can see it in Unity Console with Error mode.
When you see it you will see a Error figure(similar to a red octagon).

4.print(string message)
have same result with using  Debug.Log(string message).

my blogger can explain that
little difference  between Debug.Log() and print()


screenshot:



code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PrintScript : MonoBehaviour
{
    [Header("Counter")]
    public int Counter = 0;

    [Header("Message")]
    public string Message = "not initialized!";
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        ChangeMessage();
    }
    private void ChangeMessage()
    {
        Counter += 1;
        Message = "this is the "+Counter.ToString()+ " to call func. ChangeMessage().";
        print("print:"+Message);
        Debug.Log("Debug.Log:"+Message);
        Debug.LogWarning("Debug.LogWarning:"+Message);
        Debug.LogError("Debug.LogError:"+Message);
    }
}

Comments

Popular posts from this blog

GameObject.SetActive() v.s. GameObject.active