Added a debug logger

This commit is contained in:
Adam Ramberg 2019-04-05 14:36:20 +02:00
parent 7f1a44a090
commit 3c35adae82
5 changed files with 68 additions and 15 deletions

View File

@ -2,6 +2,9 @@
using System.Collections.Generic;
using UnityEngine;
using UnityAtoms.Extensions;
#if UNITY_EDITOR
using UnityAtoms.Logger;
#endif
namespace UnityAtoms
{
@ -24,7 +27,9 @@ namespace UnityAtoms
{
if (IsNotUsed == null)
{
Debug.LogWarning("IsUsed must be defined!");
#if UNITY_EDITOR
AtomsLogger.Warning("IsUsed must be defined when using GetUnusedGameObject");
#endif
}
return List.List.GetOrInstantiate(Prefab, position, quaternion, IsNotUsed.Call);

8
Source/Logger.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f57f1d91e8fe94dd19e2edf81ff68919
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
using UnityEngine;
namespace UnityAtoms.Logger
{
public static class AtomsLogger
{
private const string logPrefix = "Unity Atoms :: ";
public static void Log(string msg)
{
Debug.Log(logPrefix + msg);
}
public static void Warning(string msg)
{
Debug.LogWarning(logPrefix + msg);
}
public static void Error(string msg)
{
Debug.LogError(logPrefix + msg);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16ed097ddeb0a4e598c4d0506251b733
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,14 +1,18 @@

using UnityEngine;
namespace UnityAtoms.Examples
{
[CreateAssetMenu(menuName = "Unity Atoms/Examples/Intro/Health Logger")]
public class HealthLogger : IntAction
{
public override void Do(int health)
{
Debug.Log("<3: " + health);
}
}
}
using UnityEngine;
#if UNITY_EDITOR
using UnityAtoms.Logger;
#endif
namespace UnityAtoms.Examples
{
[CreateAssetMenu(menuName = "Unity Atoms/Examples/Intro/Health Logger")]
public class HealthLogger : IntAction
{
public override void Do(int health)
{
#if UNITY_EDITOR
AtomsLogger.Log("<3: " + health);
#endif
}
}
}