Exemplo n.º 1
0
    void Start()
    {
        menuScript = this.GetComponent <RUISMenuNGUI>();
        if (menuScript == null)
        {
            Debug.LogError("Did not find " + typeof(RUISMenuNGUI) + " script!");
        }

        this.guiPlane = this.transform.Find("NGUIControls/planeCollider").GetComponent <Collider>();
        if (this.guiPlane == null)
        {
            Debug.LogError("Did not find RUIS Menu collider object, onto which mouse selection ray is projected!");
        }

        if (menuScript.transform.parent == null)
        {
            Debug.LogError("The parent of GameObject '" + menuScript.name
                           + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you "
                           + "are misusing the " + typeof(RUIS3dGuiCursor) + " script.");
        }
//		else if(menuScript.transform.parent.parent == null)
//			Debug.LogError(  "The grand-parent of GameObject '" + menuScript.name
//			               + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you "
//			               + "are misusing the " + typeof(RUIS3dGuiCursor) + " script.");
//		else
//			ruisCamera = menuScript.transform.parent.parent.GetComponent<RUISCamera>();
//
//		if(ruisCamera == null)
//			Debug.LogError(  typeof(RUIS3dGuiCursor) + " script did not find "  + typeof(RUISCamera) + " from the parent of "
//			               + menuScript.transform.name + "gameobject! RUIS Menu is unavailable.");

        ruisDisplayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

        if (ruisDisplayManager == null)
        {
            this.enabled = false;
            Debug.LogError("Could not find " + typeof(RUISDisplayManager) + " script, RUIS Menu will not work!");
            return;
        }

        if (ruisDisplayManager.displays[ruisDisplayManager.guiDisplayChoice] && ruisDisplayManager.displays[ruisDisplayManager.guiDisplayChoice].linkedCamera)
        {
            ruisCamera = ruisDisplayManager.displays[ruisDisplayManager.guiDisplayChoice].linkedCamera;
        }
        else
        {
            Debug.LogError("Could not find the " + typeof(RUISCamera) + " that is linked to the " + typeof(RUISDisplay) + " with RUIS Menu!");
        }

        if (ruisDisplayManager.hideMouseOnPlay && menuScript.currentMenuState != RUISMenuNGUI.RUISMenuStates.calibration)
        {
            Cursor.visible = false;
        }
        markerObject = ruisDisplayManager.menuCursorPrefab;

        if (markerObject)
        {
            originalLocalScale = this.markerObject.transform.localScale;
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        menuScript = this.GetComponent <RUISMenuNGUI>();
        if (menuScript == null)
        {
            Debug.LogError("Did not find " + typeof(RUISMenuNGUI) + " script!");
        }

        this.guiPlane = this.transform.Find("NGUIControls/planeCollider").GetComponent <Collider>();
        if (this.guiPlane == null)
        {
            Debug.LogError("Did not find RUIS Menu collider object, onto which mouse selection ray is projected!");
        }

        if (menuScript.transform.parent == null)
        {
            Debug.LogError("The parent of GameObject '" + menuScript.name
                           + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you "
                           + "are misusing the " + typeof(RUIS3dGuiCursor) + " script.");
        }
        else if (menuScript.transform.parent.parent == null)
        {
            Debug.LogError("The grand-parent of GameObject '" + menuScript.name
                           + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you "
                           + "are misusing the " + typeof(RUIS3dGuiCursor) + " script.");
        }
        else
        {
            ruisCamera = menuScript.transform.parent.parent.GetComponent <RUISCamera>();
        }

        if (ruisCamera == null)
        {
            Debug.LogError(typeof(RUIS3dGuiCursor) + " script did not find " + typeof(RUISCamera) + " from the parent of "
                           + menuScript.transform.name + "gameobject! RUIS Menu is unavailable.");
        }

        ruisDisplayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

        if (ruisDisplayManager == null)
        {
            this.enabled = false;
            Debug.LogError("Could not find " + typeof(RUISDisplayManager) + " script, RUIS menu will not work!");
            return;
        }
        if (ruisDisplayManager.hideMouseOnPlay && menuScript.currentMenuState != RUISMenuNGUI.RUISMenuStates.calibration)
        {
            Screen.showCursor = false;
        }
        markerObject = ruisDisplayManager.menuCursorPrefab;
    }
Exemplo n.º 3
0
	void Start() 
	{
		menuScript = this.GetComponent<RUISMenuNGUI>();
		if(menuScript == null)
			Debug.LogError( "Did not find " + typeof(RUISMenuNGUI) + " script!");

		this.guiPlane = this.transform.Find ("NGUIControls/planeCollider").GetComponent<Collider>();
		if(this.guiPlane == null)
			Debug.LogError( "Did not find RUIS Menu collider object, onto which mouse selection ray is projected!" );

		if(menuScript.transform.parent == null)
			Debug.LogError(  "The parent of GameObject '" + menuScript.name 
			               + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you "
			               + "are misusing the " + typeof(RUIS3dGuiCursor) + " script.");
		else if(menuScript.transform.parent.parent == null)
			Debug.LogError(  "The grand-parent of GameObject '" + menuScript.name 
			               + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you "
			               + "are misusing the " + typeof(RUIS3dGuiCursor) + " script.");
		else
			ruisCamera = menuScript.transform.parent.parent.GetComponent<RUISCamera>();

		if(ruisCamera == null)
			Debug.LogError(  typeof(RUIS3dGuiCursor) + " script did not find "  + typeof(RUISCamera) + " from the parent of "
			               + menuScript.transform.name + "gameobject! RUIS Menu is unavailable.");
			               
		ruisDisplayManager =  FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

		if(ruisDisplayManager == null) 
		{ 
			this.enabled = false;
			Debug.LogError("Could not find " + typeof(RUISDisplayManager) + " script, RUIS menu will not work!");
			return;
		}
		if(ruisDisplayManager.hideMouseOnPlay && menuScript.currentMenuState != RUISMenuNGUI.RUISMenuStates.calibration) 
			Cursor.visible = false;
		markerObject = ruisDisplayManager.menuCursorPrefab;

		if(markerObject)
			originalLocalScale = this.markerObject.transform.localScale;
	}
Exemplo n.º 4
0
    public void Awake()
    {
    	// Check if we are in calibration scene
		ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;
		if(ruisNGUIMenu != null) 
		{
			if(ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration) 
			{
				this.enablePSMove = ruisNGUIMenu.originalEnablePSMove;
				this.enableKinect = ruisNGUIMenu.originalEnableKinect;
				this.enableKinect2 = ruisNGUIMenu.originalEnableKinect2;
				this.jumpGestureEnabled = ruisNGUIMenu.originalEnableJumpGesture;
				this.enableRazerHydra = ruisNGUIMenu.originalEnableHydra;
				this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection;
				this.PSMoveIP = ruisNGUIMenu.originalPSMoveIP;
				this.PSMovePort = ruisNGUIMenu.originalPSMovePort;
			}
		}
    	
		wandDelayed = new bool[4] {moveWand0, moveWand1, moveWand2, moveWand3};
		disabledWands = new List<GameObject>();
		
        if (!Application.isEditor || loadFromTextFileInEditor)
        {
            if (!Import(filename))
            {
                Debug.LogError("Could not load input configuration file. Creating file based on current settings.");
                Export(filename);
            }
        }

        if (!enableKinect)
        {
            Debug.Log("Kinect is disabled from RUISInputManager.");
            GetComponentInChildren<RUISKinectDisabler>().KinectNotAvailable();
        }
        else
        {
            GetComponentInChildren<NIPlayerManagerCOMSelection>().m_MaxNumberOfPlayers = maxNumberOfKinectPlayers;
        }
		
        psMoveWrapper = GetComponentInChildren<PSMoveWrapper>();
        if (enablePSMove)
        {

            if (psMoveWrapper && connectToPSMoveOnStartup)
            {
                StartCoroutine("CheckForMoveConnection");

                psMoveWrapper.Connect(PSMoveIP, PSMovePort);

                psMoveWrapper.enableDefaultInGameCalibrate = enableMoveCalibrationDuringPlay;
				
				if(delayedWandActivation)
				{	
					string names = "";
					foreach (RUISPSMoveWand moveController in FindObjectsOfType(typeof(RUISPSMoveWand)) as RUISPSMoveWand[])
			        {
			            if(		moveController != null && moveController.controllerId < 4 
							&&	moveController.controllerId >= 0 && wandDelayed[moveController.controllerId] )
						{
							// Make sure that the found RUISPSMoveWand is not under InputManager->MoveControllers GameObject
							if(		moveController.gameObject.transform.parent == null
								||	moveController.gameObject.transform.parent.parent == null
								||	(	moveController.gameObject.transform.parent.GetComponent<RUISInputManager>() == null
									 &&	moveController.gameObject.transform.parent.parent.GetComponent<RUISInputManager>() == null))
							{
								moveController.gameObject.SetActive(false);
								disabledWands.Add(moveController.gameObject);
								if(names.Length > 0)
									names += ", ";
								names += moveController.gameObject.name;
							}
						}
			        }
					if(disabledWands.Count > 0)
					{
						Debug.Log(	  "DELAYED CONTROLLER ACTIVATION INITIALIZATION: Following objects are disabled: " 
									+ names + ". If their input devices are found, they will be re-activated in "
									+ delayTime + " seconds, as configured in RUISInputManager.");
						StartCoroutine("DelayedWandActivation");
					}
				}
            }
        }
        else
        {
			Debug.Log("PS Move is disabled from RUISInputManager.");
            //psMoveWrapper.gameObject.SetActiveRecursively(false);
        }
		
		
		sixense = FindObjectOfType(typeof(SixenseInput)) as SixenseInput;
		if(enableRazerHydra)
		{
			if(sixense == null)
				Debug.LogError(		"Could not connect with Razer Hydra! Your RUIS InputManager settings indicate "
								+ 	"that you want to use Razer Hydra, but this scene does not have a gameobject "
								+	"with SixenseInput script, which is required. Add SixenseInput prefab "
								+	"into the scene.");
			// IsBaseConnected() seems to crash Unity at least when called here
//			else if(!SixenseInput.IsBaseConnected(0)) // TODO: *** Apparently there can be multiple bases
//				Debug.LogError(		"Could not connect with Razer Hydra! Check the USB connection.");
		}
		else
		{
			if(sixense != null)
			{
				sixense.gameObject.SetActive(false);
				Debug.Log(	"Razer Hydra is disabled from RUISInputManager. Disabling object " + sixense.name
						  + " that has the SixenseInput script.");
			}
		}
		
        DisableUnneededMoveWands();
		
		DisableUnneededRazerHydraWands();
        
    }
Exemplo n.º 5
0
    void Awake()
    {
        Cursor.visible = true;         // Incase cursor was hidden in previous scene

        // Check if calibration settings were chosen on previous scene
        ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;

        if (ruisNGUIMenu != null)
        {
            if (ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration)
            {
                numberOfSamplesToTake = 50;
                samplesPerSecond      = 5;
                switch (ruisNGUIMenu.calibrationDropDownSelection)
                {
                case "Kinect - Kinect2":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.Kinect_2;
                    break;

                case "Kinect - PSMove":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.PS_Move;
                    break;

                case "Kinect 2 - PSMove":
                    firstDevice  = RUISDevice.Kinect_2;
                    secondDevice = RUISDevice.PS_Move;
                    break;

                case "Kinect 2 - Oculus DK2":
                    firstDevice  = RUISDevice.Kinect_2;
                    secondDevice = RUISDevice.Oculus_DK2;
                    break;

                case "Kinect - Oculus DK2":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.Oculus_DK2;
                    break;

                case "PSMove - Oculus DK2":
                    firstDevice  = RUISDevice.PS_Move;
                    secondDevice = RUISDevice.Oculus_DK2;
                    break;

                case "Kinect floor data":
                    firstDevice  = RUISDevice.Kinect_1;
                    secondDevice = RUISDevice.Kinect_1;
                    break;

                case "Kinect 2 floor data":
                    firstDevice  = RUISDevice.Kinect_2;
                    secondDevice = RUISDevice.Kinect_2;
                    break;

                default:
                    firstDevice  = RUISDevice.Null;
                    secondDevice = RUISDevice.Null;
                    break;
                }
            }
        }

        // Init scene objects
        this.floorPlane = GameObject.Find("Floor");
        this.calibrationPhaseObjects       = GameObject.Find("CalibrationPhase");
        this.calibrationResultPhaseObjects = GameObject.Find("ResultPhase");
        this.depthViews   = GameObject.Find("Depth views");
        this.deviceModels = GameObject.Find("Device models");
        this.icons        = GameObject.Find("Icons");

        upperText = GameObject.Find("Upper Text").GetComponent <GUIText>();
        lowerText = GameObject.Find("Lower Text").GetComponent <GUIText>();

        skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
        coordinateSystem   = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;

        // Pass variables and objects to calibrationProcess
        calibrationProcessSettings                               = new RUISCalibrationProcessSettings();
        calibrationProcessSettings.xmlFilename                   = xmlFilename;
        calibrationProcessSettings.numberOfSamplesToTake         = numberOfSamplesToTake;
        calibrationProcessSettings.numberOfSamplesPerSecond      = samplesPerSecond;
        calibrationProcessSettings.calibrationCubePrefab         = this.sampleCube;
        calibrationProcessSettings.calibrationSpherePrefab       = this.sampleSphere;
        calibrationProcessSettings.calibrationPhaseObjects       = this.calibrationPhaseObjects;
        calibrationProcessSettings.calibrationResultPhaseObjects = this.calibrationResultPhaseObjects;
        calibrationProcessSettings.deviceModelObjects            = deviceModels;
        calibrationProcessSettings.depthViewObjects              = depthViews;
        calibrationProcessSettings.iconObjects                   = icons;
    }
	void Awake () {
		Cursor.visible = true; // Incase cursor was hidden in previous scene
		
		// Check if calibration settings were chosen on previous scene
		ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;
		
		if(ruisNGUIMenu != null) 
		{
			if(ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration) 
			{
				numberOfSamplesToTake = 50;
				samplesPerSecond = 5;
				switch(ruisNGUIMenu.calibrationDropDownSelection)  
				{
					case "Kinect - Kinect2":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.Kinect_2;
					break;
					case "Kinect - PSMove":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.PS_Move;
					break;
					case "Kinect 2 - PSMove":
						firstDevice = RUISDevice.Kinect_2;
						secondDevice = RUISDevice.PS_Move;
					break;
					case "Kinect 2 - Oculus DK2":
						firstDevice = RUISDevice.Kinect_2;
						secondDevice = RUISDevice.Oculus_DK2;
					break;
					case "Kinect - Oculus DK2":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.Oculus_DK2;
					break;
					case "PSMove - Oculus DK2":
						firstDevice = RUISDevice.PS_Move;
						secondDevice = RUISDevice.Oculus_DK2;
					break;
					case "Kinect floor data":
						firstDevice = RUISDevice.Kinect_1;
						secondDevice = RUISDevice.Kinect_1;
					break;
					case "Kinect 2 floor data":
						firstDevice = RUISDevice.Kinect_2;
						secondDevice = RUISDevice.Kinect_2;
					break;
					default:
						firstDevice = RUISDevice.Null;
						secondDevice = RUISDevice.Null;
					break;
				}
			}
		}
	
		// Init scene objects
		this.floorPlane = GameObject.Find ("Floor");
		this.calibrationPhaseObjects = GameObject.Find("CalibrationPhase");
		this.calibrationResultPhaseObjects = GameObject.Find("ResultPhase");
		this.depthViews = GameObject.Find ("Depth views");
		this.deviceModels = GameObject.Find ("Device models");
		this.icons = GameObject.Find ("Icons");
		
		upperText = GameObject.Find ("Upper Text").GetComponent<GUIText>();
		lowerText = GameObject.Find ("Lower Text").GetComponent<GUIText>();
		
		skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
		coordinateSystem  = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		
		// Pass variables and objects to calibrationProcess
		calibrationProcessSettings = new RUISCalibrationProcessSettings();
		calibrationProcessSettings.xmlFilename = xmlFilename;
		calibrationProcessSettings.numberOfSamplesToTake = numberOfSamplesToTake;
		calibrationProcessSettings.numberOfSamplesPerSecond = samplesPerSecond;
		calibrationProcessSettings.calibrationCubePrefab = this.sampleCube;
		calibrationProcessSettings.calibrationSpherePrefab = this.sampleSphere;
		calibrationProcessSettings.calibrationPhaseObjects = this.calibrationPhaseObjects;
		calibrationProcessSettings.calibrationResultPhaseObjects = this.calibrationResultPhaseObjects;
		calibrationProcessSettings.deviceModelObjects = deviceModels;
		calibrationProcessSettings.depthViewObjects = depthViews;
		calibrationProcessSettings.iconObjects = icons;
	}
Exemplo n.º 7
0
    public void Awake()
    {
        // Check if we are in calibration scene
        ruisNGUIMenu = FindObjectOfType(typeof(RUISMenuNGUI)) as RUISMenuNGUI;

        if (ruisNGUIMenu != null)
        {
            if (ruisNGUIMenu.currentMenuState == RUISMenuNGUI.RUISMenuStates.calibration)
            {
                this.enablePSMove                   = ruisNGUIMenu.originalEnablePSMove;
                this.enableKinect                   = ruisNGUIMenu.originalEnableKinect;
                this.enableKinect2                  = ruisNGUIMenu.originalEnableKinect2;
                this.jumpGestureEnabled             = ruisNGUIMenu.originalEnableJumpGesture;
                this.enableRazerHydra               = ruisNGUIMenu.originalEnableHydra;
                this.kinectDriftCorrectionPreferred = ruisNGUIMenu.originalKinectDriftCorrection;
                this.PSMoveIP   = ruisNGUIMenu.originalPSMoveIP;
                this.PSMovePort = ruisNGUIMenu.originalPSMovePort;
            }
        }

        wandDelayed = new bool[4] {
            moveWand0, moveWand1, moveWand2, moveWand3
        };
        disabledWands = new List <GameObject>();

        if (!Application.isEditor || loadFromTextFileInEditor)
        {
            if (!Import(filename))
            {
                Debug.LogError("Could not load input configuration file. Creating file based on current settings.");
                Export(filename);
            }
        }

        if (!enableKinect)
        {
            Debug.Log("Kinect is disabled from RUISInputManager.");
            GetComponentInChildren <RUISKinectDisabler>().KinectNotAvailable();
        }
        else
        {
            GetComponentInChildren <NIPlayerManagerCOMSelection>().m_MaxNumberOfPlayers = maxNumberOfKinectPlayers;
        }

        psMoveWrapper = GetComponentInChildren <PSMoveWrapper>();
        if (enablePSMove)
        {
            if (psMoveWrapper && connectToPSMoveOnStartup)
            {
                StartCoroutine("CheckForMoveConnection");

                psMoveWrapper.Connect(PSMoveIP, PSMovePort);

                psMoveWrapper.enableDefaultInGameCalibrate = enableMoveCalibrationDuringPlay;

                if (delayedWandActivation)
                {
                    string names = "";
                    foreach (RUISPSMoveWand moveController in FindObjectsOfType(typeof(RUISPSMoveWand)) as RUISPSMoveWand[])
                    {
                        if (moveController != null && moveController.controllerId < 4 &&
                            moveController.controllerId >= 0 && wandDelayed[moveController.controllerId])
                        {
                            // Make sure that the found RUISPSMoveWand is not under InputManager->MoveControllers GameObject
                            if (moveController.gameObject.transform.parent == null ||
                                moveController.gameObject.transform.parent.parent == null ||
                                (moveController.gameObject.transform.parent.GetComponent <RUISInputManager>() == null &&
                                 moveController.gameObject.transform.parent.parent.GetComponent <RUISInputManager>() == null))
                            {
                                moveController.gameObject.SetActive(false);
                                disabledWands.Add(moveController.gameObject);
                                if (names.Length > 0)
                                {
                                    names += ", ";
                                }
                                names += moveController.gameObject.name;
                            }
                        }
                    }
                    if (disabledWands.Count > 0)
                    {
                        Debug.Log("DELAYED CONTROLLER ACTIVATION INITIALIZATION: Following objects are disabled: "
                                  + names + ". If their input devices are found, they will be re-activated in "
                                  + delayTime + " seconds, as configured in RUISInputManager.");
                        StartCoroutine("DelayedWandActivation");
                    }
                }
            }
        }
        else
        {
            Debug.Log("PS Move is disabled from RUISInputManager.");
            //psMoveWrapper.gameObject.SetActiveRecursively(false);
        }


        sixense = FindObjectOfType(typeof(SixenseInput)) as SixenseInput;
        if (enableRazerHydra)
        {
            if (sixense == null)
            {
                Debug.LogError("Could not connect with Razer Hydra! Your RUIS InputManager settings indicate "
                               + "that you want to use Razer Hydra, but this scene does not have a gameobject "
                               + "with SixenseInput script, which is required. Add SixenseInput prefab "
                               + "into the scene.");
            }
            // IsBaseConnected() seems to crash Unity at least when called here
//			else if(!SixenseInput.IsBaseConnected(0)) // TODO: *** Apparently there can be multiple bases
//				Debug.LogError(		"Could not connect with Razer Hydra! Check the USB connection.");
        }
        else
        {
            if (sixense != null)
            {
                sixense.gameObject.SetActive(false);
                Debug.Log("Razer Hydra is disabled from RUISInputManager. Disabling object " + sixense.name
                          + " that has the SixenseInput script.");
            }
        }

        DisableUnneededMoveWands();

        DisableUnneededRazerHydraWands();
    }