Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Refresh reflection probe

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

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,354
    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,354
    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,354
    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?
     
  4. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    387
    Is there a way to add a texture instead of render texture?
     
  5. Milrosh

    Milrosh

    Joined:
    Nov 24, 2019
    Posts:
    2
    This helped me for my mobile app thank you.
     
  6. Milrosh

    Milrosh

    Joined:
    Nov 24, 2019
    Posts:
    2
    Could possibly use raycasting but don't know if it will work as not tested it myself.
     
  7. VResearch

    VResearch

    Joined:
    Jan 6, 2021
    Posts:
    12
    Hi, I am trying to add a real-time reflection probe to my Oculus Quest app. It works fine in the editor, but not at all in build. I tried both the "render every frame" option and updating it manually from the script, both works in the editor, neither when deployed on device. Is there any trick to make real-time reflection probes work on Android?
     
    Last edited: Apr 20, 2021
unityunity