MonoBehaviour.print
Declaration
public static void print(object message);Параметры
| Параметр | Описание |
|---|---|
| сообщение | Сообщение, отображаемое в консоли. |
Описание
Заносит сообщение в журнал в Консоль Unity. Функционально эквивалентно Debug.Log.
Метод print является функционально эквивалентной альтернативой Debug.Log при использовании в сценарии Monobehaviour. См. Debug.Log для дополнительной информации.
Дополнительные ресурсы: Debug.Log, Debug.LogWarning, Debug.LogError.
using UnityEngine;
public class PrintExample : MonoBehaviour { public int playerHealth = 85; public int maxHealth = 100;
void Start() { // Simply print a message in the console print("The Start method has been called.");
// Log variables using string interpolation print($"Initial player health: {playerHealth}");
// Log a variable using formatting float healthPercentage = playerHealth / (float)maxHealth; print($"The player's total score is: {healthPercentage:F2}"); } }