Tanoda
KeyEnableGameObjects.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using System.Collections;
11using System.Collections.Generic;
12
13namespace Leap.Unity {
14 public class KeyEnableGameObjects : MonoBehaviour {
15 public List<GameObject> targets;
16 [Header("Controls")]
17 public KeyCode unlockHold = KeyCode.RightShift;
18 public KeyCode toggle = KeyCode.T;
19
20 // Update is called once per frame
21 void Update() {
22 if (unlockHold != KeyCode.None &&
23 !Input.GetKey(unlockHold)) {
24 return;
25 }
26 if (Input.GetKeyDown(toggle)) {
27 for (int i = 0; i < targets.Count; i++) {
28 targets[i].SetActive(!targets[i].activeSelf);
29 }
30 }
31 }
32 }
33}