Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BrandonYJ · Jan 05, 2017 at 06:04 PM · mouseoverfillfillrate

how to Reverse VR gaze fill image HandleOut exit?

I'm using VR sample button input for the image fill but what i'm trying to achieve is after on handle out the fill bar reverse back to 0 with animation instead of resetting to 0 immediately without animation. Any help on making it possible will do I'm kinda new to Unity As well. Cheers for the help

     public IEnumerator WaitForBarToFill ()
     {
         // If the bar should disappear when it's filled, it needs to be visible now.
         if (m_BarCanvas && m_DisappearOnBarFill)
             m_BarCanvas.SetActive(true);

         // Currently the bar is unfilled.
         m_BarFilled = false;

         // Reset the timer and set the slider value as such.
         m_Timer = 0f;
         SetSliderValue (0f);

         // Keep coming back each frame until the bar is filled.
         while (!m_BarFilled)
         {
             yield return null;
         }

         // If the bar should disappear once it's filled, turn it off.
         if (m_BarCanvas && m_DisappearOnBarFill)
             m_BarCanvas.SetActive(false);
     }


     private IEnumerator FillBar ()
     {
         // When the bar starts to fill, reset the timer.
         m_Timer = 0f;

         // The amount of time it takes to fill is either the duration set in the inspector, or the duration of the radial.
         float fillTime = m_SelectionRadial != null ? m_SelectionRadial.SelectionDuration : m_Duration;

         // Until the timer is greater than the fill time...
         while (m_Timer < fillTime)
         {
             // ... add to the timer the difference between frames.
             m_Timer += Time.deltaTime;

             // Set the value of the slider or the UV based on the normalised time.
             SetSliderValue(m_Timer / fillTime);
             
             // Wait until next frame.
             yield return null;

             // If the user is still looking at the bar, go on to the next iteration of the loop.
             if (m_GazeOver)
                 continue;

             // If the user is no longer looking at the bar, reset the timer and bar and leave the function.
             m_Timer = 0f;
             SetSliderValue (0f);
             yield break;
         }

         // If the loop has finished the bar is now full.
         m_BarFilled = true;

         // If anything has subscribed to OnBarFilled call it now.
         if (OnBarFilled != null)
             OnBarFilled ();

         // Play the clip for when the bar is filled.
         m_Audio.clip = m_OnFilledClip;
         m_Audio.Play();

         // Wait for the screen to fade out.
         StartCoroutine (FadeToMenu ());

         // If the bar should be disabled once it is filled, do so now.
         if (m_DisableOnBarFill)
             enabled = false;
     }
     private IEnumerator FadeToMenu ()
     {
         // Wait for the screen to fade out.
         yield return StartCoroutine (m_VRCameraFade.BeginFadeOut (true));

         // Load the main menu by itself.
         Application.LoadLevel ("exterior");
     }

     private void SetSliderValue (float sliderValue)
     {
         // If there is a slider component set it's value to the given slider value.
         if (m_Slider)
             m_Slider.value = sliderValue;

         // If there is a renderer set the shader's property to the given slider value.
         if(m_Renderer)
             m_Renderer.sharedMaterial.SetFloat (k_SliderMaterialPropertyName, sliderValue);
     }


     private void HandleDown ()
     {
         // If the user is looking at the bar start the FillBar coroutine and store a reference to it.
         if (m_GazeOver)
             m_FillBarRoutine = StartCoroutine(FillBar());
         m_Timer = 2f;
     }


     private void HandleUp ()
     {
         // If the coroutine has been started (and thus we have a reference to it) stop it.
         if(m_FillBarRoutine != null)
             StopCoroutine (m_FillBarRoutine);

         // Reset the timer and bar values.
         m_Timer = 0f;
         SetSliderValue(0f);
     }


     private void HandleOver ()
     {
         // The user is now looking at the bar.
         m_GazeOver = true;

         // Play the clip appropriate for when the user starts looking at the bar.
         m_Audio.clip = m_OnOverClip;
         m_Audio.Play();
         //m_text.SetActive(true);

         m_FillBarRoutine = StartCoroutine(FillBar());
         //HandleDown(); // Here autoclick
     }


     private void HandleOut ()
     {
         // The user is no longer looking at the bar.
         m_GazeOver = false;
         //m_text.SetActive(false);
         // If the coroutine has been started (and thus we have a reference to it) stop it.
         if (m_FillBarRoutine != null)
             StopCoroutine(m_FillBarRoutine);

         // Reset the timer and bar values.
         m_Timer = 0f;
         SetSliderValue(0f);
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Flood Fill algorithm implementation in C# problem 2 Answers

How do I implement a fill mechanism in a drawing game 0 Answers

effect of an object when mouseover 1 Answer

I am making a MouseOver function and its not working 0 Answers

How do I display "guideline(s)" with short descriptive text and/or Object name above object on Mouseover? Anyone? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges