mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Logging refactor
dll update
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
@ -15,18 +16,18 @@ namespace ConformalDecals.Text {
|
||||
public override IEnumerator Load(UrlDir.UrlFile urlFile, FileInfo fileInfo) {
|
||||
if (_fallbackFont == null) {
|
||||
_fallbackFont = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().First(o => o.name == FallbackName);
|
||||
if (_fallbackFont == null) Debug.LogError($"Could not find fallback font '{FallbackName}'");
|
||||
if (_fallbackFont == null) Logging.LogError($"Could not find fallback font '{FallbackName}'");
|
||||
}
|
||||
|
||||
Debug.Log($"[ConformalDecals] '{urlFile.fullPath}'");
|
||||
Logging.Log($"Loading font file '{urlFile.fullPath}'");
|
||||
var bundle = AssetBundle.LoadFromFile(urlFile.fullPath);
|
||||
if (!bundle) {
|
||||
Debug.Log($"[ConformalDecals] could not load font asset {urlFile.fullPath}");
|
||||
Logging.Log($"Could not load font asset {urlFile.fullPath}");
|
||||
}
|
||||
else {
|
||||
var loadedFonts = bundle.LoadAllAssets<TMP_FontAsset>();
|
||||
foreach (var font in loadedFonts) {
|
||||
Debug.Log($"[ConformalDecals] adding font {font.name}");
|
||||
Logging.Log($"Adding font {font.name}");
|
||||
font.fallbackFontAssets.Add(_fallbackFont);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
@ -66,7 +67,6 @@ namespace ConformalDecals.Text {
|
||||
|
||||
/// Unregister a user of a piece of text
|
||||
public static void UnregisterText(DecalText text) {
|
||||
Debug.Log($"[ConformalDecals] Unregistering text '{text.Text}'");
|
||||
if (RenderCache.TryGetValue(text, out var renderedText)) {
|
||||
renderedText.UserCount--;
|
||||
if (renderedText.UserCount <= 0) {
|
||||
@ -78,10 +78,10 @@ namespace ConformalDecals.Text {
|
||||
|
||||
private void Start() {
|
||||
if (_instance != null) {
|
||||
Debug.Log("[ConformalDecals] Duplicate TextRenderer created???");
|
||||
Logging.LogError("Duplicate TextRenderer created???");
|
||||
}
|
||||
|
||||
Debug.Log("[ConformalDecals] Creating TextRenderer Object");
|
||||
Logging.Log("Creating TextRenderer Object");
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
@ -90,13 +90,13 @@ namespace ConformalDecals.Text {
|
||||
private void Setup() {
|
||||
if (_isSetup) return;
|
||||
|
||||
Debug.Log("[ConformalDecals] Setting Up TextRenderer Object");
|
||||
Logging.Log("Setting Up TextRenderer Object");
|
||||
|
||||
_tmp = gameObject.AddComponent<TextMeshPro>();
|
||||
_tmp.renderer.enabled = false; // dont automatically render
|
||||
|
||||
_blitShader = Shabby.Shabby.FindShader(ShaderName);
|
||||
if (_blitShader == null) Debug.LogError($"[ConformalDecals] could not find text blit shader named '{ShaderName}'");
|
||||
if (_blitShader == null) Logging.LogError($"Could not find text blit shader named '{ShaderName}'");
|
||||
|
||||
_isSetup = true;
|
||||
}
|
||||
@ -108,11 +108,6 @@ namespace ConformalDecals.Text {
|
||||
return null;
|
||||
}
|
||||
|
||||
Debug.Log($"[ConformalDecals] Starting Text Rendering Job. queue depth = {RenderJobs.Count}, cache size = {RenderCache.Count}");
|
||||
foreach (var cacheitem in RenderCache) {
|
||||
Debug.Log($"[ConformalDecals] Cache item: '{cacheitem.Key.Text}' with {cacheitem.Value.UserCount} users");
|
||||
}
|
||||
|
||||
job.Start();
|
||||
|
||||
Texture2D texture = null;
|
||||
@ -123,15 +118,10 @@ namespace ConformalDecals.Text {
|
||||
|
||||
if (oldRender.UserCount <= 0) {
|
||||
// this is the only usage of this output, so we are free to re-render into the texture
|
||||
Debug.Log("Render output is not shared with other users, so reusing texture and removing cache slot");
|
||||
|
||||
texture = oldRender.Texture;
|
||||
RenderCache.Remove(job.OldText);
|
||||
}
|
||||
else {
|
||||
// other things are using this render output, so decriment usercount, and we'll make a new entry instead
|
||||
Debug.Log("Render output is shared with other users, so making new output");
|
||||
}
|
||||
}
|
||||
|
||||
// now that all old references are handled, begin rendering the new output
|
||||
@ -210,7 +200,7 @@ namespace ConformalDecals.Text {
|
||||
};
|
||||
|
||||
if (textureSize.x == 0 || textureSize.y == 0) {
|
||||
Debug.LogWarning("[ConformalDecals] No text present or error in texture size calculation. Aborting.");
|
||||
Logging.LogWarning("No text present or error in texture size calculation. Aborting.");
|
||||
return new TextRenderOutput(Texture2D.blackTexture, Rect.zero);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user