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 /
  • Help Room /
avatar image
1
Question by JPhilipp · Apr 27, 2016 at 02:33 PM · vrsteam

Hiding SteamVR Vive controller models?

Hi! Using SteamVR with the Vive, a default controller model appears, but I've put a hand in the controller tree. How would one know hide the controller model that SteamVR adds automatically? Thanks!

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Rib · Jun 01, 2016 at 12:51 AM

Hi, I just faced the same issue and found a few other approaches...

In my case I have a script that's not attached directly to a controller - though I've looked up the controller game objects.

One approach I found for hiding/showing all controllers (but I'm not sure if it's really intended to be used from non-SteamVR scripts) is to send a "hide_render_models" message like this:

 SteamVR_Utils.Event.Send("hide_render_models", !visible);

Another approach I tried was to [de]activate the SteamVR_RenderModel but found that I couldn't reactivate a model for some reason...

 void SetControllerVisible(GameObject controller, bool visible)
 {
     foreach (SteamVR_RenderModel model in controller.GetComponentsInChildren<SteamVR_RenderModel>())
         model.gameObject.SetActive(visible);
 }

(Maybe if you just want to hide the models though, something like that might be ok)

Looking at the SteamVR_RenderModel.cs code that handles the hide_render_models message, I ended up with a function like this for hiding/showing specific controllers:

 void SetControllerVisible(GameObject controller, bool visible)
 {
     foreach (SteamVR_RenderModel model in controller.GetComponentsInChildren<SteamVR_RenderModel>())
     {
         foreach (var child in model.GetComponentsInChildren<MeshRenderer>())
             child.enabled = visible;
     }
 }


Comment
Add comment · Show 1 · Share
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
avatar image JPhilipp · Jun 01, 2016 at 04:47 AM 0
Share

Thanks, the last one worked nicely here when applied to the parent of a script attached to the controller! Similary to the surface hider, I still have to invoke a call to it every now and then for the $$anonymous$$i dot to not appear when the thumb starts moving over the thumb pad.

avatar image
0

Answer by JPhilipp · Apr 27, 2016 at 03:11 PM

Update: This may be totally not how it's done, but achieved the required hiding when attached to the Update() of a script attached to the Controller gameObject.

 void HideDefaultControllerIfNeeded() {
     if (!didHideDefaultController) {
         Renderer[] renderers = this.transform.parent.GetComponentsInChildren<Renderer>();
         for (int i = 0; i < renderers.Length; i++) {
             if (renderers[i].material.name == "Standard (Instance)") {
                 renderers[i].enabled = false;
                 didHideDefaultController = true;
             }
         }
     }
 }
Comment
Add comment · Share
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
avatar image
0

Answer by Mmmpies · May 24, 2016 at 06:25 PM

Ah I see you managed to work out how to hide it all. I had a play and you can hide and show the controllers with identical code:

 using UnityEngine;
 using System.Collections;
 
 public class hideController : MonoBehaviour {
 
     private bool Hidden = false;
 
     public void HideController()
     {
         Renderer[] renderers = this.transform.parent.GetComponentsInChildren<Renderer>();
         for (int i = 0; i < renderers.Length; i++) 
         {
             if (renderers[i].material.name == "Standard (Instance)") 
             {
                 renderers[i].enabled = Hidden;
             }
         }
         Hidden = !Hidden;
     }
 }

From another script that's also attached to the controller I source that script file in Start.

     private hideController myHC;
 
 // Then in Start ...
 
     void Start()
     {
         myHC = gameObject.GetComponent<hideController> ();
     }
 
 // And call the code when the trigger gets pressed (just an example)
 
         if (device.GetPressDown (SteamVR_Controller.ButtonMask.Trigger)) {
             myHC.HideController ();
         }

The bool can only be true or false so the line

Hidden = !Hidden;

Switches between true and false.

Comment
Add comment · Share
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
avatar image
0

Answer by Shii · May 12, 2021 at 01:27 PM

You can also make an array of all render models somewhere and call this:

 foreach (SteamVR_RenderModel renderModel in renderModels)
                 renderModel.SetMeshRendererState(false);
Comment
Add comment · Share
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

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

69 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to disable Vive Controllers 5.5 support 1 Answer

SteamVR Plugin and 3D-technology don't work with each other 0 Answers

Steam VR: Two Eye Setup. 1 Answer

SteamVR/Pun Networking integration 0 Answers

Please help me solve the problem with shoot a gun(HTC VIVE) 1 Answer


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