Exemplo n.º 1
0
    void Start()
    {
        Cursor.visible = false;
        ui             = GameObject.Find("NodeUIOverlay").GetComponent <UIController> ();
        selection      = GameObject.Find("SelectionCanvas").GetComponent <SelectionController> ();
        look           = GameObject.Find("EventSystem").GetComponent <LookInputModule> ();
        legend         = GameObject.Find("LegendCanvas");
        mark           = GameObject.Find("MarkCanvas");
        mark_list      = GameObject.Find("MarklistCanvas");
        quit_dialog    = GameObject.Find("QuitDialogCanvas");
        //HideLegend ();

        ui.Startup();
        quit_dialog.SetActive(false);
        ui.gameObject.SetActive(false);
        selection.gameObject.SetActive(false);
        mark.SetActive(false);
        mark_list.SetActive(false);

        nodes = new Hashtable();
        links = new Hashtable();

        statusText      = GameObject.Find("StatusText").GetComponent <GUIText>();
        statusText.text = "";

        StartCoroutine(LoadLayout());
        //GameObject.Find ("SelectionCanvas").SetActive (false);
    }
    void Awake()
    {
        // Setup the UI
        GameObject stui = GameObject.Find("ScoreText");

        scoreText = stui.GetComponent <Text>();
        GameObject edui = GameObject.Find("FinalScoreText");

        finalScoreText = edui.GetComponent <Text>();
        GameObject kText = GameObject.Find("KinectText");

        kinectConnectedText = kText.GetComponent <Text>();
        GameObject oText = GameObject.Find("OculusText");

        oculusConnectedText = oText.GetComponent <Text>();
        GameObject ovrcanvas = GameObject.Find("UICanvas");

        startAnim = ovrcanvas.GetComponent <Animator>();
        score     = 0;
        GameObject es = GameObject.Find("EventSystem");

        lookInput = es.GetComponent <LookInputModule>();


        //Disable Game over Button
        GameObject gameOverButton = GameObject.Find("RestartButton");
        Button     b = gameOverButton.GetComponent <Button>();

        gameOverButton.SetActive(false);

        //Setup Player
        platformController       = GameObject.Find("PlatformController");
        testSpawner              = platformController.GetComponent <TestSpawner>();
        player                   = GameObject.Find("FPSPreFab");
        infinitePlayerController = player.GetComponent <InfinitePlayerController>();
        playerHealth             = player.GetComponent <PlayerHealthController>();

        //Setup Kinect
        bodyManagerComponent = bodyManager.GetComponent <BodySourceManager>();
        handManagerComponent = handController.GetComponent <HandGestureTrigger>();

        //Setup Oculus
        GameObject ovrCameraRig = GameObject.Find("OVRCameraRig");

        oculusOVRManager = ovrCameraRig.GetComponent <OVRManager>();

        problemSolverObject = GameObject.Find("ProblemSolver");
    }
	// Process is called by UI system to process events
	public override void Process() {
		_singleton = this;

		// send update events if there is a selected object - this is important for InputField to receive keyboard events
		SendUpdateEventToSelectedObject();

		// see if there is a UI element that is currently being looked at
		PointerEventData lookData = GetLookPointerEventData();
		currentLook = lookData.pointerCurrentRaycast.gameObject;

		// deselect when look away
		if (deselectWhenLookAway && currentLook == null) {
			ClearSelection();
		}

		// handle enter and exit events (highlight)
		// using the function that is already defined in BaseInputModule
		HandlePointerExitAndEnter(lookData,currentLook);

		// update cursor
		UpdateCursor(lookData);

		if (!ignoreInputsWhenLookAway || ignoreInputsWhenLookAway && currentLook != null) {
			// button down handling
			_buttonUsed = false;
			if (Input.GetButtonDown (submitButtonName)) {
				ClearSelection();
				lookData.pressPosition = lookData.position;
				lookData.pointerPressRaycast = lookData.pointerCurrentRaycast;
				lookData.pointerPress = null;
				if (currentLook != null) {
					currentPressed = currentLook;
					GameObject newPressed = null;
					if (mode == Mode.Pointer) {
						newPressed = ExecuteEvents.ExecuteHierarchy (currentPressed, lookData, ExecuteEvents.pointerDownHandler);
						if (newPressed == null) {
							// some UI elements might only have click handler and not pointer down handler
							newPressed = ExecuteEvents.ExecuteHierarchy (currentPressed, lookData, ExecuteEvents.pointerClickHandler);
							if (newPressed != null) {
								currentPressed = newPressed;
							}
						} else {
							currentPressed = newPressed;
							// we want to do click on button down at same time, unlike regular mouse processing
							// which does click when mouse goes up over same object it went down on
							// reason to do this is head tracking might be jittery and this makes it easier to click buttons
							ExecuteEvents.Execute (newPressed, lookData, ExecuteEvents.pointerClickHandler);
						}
					} else if (mode == Mode.Submit) {
						newPressed = ExecuteEvents.ExecuteHierarchy (currentPressed, lookData, ExecuteEvents.submitHandler);
						if (newPressed == null) {
							// try select handler instead
							newPressed = ExecuteEvents.ExecuteHierarchy (currentPressed, lookData, ExecuteEvents.selectHandler);
						}
					}
					if (newPressed != null) {
						lookData.pointerPress = newPressed;
						currentPressed = newPressed;
						Select(currentPressed);
						_buttonUsed = true;
					}
					if (mode == Mode.Pointer) {
						if (useLookDrag) {
							bool useLookTest = true;
							if (!useLookDragSlider && currentPressed.GetComponent<Slider>()) {
								useLookTest = false;
							} else if (!useLookDragScrollbar && currentPressed.GetComponent<Scrollbar>()) {
								useLookTest = false;
								// the following is for scrollbars to work right
								// apparently they go into an odd drag mode when pointerDownHandler is called
								// a begin/end drag fixes that
								if (ExecuteEvents.Execute(currentPressed,lookData, ExecuteEvents.beginDragHandler)) {
									ExecuteEvents.Execute(currentPressed,lookData,ExecuteEvents.endDragHandler);
								}
							} 
							if (useLookTest) {
								ExecuteEvents.Execute(currentPressed,lookData, ExecuteEvents.beginDragHandler);
								lookData.pointerDrag = currentPressed;
								currentDragging = currentPressed;
							}
						} else if (currentPressed.GetComponent<Scrollbar>()) {
							// the following is for scrollbars to work right
							// apparently they go into an odd drag mode when pointerDownHandler is called
							// a begin/end drag fixes that
							if (ExecuteEvents.Execute(currentPressed,lookData, ExecuteEvents.beginDragHandler)) {
								ExecuteEvents.Execute(currentPressed,lookData,ExecuteEvents.endDragHandler);
							}
						}
					}
				}
			}
		}

		// have to handle button up even if looking away
		if (Input.GetButtonUp(submitButtonName)) {
			if (currentDragging) {
				ExecuteEvents.Execute(currentDragging,lookData,ExecuteEvents.endDragHandler);
				if (currentLook != null) {
					ExecuteEvents.ExecuteHierarchy(currentLook,lookData,ExecuteEvents.dropHandler);
				}
				lookData.pointerDrag = null;
				currentDragging = null;
			}
			if (currentPressed) {
				ExecuteEvents.Execute(currentPressed,lookData,ExecuteEvents.pointerUpHandler);
				lookData.rawPointerPress = null;
				lookData.pointerPress = null;
				currentPressed = null;
			}
		}

		// drag handling
		if (currentDragging != null) {
			ExecuteEvents.Execute (currentDragging,lookData,ExecuteEvents.dragHandler);
		}

		if (!ignoreInputsWhenLookAway || ignoreInputsWhenLookAway && currentLook != null) {
			// control axis handling
			_controlAxisUsed = false;
			if (eventSystem.currentSelectedGameObject && controlAxisName != null && controlAxisName != "") {
				float newVal = Input.GetAxis (controlAxisName);
				if (newVal > 0.01f || newVal < -0.01f) {
					if (useSmoothAxis) {
						Slider sl = eventSystem.currentSelectedGameObject.GetComponent<Slider>();
						if (sl != null) {
							float mult = sl.maxValue - sl.minValue;
							sl.value += newVal*smoothAxisMultiplier*mult;
							_controlAxisUsed = true;
						} else {
							Scrollbar sb = eventSystem.currentSelectedGameObject.GetComponent<Scrollbar>();
							if (sb != null) {
								sb.value += newVal*smoothAxisMultiplier;
								_controlAxisUsed = true;
							}
						}
					} else {
						_controlAxisUsed = true;
						float time = Time.unscaledTime;
						if (time > nextAxisActionTime) {
							nextAxisActionTime = time + 1f/steppedAxisStepsPerSecond;
							AxisEventData axisData = GetAxisEventData(newVal,0.0f,0.0f);
							if (!ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisData, ExecuteEvents.moveHandler)) {
								_controlAxisUsed = false;
							} 
						}
					}
				}
			}
		}
	}	
Exemplo n.º 4
0
    // Process is called by UI system to process events
    public override void Process()
    {
        _singleton = this;

        // send update events if there is a selected object - this is important for InputField to receive keyboard events
        SendUpdateEventToSelectedObject();

        // see if there is a UI element that is currently being looked at
        PointerEventData lookData = GetLookPointerEventData();

        if (lookData.pointerCurrentRaycast.gameObject)
        {
            currentLook = lookData.pointerCurrentRaycast.gameObject;
        }

        // handle enter and exit events (highlight)
        // using the function that is already defined in BaseInputModule
        HandlePointerExitAndEnter(lookData, currentLook);

        // update cursor
        UpdateCursor(lookData);

        // button handling
        _buttonUsed = false;
        if (Input.GetButtonDown(submitButtonName))
        {
            ClearSelection();
            lookData.pressPosition       = lookData.position;
            lookData.pointerPressRaycast = lookData.pointerCurrentRaycast;
            lookData.pointerPress        = null;
            if (currentLook != null)
            {
                currentPressed = currentLook;
                GameObject newPressed = null;
                if (mode == Mode.Pointer)
                {
                    newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.pointerDownHandler);
                    if (newPressed == null)
                    {
                        // some UI elements might only have click handler and not pointer down handler
                        newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.pointerClickHandler);
                        if (newPressed != null)
                        {
                            currentPressed = newPressed;
                        }
                    }
                    else
                    {
                        currentPressed = newPressed;
                        // we want to do click on button down at same time, unlike regular mouse processing
                        // which does click when mouse goes up over same object it went down on
                        // reason to do this is head tracking might be jittery and this makes it easier to click buttons
                        ExecuteEvents.Execute(newPressed, lookData, ExecuteEvents.pointerClickHandler);
                    }
                }
                else if (mode == Mode.Submit)
                {
                    newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.submitHandler);
                    if (newPressed == null)
                    {
                        // try select handler instead
                        newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.selectHandler);
                    }
                }
                if (newPressed != null)
                {
                    lookData.pointerPress = newPressed;
                    currentPressed        = newPressed;
                    Select(currentPressed);
                    _buttonUsed = true;
                }
                if (mode == Mode.Pointer)
                {
                    if (useLookDrag)
                    {
                        bool useLookTest = true;
                        if (!useLookDragSlider && currentPressed.GetComponent <Slider>())
                        {
                            useLookTest = false;
                        }
                        else if (!useLookDragScrollbar && currentPressed.GetComponent <Scrollbar>())
                        {
                            useLookTest = false;
                            // the following is for scrollbars to work right
                            // apparently they go into an odd drag mode when pointerDownHandler is called
                            // a begin/end drag fixes that
                            if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                            {
                                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.endDragHandler);
                            }
                        }
                        if (useLookTest)
                        {
                            if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                            {
                                lookData.pointerDrag = currentPressed;
                                currentDragging      = currentPressed;
                            }
                        }
                    }
                    else
                    {
                        // the following is for scrollbars to work right
                        // apparently they go into an odd drag mode when pointerDownHandler is called
                        // a begin/end drag fixes that
                        if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                        {
                            ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.endDragHandler);
                        }
                    }
                }
            }
        }
        else if (Input.GetButtonUp(submitButtonName))
        {
            if (currentDragging)
            {
                ExecuteEvents.Execute(currentDragging, lookData, ExecuteEvents.endDragHandler);
                if (currentLook != null)
                {
                    ExecuteEvents.ExecuteHierarchy(currentLook, lookData, ExecuteEvents.dropHandler);
                }
                lookData.pointerDrag = null;
                currentDragging      = null;
            }
            if (currentPressed)
            {
                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.pointerUpHandler);
                lookData.rawPointerPress = null;
                lookData.pointerPress    = null;
                currentPressed           = null;
            }
        }

        // drag handling
        if (currentDragging != null)
        {
            ExecuteEvents.Execute(currentDragging, lookData, ExecuteEvents.dragHandler);
        }

        // control axis handling
        _controlAxisUsed = false;
        if (eventSystem.currentSelectedGameObject && controlAxisName != null && controlAxisName != "")
        {
            float newVal = Input.GetAxis(controlAxisName);
            if (newVal > 0.01f || newVal < -0.01f)
            {
                if (useSmoothAxis)
                {
                    Slider sl = eventSystem.currentSelectedGameObject.GetComponent <Slider>();
                    if (sl != null)
                    {
                        float mult = sl.maxValue - sl.minValue;
                        sl.value        += newVal * smoothAxisMultiplier * mult;
                        _controlAxisUsed = true;
                    }
                    else
                    {
                        Scrollbar sb = eventSystem.currentSelectedGameObject.GetComponent <Scrollbar>();
                        if (sb != null)
                        {
                            sb.value        += newVal * smoothAxisMultiplier;
                            _controlAxisUsed = true;
                        }
                    }
                }
                else
                {
                    _controlAxisUsed = true;
                    float time = Time.unscaledTime;
                    if (time > nextAxisActionTime)
                    {
                        nextAxisActionTime = time + 1f / steppedAxisStepsPerSecond;
                        AxisEventData axisData = GetAxisEventData(newVal, 0.0f, 0.0f);
                        if (!ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisData, ExecuteEvents.moveHandler))
                        {
                            _controlAxisUsed = false;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    public override void Process()
    {
        _singleton = this;

        SendUpdateEventToSelectedObject();

        PointerEventData lookData = GetLookPointerEventData();

        currentLook = lookData.pointerCurrentRaycast.gameObject;

        if (deselectWhenLookAway && currentLook == null)
        {
            ClearSelection();
        }

        // handle enter and exit events (highlight)
        // using the function that is already defined in BaseInputModule
        HandlePointerExitAndEnter(lookData, currentLook);

        // update cursor
        UpdateCursor(lookData);

        if (!ignoreInputsWhenLookAway || ignoreInputsWhenLookAway && currentLook != null)
        {
            // button down handling
            _buttonUsed = false;
            if (Input.GetButtonDown(submitButtonName))
            {
                ClearSelection();
                lookData.pressPosition       = lookData.position;
                lookData.pointerPressRaycast = lookData.pointerCurrentRaycast;
                lookData.pointerPress        = null;
                if (currentLook != null)
                {
                    currentPressed = currentLook;
                    GameObject newPressed = null;
                    if (mode == Mode.Pointer)
                    {
                        newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.pointerDownHandler);
                        if (newPressed == null)
                        {
                            // some UI elements might only have click handler and not pointer down handler
                            newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.pointerClickHandler);
                            if (newPressed != null)
                            {
                                currentPressed = newPressed;
                            }
                        }
                        else
                        {
                            currentPressed = newPressed;

                            ExecuteEvents.Execute(newPressed, lookData, ExecuteEvents.pointerClickHandler);
                        }
                    }
                    else if (mode == Mode.Submit)
                    {
                        newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.submitHandler);
                        if (newPressed == null)
                        {
                            // try select handler instead
                            newPressed = ExecuteEvents.ExecuteHierarchy(currentPressed, lookData, ExecuteEvents.selectHandler);
                        }
                    }
                    if (newPressed != null)
                    {
                        lookData.pointerPress = newPressed;
                        currentPressed        = newPressed;
                        Select(currentPressed);
                        _buttonUsed = true;
                    }
                    if (mode == Mode.Pointer)
                    {
                        if (useLookDrag)
                        {
                            bool useLookTest = true;
                            if (!useLookDragSlider && currentPressed.GetComponent <Slider>())
                            {
                                useLookTest = false;
                            }
                            else if (!useLookDragScrollbar && currentPressed.GetComponent <Scrollbar>())
                            {
                                useLookTest = false;

                                if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                                {
                                    ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.endDragHandler);
                                }
                            }
                            if (useLookTest)
                            {
                                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler);
                                lookData.pointerDrag = currentPressed;
                                currentDragging      = currentPressed;
                            }
                        }
                        else if (currentPressed.GetComponent <Scrollbar>())
                        {
                            if (ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.beginDragHandler))
                            {
                                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.endDragHandler);
                            }
                        }
                    }
                }
            }
        }


        if (Input.GetButtonUp(submitButtonName))
        {
            if (currentDragging)
            {
                ExecuteEvents.Execute(currentDragging, lookData, ExecuteEvents.endDragHandler);
                if (currentLook != null)
                {
                    ExecuteEvents.ExecuteHierarchy(currentLook, lookData, ExecuteEvents.dropHandler);
                }
                lookData.pointerDrag = null;
                currentDragging      = null;
            }
            if (currentPressed)
            {
                ExecuteEvents.Execute(currentPressed, lookData, ExecuteEvents.pointerUpHandler);
                lookData.rawPointerPress = null;
                lookData.pointerPress    = null;
                currentPressed           = null;
            }
        }


        if (currentDragging != null)
        {
            ExecuteEvents.Execute(currentDragging, lookData, ExecuteEvents.dragHandler);
        }

        if (!ignoreInputsWhenLookAway || ignoreInputsWhenLookAway && currentLook != null)
        {
            _controlAxisUsed = false;
            if (eventSystem.currentSelectedGameObject && controlAxisName != null && controlAxisName != "")
            {
                float newVal = Input.GetAxis(controlAxisName);
                if (newVal > 0.01f || newVal < -0.01f)
                {
                    if (useSmoothAxis)
                    {
                        Slider sl = eventSystem.currentSelectedGameObject.GetComponent <Slider>();
                        if (sl != null)
                        {
                            float mult = sl.maxValue - sl.minValue;
                            sl.value        += newVal * smoothAxisMultiplier * mult;
                            _controlAxisUsed = true;
                        }
                        else
                        {
                            Scrollbar sb = eventSystem.currentSelectedGameObject.GetComponent <Scrollbar>();
                            if (sb != null)
                            {
                                sb.value        += newVal * smoothAxisMultiplier;
                                _controlAxisUsed = true;
                            }
                        }
                    }
                    else
                    {
                        _controlAxisUsed = true;
                        float time = Time.unscaledTime;
                        if (time > nextAxisActionTime)
                        {
                            nextAxisActionTime = time + 1f / steppedAxisStepsPerSecond;
                            AxisEventData axisData = GetAxisEventData(newVal, 0.0f, 0.0f);
                            if (!ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisData, ExecuteEvents.moveHandler))
                            {
                                _controlAxisUsed = false;
                            }
                        }
                    }
                }
            }
        }
    }
    void Awake ()
	{
		// Setup the UI
        GameObject stui = GameObject.Find("ScoreText");
        scoreText = stui.GetComponent<Text>();
        GameObject edui = GameObject.Find("FinalScoreText");
        finalScoreText = edui.GetComponent<Text>();
        GameObject kText = GameObject.Find("KinectText");
        kinectConnectedText = kText.GetComponent<Text>();
        GameObject oText = GameObject.Find("OculusText");
        oculusConnectedText = oText.GetComponent<Text>();
        GameObject ovrcanvas = GameObject.Find("UICanvas");
        startAnim = ovrcanvas.GetComponent<Animator>();
        score = 0;
        GameObject es = GameObject.Find("EventSystem");
        lookInput = es.GetComponent<LookInputModule>();


        //Disable Game over Button
        GameObject gameOverButton = GameObject.Find("RestartButton");
        Button b = gameOverButton.GetComponent<Button>();
        gameOverButton.SetActive(false);

        //Setup Player
        platformController = GameObject.Find("PlatformController");
        testSpawner = platformController.GetComponent<TestSpawner>();
        player = GameObject.Find("FPSPreFab");
        infinitePlayerController = player.GetComponent<InfinitePlayerController>();
        playerHealth = player.GetComponent<PlayerHealthController>();

        //Setup Kinect
        bodyManagerComponent = bodyManager.GetComponent<BodySourceManager>();
        handManagerComponent = handController.GetComponent<HandGestureTrigger>();

        //Setup Oculus
        GameObject ovrCameraRig = GameObject.Find("OVRCameraRig");
        oculusOVRManager = ovrCameraRig.GetComponent<OVRManager>();

        problemSolverObject = GameObject.Find("ProblemSolver");

    }
Exemplo n.º 7
0
    void Start()
    {
        Cursor.visible = false;
        ui = GameObject.Find ("NodeUIOverlay").GetComponent<UIController> ();
        selection = GameObject.Find ("SelectionCanvas").GetComponent<SelectionController> ();
        look = GameObject.Find ("EventSystem").GetComponent<LookInputModule> ();
        legend = GameObject.Find ("LegendCanvas");
        mark = GameObject.Find ("MarkCanvas");
        mark_list = GameObject.Find ("MarklistCanvas");
        quit_dialog = GameObject.Find ("QuitDialogCanvas");
        //HideLegend ();

        ui.Startup ();
        quit_dialog.SetActive (false);
        ui.gameObject.SetActive (false);
        selection.gameObject.SetActive (false);
        mark.SetActive (false);
        mark_list.SetActive (false);

        nodes = new Hashtable();
        links = new Hashtable();

        statusText = GameObject.Find("StatusText").GetComponent<GUIText>();
        statusText.text = "";

        StartCoroutine( LoadLayout() );
        //GameObject.Find ("SelectionCanvas").SetActive (false);
    }