You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using System;
|
|
using ConformalDecals.MaterialModifiers;
|
|
using ConformalDecals.Util;
|
|
using UnityEngine;
|
|
|
|
namespace ConformalDecals {
|
|
public class ModuleConformalDecalFlag : ModuleConformalDecalBase {
|
|
|
|
[KSPField]
|
|
private MaterialTextureProperty _flagTextureProperty;
|
|
|
|
public override void OnLoad(ConfigNode node) {
|
|
base.OnLoad(node);
|
|
|
|
_flagTextureProperty = new MaterialTextureProperty("_MainTex", Texture2D.whiteTexture);
|
|
materialProperties.AddProperty(_flagTextureProperty);
|
|
}
|
|
|
|
public override void OnStart(StartState state) {
|
|
base.OnStart(state);
|
|
|
|
UpdateFlag(EditorLogic.FlagURL != string.Empty ? EditorLogic.FlagURL : HighLogic.CurrentGame.flagURL);
|
|
GameEvents.onMissionFlagSelect.Add(UpdateFlag);
|
|
}
|
|
|
|
private void UpdateFlag(string flagUrl) {
|
|
_flagTextureProperty.texture = GameDatabase.Instance.GetTexture(flagUrl, false);
|
|
|
|
materialProperties.UpdateMaterials();
|
|
}
|
|
}
|
|
} |