File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22using kOS . Suffixed ;
33using kOS . Safe . Utilities ;
44using UnityEngine ;
5+ using System ;
56
67namespace kOS . Module
78{
@@ -61,6 +62,10 @@ public override void OnAwake()
6162 part . RemoveModule ( pm ) ;
6263 }
6364 }
65+
66+ // make this module cheaper in update loops
67+ isEnabled = false ;
68+ enabled = false ;
6469 }
6570
6671 public void TypingDone ( string newValue )
@@ -76,4 +81,39 @@ public void TypingCancel()
7681 typingWindow = null ;
7782 }
7883 }
84+
85+ // setting isEnabled to false prevents the nametag from showing up in the PAW...work around that.
86+ [ KSPAddon ( KSPAddon . Startup . FlightAndEditor , false ) ]
87+ class KOSNameTagActivationManager : MonoBehaviour
88+ {
89+ void Awake ( )
90+ {
91+ GameEvents . onPartActionUICreate . Add ( OnPartActionUICreate ) ;
92+ GameEvents . onPartActionUIShown . Add ( OnPartActionUIShown ) ;
93+ }
94+
95+ void OnDestroy ( )
96+ {
97+ GameEvents . onPartActionUICreate . Remove ( OnPartActionUICreate ) ;
98+ GameEvents . onPartActionUIShown . Remove ( OnPartActionUIShown ) ;
99+ }
100+
101+ private void OnPartActionUICreate ( Part part )
102+ {
103+ var nameTagModule = part . FindModuleImplementing < KOSNameTag > ( ) ;
104+ if ( nameTagModule != null )
105+ {
106+ nameTagModule . isEnabled = true ;
107+ }
108+ }
109+
110+ private void OnPartActionUIShown ( UIPartActionWindow paw , Part part )
111+ {
112+ var nameTagModule = part . FindModuleImplementing < KOSNameTag > ( ) ;
113+ if ( nameTagModule != null )
114+ {
115+ nameTagModule . isEnabled = false ;
116+ }
117+ }
118+ }
79119}
You can’t perform that action at this time.
0 commit comments