9 Commits
0.2.0 ... 0.2.2

Author SHA1 Message Date
5065a8abf3 Merge branch 'main' into release 2020-10-11 16:21:34 -07:00
1ebed608a8 Fix corrupted text rendering
Fix text corruption when rendering text right after a scene change by delaying it by a single frame in OnLoad
2020-10-11 03:05:07 -07:00
98a790630e Remove call to get_dataPath from constructor
Fixes error in development build of KSP
2020-10-07 00:12:15 -07:00
ef90f73288 Update ConformalDecals.version 2020-10-04 21:03:46 -07:00
880f463ee0 Merge branch 'master' into release 2020-10-04 16:15:45 -07:00
0066cc332e Changelog and version bump 2020-10-04 16:15:06 -07:00
8f22856064 Use enter/return for newline in text entry 2020-10-04 16:05:24 -07:00
5ef33b1d85 Use supported render texture format on DirectX 2020-10-04 14:59:58 -07:00
27ecd82193 Rename font file to avoid windows legacy features 2020-10-04 14:40:07 -07:00
13 changed files with 62 additions and 28 deletions

View File

@ -883,7 +883,7 @@ MonoBehaviour:
m_InputType: 0
m_AsteriskChar: 42
m_KeyboardType: 0
m_LineType: 1
m_LineType: 2
m_HideMobileInput: 0
m_CharacterValidation: 0
m_RegexValue:
@ -1407,7 +1407,7 @@ MonoBehaviour:
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_isInputParsingRequired: 0
m_inputSource: 0
m_inputSource: 3
m_hasFontAssetChanged: 0
m_subTextObjects:
- {fileID: 0}
@ -3679,7 +3679,7 @@ MonoBehaviour:
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_isInputParsingRequired: 0
m_inputSource: 3
m_inputSource: 0
m_hasFontAssetChanged: 0
m_subTextObjects:
- {fileID: 0}
@ -3838,7 +3838,7 @@ MonoBehaviour:
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_isInputParsingRequired: 0
m_inputSource: 3
m_inputSource: 0
m_hasFontAssetChanged: 0
m_subTextObjects:
- {fileID: 0}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8580f3c17793051fdc08447401fb7920665ad681ff352588508044b662a3240b
size 364900

View File

@ -6,13 +6,13 @@
{
"MAJOR":0,
"MINOR":2,
"PATCH":0,
"PATCH":2,
"BUILD":0
},
"KSP_VERSION":
{
"MAJOR":1,
"MINOR":9,
"MINOR":10,
"PATCH":1
},
"KSP_VERSION_MIN":{
@ -25,4 +25,4 @@
"MINOR":10,
"PATCH":99
}
}
}

View File

@ -1,4 +1,4 @@
# Conformal Decals v0.2.0
# Conformal Decals v0.2.2
[![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)

View File

@ -36,6 +36,9 @@
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAssets, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls\KSPAssets.dll</HintPath>
</Reference>
<Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/Shabby.dll</HintPath>
</Reference>

View File

@ -1,3 +1,4 @@
using System.Collections;
using ConformalDecals.MaterialProperties;
using ConformalDecals.Text;
using ConformalDecals.UI;
@ -99,7 +100,15 @@ namespace ConformalDecals {
base.OnLoad(node);
OnAfterDeserialize();
UpdateTextRecursive();
if (HighLogic.LoadedSceneIsGame) {
// For some reason, rendering doesnt work right on the first frame a scene is loaded
// So delay any rendering until the next frame when called in OnLoad
// This is probably a problem with Unity, not KSP
StartCoroutine(UpdateTextLate());
}
else {
UpdateText();
}
}
public override void OnSave(ConfigNode node) {
@ -107,12 +116,6 @@ namespace ConformalDecals {
base.OnSave(node);
}
public override void OnStart(StartState state) {
base.OnStart(state);
UpdateTextRecursive();
}
public override void OnAwake() {
base.OnAwake();
@ -210,7 +213,7 @@ namespace ConformalDecals {
public void OnAfterDeserialize() {
_font = DecalConfig.GetFont(fontName);
_style = new DecalTextStyle((FontStyles) style, vertical, lineSpacing, charSpacing);
if (!ParseUtil.TryParseColor32(fillColor, out _fillColor)) {
Logging.LogWarning($"Improperly formatted color value for fill: '{fillColor}'");
_fillColor = Color.magenta;
@ -252,6 +255,11 @@ namespace ConformalDecals {
}
}
private IEnumerator UpdateTextLate() {
yield return null;
UpdateText();
}
private void UpdateText() {
// Render text
var newText = new DecalText(text, _font, _style);

View File

@ -8,7 +8,7 @@ using UnityEngine;
namespace ConformalDecals.Text {
/// KSP database loader for KSPFont files which contain TextMeshPro font assets
[DatabaseLoaderAttrib(new[] {"kspfont"})]
[DatabaseLoaderAttrib(new[] {"decalfont"})]
public class FontLoader : DatabaseLoader<GameDatabase.TextureInfo> {
private const string FallbackName = "NotoSans-Regular SDF";
private static TMP_FontAsset _fallbackFont;

View File

@ -4,6 +4,7 @@ using ConformalDecals.Util;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
namespace ConformalDecals.Text {
// TODO: Testing shows the job system is unnecessary, so remove job system code.
@ -15,10 +16,11 @@ namespace ConformalDecals.Text {
/// Texture format used for returned textures.
/// Unfortunately due to how Unity textures work, this cannot be R8 or Alpha8,
/// so theres always a superfluous green channel using memory
public const TextureFormat TextTextureFormat = TextureFormat.RG16;
public static TextureFormat textTextureFormat = TextureFormat.RG16;
/// Render Texture format used when rendering
public const RenderTextureFormat TextRenderTextureFormat = RenderTextureFormat.R8;
/// Overriden below to be ARGB32 on DirectX because DirectX is dumb
public static RenderTextureFormat textRenderTextureFormat = RenderTextureFormat.R8;
/// The text renderer object within the scene which contains the TextMeshPro component used for rendering.
public static TextRenderer Instance {
@ -84,6 +86,15 @@ namespace ConformalDecals.Text {
Logging.Log("Creating TextRenderer Object");
_instance = this;
DontDestroyOnLoad(gameObject);
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12) {
textRenderTextureFormat = RenderTextureFormat.ARGB32; // DirectX is dumb
}
if (!SystemInfo.SupportsTextureFormat(textTextureFormat)) {
Logging.LogError($"Text texture format {textTextureFormat} not supported on this platform.");
}
if (!SystemInfo.SupportsRenderTextureFormat(textRenderTextureFormat)) {
Logging.LogError($"Text texture format {textRenderTextureFormat} not supported on this platform.");
}
}
/// Setup this text renderer instance for rendering
@ -227,10 +238,10 @@ namespace ConformalDecals.Text {
// SETUP TEXTURE
if (texture == null) {
texture = new Texture2D(textureSize.x, textureSize.y, TextTextureFormat, true);
texture = new Texture2D(textureSize.x, textureSize.y, textTextureFormat, true);
}
else if (texture.width != textureSize.x || texture.height != textureSize.y || texture.format != TextTextureFormat) {
texture.Resize(textureSize.x, textureSize.y, TextTextureFormat, true);
else if (texture.width != textureSize.x || texture.height != textureSize.y || texture.format != textTextureFormat) {
texture.Resize(textureSize.x, textureSize.y, textTextureFormat, true);
}
// GENERATE PROJECTION MATRIX
@ -239,13 +250,14 @@ namespace ConformalDecals.Text {
bounds.center.y - halfSize.y, bounds.center.y + halfSize.y, -1, 1);
// GET RENDERTEX
var renderTex = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 0, TextRenderTextureFormat, RenderTextureReadWrite.Linear, 1);
var renderTex = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 0, textRenderTextureFormat, RenderTextureReadWrite.Linear, 1);
renderTex.autoGenerateMips = false;
// RENDER
Graphics.SetRenderTarget(renderTex);
GL.PushMatrix();
GL.LoadProjectionMatrix(matrix);
GL.LoadIdentity();
GL.Clear(false, true, Color.black);
for (var i = 0; i < meshes.Length; i++) {

View File

@ -5,8 +5,8 @@ using UnityEngine.UI;
namespace ConformalDecals.UI {
[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class UILoader : MonoBehaviour {
private static readonly string Path = KSPUtil.ApplicationRootPath + "GameData/ConformalDecals/Resources/";
private static string _path;
private static GameObject _textEntryPrefab;
private static GameObject _fontMenuPrefab;
private static GameObject _colorPickerPrefab;
@ -16,7 +16,8 @@ namespace ConformalDecals.UI {
public static GameObject ColorPickerPrefab => _colorPickerPrefab;
private void Awake() {
var prefabs = AssetBundle.LoadFromFile(Path + "ui.conformaldecals");
_path = KSPUtil.ApplicationRootPath + "GameData/ConformalDecals/Resources/";
var prefabs = AssetBundle.LoadFromFile(_path + "ui.conformaldecals");
_textEntryPrefab = prefabs.LoadAsset("TextEntryPanel") as GameObject;
_fontMenuPrefab = prefabs.LoadAsset("FontMenuPanel") as GameObject;

View File

@ -1,3 +1,16 @@
v0.2.2
------
- Fixes:
- Fixed corrupted text rendering when a vessel loads during a scene change.
v0.2.1
------
- Changes:
- Pressing enter in the text entry window now types a newline.
- Fixes:
- Renamed font assetbundle. The old extension was causing the game to try to load it twice on Windows due to legacy compatability features.
- Fixed text rendering on DirectX resulting in black boxes by using ARGB32 instead of RG16 for the render texture in DirectX.
v0.2.0
------
- New Parts: