Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Refresh reflection probe

Discussion in 'Scripting' started by tawdry, Jun 15, 2018.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,124
    Hi
    How do you tell the probe to refresh via scripting I can't find a code example anywhere least not one that works tried a few variations on the unity manual example but none work.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class refprobe : MonoBehaviour {
    6.    
    7.     // Use this for initialization
    8.     void Start () {
    9.        
    10.     }
    11.    
    12.     // Update is called once per frame
    13.     void Update () {
    14.         ReflectionProbe.RenderProbe(RenderTexture = null);
    15.  
    16.     }
    17. }
    18.  
     
  2. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,124
    Ok figured it out so anyone else who need to do this here is the script how to
    Just drag the relevant probe into the public slot.Not at all optimised just wanted to get it working first.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class refprobe : MonoBehaviour {
    6.     public ReflectionProbe ef ;
    7.     RenderTexture targetTexture ;
    8.  
    9.     // Use this for initialization
    10.     void Start () {
    11.        
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update ()
    16.     {
    17.         //ef.refreshMode=1;
    18.         ef.RenderProbe(targetTexture = null);
    19.    
    20.     }
    21. }
     
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,124
    Is there a way to add an object to the reflection probe without having to redo the entire probe area.Lets say a npc walks into frame i just want to render him new but keep the already rendered from before?