Skip to content

Commit

Permalink
Release 8.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Release Automat committed Aug 18, 2024
1 parent 7024999 commit 094525d
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Packages/tlp.udonutils/Editor/Tests/TestWithLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public virtual void Setup() {

UdonTestUtils.UdonTestEnvironment.ResetApiBindings();
LogAssert.ignoreFailingMessages = false;
TlpLogger = new GameObject(TlpBaseBehaviour.TlpLoggerGameObjectName).AddComponent<TlpLogger>();
Debug.Log($"Created {TlpBaseBehaviour.TlpLoggerGameObjectName}: {TlpLogger == true}");
TlpLogger = new GameObject(TlpLogger.ExpectedGameObjectName()).AddComponent<TlpLogger>();
Debug.Log($"Created {TlpLogger.ExpectedGameObjectName()}: {TlpLogger == true}");
TlpLogger.Severity = ELogLevel.Warning;

UdonTestEnvironment = new UdonTestUtils.UdonTestEnvironment();
Expand Down
11 changes: 11 additions & 0 deletions Packages/tlp.udonutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [8.2.1] - 2024-08-18

#### 🐛 Bug Fixes

- *(TlpBaseBehaviour)* Correct gameobject path in setup error message

#### ⚙️ Miscellaneous Tasks

- Prevent error log spam when logger is missing
- Add support for com.vrchat.worlds 3.7.x

### [8.2.0] - 2024-06-02

#### 🚀 Features
Expand Down
22 changes: 21 additions & 1 deletion Packages/tlp.udonutils/Runtime/Logger/TlpLogger.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using JetBrains.Annotations;
using TLP.UdonUtils.Runtime.Common;
using TLP.UdonUtils.Runtime.Sources;
using UdonSharp;
using UnityEngine;
Expand Down Expand Up @@ -74,6 +76,20 @@ public class TlpLogger : TlpBaseBehaviour
private float _lastLog;
#endregion

public void OnEnable() {
#region TLP_DEBUG
#if TLP_DEBUG
DebugLog(Prefix, nameof(OnEnable), ExecutionOrder, this);
#endif
#endregion

string expectedName = ExpectedGameObjectName();
if (gameObject.name == expectedName) {
return;
}
Warn(Prefix, $"Changing name of GameObject '{transform.GetPathInScene()}' to '{expectedName}'", this);
gameObject.name = expectedName;
}

public void Update() {
_frameTimeStopwatch.Restart();
Expand Down Expand Up @@ -194,6 +210,10 @@ public virtual void Error(string logPrefix, string message, Object context) {
}

#region Hook Implementations
public static string ExpectedGameObjectName() {
return $"TLP_Logger";
}

protected override bool SetupAndValidate() {
if (!Utilities.IsValid(TimeSource)) {
Error($"{nameof(TimeSource)} is not set");
Expand Down
38 changes: 31 additions & 7 deletions Packages/tlp.udonutils/Runtime/TlpBaseBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class TlpBaseBehaviour : UdonSharpBehaviour

protected const int InvalidPlayer = -1;
protected const int NoUser = InvalidPlayer;
public const string TlpLoggerGameObjectName = "TLP_Logger";
private const string PlayerTagTlpLoggerMissingLogged = "TlpLoggerMissingLogged";
#endregion

#region Settings
Expand Down Expand Up @@ -196,7 +196,7 @@ public virtual void Start() {
if (!SetupAndValidate()) {
ErrorAndDisableGameObject(
$"Some dependencies are not set up correctly. " +
$"Deactivating GameObject '{this.GetComponentPathInScene()}'");
$"Deactivating GameObject '{transform.GetPathInScene()}'");
}
}
#endregion
Expand All @@ -212,14 +212,26 @@ protected virtual bool SetupAndValidate() {
return true;
}

Debug.LogError($"{LOGPrefix} : No {nameof(TlpLogger)} found. Please add the Prefab 'TLP_Logger' to your scene.");
if (MissingLoggerLogged()) {
// no need to fail again on all the other scripts if the first
// one already logged the error regarding the missing logger
return true;
}

GloballyRememberMissingLoggerLogged();
Debug.LogError(
$"{LOGPrefix}: No active {nameof(TlpLogger)} found. Please add the Prefab 'TLP_Logger' to your scene and make sure the GameObject is activated", this);
return false;
}

private static void GloballyRememberMissingLoggerLogged() {
Networking.LocalPlayer.SetPlayerTag(PlayerTagTlpLoggerMissingLogged, "true");
}
#endregion

#region Logging
private bool _hadLogger;
private string LOGPrefix => $"[{ExecutionOrderReadOnly} {this.GetScriptPathInScene()}]";
private string LOGPrefix => $"[{ExecutionOrderReadOnly} {this.GetScriptPathInScene()}] ";


protected TlpLogger Logger { private set; get; }
Expand Down Expand Up @@ -295,14 +307,15 @@ private bool GetLogger() {
return true;
}

var logger = GameObject.Find(TlpLoggerGameObjectName);
var logger = GameObject.Find(TlpLogger.ExpectedGameObjectName());
if (!Utilities.IsValid(logger)) {
if (_hadLogger) {
#if TLP_DEBUG
Debug.LogWarning($"{LOGPrefix} : Logger is already destroyed", this);
#endif
} else {
Debug.LogWarning($"{LOGPrefix} : GameObject '{TlpLoggerGameObjectName}' not found", this);
} else if (!MissingLoggerLogged()) {
GloballyRememberMissingLoggerLogged();
Debug.LogError($"{LOGPrefix}: No active TlpLogger found. Please add the Prefab '{TlpLogger.ExpectedGameObjectName()}' to your scene and make sure the GameObject is activated", this);
}

return false;
Expand Down Expand Up @@ -436,5 +449,16 @@ public virtual void OnPrepareForReturnToPool() {
#endif
}
#endregion

#region Internal
private static bool MissingLoggerLogged() {
var localPlayer = Networking.LocalPlayer;
if (!Utilities.IsValid(localPlayer)) {
return false;
}

return localPlayer.GetPlayerTag(PlayerTagTlpLoggerMissingLogged) == "true";
}
#endregion
}
}
4 changes: 2 additions & 2 deletions Packages/tlp.udonutils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tlp.udonutils",
"displayName": "TLP UdonUtils",
"version": "8.2.0",
"version": "8.2.1",
"description": "Contains the base scripts/tools for TLP packages as well as prefabs and potentially helpful scripts for VRChat worlds.",
"gitDependencies": {},
"legacyFolders": {
Expand All @@ -14,7 +14,7 @@
"url": "https://github.com/Guribo"
},
"vpmDependencies": {
"com.vrchat.worlds": "3.6.x",
"com.vrchat.worlds": "3.7.x",
"com.cyan.playerobjectpool": "1.1.x"
},
"unity": "2022.3"
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [8.2.1] - 2024-08-18

#### 🐛 Bug Fixes

- *(TlpBaseBehaviour)* Correct gameobject path in setup error message

#### ⚙️ Miscellaneous Tasks

- Prevent error log spam when logger is missing
- Add support for com.vrchat.worlds 3.7.x

### [8.2.0] - 2024-06-02

#### 🚀 Features
Expand Down

0 comments on commit 094525d

Please sign in to comment.