mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
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();
|
||
|
}
|
||
|
}
|
||
|
}
|