Run some logic only at startup

feature-better-tweakables
Andrew Cassidy 3 years ago
parent 6ee52ac18e
commit f20119565f

@ -71,16 +71,19 @@ namespace ConformalDecals {
[KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
UI_FloatRange()]
public float opacity = 1.0f;
private MaterialFloatProperty _opacityProperty;
[KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
UI_FloatRange()]
public float cutoff = 0.5f;
private MaterialFloatProperty _cutoffProperty;
[KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"),
UI_FloatRange()]
public float wear = 100;
private MaterialFloatProperty _wearProperty;
[KSPField(guiName = "#LOC_ConformalDecals_gui-multiproject", guiActive = false, guiActiveEditor = true, isPersistant = true),
@ -380,6 +383,7 @@ namespace ConformalDecals {
/// Load any settings from the decal config
protected virtual void LoadDecal(ConfigNode node) {
// PARSE TRANSFORMS
if (!HighLogic.LoadedSceneIsGame) {
decalFrontTransform = part.FindModelTransform(decalFront);
if (decalFrontTransform == null) throw new FormatException($"Could not find decalFront transform: '{decalFront}'.");
@ -413,6 +417,7 @@ namespace ConformalDecals {
}
}
}
}
// PARSE MATERIAL PROPERTIES
// set shader
@ -598,14 +603,14 @@ namespace ConformalDecals {
// update material scale
materialProperties.UpdateScale(size);
decalProjectorTransform.localScale = new Vector3(size.x, size.y, depth);
if (_isAttached) {
// update orthogonal matrix
_orthoMatrix = Matrix4x4.identity;
_orthoMatrix[0, 3] = 0.5f;
_orthoMatrix[1, 3] = 0.5f;
decalProjectorTransform.localScale = new Vector3(size.x, size.y, depth);
var projectionBounds = _boundsRenderer.bounds;
// disable all targets

Loading…
Cancel
Save