Search Unity

Set Active Button in VR hotspots

Discussion in 'AR/VR (XR) Discussion' started by greenpyro, Jun 22, 2017.

  1. greenpyro

    greenpyro

    Joined:
    Jun 22, 2017
    Posts:
    4
    Trying to make a button based of the VR Samples that will change the active state of an element to true and then again to false if rehit.

    Wondering if anyone has any experience with this I am trying to amend the ExampleInteractiveItem to make make this work and have something like below but keeps throwing errors and cant seem to figure this out - not a C# expert by any means. Wondering if there is a Script library for this like some other platforms have?:

    Code (CSharp):
    1. using UnityEngine;
    2. using VRStandardAssets.Utils;
    3.  
    4.  
    5. namespace VRStandardAssets.Examples
    6. {
    7.     // This script is a simple example of how an interactive item can
    8.     // be used to change things on gameobjects by handling events.
    9.     public class PopUpInteractiveItem : MonoBehaviour
    10.     {
    11.          
    12.         [SerializeField] private VRInteractiveItem m_InteractiveItem;
    13.         [SerializeField] private Renderer m_Renderer;
    14.    
    15.  
    16.  
    17.            
    18.  
    19.         //Handle the Click event
    20.         private void HandleClick()
    21.         {
    22.             if (m_Renderer) {
    23.                 m_Renderer.SetActive (!m_Renderer.activeInHierarchy);
    24.                 Debug.Log ("toggle");
    25.             }
    26.         }
    27.  
    28.  
    29.  
    30.     }
    31.  
    32. }