void ApplyGradient(ExitPollPanel panel)
        {
            var horizontal = panel.GetComponentInChildren <UnityEngine.UI.HorizontalLayoutGroup>();

            if (horizontal == null)
            {
                return;
            }
            Transform horizontalGroup = horizontal.transform;
            int       gazeButtonCount = horizontalGroup.childCount;

            //this should only colour enabled gameobjects

            for (int i = 0; i < gazeButtonCount; i++)
            {
                var imagechild = horizontalGroup.GetChild(i).Find("Image");
                if (imagechild == null)
                {
                    continue;
                }
                var image = imagechild.GetComponent <UnityEngine.UI.Image>();
                if (image == null)
                {
                    continue;
                }
                panel.SetIntegerButtonColor(image, i / (float)gazeButtonCount);
            }
            Debug.Log("Set " + gazeButtonCount + " colours on gaze buttons");
        }
Пример #2
0
        void IterateToNextQuestion()
        {
            bool    useLastPanelPosition = false;
            Vector3 lastPanelPosition    = Vector3.zero;

            //close current panel
            if (CurrentExitPollPanel != null)
            {
                lastPanelPosition    = CurrentExitPollPanel.transform.position;
                useLastPanelPosition = true;
                //CurrentExitPollPanel = null;
            }

            if (!useLastPanelPosition)
            {
                if (!GetSpawnPosition(out lastPanelPosition))
                {
                    CognitiveVR.Util.logDebug("no last position set. invoke endaction");
                    if (EndAction != null)
                    {
                        EndAction.Invoke();
                    }
                    OverridePosition = null;
                    OverrideRotation = null;
                    if (_pointer)
                    {
                        _pointer.SetVisible(false);
                    }
                    ExitPoll.CurrentExitPollSet = null;
                    return;
                }
            }

            //if next question, display that
            if (panelProperties.Count > 0 && currentPanelIndex < panelProperties.Count)
            {
                DisplayPanel(panelProperties[currentPanelIndex], panelCount, lastPanelPosition);
                //panelProperties.RemoveAt(0);
            }
            else //finished everything format and send
            {
                SendResponsesAsTransaction(); //for personalization api
                var responses = FormatResponses();
                SendQuestionResponses(responses); //for exitpoll microservice
                CurrentExitPollPanel = null;
                if (EndAction != null)
                {
                    EndAction.Invoke();
                }
                OverridePosition = null;
                OverrideRotation = null;
                if (_pointer)
                {
                    _pointer.SetVisible(false);
                }
                ExitPoll.CurrentExitPollSet = null;
            }
            panelCount++;
        }
Пример #3
0
 /// <summary>
 /// Use EndQuestionSet to close the active panel and immediately end the question set
 /// this sets the current panel to null and calls endaction. it assumes the panel closes itself
 /// </summary>
 public void OnPanelError()
 {
     //SendResponsesAsTransaction(); //for personalization api
     //var responses = FormatResponses();
     //SendQuestionResponses(responses); //for exitpoll microservice
     CurrentExitPollPanel = null;
     Cleanup(false);
     CognitiveVR.Util.logDebug("Exit poll OnPanelError - HMD is null, manually closing question set or new exit poll while one is active");
 }
Пример #4
0
 /// <summary>
 /// Use EndQuestionSet to close the active panel and immediately end the question set
 /// this sets the current panel to null and calls endaction. it assumes the panel closes itself
 /// </summary>
 public void OnPanelError()
 {
     //SendResponsesAsTransaction(); //for personalization api
     //var responses = FormatResponses();
     //SendQuestionResponses(responses); //for exitpoll microservice
     CurrentExitPollPanel = null;
     if (EndAction != null)
     {
         EndAction.Invoke();
     }
     OverridePosition = null;
     OverrideRotation = null;
     if (_pointer)
     {
         _pointer.SetVisible(false);
     }
     ExitPoll.CurrentExitPollSet = null;
     CognitiveVR.Util.logDebug("Exit poll OnPanelError - HMD is null, manually closing question set or new exit poll while one is active");
 }
Пример #5
0
        void IterateToNextQuestion()
        {
            if (GameplayReferences.HMD == null)
            {
                Cleanup(false);
                return;
            }

            bool       useLastPanelPosition = false;
            Vector3    lastPanelPosition    = Vector3.zero;
            Quaternion lastPanelRotation    = Quaternion.identity;

            //close current panel
            if (CurrentExitPollPanel != null)
            {
                lastPanelPosition    = CurrentExitPollPanel.transform.position;
                lastPanelRotation    = CurrentExitPollPanel.transform.rotation;
                useLastPanelPosition = true;
                //CurrentExitPollPanel = null;
            }

            if (!useLastPanelPosition)
            {
                if (!GetSpawnPosition(out lastPanelPosition))
                {
                    CognitiveVR.Util.logDebug("no last position set. invoke endaction");
                    Cleanup(false);
                    return;
                }
            }

            //if next question, display that
            if (panelProperties.Count > 0 && currentPanelIndex < panelProperties.Count)
            {
                //DisplayPanel(panelProperties[currentPanelIndex], panelCount, lastPanelPosition);
                var prefab = GetPrefab(panelProperties[currentPanelIndex]);
                if (prefab == null)
                {
                    Util.logError("couldn't find prefab " + panelProperties[currentPanelIndex]);
                    Cleanup(false);
                    return;
                }

                Vector3    spawnPosition = lastPanelPosition;
                Quaternion spawnRotation = lastPanelRotation;

                if (currentPanelIndex == 0)
                {
                    //figure out world spawn position
                    if (myparameters.UseOverridePosition || myparameters.ExitpollSpawnType == ExitPoll.SpawnType.World)
                    {
                        spawnPosition = myparameters.OverridePosition;
                    }
                    if (myparameters.UseOverrideRotation || myparameters.ExitpollSpawnType == ExitPoll.SpawnType.World)
                    {
                        spawnRotation = myparameters.OverrideRotation;
                    }
                }
                var newPanelGo = GameObject.Instantiate <GameObject>(prefab, spawnPosition, spawnRotation);

                CurrentExitPollPanel = newPanelGo.GetComponent <ExitPollPanel>();

                if (CurrentExitPollPanel == null)
                {
                    Debug.LogError(newPanelGo.gameObject.name + " does not have ExitPollPanel component!");
                    GameObject.Destroy(newPanelGo);
                    Cleanup(false);
                    return;
                }
                CurrentExitPollPanel.Initialize(panelProperties[currentPanelIndex], panelCount, this);

                if (myparameters.ExitpollSpawnType == ExitPoll.SpawnType.World && myparameters.UseAttachTransform)
                {
                    if (myparameters.AttachTransform != null)
                    {
                        newPanelGo.transform.SetParent(myparameters.AttachTransform);
                    }
                }
            }
            else //finished everything format and send
            {
                SendResponsesAsTransaction(); //for personalization api
                var responses = FormatResponses();
                NetworkManager.PostExitpollAnswers(responses, QuestionSetName, questionSetVersion); //for exitpoll microservice
                CurrentExitPollPanel = null;
                Cleanup(true);
            }
            panelCount++;
        }
Пример #6
0
        void DisplayPanel(Dictionary <string, string> properties, int panelId, Vector3 spawnPoint)
        {
            GameObject prefab = null;

            switch (properties["type"])
            {
            case "HAPPYSAD":
                prefab = ExitPoll.ExitPollHappySad;
                break;

            case "SCALE":
                prefab = ExitPoll.ExitPollScale;
                break;

            case "MULTIPLE":
                prefab = ExitPoll.ExitPollMultiple;
                break;

            case "VOICE":
                prefab = ExitPoll.ExitPollVoice;
                break;

            case "THUMBS":
                prefab = ExitPoll.ExitPollThumbs;
                break;

            case "BOOLEAN":
                prefab = ExitPoll.ExitPollTrueFalse;
                break;
            }
            if (prefab == null)
            {
                Util.logError("couldn't find prefab " + properties["type"]);
                if (EndAction != null)
                {
                    EndAction.Invoke();
                }
                OverridePosition = null;
                OverrideRotation = null;
                if (_pointer)
                {
                    _pointer.SetVisible(false);
                }
                ExitPoll.CurrentExitPollSet = null;
                return;
            }

            var newPanelGo = GameObject.Instantiate <GameObject>(prefab);

            //set position
            if (OverridePosition.HasValue)
            {
                newPanelGo.transform.position = OverridePosition.Value;
            }
            else
            {
                newPanelGo.transform.position = spawnPoint;
            }

            //set rotation
            if (OverrideRotation.HasValue)
            {
                newPanelGo.transform.rotation = OverrideRotation.Value;
            }
            else
            {
                newPanelGo.transform.rotation = Quaternion.LookRotation(newPanelGo.transform.position - CognitiveVR_Manager.HMD.position, Vector3.up);
            }

            CurrentExitPollPanel = newPanelGo.GetComponent <ExitPollPanel>();

            CurrentExitPollPanel.Initialize(properties, panelId, this);
        }