Search Unity

How do I to turn off items on a button click

Discussion in 'AR/VR (XR) Discussion' started by JBEDUnity, Jul 21, 2020.

  1. JBEDUnity

    JBEDUnity

    Joined:
    Jul 13, 2020
    Posts:
    23
    Not sure what's going on here but I just want to be able to switch between things being on or off as I click on a button.


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class InputTest : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    public GameObject[] objects;
    public int activeIndex = 0;
    public int aIndex;

    if (OVRInput.Get(OVRInput.Button.One))
    {
    activeIndex = aIndex;
    for (int i = 0; i < objects.Length; i++)
    objects.SetActive(i == activeIndex);
    }

    }
    }