private void Start() { // Create commands m_ButtonCommand = new vrCommand("GUIMenuSample.ButtonCommand", ButtonHandler); m_CheckboxCommand = new vrCommand("GUIMenuSample.CheckboxCommand", CheckboxHandler); m_RadioCommand = new vrCommand("GUIMenuSample.RadioCommand", RadioHandler); m_ColorPickerCommand = new vrCommand("GUIMenuSample.ColorPickerCommand", ColorPickerHandler); m_SliderCommand = new vrCommand("GUIMenuSample.SliderCommand", SliderHandler); m_ListCommand = new vrCommand("GUIMenuSample.ListCommand", ListHandler); // Create GUI m_GUIRendererWeb = null; VRWebView webViewScript = GetComponent <VRWebView>(); if (webViewScript == null) { MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView."); enabled = false; return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); m_Menu = new vrWidgetMenu("GUIMenuSample.MainMenu", m_GUIRendererWeb); m_Button1 = new vrWidgetButton("GUIMenuSample.Button1", m_Menu, "Button", m_ButtonCommand); new vrWidgetSeparator("GUIMenuSample.Separator1", m_Menu); m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", m_Menu, "Toggle Button", m_CheckboxCommand, true); m_Submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", m_Menu, "Sub Menu"); m_Submenu.SetVisible(true); m_Radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", m_Submenu, "Huey", m_RadioCommand, "Huey"); m_Radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", m_Submenu, "Dewey", m_RadioCommand, "Dewey"); m_Radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", m_Submenu, "Louie", m_RadioCommand, "Louie"); m_Picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", m_Menu, "Color Picker", m_ColorPickerCommand, new vrVec4(0, 0, 0, 0)); m_Slider = new vrWidgetSlider("GUIMenuSample.Slider", m_Menu, "Slider", m_SliderCommand, 50.0f, 0.0f, 100.0f, 1.0f); vrValue listContents = vrValue.CreateList(); listContents.AddListItem("Item 1"); listContents.AddListItem("Item 2"); m_List = new vrWidgetList("GUIMenuSample.List", m_Menu, "List", m_ListCommand, listContents, 0); }
private void Start() { // Create commands m_ButtonCommand = new vrCommand("GUIMenuSample.ButtonCommand", ButtonHandler); m_CheckboxCommand = new vrCommand("GUIMenuSample.CheckboxCommand", CheckboxHandler); m_RadioCommand = new vrCommand("GUIMenuSample.RadioCommand", RadioHandler); m_ColorPickerCommand = new vrCommand("GUIMenuSample.ColorPickerCommand", ColorPickerHandler); m_SliderCommand = new vrCommand("GUIMenuSample.SliderCommand", SliderHandler); m_ListCommand = new vrCommand("GUIMenuSample.ListCommand", ListHandler); // Create GUI m_GUIRendererWeb = null; VRWebView webViewScript = GetComponent<VRWebView>(); if (webViewScript == null) { MVRTools.Log(0, "[X] VRGUIMenuSample does not have a WebView."); enabled = false; return; } m_GUIRendererWeb = new vrGUIRendererWeb("", webViewScript.webView); m_Menu = new vrWidgetMenu("GUIMenuSample.MainMenu", m_GUIRendererWeb); m_Button1 = new vrWidgetButton("GUIMenuSample.Button1", m_Menu, "Button", m_ButtonCommand); new vrWidgetSeparator("GUIMenuSample.Separator1", m_Menu); m_Checkbox = new vrWidgetToggleButton("GUIMenuSample.Checkbox", m_Menu, "Toggle Button", m_CheckboxCommand, true); m_Submenu = new vrWidgetMenu("GUIMenuSample.SubMenu", m_Menu, "Sub Menu"); m_Submenu.SetVisible(true); m_Radio1 = new vrWidgetRadioButton("GUIMenuSample.Radio1", m_Submenu, "Huey", m_RadioCommand, "Huey"); m_Radio2 = new vrWidgetRadioButton("GUIMenuSample.Radio2", m_Submenu, "Dewey", m_RadioCommand, "Dewey"); m_Radio3 = new vrWidgetRadioButton("GUIMenuSample.Radio3", m_Submenu, "Louie", m_RadioCommand, "Louie"); m_Picker = new vrWidgetColorPicker("GUIMenuSample.ColorPicker", m_Menu, "Color Picker", m_ColorPickerCommand, new vrVec4(0, 0, 0, 0)); m_Slider = new vrWidgetSlider("GUIMenuSample.Slider", m_Menu, "Slider", m_SliderCommand, 50.0f, 0.0f, 100.0f, 1.0f); vrValue listContents = vrValue.CreateList(); listContents.AddListItem( "Item 1" ); listContents.AddListItem( "Item 2" ); m_List = new vrWidgetList("GUIMenuSample.List", m_Menu, "List", m_ListCommand, listContents, 0); }
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); }