Search Unity

Hotspot gaze _360 interactive video sample project_HELP! :(

Discussion in 'VR' started by SUPERSTARIQ, Aug 11, 2018.

  1. SUPERSTARIQ

    SUPERSTARIQ

    Joined:
    Aug 11, 2018
    Posts:
    1
    Hi Guys and Girls....

    Well... Im super new to unity , but learning really quickly.

    Im very interested and have been playing around with the 360 interactive sample project from the unity asset store.

    Amazing package , but struggling with the hotspot example gaze.


    upload_2018-8-11_17-11-33.png



    The problem Im having linking one scene to another with the hotspot gaze.
    I can move from the initial hotspot example gaze scene as illutsrated in the video above., but once i get to the next scene i ma basically stuck there.
    even though i put hotspots in the second scene, i cannot seem to trigger the hotpot to load a new scene ( scene 3)

    I think is the video manager which prevents me from doing this ; it has a gamemanager script attached-

    using System.Collections;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    using UnityEngine.UI;
    using UnityEngine.Video;
    //The Game Manager keeps track of which scenes to load, handles loading scenes, fading between scenes and also video playing/pausing
    namespace Interactive360
    {
    public class GameManager : MonoBehaviour
    {
    public static GameManager instance = null;
    Scene scene;
    VideoPlayer video;
    Animator anim;
    Image fadeImage;
    AsyncOperation operation;
    [Header("Scene Management")]
    public string[] scenesToLoad;
    public string activeScene;
    [Space]
    [Header("UI Settings")]
    public bool useFade;
    public GameObject fadeOverlay;
    public GameObject ControlUI;
    public GameObject LoadingUI;
    //make sure that we only have a single instance of the game manager
    void Awake()
    {
    if (instance == null)
    {
    DontDestroyOnLoad(gameObject);
    instance = this;
    }
    else if (instance != this)
    {
    Destroy(gameObject);
    }
    }

    //set the initial active scene
    void Start()
    {
    scene = SceneManager.GetActiveScene();
    activeScene = scene.buildIndex + " - " + scene.name;
    }
    //Select scene is called from either the menu manager or hotspot manager, and is used to load the desired scene
    public void SelectScene(string sceneToLoad)
    {
    //if we want to use the fading between scenes, start the coroutine here
    if (useFade)
    {
    StartCoroutine(FadeOutAndIn(sceneToLoad));
    }
    //if we dont want to use fading, just load the next scene
    else
    {
    SceneManager.LoadScene(sceneToLoad);
    }
    //set the active scene to the next scene
    activeScene = sceneToLoad;
    }
    IEnumerator FadeOutAndIn(string sceneToLoad)
    {
    //get references to animatior and image component
    anim = fadeOverlay.GetComponent<Animator>();
    fadeImage = fadeOverlay.GetComponent<Image>();
    //turn control UI off and loading UI on
    ControlUI.SetActive(false);
    LoadingUI.SetActive(true);
    //set FadeOut to true on the animator so our image will fade out
    anim.SetBool("FadeOut", true);
    //wait until the fade image is entirely black (alpha=1) then load next scene
    yield return new WaitUntil(() => fadeImage.color.a == 1);
    SceneManager.LoadScene(sceneToLoad);
    Scene scene = SceneManager.GetSceneByName(sceneToLoad);
    Debug.Log("loading scene:" + scene.name);
    yield return new WaitUntil(() => scene.isLoaded);
    // grab video and wait until it is loaded and prepared before starting the fade out
    video = FindObjectOfType<VideoPlayer>();
    yield return new WaitUntil(() => video.isPrepared);
    //set FadeOUt to false on the animator so our image will fade back in
    anim.SetBool("FadeOut", false);

    //wait until the fade image is completely transparent (alpha = 0) and then turn loading UI off and control UI back on
    yield return new WaitUntil(() => fadeImage.color.a == 0);
    LoadingUI.SetActive(false);

    //if we have not destroyed the control UI, set it to active
    if (ControlUI)
    ControlUI.SetActive(true);

    }
    //Find the video in the scene and pause it
    public void PauseVideo()
    {
    if (!video)
    {
    video = FindObjectOfType<VideoPlayer>();
    }
    video.Pause();
    }
    //Find the video in the scene and play it
    public void PlayVideo()
    {
    if (!video)
    {
    video = FindObjectOfType<VideoPlayer>();
    }
    video.Play();
    }
    }
    }


    OR is it the hotspot gaze button causing this problem-
    using System.Collections;
    using UnityEngine;
    using Interactive360.Utils;
    using UnityEngine.UI;
    //This class will invoke an OnClick event for the hotspot button as soon after the users gazes over it for a defined period of time
    namespace Interactive360
    {
    [RequireComponent(typeof(VRInteractiveItem))]
    [RequireComponent(typeof(BoxCollider))]
    public class HotspotButtonGaze : MonoBehaviour
    {

    private Button m_Button; // The button we are going to call onClick for
    private bool isOver = false; // Bool value to let us know whether or not the gaze is over the button
    private VRInteractiveItem m_InteractiveItem; // The interactable object for where the user should look to cause on "onClick" event.
    public bool m_UsingFillImage = true; // Are we using the fill UI for this
    [SerializeField] private Image m_SelectionImage; // Reference to the image who's fill amount is adjusted to display the bar. This will likely be attached to our Camera UI
    [SerializeField] private bool m_HideOnStart = true; // Whether or not the bar should be visible at the start.
    public float m_WaitTime = 2f; // The time we are waiting to complete the gaze interaction
    private Coroutine m_SelectionFillRoutine; // Used to start and stop the filling coroutine based on input.
    private bool m_RadialFilled; // Used to allow the coroutine to wait for the bar to fill.
    private bool m_IsSelectionRadialActive; // Whether or not the bar is currently useable.
    private void Awake()
    {
    m_Button = GetComponent<Button>(); //Reference to Button component
    m_InteractiveItem = GetComponent<VRInteractiveItem>(); //Reference to VRInteractiveItem Component
    }
    private void Start()
    {
    // Setup the radial to have no fill at the start and hide if necessary.
    m_SelectionImage.fillAmount = 0f;
    if (m_HideOnStart)
    Hide();
    }
    public void Hide()
    {
    m_SelectionImage.gameObject.SetActive(false);
    m_IsSelectionRadialActive = false;
    // This effectively resets the radial for when it's shown again.
    m_SelectionImage.fillAmount = 0f;
    }
    public void Show()
    {
    m_SelectionImage.gameObject.SetActive(true);
    m_IsSelectionRadialActive = true;
    }
    private void OnEnable()
    {
    m_InteractiveItem.OnOver += HandleOver;
    m_InteractiveItem.OnOut += HandleOut;
    }
    private void OnDisable()
    {
    m_InteractiveItem.OnOver -= HandleOver;
    m_InteractiveItem.OnOut -= HandleOut;
    }
    private IEnumerator FillSelectionRadial()
    {
    // At the start of the coroutine, the bar is not filled.
    m_RadialFilled = false;
    // Make sure the radial is visible and usable.
    Show();
    // Create a timer and reset the fill amount.
    float timer = 0f;
    m_SelectionImage.fillAmount = 0f;
    // This loop is executed once per frame until the timer exceeds the duration.
    while (timer < m_WaitTime)
    {
    // The image's fill amount requires a value from 0 to 1 so we normalise the time.
    m_SelectionImage.fillAmount = timer / m_WaitTime;
    // Increase the timer by the time between frames and wait for the next frame.
    timer += Time.deltaTime;
    yield return null;
    }
    // When the loop is finished set the fill amount to be full.
    m_SelectionImage.fillAmount = 1f;
    // Turn off the radial so it can only be used once.
    m_IsSelectionRadialActive = false;
    // The radial is now filled so the coroutine waiting for it can continue.
    m_RadialFilled = true;
    // call OnClick now that the selection is complete
    m_Button.onClick.Invoke();
    // Once it's been used make the radial invisible.
    Hide();
    }
    // When the user looks at the rendering of the scene, wait 1 second
    // if we are still over after 1 full second, invoke click
    private IEnumerator WaitAndClick()
    {
    yield return new WaitForSeconds(m_WaitTime);
    if (isOver == true)
    {
    m_Button.onClick.Invoke();
    }
    }
    private void HandleOver()
    {
    isOver = true;
    //if this menu button gaze is for a hotspot, start the FillSelectionRadial coroutine. If it is not
    if (m_UsingFillImage)
    {
    Debug.Log("start coroutine");
    m_SelectionFillRoutine = StartCoroutine(FillSelectionRadial());
    }
    else
    StartCoroutine(WaitAndClick());
    }
    private void HandleOut()
    {
    isOver = false;
    // If the radial is active stop filling it and reset it's amount.
    if (m_IsSelectionRadialActive)
    {
    if (m_SelectionFillRoutine != null)
    StopCoroutine(m_SelectionFillRoutine);
    m_SelectionImage.fillAmount = 0f;
    }
    }
    }
    }

    Im assuming this code references the first scene- and follows me to the second scene.
    but once in the second scene how can i modify it to take me to a third scene?

    Sorry this may be the easiest question ever to some. but Iv never learnt code and have been trying from youtube tutorials for weeks to remedy this.

    If there are any users out there that could even steer me in the right direction would be greatly appreciated!!
     
  2. mahditafer

    mahditafer

    Joined:
    Apr 25, 2019
    Posts:
    1
    j le même problème moi aussi je suis nouveau et j'arrive pas a trouver une solution
    help
     
  3. SIT_XR

    SIT_XR

    Joined:
    Jan 8, 2020
    Posts:
    5
    Hi,
    i had the same problem, i fixed it with a "Main Menu Scene" that Scene is the only scene with Hotspots, Videomanager, MainCamera-Gaze & FadeOut. All these GameObjects will go to the DontDestroyOnLoad "Scene" when you press play. After that i removed the Click Event on the Hotspot Buttons, because this s*** is responsible for hiding your cursor and it will never appear again (WTF!?). Now you have only one global Hotspots Gameobject. My Solution was a HotSpotinformation Class which contains the Hotspot-to-Hotspot Relation (on which Hotspot is another Hotspot Visible and where). I made this because i plan to make a dynamic Application where i can put my Videos with the Hotspot Informations (json or xml) in a folder and everything is fine.
     

    Attached Files: