Ejemplo n.º 1
0
 /// @brief mono-behavior OnGUI for GUI logic. Is also responsible for mode change
 void OnGUI()
 {
     // option 1: we are in skeleton mode. All we need to do is try to detect the exit pose
     if (m_mode == SkeletonGUIModes.SkeletonMode)
     {
         // this tells us if we are detecting the exit pose.
         float val = m_input.GetAxis("SkeletonSwitch");
         if (val >= 1.0f)
         {
             // we have detected the exit pose so we are moving to GUI mode.
             m_mode = SkeletonGUIModes.GUIMode;
             // deactivate the skeleton (controller, not the capability)
             m_skeletonManager.SetAllSkeletonPlayersToState(false);
             // when tracking a hand we need a high smoothing factor.
             m_settings.SmoothFactor = 0.95f;
             // reactivate NIGUI.
             NIGUI.SetActive(true);
             return;
         }
         if (val > 0)
         {
             // The value is between 0 and 1 so we have detected the exit pose and are waiting
             // for it to continue long enough.
             // Just pop up a message telling the user to continue holding the pose...
             tempRect.y = 40;
             if (m_image != null)
             {
                 Rect tmpRect2 = tempRect;
                 tmpRect2.height = 128;
                 tmpRect2.width  = 128;
                 GUI.Box(tmpRect2, m_image);
                 tempRect.y = 168;
             }
             GUI.Box(tempRect, "Hold the pose until " + val + " reaches 1");
             return;
         }
         return; // nothing to do
     }
     // here we are on GUI mode. Lets draw the GUI
     tempRect.y = Screen.height / 2 - 20;
     if (NIGUI.Button(tempRect, "Resume"))
     {
         // move back to skeleton mode.
         m_mode = SkeletonGUIModes.SkeletonMode;
         // reactivate the skeleton controllers
         m_skeletonManager.SetAllSkeletonPlayersToState(true);
         // set a regular smoothing
         m_settings.SmoothFactor = 0.5f;
         // deactivate NIGUI.
         NIGUI.SetActive(false);
         return;
     }
     tempRect.y = Screen.height / 2 + 30;
     if (NIGUI.Button(tempRect, "Exit"))
     {
         // note: in editor mode this doesn't really do anything...
         Application.Quit();
         return;
     }
 }
Ejemplo n.º 2
0
    /// mono-behavior OnGUI to show GUI elements
    public void OnGUI()
    {
        //debug


        GUI.skin = customSkin;

        //GUILayout.Button("I am a custom styled Button", "MyCustomControl");
        // create a regular label
        myRect.x      = 20;
        myRect.y      = 20;
        myRect.width  = 300;
        myRect.height = 30;
        //GUI.Label(myRect, "Welcome to Virtual Dressing Room! ^_^");


        // place the first button
        //myRect.x = 20;
        //myRect.y = 330;
        //myRect.width = 200;
        //myRect.height = 150;
        //NIGUI.Button(myRect, "Random Try-on!");



        // place the selection grid GUI element
        myRect.x      = 20;
        myRect.y      = 10;
        myRect.width  = 200;
        myRect.height = 300;
        categoryInt   = NIGUI.SelectionGrid(myRect, categoryInt, categoryStrings, 1);



        //ITEM GROUP
        // placed the clipped area for the button
        myRect.x      = (Screen.width) - 260;
        myRect.y      = 0;
        myRect.width  = 400;
        myRect.height = Screen.height;
        NIGUI.BeginGroup(myRect);
        // internal background
        //myRect.x = 0;
        //myRect.y = 0;
        //Color c = GUI.backgroundColor;
        //Color almostClear = c;
        //almostClear.a = 0.2f;
        //GUI.backgroundColor = almostClear;
        //GUI.Box(myRect, "");
        //GUI.backgroundColor = c;

        //internal buttons
        Texture[] tempItems = upperGarment;//(Texture[])catArray[0];// = upperGarment;//(Texture[])categories[categoryStrings[categoryInt]];
        switch (categoryInt)
        {
        case 0:
            tempItems = upperGarment;
            break;

        case 1:
            tempItems = pant;
            break;

        case 2:
            tempItems = dress;
            break;

        case 3:
            tempItems = shoes;
            break;

        case 4:
            tempItems = accessory;
            break;
        }
        Debug.Log("category index: " + categoryInt);
        itemInt = NIGUI.SelectionGrid(new Rect(100, 10 - ITEMHEIGHT * itemTopIndex, ITEMWIDTH, tempItems.Length * ITEMHEIGHT), itemInt, tempItems, 1);
        if (NIGUI.Button(new Rect(10, 150, 80, 80), upTexture))
        {
            if (itemTopIndex > 0)
            {
                itemTopIndex--;
            }
        }
        if (NIGUI.Button(new Rect(10, 250, 80, 80), downTexture))
        {
            if (itemTopIndex < tempItems.Length - 1)
            {
                itemTopIndex++;
            }
        }
        //if (NIGUI.Button(new Rect(50, 50, 100, 200), "Garment Sample"))
        //    buttonPressedMessage = "Internal button was pressed";
        NIGUI.EndGroup();
    }
Ejemplo n.º 3
0
    /// mono-behavior OnGUI to show GUI elements
    public void OnGUI()
    {
        // create a regular label
        myRect.x      = (Screen.width / 2) - 40;
        myRect.y      = 20;
        myRect.width  = 80;
        myRect.height = 30;
        GUI.Label(myRect, "Example GUI");


        // place the first button
        myRect.x      = 200;
        myRect.y      = 50;
        myRect.width  = 80;
        myRect.height = 40;
        if (NIGUI.Button(myRect, "Button1"))
        {
            buttonPressedMessage = "Button 1 was pressed at time=" + Time.time;
        }

        // place the second button
        myRect.x = 300;
        myRect.y = 50;
        if (NIGUI.Button(myRect, "Button2"))
        {
            buttonPressedMessage = "Button 2 was pressed at time=" + Time.time;
        }


        // place the repeat button
        myRect.x = 200;
        myRect.y = 100;
        if (NIGUI.RepeatButton(myRect, "Repeat"))
        {
            buttonPressedMessage = "Repeat button was pressed at time=" + Time.time;
        }

        // place the toggle button
        myRect.x     = 300;
        myRect.y     = 100;
        myRect.width = 250;
        m_toggle1    = NIGUI.Toggle(myRect, m_toggle1, "Toggle example");

        // place the GUI changed frame
        myRect.x      = 50;
        myRect.y      = (Screen.height / 2) - 140;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, guiFrameCahngedMessage);

        // place the vScroll value label
        myRect.x      = 50;
        myRect.y      = (Screen.height / 2) - 100;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, "vScroll=" + vScroll);

        // place the hScroll value label
        myRect.x      = 50;
        myRect.y      = (Screen.height / 2) - 60;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, "hScroll=" + hScroll);

        // place the button pressed label
        myRect.x      = 50;
        myRect.y      = (Screen.height / 2) - 20;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, buttonPressedMessage);

        // Click axis value label
        myRect.x      = 50;
        myRect.y      = (Screen.height / 2) + 20;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, "value=" + m_input.GetAxis("NIGUI_CLICK"));


        // place the toolbar GUI
        myRect.x      = 50;
        myRect.y      = Screen.height - 200;
        myRect.width  = 350;
        myRect.height = 30;
        toolbarInt    = NIGUI.Toolbar(myRect, toolbarInt, toolbarStrings);

        // place the selection grid GUI element
        myRect.x         = 50;
        myRect.y         = Screen.height - 150;
        myRect.width     = 350;
        myRect.height    = 90;
        selectionGridInt = NIGUI.SelectionGrid(myRect, selectionGridInt, toolbarStrings, 2);

        // place the horizontal scrollbar of the clipped button
        myRect.x      = (Screen.width) - 500;
        myRect.y      = (Screen.height / 2) - 240;
        myRect.width  = 400;
        myRect.height = 20;
        hScroll       = NIGUI.HorizontalScrollbar(myRect, hScroll, 0.0f, 0.0f, 300.0f);

        // place the vertical scrollbar of the clipped button
        myRect.x      = (Screen.width) - 510;
        myRect.y      = (Screen.height / 2) - 225;
        myRect.width  = 10;
        myRect.height = 200;
        vScroll       = NIGUI.VerticalScrollbar(myRect, vScroll, 40.0f, 0.0f, 140.0f);

        // placed the clipped area for the button
        myRect.x      = (Screen.width) - 500;
        myRect.y      = (Screen.height / 2) - 225;
        myRect.width  = 400;
        myRect.height = 200;
        NIGUI.BeginGroup(myRect);
        // place the internal button
        myRect.x = 0;
        myRect.y = 0;
        Color c           = GUI.backgroundColor;
        Color almostClear = c;

        almostClear.a       = 0.2f;
        GUI.backgroundColor = almostClear;
        GUI.Box(myRect, "");
        GUI.backgroundColor = c;
        if (NIGUI.Button(new Rect(150 - hScroll, 50 - vScroll, 300, 200), "a button to be clipped by the view"))
        {
            buttonPressedMessage = "Internal button to group was pressed";
        }
        NIGUI.EndGroup();

        // place the float slider
        myRect.x      = (Screen.width) - 500;
        myRect.y      = (Screen.height / 2) + 110;
        myRect.width  = 350;
        myRect.height = 30;
        floatSlider   = NIGUI.HorizontalSlider(myRect, floatSlider, -5.0f, 5.0f);

        // place the float slider label
        myRect.x      = (Screen.width) - 500;
        myRect.y      = (Screen.height / 2) + 80;
        myRect.width  = 350;
        myRect.height = 30;
        GUI.Label(myRect, "float slide=" + floatSlider);


        // place the int slider
        myRect.x      = (Screen.width) - 510;
        myRect.y      = (Screen.height / 2) + 120;
        myRect.width  = 30;
        myRect.height = 150;
        intSlider     = NIGUI.VerticalSlider(myRect, intSlider, -10.0f, 10.0f);


        // place the int slider label
        myRect.x      = (Screen.width) - 490;
        myRect.y      = (Screen.height / 2) + 180;
        myRect.width  = 350;
        myRect.height = 30;
        GUI.Label(myRect, "int slide=" + Mathf.RoundToInt(intSlider));


        // update the GUI changed frame
        if (NIGUI.changed)
        {
            guiFrameCahngedMessage = "GUI changed at frame=" + Time.frameCount;
        }
    }
    /// mono-behavior OnGUI to show GUI elements
    public void OnGUI()
    {
        // create a regular label
        myRect.x      = (Screen.width / 2) - 40;
        myRect.y      = 20;
        myRect.width  = 80;
        myRect.height = 30;
        GUI.Label(myRect, "Example GUI");
        // place the first button

        myRect.x      = 200;
        myRect.y      = 50;
        myRect.width  = 80;
        myRect.height = 40;
        if (NIGUI.Button(myRect, "Button1"))
        {
            lastMessage = "Button 1 was pressed at time=" + Time.time;
        }

        myRect.x = 500;
        myRect.y = 50;
        if (NIGUI.Button(myRect, "Button2"))
        {
            lastMessage = "Button 2 was pressed at time=" + Time.time;
        }


        myRect.x = 700;
        myRect.y = 50;
        if (NIGUI.RepeatButton(myRect, "Repeat"))
        {
            lastMessage = "Repeat button was pressed at time=" + Time.time;
        }

        myRect.x     = 500;
        myRect.y     = 125;
        myRect.width = 250;
        m_toggle1    = NIGUI.Toggle(myRect, m_toggle1, "Toggle example");

        myRect.x      = 200;
        myRect.y      = (Screen.height / 2) - 15;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, lastMessage);

        myRect.x      = 200;
        myRect.y      = (Screen.height / 2) + 40;
        myRect.width  = 250;
        myRect.height = 30;
        if (Time.time > 10)
        {
            GUI.Box(myRect, "value=" + m_input.GetAxis("NIGUI_CLICK"));
        }


        myRect.x      = 200;
        myRect.y      = (Screen.height / 2) + 80;
        myRect.width  = 350;
        myRect.height = 30;
        toolbarInt    = NIGUI.Toolbar(myRect, toolbarInt, toolbarStrings);

        myRect.x         = 200;
        myRect.y         = (Screen.height / 2) + 120;
        myRect.width     = 350;
        myRect.height    = 90;
        selectionGridInt = NIGUI.SelectionGrid(myRect, selectionGridInt, toolbarStrings, 2);

        myRect.x      = 700;
        myRect.y      = 200;
        myRect.width  = 400;
        myRect.height = 20;

        hScroll       = NIGUI.HorizontalScrollbar(myRect, hScroll, 0.0f, 0.0f, 300.0f);
        myRect.x      = 200;
        myRect.y      = (Screen.height / 2) - 50;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, "hScroll=" + hScroll);

        myRect.x      = 680;
        myRect.y      = 215;
        myRect.width  = 10;
        myRect.height = 200;
        vScroll       = NIGUI.VerticalScrollbar(myRect, vScroll, 40.0f, 0.0f, 140.0f);
        myRect.x      = 200;
        myRect.y      = (Screen.height / 2) - 90;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, "vScroll=" + vScroll);


        myRect.x      = 700;
        myRect.y      = 215;
        myRect.width  = 400;
        myRect.height = 200;
        NIGUI.BeginGroup(myRect);
        myRect.x = 0;
        myRect.y = 0;
        Color c           = GUI.backgroundColor;
        Color almostClear = c;

        almostClear.a       = 0.2f;
        GUI.backgroundColor = almostClear;
        GUI.Box(myRect, "");
        GUI.backgroundColor = c;
        if (NIGUI.Button(new Rect(150 - hScroll, 50 - vScroll, 300, 200), "a button to be clipped by the view"))
        {
            lastMessage = "Internal button to group was pressed";
        }
        NIGUI.EndGroup();



        myRect.x      = 700;
        myRect.y      = (Screen.height / 2) + 80;
        myRect.width  = 350;
        myRect.height = 30;
        GUI.Label(myRect, "float slide=" + floatSlider);
        myRect.x      = 700;
        myRect.y      = (Screen.height / 2) + 110;
        myRect.width  = 350;
        myRect.height = 30;
        floatSlider   = NIGUI.HorizontalSlider(myRect, floatSlider, -5.0f, 5.0f);


        myRect.x      = 750;
        myRect.y      = (Screen.height / 2) + 120;
        myRect.width  = 350;
        myRect.height = 30;
        GUI.Label(myRect, "int slide=" + Mathf.RoundToInt(intSlider));
        myRect.x      = 700;
        myRect.y      = (Screen.height / 2) + 110;
        myRect.width  = 30;
        myRect.height = 150;
        intSlider     = NIGUI.VerticalSlider(myRect, intSlider, -10.0f, 10.0f);
        if (NIGUI.changed)
        {
            lastMessage2 = "GUI changed at frame=" + Time.frameCount;
        }

        myRect.x      = 200;
        myRect.y      = (Screen.height / 2) - 130;
        myRect.width  = 250;
        myRect.height = 30;
        GUI.Box(myRect, lastMessage2);
    }