protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationWandJoystick(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_DirectionReferenceNode = MiddleVR.VRDisplayMgr.GetNode(DirectionReferenceNode);
        m_TurnAroundNode         = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_DirectionReferenceNode != null && m_TurnAroundNode != null)
        {
            m_it.SetDirectionReferenceNode(m_DirectionReferenceNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);
            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);
            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationWandJoystick: One or several nodes are missing.");
        }
    }
    // Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationElastic(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_NavigationNode = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_ReferenceNode != null && m_NavigationNode != null && m_TurnAroundNode != null)
        {
            m_it.SetActionButton(WandActionButton);

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);

            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);

            m_it.SetDistanceThreshold(DistanceThreshold);
            m_it.SetAngleThreshold(AngleThreshold);

            m_it.SetUseRotationYaw(UseRotationYaw);

            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationElastic: One or several nodes are missing.");
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionManipulationRay(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_HandNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);

        if (m_HandNode != null)
        {
            m_it.SetGrabWandButton(WandGrabButton);
            m_it.SetManipulatorNode(m_HandNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionManipulationRay: One or several nodes are missing.");
        }

        m_Wand = this.GetComponent <VRWand>();
    }
    // Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationWandJoystick(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_DirectionReferenceNode = MiddleVR.VRDisplayMgr.GetNode(DirectionReferenceNode);
        m_NavigationNode         = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);
        m_TurnAroundNode         = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_DirectionReferenceNode != null && m_NavigationNode != null && m_TurnAroundNode != null)
        {
            m_it.SetDirectionReferenceNode(m_DirectionReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);
            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationWandJoystick: One or several nodes are missing.");
        }
    }
Пример #5
0
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionVirtualHandGogo(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        vrNode3D handNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);
        vrNode3D headNode = MiddleVR.VRDisplayMgr.GetNode(HeadNode);

        if (handNode != null && headNode != null)
        {
            m_it.SetHandNode(handNode);
            m_it.SetHeadNode(headNode);
            m_it.SetGogoStartDistance(GogoStartDistance);
            m_it.SetRealDistanceMax(RealDistanceMax);
            m_it.SetVirtualDistanceMax(VirtualDistanceMax);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionVirtualHandGogo: One or several nodes are missing.");
        }
    }
Пример #6
0
 void Start()
 {
     if (ElasticRoot == null || Elastic == null)
     {
         MiddleVR.VRLog(2, "[X] VRElasticRepresentation error: bad ElasticRoot or Elastic GameObject reference");
     }
 }
    private void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_VRMgr = GameObject.Find("VRManager").GetComponent <VRManagerScript>();

        m_it = new vrInteractionManipulationHomer(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_HandNode = MiddleVR.VRDisplayMgr.GetNode(HandNode);

        if (m_HandNode != null)
        {
            m_it.SetGrabWandButton(WandGrabButton);
            m_it.SetTranslationScale(TranslationScale);
            m_it.SetRotationScale(RotationScale);
            m_it.SetManipulatorNode(m_HandNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionManipulationHomer: One or several nodes are missing.");
        }

        m_Wand = this.GetComponent <VRWand>();
    }
 protected void OnEnable()
 {
     MiddleVR.VRLog(3, "[ ] VRInteractionManipulationRay: enabled");
     if (m_it != null)
     {
         MiddleVR.VRInteractionMgr.Activate(m_it);
     }
 }
 void OnEnable()
 {
     MiddleVR.VRLog(3, "[ ] VRInteractionNavigationElastic: enabled");
     if (m_it != null)
     {
         MiddleVR.VRInteractionMgr.Activate(m_it);
     }
 }
Пример #10
0
    /*
     * protected void Update()
     * {
     *  // Nothing to do for this interaction, everything is done in the kernel
     * }
     */

    protected void OnEnable()
    {
        MiddleVR.VRLog(3, "[ ] VRInteractionVirtualHandGogo: enabled");
        if (m_it != null)
        {
            MiddleVR.VRInteractionMgr.Activate(m_it);
        }
    }
 protected void OnEnable()
 {
     MiddleVR.VRLog(3, "[ ] VRInteractionNavigationGrabWorld: enabled");
     if (m_it != null)
     {
         MiddleVR.VRInteractionMgr.Activate(m_it);
     }
 }
 void OnDisable()
 {
     MiddleVR.VRLog(3, "[ ] VRInteractionNavigationElastic: disabled");
     if (m_it != null && MiddleVR.VRInteractionMgr != null)
     {
         MiddleVR.VRInteractionMgr.Deactivate(m_it);
     }
 }
 protected void OnDisable()
 {
     MiddleVR.VRLog(3, "[ ] VRInteractionNavigationWandJoystick: disabled");
     if (m_it != null && MiddleVR.VRInteractionMgr != null)
     {
         MiddleVR.VRInteractionMgr.Deactivate(m_it);
     }
 }
Пример #14
0
    protected void OnDisable()
    {
        MiddleVR.VRLog(3, "[ ] VRInteractionVirtualHandGogo: disabled");

        if (m_it != null && MiddleVR.VRInteractionMgr != null)
        {
            MiddleVR.VRInteractionMgr.Deactivate(m_it);
        }
    }
    protected void OnDisable()
    {
        MiddleVR.VRLog(3, "[ ] VRInteractionManipulationRay: disabled");

        if (m_it != null && MiddleVR.VRInteractionMgr != null)
        {
            MiddleVR.VRInteractionMgr.Deactivate(m_it);
        }
    }
Пример #16
0
    private void OnDestroy()
    {
#if VRWEBVIEW_UNITY_FREE
        m_PixelsHandle.Free();
#else
        MiddleVR_CancelCopyBufferToTexture(m_NativeTexturePtr);
#endif
        MiddleVR.DisposeObject(ref m_Image);
        MiddleVR.DisposeObject(ref m_WebView);
    }
    void OnDisable()
    {
        MiddleVR.VRLog(3, "[ ] VRInteractionManipulationReturnObjects: disabled");

        // Reset all objects and release them
        foreach (ReturningObject returningObject in m_ReturningObjects)
        {
            _ResetObjectProperties(returningObject);
        }

        m_ReturningObjects.Clear();
    }
Пример #18
0
    private void OnDestroy()
    {
        // Listener
        MiddleVR.DisposeObject(ref m_Listener);

        // Commands
        foreach (var item in m_Commands)
        {
            MiddleVR.DisposeObject(item.Value);
        }
        m_Commands.Clear();

        MiddleVR.DisposeObject(ref m_ResetCurrentButtonCommand);
        MiddleVR.DisposeObject(ref m_ResetZeroButtonCommand);
        MiddleVR.DisposeObject(ref m_ExitButtonCommand);
        MiddleVR.DisposeObject(ref m_FramerateCheckboxCommand);
        MiddleVR.DisposeObject(ref m_ProxiWarningCheckboxCommand);
        MiddleVR.DisposeObject(ref m_NavigationModeRadioCommand);
        MiddleVR.DisposeObject(ref m_FlyCheckboxCommand);
        MiddleVR.DisposeObject(ref m_CollisionsCheckboxCommand);
        MiddleVR.DisposeObject(ref m_ManipulationModeRadioCommand);
        MiddleVR.DisposeObject(ref m_ReturnObjectsCheckboxCommand);
        MiddleVR.DisposeObject(ref m_VirtualHandModeRadioCommand);

        // Widgets
        foreach (var item in m_Buttons)
        {
            MiddleVR.DisposeObject(item.Value);
        }
        m_Buttons.Clear();

        MiddleVR.DisposeObject(ref m_ResetButtonMenu);
        MiddleVR.DisposeObject(ref m_ResetCurrentButton);
        MiddleVR.DisposeObject(ref m_ResetZeroButton);
        MiddleVR.DisposeObject(ref m_ExitButtonMenu);
        MiddleVR.DisposeObject(ref m_ExitButton);
        MiddleVR.DisposeObject(ref m_GeneralOptions);
        MiddleVR.DisposeObject(ref m_FramerateCheckbox);
        MiddleVR.DisposeObject(ref m_ProxiWarningCheckbox);
        MiddleVR.DisposeObject(ref m_GeneralSeparator);
        MiddleVR.DisposeObject(ref m_NavigationOptions);
        MiddleVR.DisposeObject(ref m_NavigationSeparator);
        MiddleVR.DisposeObject(ref m_FlyCheckbox);
        MiddleVR.DisposeObject(ref m_CollisionsCheckbox);
        MiddleVR.DisposeObject(ref m_ManipulationOptions);
        MiddleVR.DisposeObject(ref m_ManipulationSeparator);
        MiddleVR.DisposeObject(ref m_ReturnObjectsCheckbox);
        MiddleVR.DisposeObject(ref m_VirtualHandOptions);
        MiddleVR.DisposeObject(ref m_Menu);

        // GUIRenderer
        MiddleVR.DisposeObject(ref m_GUIRendererWeb);
    }
    void UpdateElasticRepresentation()
    {
        if (m_ElasticRepresentation == null)
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationElastic error: bad elastic representation reference");
            return;
        }

        Vector3 startPosition = MVRTools.ToUnity(m_it.GetInteractionStartWorldMatrix().GetTranslation());
        Vector3 endPosition   = MVRTools.ToUnity(m_ReferenceNode.GetPositionWorld());

        m_ElasticRepresentation.SetElasticPoints(startPosition, endPosition);
    }
Пример #20
0
    private IEnumerator LaunchWebRTCServer()
    {
        MiddleVR.VRLog(1, "[>] Starting copy of the WebRTC server.");

        // We currently have to copy the WebRTC server in %appdata%/MiddleVR
        // due to Windows not allowing a process to start an other process
        // from "Program Files" without admin right.
        var copyingServerThread = new Thread(CopyWebRTCServer);

        copyingServerThread.Start();

        while (!m_ServerReady)
        {
            yield return(null);
        }

        copyingServerThread.Join();

        MiddleVR.VRLog(1, "[<] Ending copy of the WebRTC server.");

        m_NetworkManager = FindObjectOfType <NetworkManager>();

        var startInfo = new ProcessStartInfo();

        startInfo.CreateNoWindow  = true;
        startInfo.UseShellExecute = false;
        startInfo.WindowStyle     = ProcessWindowStyle.Hidden;

        string pathToAppDataWebRTCServer = Path.GetFullPath(MiddleVR.VRKernel.GetAppDataFolder() + "\\MVRRTCServer");

        startInfo.WorkingDirectory = pathToAppDataWebRTCServer;
        startInfo.FileName         = pathToAppDataWebRTCServer + "\\node.exe";
        startInfo.Arguments        = pathToAppDataWebRTCServer + "\\server.js " + (m_NetworkManager.networkPort + 1).ToString();

        m_WebRTCServerProcess           = new Process();
        m_WebRTCServerProcess.StartInfo = startInfo;
        try
        {
            if (!m_WebRTCServerProcess.Start())
            {
                MiddleVR.VRLog(1, "[X] An error occured when launching the voice chat server, process already running.");
            }
        }
        catch (Exception e)
        {
            MiddleVR.VRLog(1, "[X] An error occured when launching the voice chat server.\n" + e.Message);
        }

        m_RTCServerURL = "https://" + m_NetworkManager.networkAddress + ":" + (m_NetworkManager.networkPort + 1).ToString();
    }
Пример #21
0
    void OnPostRender()
    {
        MiddleVR.VRLog(3, "[ ] PostRender : " + name);
        vrCamera cam = MiddleVR.VRDisplayMgr.GetCamera(name);

        int id = -1;

        if (cam != null)
        {
            id = (int)cam.GetId();
        }

        GL.IssuePluginEvent(id);
    }
Пример #22
0
    // Update is called once per frame
    void Update()
    {
        if (m_Init == true)
        {
            m_Tracker.SetX(0.0f);
            m_Tracker.SetY(0.0f);
            m_Tracker.SetZ(0.0f);

            float yaw   = 0.0f;
            float pitch = MiddleVR.RadToDeg(Mathf.Asin(Mathf.Clamp(m_Wiimote.GetValue(2), -1, 1)));
            float roll  = MiddleVR.RadToDeg(Mathf.Asin(Mathf.Clamp(m_Wiimote.GetValue(1), -1, 1)));

            m_Tracker.SetYaw(yaw);
            m_Tracker.SetPitch(pitch);
            m_Tracker.SetRoll(roll);
        }
    }
Пример #23
0
    protected void OnApplicationQuit()
    {
        MVRNodesCreator.DestroyInstance();
        MVRNodesMapper.DestroyInstance();

        MiddleVR.DisposeObject(ref m_shareRandomStateCommand);
        MiddleVR.DisposeObject(ref m_startParticlesCommand);

        MVRTools.VRDestroy(Application.isEditor);

        // Unity 5.6 players crash on exit when any "-force-*" parameter is on the command line.
        // When launching from middlevr configuration, one of these parameters is always set,
        // so we kill the process as a workaround.
        // The environment variable MIDDLEVR_FORCE_KILL_PLAYER can be set to "false" (case insensitive)
        // to disable this behaviour.
#if UNITY_5_6_OR_NEWER && !UNITY_EDITOR
        string[] crashingArguments = new string[] { "-force-d3d11", "-force-d3d9", "-force-opengl" };

        bool commandLineHasCrashingArgument = Environment.GetCommandLineArgs().Any(
            commandLineArg => crashingArguments.Any(
                crashingArg => String.Equals(commandLineArg, crashingArg, StringComparison.OrdinalIgnoreCase)));

        if (commandLineHasCrashingArgument)
        {
            bool forceKill = true;

            string forceKillEnvVar = Environment.GetEnvironmentVariable("MIDDLEVR_FORCE_KILL_PLAYER");
            if (forceKillEnvVar != null)
            {
                Boolean.TryParse(forceKillEnvVar, out forceKill);
            }

            if (forceKill)
            {
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }
#endif
    }
Пример #24
0
    private void OnDestroy()
    {
        MiddleVR.DisposeObject(ref m_ButtonCommand);
        MiddleVR.DisposeObject(ref m_CheckboxCommand);
        MiddleVR.DisposeObject(ref m_RadioCommand);
        MiddleVR.DisposeObject(ref m_ColorPickerCommand);
        MiddleVR.DisposeObject(ref m_SliderCommand);
        MiddleVR.DisposeObject(ref m_ListCommand);

        MiddleVR.DisposeObject(ref m_Button1);
        MiddleVR.DisposeObject(ref m_Checkbox);
        MiddleVR.DisposeObject(ref m_Submenu);
        MiddleVR.DisposeObject(ref m_Radio1);
        MiddleVR.DisposeObject(ref m_Radio2);
        MiddleVR.DisposeObject(ref m_Radio3);
        MiddleVR.DisposeObject(ref m_Picker);
        MiddleVR.DisposeObject(ref m_Slider);
        MiddleVR.DisposeObject(ref m_List);

        MiddleVR.DisposeObject(ref m_Menu);

        MiddleVR.DisposeObject(ref m_GUIRendererWeb);
    }
Пример #25
0
    // Use this for initialization
    void Start()
    {
        m_it = new vrInteractionNavigationGrabWorld(Name);
        GC.SuppressFinalize(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_NavigationNode = MiddleVR.VRDisplayMgr.GetNode(NavigationNode);

        if (m_ReferenceNode != null && m_NavigationNode != null)
        {
            m_it.SetActionButton(WandActionButton);

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetNavigationNode(m_NavigationNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationGrabWorld: One or several nodes are missing.");
        }
    }
    private void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationElastic(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode  = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);
        m_TurnAroundNode = MiddleVR.VRDisplayMgr.GetNode(TurnAroundNode);

        if (m_ReferenceNode != null && m_TurnAroundNode != null)
        {
            m_it.SetActionButton(WandActionButton);

            m_it.SetReferenceNode(m_ReferenceNode);
            m_it.SetTurnAroundNode(m_TurnAroundNode);

            m_it.SetTranslationSpeed(TranslationSpeed);
            m_it.SetRotationSpeed(RotationSpeed);

            m_it.SetDistanceThreshold(DistanceThreshold);
            m_it.SetAngleThreshold(AngleThreshold);

            m_it.SetUseRotationYaw(UseRotationYaw);

            m_it.SetFly(Fly);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationElastic: One or several nodes are missing.");
        }
    }
    protected void Start()
    {
        // Make sure the base interaction is started
        InitializeBaseInteraction();

        m_it = new vrInteractionNavigationGrabWorld(Name);
        // Must tell base class about our interaction
        SetInteraction(m_it);

        MiddleVR.VRInteractionMgr.AddInteraction(m_it);
        MiddleVR.VRInteractionMgr.Activate(m_it);

        m_ReferenceNode = MiddleVR.VRDisplayMgr.GetNode(ReferenceNode);

        if (m_ReferenceNode != null)
        {
            m_it.SetActionButton(WandActionButton);
            m_it.SetReferenceNode(m_ReferenceNode);
        }
        else
        {
            MiddleVR.VRLog(2, "[X] VRInteractionNavigationGrabWorld: One or several nodes are missing.");
        }
    }
Пример #28
0
    protected void Start()
    {
        // Check if we are running MiddleVR
        if (MiddleVR.VRKernel == null)
        {
            Debug.Log("[X] VRManager is missing from the scene !");
            enabled = false;
            return;
        }

        if (SystemInfo.graphicsDeviceID == 0)
        {
            Debug.Log("[~] Running in batchmode - disabling VRWebView script");
            enabled = false;
            return;
        }

        m_VirtualMousePosition = new Vector2(0, 0);

        if (Application.isEditor)
        {
            // Get the vrCameras corresponding Cameras
            m_Cameras = new List <Camera>();

            uint camerasNb = MiddleVR.VRDisplayMgr.GetCamerasNb();
            for (uint i = 0; i < camerasNb; ++i)
            {
                vrCamera   vrcamera  = MiddleVR.VRDisplayMgr.GetCameraByIndex(i);
                GameObject cameraObj = GameObject.Find(vrcamera.GetName());
                Camera     camera    = cameraObj.GetComponent <Camera>();
                if (camera != null)
                {
                    m_Cameras.Add(camera);
                }
            }
        }

        m_Texture          = new Texture2D(m_Width, m_Height, TextureFormat.ARGB32, false);
        m_Texture.wrapMode = TextureWrapMode.Clamp;

        // Create vrImage and Texture2D
#if VRWEBVIEW_UNITY_FREE
        // Texture2D.SetPixels takes RGBA.
        m_Image        = new vrImage("", (uint)m_Width, (uint)m_Height, VRImagePixelFormat.VRImagePixelFormat_RGBA);
        m_Pixels       = m_Texture.GetPixels32(0);
        m_PixelsHandle = GCHandle.Alloc(m_Pixels, GCHandleType.Pinned);
#else
        // OpenGL and Direct3D 9: Memory order for texture upload is BGRA (little-endian representation of ARGB32)
        // Direct3D 11: Unity seems to ignore TextureFormat.ARGB32 and always creates an RGBA texture.
        // We let vrImage do the pixel format conversion because this operation is done in another thread.
        if (SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            m_Image = new vrImage("", (uint)m_Width, (uint)m_Height, VRImagePixelFormat.VRImagePixelFormat_RGBA);
        }
        else
        {
            m_Image = new vrImage("", (uint)m_Width, (uint)m_Height, VRImagePixelFormat.VRImagePixelFormat_BGRA);
        }
#endif

        // Fill texture
        Color32[] colors = new Color32[(m_Width * m_Height)];

        for (int i = 0; i < (m_Width * m_Height); i++)
        {
            colors[i].r = 0;
            colors[i].g = 0;
            colors[i].b = 0;
            colors[i].a = 0;
        }

        m_Texture.SetPixels32(colors);
        m_Texture.Apply(false, false);

#if !VRWEBVIEW_UNITY_FREE
        m_NativeTexturePtr = m_Texture.GetNativeTexturePtr();
#endif

        // Attach texture
        if (gameObject != null && gameObject.GetComponent <GUITexture>() == null && gameObject.GetComponent <Renderer>() != null)
        {
            var renderer = gameObject.GetComponent <Renderer>();

            // Assign the material/shader to the object attached
            renderer.material             = Resources.Load("VRWebViewMaterial", typeof(Material)) as Material;
            renderer.material.mainTexture = this.m_Texture;
        }
        else if (gameObject != null && gameObject.GetComponent <GUITexture>() != null)
        {
            gameObject.GetComponent <GUITexture>().texture = this.m_Texture;
        }
        else
        {
            MiddleVR.VRLog(2, "VRWebView must be attached to a GameObject with a renderer or a GUITexture !");
            enabled = false;
            return;
        }

        // Handle Cluster
        if (MiddleVR.VRClusterMgr.IsServer() && !MiddleVR.VRKernel.GetEditorMode())
        {
            MiddleVR.VRClusterMgr.AddSynchronizedObject(m_Image);
        }

        if (!MiddleVR.VRClusterMgr.IsClient())
        {
            if (m_DirectoryProviders.Length == 0 && m_ArchiveProviders.Length == 0)
            {
                m_WebView = new vrWebView("", GetAbsoluteURL(m_URL), (uint)m_Width, (uint)m_Height, m_Image);
            }
            else
            {
                m_WebView = new vrWebView("", "", (uint)m_Width, (uint)m_Height, m_Image);

                int order = 0;

                foreach (VRWebViewDirectoryProvider directoryProvider in m_DirectoryProviders)
                {
                    m_WebView.AddDirectoryProvider(directoryProvider.m_URL, Application.dataPath + System.IO.Path.DirectorySeparatorChar + directoryProvider.m_DirectoryPath, order, "VRWebViewProvider" + order);
                    order++;
                }

                foreach (VRWebViewArchiveProvider archiveProvider in m_ArchiveProviders)
                {
                    m_WebView.AddArchiveProvider(archiveProvider.m_URL, Application.dataPath + System.IO.Path.DirectorySeparatorChar + archiveProvider.m_ArchivePath, archiveProvider.m_Password, order, "VRWebViewProvider" + order);
                    order++;
                }

                m_WebView.SetURL(GetAbsoluteURL(m_URL));
            }
            m_WebView.SetZoom(m_Zoom);
        }
    }
 void OnEnable()
 {
     MiddleVR.VRLog(3, "[ ] VRInteractionManipulationReturnObjects: enabled");
 }
Пример #30
0
 private void OnDestroy()
 {
     MiddleVR.DisposeObject(ref m_MyCommand);
 }