@@ -6,7 +6,7 @@ public class FogRendererToggler : MonoBehaviour
66 public GameObject mesh ; // reference to the render you want toggled based on the position of this transform
77 [ Range ( 0f , 1f ) ] public float threshold = 0.1f ; //the threshold for when this script considers myRenderer should render
88
9- private const float _UPDATE_RATE = 0.2f ;
9+ private const float _UPDATE_RATE = 0.5f ;
1010
1111 private Camera _camera ; // the camera using the masked render texture
1212 private Coroutine _texUpdateCoroutine ;
@@ -17,7 +17,7 @@ public class FogRendererToggler : MonoBehaviour
1717 private static Rect _rect ;
1818 private static bool _validTexture = true ;
1919
20- private void Awake ( )
20+ private void Start ( )
2121 {
2222 // disable if:
2323 // - FOV game parameter is inactive
@@ -26,17 +26,23 @@ private void Awake()
2626 ! GameManager . instance . gameGlobalParameters . enableFOV ||
2727 ! mesh
2828 ) {
29- this . enabled = false ;
29+ Destroy ( this ) ;
30+ return ;
31+ }
32+
33+ // also disable if the unit is mine
34+ UnitManager um = GetComponent < UnitManager > ( ) ;
35+ if ( um != null && um . Unit . Owner == GameManager . instance . gamePlayersParameters . myPlayerId )
36+ {
37+ Destroy ( this ) ;
3038 return ;
3139 }
3240
3341 // mark the "first" (arbitrary) instance as main
3442 if ( _mainInstance == null )
3543 _mainInstance = this ;
36- }
3744
38- private void OnEnable ( )
39- {
45+
4046 // only run the texture updates on the main instance
4147 if ( _mainInstance == this )
4248 {
@@ -60,6 +66,7 @@ private void OnDisable()
6066
6167 private void LateUpdate ( )
6268 {
69+ if ( ! _camera ) return ;
6370 bool active = _GetColorAtPosition ( ) . grayscale >= threshold ;
6471 if ( mesh . activeSelf != active )
6572 mesh . SetActive ( active ) ;
0 commit comments