3

I try to code a script to change the skybox when someone touch the touch pad (of the samsung gear VR). I make some research about the touchpad input, and I found that it's supposed to work like a mouse. Sooo I've done this :

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

public class skyboxSwitcher : MonoBehaviour {   
   public List<Material> boxes = new List<Material>();  
   private int index = 0;

   void Update() {
      if (Input.GetMouseButtonDown(0)) 
         switchBox();
   } 

   public void switchBox() {
      if (boxes.Count > 0) {
         index++;
         if (index >= boxes.Count) {
            index = 0;
         }
         RenderSettings.skybox = boxes[index];
      }
   }
}

But it's does not work. I read the documentation and try some other inputs, but still get the same result. Maybe someone already had the same issue? Thanks :)

Cactus
  • 27,075
  • 9
  • 69
  • 149
Lubelia
  • 31
  • 5
  • `voidUpdate()` should be `void Update()` and `publicvoidswitchBox()` should be `public void switchBox()` (or are those typos?) – Robert Nov 27 '15 at 14:41
  • 1
    Ho, in my code I put spaces, but when I copy paste here they must have disappeared :/ I'm gonna try to edit my post! – Lubelia Nov 27 '15 at 15:42
  • hehe - I thought that might be the case. =) Anyway, `Input.GetMouseButtonDown(0)` is correct. I have used it successfully. See this question: http://stackoverflow.com/questions/32289354/input-not-recognised-from-touchpad – Robert Nov 27 '15 at 16:26

1 Answers1

0

This should works, but you can also use :

if (Input.GetButtonDown("Fire1"))

But you need at last Unity 5.2 (I think).