Ejemplo n.º 1
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            // if we received new objects build them
            if (receiveObjectQueue.Count > 0)
            {
                int count = 0;
                for (int i = 0; i < receiveObjectQueue.Count; i++)
                {
                    try
                    {
                        print("sceneLoader.createSceneGraph ");
                        sceneLoader.createSceneGraph(receiveObjectQueue[i]);

                        // HACK
                        mainController.repositionCamera();
                        // Camera.main.GetComponent<MoveCamera>().calibrate();
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        print("Exception: " + e.ToString());
                    }
                    count++;
                }
                receiveObjectQueue.RemoveRange(0, count);
            }

            if (!deactivateReceive)
            {
                //process all available transforms send by server & delete them from Queue
                int count = 0;
                for (int i = 0; i < receiveMessageQueue.Count; i++)
                {
                    // Debug.Log(receiveMessageQueue[i] as string);
                    try
                    {
                        parseTransformation(receiveMessageQueue[i] as string);
                    }
                    catch
                    {
                        VPETSettings.Instance.msg = "Error: parseTransformation";
                    }
                    count++;
                }
                receiveMessageQueue.RemoveRange(0, count);
            }

            if (camObject != null && camObject.GetComponent <Renderer>().enabled&& (Time.time - lastNcamReceivedTime) > 10)
            {
                camObject.GetComponent <Renderer>().enabled = false;
            }

            currentTimeTime = Time.time;
        }
Ejemplo n.º 2
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            // if we received new objects build them
            if (m_sceneTransferDirty)
            {
                m_sceneTransferDirty = false;
                print("sceneLoader.createSceneGraph");
                Vector3    scenePos = scene.position;
                Quaternion scenRot  = scene.rotation;
                scene.rotation = Quaternion.identity;
                scene.position = Vector3.zero;
                sceneLoader.createSceneGraph();
                sendUpdateObjects();
                // HACK
                mainController.repositionCamera();
                mainController.SetSceneScale(VPETSettings.Instance.sceneScale);
                // Camera.main.GetComponent<MoveCamera>().calibrate();

                scene.rotation = scenRot;
                scene.position = scenePos;
            }

            if (!deactivateReceive)
            {
                //process all available transforms send by server & delete them from Queue
                int count = 0;
                for (int i = 0; i < receiveMessageQueue.Count; i++)
                {
                    // Debug.Log(receiveMessageQueue[i] as string);
                    try
                    {
                        parseTransformation(receiveMessageQueue[i] as string);
                    }
                    catch
                    {
                        VPETSettings.Instance.msg = "Error: parseTransformation";
                    }
                    count++;
                }
                receiveMessageQueue.RemoveRange(0, count);
            }
            if (camObject != null && camObject.GetComponent <Renderer>().enabled&& (Time.time - lastNcamReceivedTime) > 10)
            {
                camObject.GetComponent <Renderer>().enabled = false;
            }

            currentTimeTime = Time.time;
        }
Ejemplo n.º 3
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            // if we received new objects build them
            if (m_sceneTransferDirty)
            {
                m_sceneTransferDirty = false;
                print("sceneLoader.createSceneGraph");
                sceneLoader.createSceneGraph( );
                sendUpdateObjects();
                // HACK
                mainController.repositionCamera();
                // Camera.main.GetComponent<MoveCamera>().calibrate();
            }

            if (!deactivateReceive)
            {
                //process all available transforms send by server & delete them from Queue
                int count = 0;
                for (int i = 0; i < receiveMessageQueue.Count; i++)
                {
                    // Debug.Log(receiveMessageQueue[i] as string);
                    try
                    {
                        parseTransformation(receiveMessageQueue[i] as string);
                    }
                    catch
                    {
                        VPETSettings.Instance.msg = "Error: parseTransformation";
                    }
                    count++;
                }
                receiveMessageQueue.RemoveRange(0, count);
            }

            currentTimeTime = Time.time;
        }
Ejemplo n.º 4
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
#if !SCENE_HOST
            // if we received new objects build them
            if (m_sceneTransferDirty)
            {
                m_sceneTransferDirty = false;
                print("sceneLoader.createSceneGraph");

                Vector3    scenePos = scene.position;
                Quaternion scenRot  = scene.rotation;
                scene.rotation = Quaternion.identity;
                scene.position = Vector3.zero;

                sceneLoader.createSceneGraph();
                SendObjectUpdate(null, ParameterType.RESENDUPDATE);

                int refListCount = SceneLoader.SceneEditableObjects.Count +
                                   SceneLoader.SelectableLights.Count +
                                   SceneLoader.SceneCameraList.Count;

                sceneObjectRefList = new SceneObject[refListCount];

                foreach (GameObject gameObject in SceneLoader.SceneEditableObjects)
                {
                    Debug.Log(gameObject.name);
                    SceneObject sceneObject = gameObject.GetComponent <SceneObject>();
                    Debug.Log(sceneObject.id + " " + sceneObject.name);
                    if (sceneObjectRefList.Length > sceneObject.id)
                    {
                        sceneObjectRefList[sceneObject.id] = sceneObject;
                    }
                }

                foreach (GameObject gameObject in SceneLoader.SelectableLights)
                {
                    SceneObject sceneObject = gameObject.GetComponent <SceneObjectLight>();
                    if (sceneObjectRefList.Length > sceneObject.id)
                    {
                        sceneObjectRefList[sceneObject.id] = sceneObject;
                    }
                }

                foreach (GameObject gameObject in SceneLoader.SceneCameraList)
                {
                    SceneObject sceneObject = gameObject.GetComponent <SceneObjectCamera>();
                    GameObject  camGeometry = sceneObject.transform.GetChild(0).gameObject;
                    camGeometry.SetActive(mainController.showCam);
                    if (sceneObjectRefList.Length > sceneObject.id)
                    {
                        sceneObjectRefList[sceneObject.id] = sceneObject;
                    }
                }

                mainController.SetSceneScale(VPETSettings.Instance.sceneScale);
                // Camera.main.GetComponent<MoveCamera>().calibrate();

                scene.rotation = scenRot;
                scene.position = scenePos;

                mainController.repositionCamera();
            }
#endif

            if (!deactivateReceive)
            {
                //process all available transforms send by server & delete them from Queue
                int count = 0;
                for (int i = 0; i < receiveMessageQueue.Count; i++)
                {
                    // Debug.Log(receiveMessageQueue[i] as string);
                    try
                    {
                        parseTransformation(receiveMessageQueue[i] as byte[]);
                    }
                    catch
                    {
                        VPETSettings.Instance.msg = "Error: parseTransformation";
                    }
                    count++;
                }
                receiveMessageQueue.RemoveRange(0, count);
            }

            currentTimeTime = Time.time;
        }
Ejemplo n.º 5
0
        //!
        //! Wrapper for unity API function GetButtonDown() that does not behave like described on iOS.
        //! Using a dictionary to keep track of the status of controller buttons.
        //! A bool flag gets kept for every button name this function is called for.
        //! The function can be probably removed when the iOS unity API issue was fixed.
        //! @param      buttonName       name of a button like its defined in the Input Manager.
        //! @return     true only for the first time the function gets called for a certain button after the user stated pressing it.
        //!

        /*private bool buttonPressed(string buttonName)
         * {
         *  if (Input.GetButtonDown(buttonName))
         *  {
         *      float buttonPressedTimestamp = 0f;
         *      if (buttonPressedState.TryGetValue(buttonName, out buttonPressedTimestamp))
         *      {
         *          if (buttonPressedTimestamp > 0f)
         *              return false;
         *          else
         *          {
         *              buttonPressedState[buttonName] = Time.time;
         *              return true;
         *          }
         *      }
         *      else
         *      {
         *          buttonPressedState.Add(buttonName, Time.time);
         *          return true;
         *      }
         *  }
         *  else if (Input.GetButtonUp(buttonName) && buttonPressedState.ContainsKey(buttonName))
         *          buttonPressedState[buttonName] = 0f;
         *  return false;
         * }*/

        //!
        //! Function to mesure for how long a button has already been pressed.
        //! In case the given button is not pressed at all ...
        //! @param      buttonName       name of a button like its defined in the Input Manager.
        //! @return     the time in seconds for how long the button has been already pressed or 0 if the button isn't pressed
        //!

        /*private float buttonPressedTime(string buttonName) {
         *  float buttonPressedTimestamp = 0f;
         *  if (!buttonPressedState.TryGetValue(buttonName, out buttonPressedTimestamp)) {
         *      buttonPressed(buttonName);
         *      return buttonPressedTimestamp; // this should be an exception
         *  }
         *  else if (buttonPressedTimestamp > 0f)
         *      return Time.time - buttonPressedTimestamp;
         *  else
         *      return buttonPressedTimestamp;
         * }*/

        //!
        //! all possible inputs
        //! called every frame by MoveCamera (in its update() function)
        //!
        private void getButtonUpdates()
        {
            if (gamepad.leftShoulder.isPressed)
            //if (Input.GetButton("L1"))
            {
                getcurrentCrosshairObject();
                // hide center menu
                mainController.deselect();
                // switch to camera mode
                moveCameraActive   = true;
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                // show crosshair
                crossHair.SetActive(true);

                // initial state, previousCrosshairObject == some object, currentCrosshairObject == null
                if (previousCrosshairObject != null && currentCrosshairObject == null)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // initial state, previousCrosshairObject == some object (previous), currentCrosshairObject == some object new
                else if (currentCrosshairObject != null && previousCrosshairObject != null && currentCrosshairObject != previousCrosshairObject)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // highlight current selection
                else if (currentCrosshairObject)
                {
                    outlineEffect.lineColor0 = new Color(1f, 0.9f, 0.7f);
                    currentCrosshairObject.GetComponent <SceneObject>().callShowHighlighted(currentCrosshairObject);
                }
            }
            else if (gamepad.leftShoulder.wasReleasedThisFrame)
            //else if (Input.GetButtonUp("L1"))
            {
                if (currentCrosshairObject != null)
                {
                    outlineEffect.lineColor0 = new Color(1.0f, 0.8f, 0.3f);
                    mainController.handleSelection(currentCrosshairObject.GetComponent <Transform>());
                }
                crossHair.SetActive(false);
            }
            // enter translation mode
            else if (gamepad.buttonNorth.wasPressedThisFrame)
            //else if (buttonPressed("Fire3"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter rotation mode
            else if (gamepad.buttonEast.wasPressedThisFrame)
            //else if (buttonPressed("Fire1"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter scale mode
            else if (gamepad.buttonSouth.wasPressedThisFrame)
            //else if (buttonPressed("Fire0"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter scale mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // enter camera mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>() is SceneObjectLight)
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
            }
            // toggle configuration window
            else if (gamepad.startButton.wasPressedThisFrame)
            //else if (Input.GetButtonDown("Settings"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(3).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // toggle predefined bookmarks
            else if (gamepad.rightShoulder.wasPressedThisFrame && !mainController.arMode)
            {
                //else if (buttonPressed("R1") && !mainController.arMode)
                mainController.repositionCamera();
            }

            // disable tracking
            else if (gamepad.rightTrigger.wasPressedThisFrame && !mainController.arMode)
            //else if (buttonPressed("R2") && !mainController.arMode)
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // deselect or reset current selection
            //TODO: reimplement hold
            if (gamepad.buttonWest.wasPressedThisFrame /*&& buttonPressedTime("Fire2") > 0f && buttonPressedTime("Fire2") < deselectHoldDuration*/)
            //if (!Input.GetButton("Fire2") && buttonPressedTime("Fire2") > 0f && buttonPressedTime("Fire2") < deselectHoldDuration)
            {
                mainController.handleSelection();
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                moveCameraActive   = true;
            }

            /*else if (gamepad.buttonWest.isPressed && buttonPressedTime("Fire2") > deselectHoldDuration) {
             * //else if (Input.GetButton("Fire2") && buttonPressedTime("Fire2") > deselectHoldDuration){
             *  if (mainController.getCurrentSelection())
             *  {
             *      if (mainController.getCurrentSelection().GetComponent<SceneObject>().GetType() == typeof(SceneObjectLight))
             *          mainController.getCurrentSelection().GetComponent<SceneObjectLight>().resetAll();
             *      else
             *          mainController.getCurrentSelection().GetComponent<SceneObject>().resetAll();
             *  }
             * }*/
            if (gamepad.bButton.wasPressedThisFrame)
            {
            }

            // cycle through edit modes
            else if (gamepad.leftTrigger.wasPressedThisFrame)
            //else if (buttonPressed("L2"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(1).GetComponent <MenuButtonList>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // cycle through object list
            else if (gamepad.dpad.up.wasPressedThisFrame ||
                     gamepad.dpad.down.wasPressedThisFrame ||
                     gamepad.dpad.left.wasPressedThisFrame ||
                     gamepad.dpad.right.wasPressedThisFrame)
            //else if ( (buttonPressed("DPAD_H")) ||
            //		  (buttonPressed("DPAD_H_neg")) ||
            //		  (buttonPressed("DPAD_V")) ||
            //		  (buttonPressed("DPAD_V_neg")) )
            {
                if (gamepad.dpad.right.wasPressedThisFrame || gamepad.dpad.up.wasPressedThisFrame)
                {
                    //if (Input.GetButtonDown("DPAD_H") || Input.GetButtonDown("DPAD_V"))
                    DPADdirection = 1;
                }
                else
                {
                    DPADdirection = -1;
                }

                int  match       = -1;
                bool cycleLights = false;
#if UNITY_EDITOR || UNITY_STANDALONE
                if (gamepad.dpad.y.ReadValue() != 0)
                {
                    //if (Input.GetAxis("DPAD_V") != 0)
                    cycleLights = true;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (gamepad.dpad.up.wasPressedThisFrame || gamepad.dpad.down.wasPressedThisFrame)
                {
                    //if (Input.GetButtonDown("DPAD_V") || Input.GetButtonDown("DPAD_V_neg") )
                    cycleLights = true;
                }
#endif
                Transform currentSelection = mainController.getCurrentSelection();
                mainController.handleSelection();
                if (cycleLights)
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SelectableLights.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectLight(0);
                    }
                    else
                    {
                        selectLight(match + DPADdirection);
                    }
                }
                else
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SceneEditableObjects.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectObject(0);
                    }
                    else
                    {
                        selectObject(match + DPADdirection);
                    }
                }

                // reactivate last selected edit mode
                if (moveObjectActive)
                {
                    mainController.buttonTranslationClicked(true);
                }
                else if (rotateObjectActive)
                {
                    mainController.buttonRotationClicked(true);
                }
                else if (scaleObjectActive & !mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                {
                    mainController.buttonScaleClicked(true);
                }
            }
        }
Ejemplo n.º 6
0
        //!
        //! all possible inputs
        //! called every frame by MoveCamera (in its update() function)
        //!
        public void getButtonUpdates()
        {
            if (Input.GetButton("L1"))
            {
                getcurrentCrosshairObject();
                // hide center menu
                mainController.deselect();
                // switch to camera mode
                moveCameraActive   = true;
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                // show crosshair
                crossHair.SetActive(true);

                // initial state, previousCrosshairObject == some object, currentCrosshairObject == null
                if (previousCrosshairObject != null && currentCrosshairObject == null)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // initial state, previousCrosshairObject == some object (previous), currentCrosshairObject == some object new
                else if (currentCrosshairObject != null && previousCrosshairObject != null && currentCrosshairObject != previousCrosshairObject)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // highlight current selection
                else if (currentCrosshairObject)
                {
                    outlineEffect.lineColor0 = new Color(1f, 0.9f, 0.7f);
                    currentCrosshairObject.GetComponent <SceneObject>().callShowHighlighted(currentCrosshairObject);
                }
            }
            else if (Input.GetButtonUp("L1"))
            {
                if (currentCrosshairObject != null)
                {
                    outlineEffect.lineColor0 = new Color(1.0f, 0.8f, 0.3f);
                    mainController.handleSelection(currentCrosshairObject.GetComponent <Transform>());
                }
                crossHair.SetActive(false);
            }
            // enter translation mode
            else if (buttonPressed("Fire3"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter rotation mode
            else if (buttonPressed("Fire1"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter scale mode
            else if (buttonPressed("Fire0"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter scale mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // enter camera mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>() is SceneObjectLight)
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
            }
            // toggle configuration window
            else if (Input.GetButtonDown("Settings"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(3).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // toggle predefined bookmarks
            else if (buttonPressed("R1") && !mainController.arMode)
            {
                mainController.repositionCamera();
            }

            // disable tracking
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("R2") < 0 && !hasPressedR2 && !mainController.arMode)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (buttonPressed("R2") && !mainController.arMode)
#endif
            {
                hasPressedR2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // deselect or reset current selection
            if (!Input.GetButton("Fire2") && buttonPressedTime("Fire2") > 0f &&
                buttonPressedTime("Fire2") < deselectHoldDuration)
            {
                mainController.handleSelection();
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                moveCameraActive   = true;
            }
            else if (Input.GetButton("Fire2") && buttonPressedTime("Fire2") > deselectHoldDuration)
            {
                if (mainController.getCurrentSelection())
                {
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().GetType() == typeof(SceneObjectLight))
                    {
                        mainController.getCurrentSelection().GetComponent <SceneObjectLight>().resetAll();
                    }
                    else
                    {
                        mainController.getCurrentSelection().GetComponent <SceneObject>().resetAll();
                    }
                }
            }
            if (buttonPressed("Fire2"))
            {
            }

            // cycle through edit modes
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_LINUX
            else if (Input.GetAxis("L2") > 0 && !hasPressedL2)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (buttonPressed("L2"))
#endif
            {
                hasPressedL2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(1).GetComponent <MenuButtonList>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // cycle through object list
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("DPAD_H") != 0 && !hasPressedDirectionalPad ||
                     Input.GetAxis("DPAD_V") != 0 && !hasPressedDirectionalPad)
            {
                if (Input.GetAxis("DPAD_H") == 1 || Input.GetAxis("DPAD_V") == 1)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if ((buttonPressed("DPAD_H")) ||
                     (buttonPressed("DPAD_H_neg")) ||
                     (buttonPressed("DPAD_V")) ||
                     (buttonPressed("DPAD_V_neg")))
            {
                if (Input.GetButtonDown("DPAD_H") || Input.GetButtonDown("DPAD_V"))
#endif
                { DPADdirection = 1; }
                else
                {
                    DPADdirection = -1;
                }

                hasPressedDirectionalPad = true;
                int  match       = -1;
                bool cycleLights = false;
#if UNITY_EDITOR || UNITY_STANDALONE
                if (Input.GetAxis("DPAD_V") != 0)
                {
                    cycleLights = true;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (Input.GetButtonDown("DPAD_V") || Input.GetButtonDown("DPAD_V_neg"))
                {
                    cycleLights = true;
                }
#endif
                Transform currentSelection = mainController.getCurrentSelection();
                mainController.handleSelection();
                if (cycleLights)
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SelectableLights.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectLight(0);
                    }
                    else
                    {
                        selectLight(match + DPADdirection);
                    }
                }
                else
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SceneEditableObjects.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectObject(0);
                    }
                    else
                    {
                        selectObject(match + DPADdirection);
                    }
                }

                // reactivate last selected edit mode
                if (moveObjectActive)
                {
                    mainController.buttonTranslationClicked(true);
                }
                else if (rotateObjectActive)
                {
                    mainController.buttonRotationClicked(true);
                }
                else if (scaleObjectActive & !mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                {
                    mainController.buttonScaleClicked(true);
                }
            }
            // Dpad and R2 reset
#if UNITY_EDITOR || UNITY_STANDALONE
            if (Input.GetAxis("DPAD_H") == 0 && (Input.GetAxis("DPAD_V") == 0))
            {
                hasPressedDirectionalPad = false;
            }
            if (Input.GetAxis("R2") == 0)
            {
                hasPressedR2 = false;
            }
            if (Input.GetAxis("L2") == 0)
            {
                hasPressedL2 = false;
            }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            if (!buttonPressed("DPAD_H") && !buttonPressed("DPAD_V"))
            {
                hasPressedDirectionalPad = false;
            }
#endif
        }
Ejemplo n.º 7
0
        //!
        //! all possible inputs
        //!
        public void getButtonUpdates()
        {
            if (Input.GetButtonDown("L1"))
            {
                // toggle gravity
                if (mainController.getCurrentSelection())
                {
                    if (mainController.UIAdapter.CenterMenu.transform.GetChild(4).GetComponent <MenuButtonToggle>().enabled & !(mainController.UIAdapter.LayoutUI == layouts.ANIMATION))
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(4).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    // set keyframe for current selection (translate, rotate, scale)
                    if (mainController.UIAdapter.LayoutUI == layouts.ANIMATION & !moveCameraActive)
                    {
                        mainController.AnimationController.setKeyFrame();
                    }
                }
            }
            // enter translation mode
            else if (Input.GetButtonDown("Fire3"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.handleSelection();
                }
            }
            // enter rotation mode
            else if (Input.GetButtonDown("Fire1"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.handleSelection();
                }
            }
            // enter scale mode
            else if (Input.GetButtonDown("Fire0"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter scale mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // enter camera mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.handleSelection();
                }
            }
            // toggle configuration window
            else if (Input.GetButtonDown("Settings"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(3).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // toggle predefined bookmarks
            else if (Input.GetButtonDown("R1") && !mainController.arMode)
            {
                mainController.repositionCamera();
            }
            // disable tracking
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("R2") < 0 && !hasPressedR2 && !mainController.arMode)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (Input.GetButtonDown("R2") && !mainController.arMode)
#endif
            {
                hasPressedR2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }
            // reset current selection
            else if (Input.GetButtonDown("Fire2"))
            {
                if (mainController.getCurrentSelection())
                {
                    mainController.getCurrentSelection().GetComponent <SceneObject>().resetAll();
                }
            }
            // cycle through edit modes
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_LINUX
            else if (Input.GetAxis("L2") > 0 && !hasPressedL2)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (Input.GetButtonDown("L2"))
#endif
            {
                hasPressedL2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(1).GetComponent <MenuButtonList>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // cycle through object list
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("DPAD_H") != 0 && hasPressedDirectionalPad == false ||
                     Input.GetAxis("DPAD_V") != 0 && hasPressedDirectionalPad == false)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if ((Input.GetButtonDown("DPAD_H")) ||
                     (Input.GetButtonDown("DPAD_H_neg")) ||
                     (Input.GetButtonDown("DPAD_V")) ||
                     (Input.GetButtonDown("DPAD_V_neg")))
#endif
            {
#if UNITY_EDITOR || UNITY_STANDALONE
                if (Input.GetAxis("DPAD_H") == 1 || Input.GetAxis("DPAD_V") == 1)
                {
                    DPADdirection = 1;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (Input.GetButtonDown("DPAD_H") || Input.GetButtonDown("DPAD_V"))
                {
                    DPADdirection = 1;
                }
#endif
                else
                {
                    DPADdirection = -1;
                }
                hasPressedDirectionalPad = true;
                int  match       = -1;
                bool cycleLights = false;
#if UNITY_EDITOR || UNITY_STANDALONE
                if (Input.GetAxis("DPAD_V") != 0)
                {
                    cycleLights = true;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (Input.GetButtonDown("DPAD_V") || Input.GetButtonDown("DPAD_V_neg"))
                {
                    cycleLights = true;
                }
#endif
                Transform currentSelection = mainController.getCurrentSelection();
                mainController.handleSelection();
                if (cycleLights)
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SelectableLights.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectLight(0);
                    }
                    else
                    {
                        selectLight(match + DPADdirection);
                    }
                }
                else
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SceneEditableObjects.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectObject(0);
                    }
                    else
                    {
                        selectObject(match + DPADdirection);
                    }
                }

                // reactivate last selected edit mode
                if (moveObjectActive)
                {
                    mainController.buttonTranslationClicked(true);
                }
                else if (rotateObjectActive)
                {
                    mainController.buttonRotationClicked(true);
                }
                else if (scaleObjectActive & !mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                {
                    mainController.buttonScaleClicked(true);
                }
            }
            // Dpad and R2 reset
#if UNITY_EDITOR || UNITY_STANDALONE
            if (Input.GetAxis("DPAD_H") == 0 && (Input.GetAxis("DPAD_V") == 0))
            {
                hasPressedDirectionalPad = false;
            }
            if (Input.GetAxis("R2") == 0)
            {
                hasPressedR2 = false;
            }
            if (Input.GetAxis("L2") == 0)
            {
                hasPressedL2 = false;
            }
#endif
        }