/// <summary> /// Depending on given marker name switch through ITs to show them in the GUI. /// Does not set the current IT /// </summary> private void SwitchThroughIT(String markerName) { bool firstSelection = false; // disable current IT component if(_currentIT == null) { firstSelection = true; } foreach (ObjectSelectionBase it in _its) { if (firstSelection) { if (it.GetType().ToString() == "VirtualHandInteraction") { // set it as current _tempCurrentIT = it; SetCurrentIT(_tempCurrentIT); //_currentIT = it; //it.enabled = true; Debug.Log("Init Interaction Technique set!"); } } else { if (//_currentIT != it && ( (markerName == "Marker4" && it.GetType().ToString() == "GoGoInteraction") || (markerName == "Marker0" && it.GetType().ToString() == "HomerInteraction") || (markerName == "Marker5" && it.GetType().ToString() == "VirtualHandInteraction") //) ) { _tempCurrentIT = it; return; } } } if (_tempCurrentIT == null) { Debug.Log("Could not set Interaction Technique!"); _itsAvailable = false; } }
/// <summary> /// Set given IT by enabling its corresponding component and disabling the other. /// </summary> private void SetCurrentIT(ObjectSelectionBase it) { if(_currentIT != null) { // disable current IT component _currentIT.enabled = false; } // set new current it and enable _currentIT = it; _currentIT.enabled = true; _tempCurrentIT = _currentIT; }
private void enableInteractionTechnique(ObjectSelectionBase it) { disableAllTechniques (); it.enabled = true; currentTechnique = it; }
/* ------------------ VRUE Tasks START ------------------- ----------------------------------------------------------------- */ /// <summary> /// Called on Startup to register the attached IT components by first disabling them all /// and then enable the default IT. /// </summary> private void RegisterITs() { _itsAvailable = true; // to be on the safe side disable all attached components foreach (ObjectSelectionBase it in _its) { it.enabled = false; } // by default set VirtualHand Interaction _currentIT = null; _tempCurrentIT = null; SwitchThroughIT(""); }
/// <summary> /// Unity Callback /// OnGUI is called every frame for rendering and handling GUI events. /// </summary> void OnGUI() { /* ------------------ VRUE Tasks START -------------------------- * check if ITs are available * if trigger marker is visible and no objects are currently selected by interaction game object show GUI * depending on visible marker switch through availabe ITs * implement user confirmation and set selected IT only if user has confirmed it * disable the GUI if virtual hand has selected objects and if user has confirmend an IT ----------------------------------------------------------------- */ Debug.Log ("Selection Enabled: " + itSelectionEnabled); if (interactionTechniques.Length == 0) { return; } itSelected = currentTechnique.getSelectionState (); String marker = gameObject.GetComponent<MultiMarkerSwitch> ().GetFaceFront (); if (marker == _triggerMarker && !itSelectionEnabled) { itSelectionEnabled = true; } else if (itSelectionEnabled && Input.GetButtonUp ("Fire2")) { enableInteractionTechnique (newTechnique); itSelectionEnabled = false; } if (!itSelected && itSelectionEnabled) { GUI.BeginGroup (new Rect (Screen.width / 2 - 100, 20, 300, 500)); ObjectSelectionBase temp; if (itDictionary.TryGetValue (marker, out temp)) { newTechnique = temp; GUI.Box (new Rect (0, 0, 300, 50), newTechnique.GetType ().ToString (), vrue11Style); } else { GUI.Box (new Rect (0, 0, 300, 50), currentTechnique.GetType ().ToString (), vrue11Style); } GUI.EndGroup (); } // ------------------ VRUE Tasks END ---------------------------- }