private void AddButton(VRMenu iVRMenu)
    {
        // Add a button at the start of the menu
        m_MyItemCommand = new vrCommand("VRMenu.MyCustomButtonCommand", MyItemCommandHandler);

        vrWidgetButton button = new vrWidgetButton("VRMenu.MyCustomButton", iVRMenu.menu, "My Menu Item", m_MyItemCommand);
        iVRMenu.menu.SetChildIndex(button, 0);

        // Add a separator below it
        vrWidgetSeparator separator = new vrWidgetSeparator("VRMenu.MyCustomSeparator", iVRMenu.menu);
        iVRMenu.menu.SetChildIndex(separator, 1);
    }
示例#2
0
    private void AddButton(VRMenu vrmenu)
    {
        // Add a button at the start of the menu
        m_MyItemCommand = new vrCommand("VRMenu.MyCustomButtonCommand", MyItemCommandHandler);

        vrWidgetButton button = new vrWidgetButton("VRMenu.MyCustomButton", vrmenu.menu, "My Menu Item", m_MyItemCommand);

        vrmenu.menu.SetChildIndex(button, 0);

        // Add a separator below it
        vrWidgetSeparator separator = new vrWidgetSeparator("VRMenu.MyCustomSeparator", vrmenu.menu);

        vrmenu.menu.SetChildIndex(separator, 1);
    }
    private void AddButton(VRMenu iVRMenu)
    {
        // Add a button at the start of the menu
        var button = new vrWidgetButton("VRMenu.MyCustomButton", iVRMenu.menu, "My Menu Item", MVRTools.GetCommand("MyItemCommandHandler"));

        iVRMenu.menu.SetChildIndex(button, 0);
        MVRTools.RegisterObject(this, button);

        // Add a separator below it
        var separator = new vrWidgetSeparator("VRMenu.MyCustomSeparator", iVRMenu.menu);

        iVRMenu.menu.SetChildIndex(separator, 1);
        MVRTools.RegisterObject(this, separator);
    }
    // Start waits on VRMenu creation with a coroutine
    protected IEnumerator Start()
    {
        MVRTools.RegisterCommands(this);

        // Wait for the menu to be created
        VRMenu MiddleVRMenu = null;

        while (MiddleVRMenu == null || MiddleVRMenu.menu == null)
        {
            // Wait for VRMenu to be created
            yield return(null);

            MiddleVRMenu = FindObjectOfType(typeof(VRMenu)) as VRMenu;
        }

        // Add a "Networking" submenu
        var networkMenu = new vrWidgetMenu("VRMenu.Networking", MiddleVRMenu.menu, "Networking");

        MiddleVRMenu.menu.SetChildIndex(networkMenu, 0);
        MVRTools.RegisterObject(this, networkMenu);

        // Add a separator below it
        var separator = new vrWidgetSeparator("", MiddleVRMenu.menu);

        MiddleVRMenu.menu.SetChildIndex(separator, 2);
        MVRTools.RegisterObject(this, separator);

        var networkManager = GetComponent <NetworkManager>();
        var defaultAddress = networkManager.networkAddress + ":" + networkManager.networkPort;

        m_StartHostButton = new vrWidgetButton("VRMenu.Networking.StartNetworkHost", networkMenu, "Start host (Server and client)", MVRTools.GetCommand("NetworkStartHost"));
        MVRTools.RegisterObject(this, m_StartHostButton);

        m_ConnectToLocalServerButton = new vrWidgetButton("VRMenu.Networking.ConnectToDefaultServer", networkMenu, "Connect to default server (" + defaultAddress + ")", MVRTools.GetCommand("NetworkConnectToDefaultServer"));
        MVRTools.RegisterObject(this, m_ConnectToLocalServerButton);

        m_DisconnectButton = new vrWidgetButton("VRMenu.Networking.Disconnect", networkMenu, "Disconnect", MVRTools.GetCommand("NetworkDisconnect"));
        MVRTools.RegisterObject(this, m_DisconnectButton);
    }
示例#5
0
    protected void Start()
    {
        // Retrieve the VRManager
        VRManagerScript[] foundVRManager = FindObjectsOfType(typeof(VRManagerScript)) as VRManagerScript[];
        if (foundVRManager.Length != 0)
        {
            m_VRManager = foundVRManager[0];
        }
        else
        {
            MVRTools.Log("[X] VRMenu: impossible to retrieve the VRManager.");
            return;
        }

        // Start listening to MiddleVR events
        m_Listener = new vrEventListener(EventListener);
        MiddleVR.VRInteractionMgr.AddEventListener(m_Listener);

        // Create commands

        // General
        m_ResetCurrentButtonCommand   = new vrCommand("VRMenu.ResetCurrentButtonCommand", ResetCurrentButtonHandler);
        m_ResetZeroButtonCommand      = new vrCommand("VRMenu.ResetZeroButtonCommand", ResetZeroButtonHandler);
        m_ExitButtonCommand           = new vrCommand("VRMenu.ExitButtonCommand", ExitButtonHandler);
        m_FramerateCheckboxCommand    = new vrCommand("VRMenu.FramerateCheckboxCommand", FramerateCheckboxHandler);
        m_ProxiWarningCheckboxCommand = new vrCommand("VRMenu.ProxiWarningCheckboxCommand", ProxiWarningCheckboxHandler);

        // Navigation
        m_FlyCheckboxCommand        = new vrCommand("VRMenu.FlyCheckboxCommand", FlyCheckboxHandler);
        m_CollisionsCheckboxCommand = new vrCommand("VRMenu.CollisionsCheckboxCommand", CollisionsCheckboxHandler);

        // Manipulation
        m_ReturnObjectsCheckboxCommand = new vrCommand("VRMenu.ReturnObjectsCheckboxCommand", ReturnObjectsCheckboxHandler);

        // Create GUI
        m_GUIRendererWeb = null;

        VRWebView webViewScript = GetComponent <VRWebView>();

        if (webViewScript == null)
        {
            MVRTools.Log(1, "[X] VRMenu does not have a WebView.");
            return;
        }

        m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView);

        m_Menu = new vrWidgetMenu("VRMenu.VRManagerMenu", m_GUIRendererWeb);

        // Navigation
        m_NavigationOptions = new vrWidgetMenu("VRMenu.NavigationOptions", m_Menu, "Navigation");

        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick"), "Joystick", m_NavigationOptions, NavigationJoystickHandler);
        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationElastic"), "Elastic", m_NavigationOptions, NavigationElasticHandler);
        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld"), "Grab The World", m_NavigationOptions, NavigationGrabWorldHandler);

        m_NavigationSeparator = new vrWidgetSeparator("VRMenu.NavigationSeparator", m_NavigationOptions);
        m_FlyCheckbox         = new vrWidgetToggleButton("VRMenu.FlyCheckbox", m_NavigationOptions, "Fly", m_FlyCheckboxCommand, m_VRManager.Fly);
        m_CollisionsCheckbox  = new vrWidgetToggleButton("VRMenu.CollisionsCheckbox", m_NavigationOptions, "Navigation Collisions", m_CollisionsCheckboxCommand, m_VRManager.NavigationCollisions);

        // Manipulation
        m_ManipulationOptions = new vrWidgetMenu("VRMenu.ManipulationOptions", m_Menu, "Manipulation");

        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationRay"), "Ray", m_ManipulationOptions, ManipulationRayHandler);
        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"), "Homer", m_ManipulationOptions, ManipulationHomerHandler);

        m_ManipulationSeparator = new vrWidgetSeparator("VRMenu.ManipulationSeparator", m_ManipulationOptions);
        m_ReturnObjectsCheckbox = new vrWidgetToggleButton("VRMenu.ReturnObjectsCheckbox", m_ManipulationOptions, "Return Objects", m_ReturnObjectsCheckboxCommand, m_VRManager.ManipulationReturnObjects);

        // Virtual Hand
        m_VirtualHandOptions = new vrWidgetMenu("VRMenu.VirtualHandOptions", m_Menu, "Virtual Hand");

        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"), "Gogo", m_VirtualHandOptions, VirtualHandGogoButtonHandler);

        // General
        m_GeneralSeparator = new vrWidgetSeparator("VRMenu.GeneralSeparator", m_Menu);
        m_GeneralOptions   = new vrWidgetMenu("VRMenu.GeneralOptions", m_Menu, "General Options");

        m_FramerateCheckbox    = new vrWidgetToggleButton("VRMenu.FramerateCheckbox", m_GeneralOptions, "Show Frame Rate", m_FramerateCheckboxCommand, m_VRManager.ShowFPS);
        m_ProxiWarningCheckbox = new vrWidgetToggleButton("VRMenu.ProxiWarningCheckbox", m_GeneralOptions, "Show Proximity Warning", m_ProxiWarningCheckboxCommand, m_VRManager.ShowScreenProximityWarnings);

        // Reset and Exit
        m_ResetButtonMenu    = new vrWidgetMenu("VRMenu.ResetButtonMenu", m_Menu, "Reset Simulation");
        m_ResetCurrentButton = new vrWidgetButton("VRMenu.ResetCurrentButton", m_ResetButtonMenu, "Reload current level", m_ResetCurrentButtonCommand);
        m_ResetZeroButton    = new vrWidgetButton("VRMenu.ResetZeroButton", m_ResetButtonMenu, "Reload level zero", m_ResetZeroButtonCommand);

        m_ExitButtonMenu = new vrWidgetMenu("VRMenu.ExitButtonMenu", m_Menu, "Exit Simulation");
        m_ExitButton     = new vrWidgetButton("VRMenu.ExitButton", m_ExitButtonMenu, "Yes, Exit Simulation", m_ExitButtonCommand);
    }
示例#6
0
文件: VRMenu.cs 项目: fbav/locomotion
    protected void Start()
    {
        // Retrieve the VRManager
        VRManagerScript[] foundVRManager = FindObjectsOfType(typeof(VRManagerScript)) as VRManagerScript[];
        if (foundVRManager.Length != 0)
        {
            m_VRManager = foundVRManager[0];
        }
        else
        {
            MVRTools.Log("[X] VRMenu: impossible to retrieve the VRManager.");
            return;
        }

        // Start listening to MiddleVR events
        m_Listener = new vrEventListener(EventListener);
        MiddleVR.VRInteractionMgr.AddEventListener(m_Listener);

        // Create commands

        // General
        m_ResetCurrentButtonCommand   = new vrCommand("VRMenu.ResetCurrentButtonCommand", ResetCurrentButtonHandler);
        m_ResetZeroButtonCommand      = new vrCommand("VRMenu.ResetZeroButtonCommand", ResetZeroButtonHandler);
        m_ExitButtonCommand           = new vrCommand("VRMenu.ExitButtonCommand", ExitButtonHandler);
        m_FramerateCheckboxCommand    = new vrCommand("VRMenu.FramerateCheckboxCommand", FramerateCheckboxHandler);
        m_ProxiWarningCheckboxCommand = new vrCommand("VRMenu.ProxiWarningCheckboxCommand", ProxiWarningCheckboxHandler);

        // Navigation
        m_FlyCheckboxCommand          = new vrCommand("VRMenu.FlyCheckboxCommand", FlyCheckboxHandler);
        m_CollisionsCheckboxCommand   = new vrCommand("VRMenu.CollisionsCheckboxCommand", CollisionsCheckboxHandler);

        // Manipulation
        m_ReturnObjectsCheckboxCommand = new vrCommand("VRMenu.ReturnObjectsCheckboxCommand", ReturnObjectsCheckboxHandler);

        // Create GUI
        m_GUIRendererWeb = null;

        VRWebView webViewScript = GetComponent<VRWebView>();

        if (webViewScript == null)
        {
            MVRTools.Log(1, "[X] VRMenu does not have a WebView.");
            return;
        }

        m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView);

        m_Menu = new vrWidgetMenu("VRMenu.VRManagerMenu", m_GUIRendererWeb);

        // Navigation
        m_NavigationOptions = new vrWidgetMenu("VRMenu.NavigationOptions", m_Menu, "Navigation");

        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick"), "Joystick", m_NavigationOptions, NavigationJoystickHandler);
        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationElastic"), "Elastic", m_NavigationOptions, NavigationElasticHandler);
        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld"), "Grab The World", m_NavigationOptions, NavigationGrabWorldHandler);

        m_NavigationSeparator = new vrWidgetSeparator("VRMenu.NavigationSeparator", m_NavigationOptions);
        m_FlyCheckbox         = new vrWidgetToggleButton("VRMenu.FlyCheckbox", m_NavigationOptions, "Fly", m_FlyCheckboxCommand, m_VRManager.Fly);
        m_CollisionsCheckbox  = new vrWidgetToggleButton("VRMenu.CollisionsCheckbox", m_NavigationOptions, "Navigation Collisions", m_CollisionsCheckboxCommand, m_VRManager.NavigationCollisions);

        // Manipulation
        m_ManipulationOptions = new vrWidgetMenu("VRMenu.ManipulationOptions", m_Menu, "Manipulation");

        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationRay"), "Ray", m_ManipulationOptions, ManipulationRayHandler);
        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"), "Homer", m_ManipulationOptions, ManipulationHomerHandler);

        m_ManipulationSeparator = new vrWidgetSeparator("VRMenu.ManipulationSeparator", m_ManipulationOptions);
        m_ReturnObjectsCheckbox = new vrWidgetToggleButton("VRMenu.ReturnObjectsCheckbox", m_ManipulationOptions, "Return Objects", m_ReturnObjectsCheckboxCommand, m_VRManager.ManipulationReturnObjects);

        // Virtual Hand
        m_VirtualHandOptions = new vrWidgetMenu("VRMenu.VirtualHandOptions", m_Menu, "Virtual Hand");

        CreateInteractionToggleButton(MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"), "Gogo", m_VirtualHandOptions, VirtualHandGogoButtonHandler);

        // General
        m_GeneralSeparator = new vrWidgetSeparator("VRMenu.GeneralSeparator", m_Menu);
        m_GeneralOptions   = new vrWidgetMenu("VRMenu.GeneralOptions", m_Menu, "General Options");

        m_FramerateCheckbox    = new vrWidgetToggleButton("VRMenu.FramerateCheckbox", m_GeneralOptions, "Show Frame Rate", m_FramerateCheckboxCommand, m_VRManager.ShowFPS);
        m_ProxiWarningCheckbox = new vrWidgetToggleButton("VRMenu.ProxiWarningCheckbox", m_GeneralOptions, "Show Proximity Warning", m_ProxiWarningCheckboxCommand, m_VRManager.ShowScreenProximityWarnings);

        // Reset and Exit
        m_ResetButtonMenu    = new vrWidgetMenu("VRMenu.ResetButtonMenu", m_Menu, "Reset Simulation");
        m_ResetCurrentButton = new vrWidgetButton("VRMenu.ResetCurrentButton", m_ResetButtonMenu, "Reload current level", m_ResetCurrentButtonCommand);
        m_ResetZeroButton    = new vrWidgetButton("VRMenu.ResetZeroButton", m_ResetButtonMenu, "Reload level zero", m_ResetZeroButtonCommand);

        m_ExitButtonMenu = new vrWidgetMenu("VRMenu.ExitButtonMenu", m_Menu, "Exit Simulation");
        m_ExitButton     = new vrWidgetButton("VRMenu.ExitButton", m_ExitButtonMenu, "Yes, Exit Simulation", m_ExitButtonCommand);
    }
    private void Start()
    {
        // Automatically register all methods with the [VRCommand] attribute
        MVRTools.RegisterCommands(this);

        // Create GUI

        VRWebView webViewScript = GetComponent <VRWebView>();

        if (webViewScript == null)
        {
            MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView.");
            enabled = false;
            return;
        }

        var GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView);

        // Register the object so the garbage collector does not collect it after this method.
        // The object will be disposed when the GameObject is destroyed.
        MVRTools.RegisterObject(this, GUIRendererWeb);

        var menu = new vrWidgetMenu("GUIMenuSample.MainMenu", GUIRendererWeb);

        MVRTools.RegisterObject(this, menu);

        var button1 = new vrWidgetButton("GUIMenuSample.Button1", menu, "Button", MVRTools.GetCommand("ButtonHandler"));

        MVRTools.RegisterObject(this, button1);

        var separator = new vrWidgetSeparator("GUIMenuSample.Separator1", menu);

        MVRTools.RegisterObject(this, separator);

        m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", menu, "Toggle Button", MVRTools.GetCommand("CheckboxHandler"), true);
        MVRTools.RegisterObject(this, m_Checkbox);

        var submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", menu, "Sub Menu");

        submenu.SetVisible(true);
        MVRTools.RegisterObject(this, submenu);

        var radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", submenu, "Huey", MVRTools.GetCommand("RadioHandler"), "Huey");

        MVRTools.RegisterObject(this, radio1);
        var radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", submenu, "Dewey", MVRTools.GetCommand("RadioHandler"), "Dewey");

        MVRTools.RegisterObject(this, radio2);
        var radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", submenu, "Louie", MVRTools.GetCommand("RadioHandler"), "Louie");

        MVRTools.RegisterObject(this, radio3);

        var picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", menu, "Color Picker", MVRTools.GetCommand("ColorPickerHandler"), new vrVec4(0, 0, 0, 0));

        MVRTools.RegisterObject(this, picker);

        var slider = new vrWidgetSlider("GUIMenuSample.Slider", menu, "Slider", MVRTools.GetCommand("SliderHandler"), 50.0f, 0.0f, 100.0f, 1.0f);

        MVRTools.RegisterObject(this, slider);

        vrValue listContents = vrValue.CreateList();

        listContents.AddListItem("Item 1");
        listContents.AddListItem("Item 2");

        var list = new vrWidgetList("GUIMenuSample.List", menu, "List", MVRTools.GetCommand("ListHandler"), listContents, 0);

        MVRTools.RegisterObject(this, list);
    }