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.

What does the following code means in ARFoundation samples?

Discussion in 'AR' started by zyonneo, Feb 26, 2020.

  1. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    385
    Some code in ARFoundation which contains maths not understandable.
    Code (CSharp):
    1.  
    2. if (slider != null)
    3.             scale = slider.value * (max - min) + min;
    4. //What does the above expression means specially (max-min)+ min
    5.  
    6. void OnEnable()
    7.     {
    8.         if (slider != null)
    9.             slider.value = (scale - min) / (max - min);
    10. //The above expression meaning.
    11.         UpdateText();
    12.     }
    13.  
    I have commented the section which I dont understand
    Why is the expression given on OnEnable()?
     
  2. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    Hello,

    I think it's just a normalisation because the minimum is not 0.

    Best,
    Alexis