22using System . Collections ;
33using System . Collections . Generic ;
44
5- // This is in fact just the Water script from Pro Standard Assets,
6- // just with refraction stuff removed.
5+ // This MirrorReflection.cs is the version for Scriptable Render Pipeline.
76
87namespace UnityChan
98{
@@ -16,8 +15,15 @@ public enum Mode
1615 wall
1716 }
1817
19- public Mode _Mode = Mode . water ;
18+ public enum SetMirrorFor
19+ {
20+ GameView , // Set this mirror object for Game view.
21+ SceneView // Set this mirror object for Scene view.
22+ }
2023
24+
25+ public Mode _Mode = Mode . water ;
26+ public SetMirrorFor _SetMirrorFor = SetMirrorFor . GameView ;
2127 public bool m_DisablePixelLights = true ;
2228 public int m_TextureSize = 256 ;
2329 [ SerializeField ]
@@ -35,13 +41,21 @@ public enum Mode
3541 private int m_OldReflectionTextureSize = 0 ;
3642 private static bool s_InsideRendering = false ;
3743
38- public void OnWillRenderObject ( )
44+ public void Update ( )
3945 {
4046 var rend = GetComponent < Renderer > ( ) ;
4147 if ( ! enabled || ! rend || ! rend . sharedMaterial || ! rend . enabled )
4248 return ;
49+ Camera cam = null ;
50+ switch ( _SetMirrorFor ) {
51+ case SetMirrorFor . GameView :
52+ cam = Camera . main ;
53+ break ;
54+ case SetMirrorFor . SceneView :
55+ cam = Camera . current ;
56+ break ;
57+ }
4358
44- Camera cam = Camera . current ;
4559 if ( ! cam )
4660 return ;
4761
0 commit comments