mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-06-11 05:54:07 +00:00
drewcassidy
22150574df
• add shader variants for decal previewing • start to add code for part icon • refactor material properties to be serializable todo: • fix decal preview scale (need to call UpdateScale on detached state) • fix texture preview in part icon • adjust culling per-object when rendering (turns out cull and ztest values are used by unity at the render time, not by the shader itself, so they can be adjusted in material property blocks!)
46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using ConformalDecals.MaterialModifiers;
|
|
using ConformalDecals.Util;
|
|
using UnityEngine;
|
|
|
|
namespace ConformalDecals {
|
|
public class ModuleConformalDecalGeneric : ModuleConformalDecalBase {
|
|
public override void OnLoad(ConfigNode node) {
|
|
base.OnLoad(node);
|
|
|
|
// set shader
|
|
materialProperties.SetShader(shader);
|
|
// add texture nodes
|
|
foreach (var textureNode in node.GetNodes("TEXTURE")) {
|
|
var textureProperty = ScriptableObject.CreateInstance<MaterialTextureProperty>();
|
|
textureProperty.ParseNode(textureNode);
|
|
materialProperties.AddProperty(textureProperty);
|
|
}
|
|
|
|
// add float nodes
|
|
foreach (var floatNode in node.GetNodes("FLOAT")) {
|
|
var floatProperty = ScriptableObject.CreateInstance<MaterialFloatProperty>();
|
|
floatProperty.ParseNode(floatNode);
|
|
materialProperties.AddProperty(floatProperty);
|
|
}
|
|
|
|
// add color nodes
|
|
foreach (var colorNode in node.GetNodes("COLOR")) {
|
|
var colorProperty = ScriptableObject.CreateInstance<MaterialColorProperty>();
|
|
colorProperty.ParseNode(colorNode);
|
|
materialProperties.AddProperty(colorProperty);
|
|
}
|
|
|
|
if (HighLogic.LoadedSceneIsGame) {
|
|
UpdateMaterials();
|
|
UpdateScale();
|
|
UpdateProjection();
|
|
}
|
|
}
|
|
|
|
public override void OnIconCreate() {
|
|
this.Log("called OnIconCreate");
|
|
OnStart(StartState.None);
|
|
UpdateScale();
|
|
}
|
|
}
|
|
} |