예제 #1
0
    public void OnGUI()
    {
        // TODO: REMOVE ME
        ServiceLocator.getITouch().OnGUI();

        float scrW, scrH;

        scrW = getScreenWidth();
        scrH = getScreenHeight();

        if (menuStack.Count > 0)
        {
            IMenu menu = menuStack.Peek();

            if (menu != null)
            {
                if (_enterMenu)
                {
                    if (menu.exit(false))
                    {
                        instance.menuStack.Push(nextMenu);
                        _enterMenu = false;
                    }
                }
                else if (_exitMenu)
                {
                    if (menu.exit(true))
                    {
                        menu.Dispose();
                        menuStack.Pop();

                        menu      = menuStack.Peek();
                        _exitMenu = false;
                    }
                }
                else
                {
                    menu.enter();
                }

                float   angle = 0, xOffset = 0, yOffset = 0;
                Vector2 pivot = Vector2.zero;

                if (orientation == Orientation.PORTRAIT_DOWN)
                {
                    angle   = 180;
                    xOffset = -scrW;
                    yOffset = -scrH;
                }
                else if (orientation == Orientation.LANDSCAPE_LEFT)
                {
                    angle   = 90;
                    yOffset = -scrH;
                }
                else if (orientation == Orientation.LANDSCAPE_RIGHT)
                {
                    angle   = 270;
                    xOffset = -scrW;
                }

                GUIX.clear(menu.getColor());

                GUIX.beginRotate(pivot, angle);
                GUI.BeginClip(new Rect(xOffset, yOffset, scrW, scrH));
                menu.draw(scrW, scrH);
                GUI.EndClip();
                GUIX.endRotate();
            }
            manager.OnGUI();
        }

        Rect topBar = new Rect(0, 0, Screen.width, 20);

        if (CrhcSettings.debugShowTouchPosition)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);

            Vector2 pos = ServiceLocator.getITouch().getTouchPosition();
            int     x, y;
            x = (int)pos.x;
            y = (int)pos.y;

            GUI.Label(topBar, "Touch Position: (" + x + ", " + y + ") / (" + (int)(100f * x / scrW) + " %, " + (int)(100f * y / scrH) + " %)");
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowMemory)
        {
            long allocMemory = Profiler.GetTotalAllocatedMemory(), totalMemory = Profiler.GetTotalReservedMemory();
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Memory: " + (allocMemory / (Math.Pow(10, 6))) + "/" + (totalMemory / (Math.Pow(10, 6))) + " MB");
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowFps)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "FPS: " + m_lastFramerate);
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowMenuElementCount)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Menu Element Count: " + IMenuThing.menuElementCount);
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowReferenceCount)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Reference Count: " + ServiceLocator.getILoader().getReferenceCount());
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowGuixStackCounts)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Clip Stack Count: " + GUIX.getClipStackSize());
            topBar.y += 20;
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Local Clip Stack Count: " + GUIX.getLocalClipStackSize());
            topBar.y += 20;
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Color Stack Count: " + GUIX.getColorStackSize());
            topBar.y += 20;
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Action List Count: " + GUIX.getActionListSize());
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowFileManagerStackCount)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Directory Stack Count: " + ServiceLocator.getIFileManager().getDirectoryStackSize());
            topBar.y += 20;
        }

        ILog log = ServiceLocator.getILog();

        if (doDrawLog && log is OnScreenLog)
        {
            (log as OnScreenLog).OnGUI();
        }
    }
예제 #2
0
    public void OnGUI()
    {
        if (!VuforiaBehaviour.Instance.enabled)
        {
            return;
        }

        if (exp == null)
        {
            return;
        }

        Reference <Texture2D> img, overlay, outline;

        img     = exp.getImg();
        overlay = exp.getOverlay();
        outline = exp.getOutline();

        if (!img.isLoaded())
        {
            return;
        }

        Texture2D imgTex = img.getResource();

        float scrW = AppRunner.getScreenWidth(), scrH = AppRunner.getScreenHeight(), angle = 0, xOffset = 0, yOffset = 0;
        float s = CrhcConstants.SIZE_VUFORIA_FRAME.getAs(NumberType.PIXELS), p = 30;

        Orientation orientation = AppRunner.getOrientation();

        if (orientation == Orientation.PORTRAIT_DOWN)
        {
            angle   = 180;
            xOffset = -scrW;
            yOffset = -scrH;
        }
        else if (orientation == Orientation.LANDSCAPE_LEFT)
        {
            angle   = 90;
            yOffset = -scrH;
        }
        else if (orientation == Orientation.LANDSCAPE_RIGHT)
        {
            angle   = 270;
            xOffset = -scrW;
        }


        Rect region             = TextureUtility.getUseRect(new Rect(xOffset + scrW - s - p, yOffset + p, s, s), imgTex, AspectType.FIT_IN_REGION);

        if (didMatch)
        {
            frameAlpha += (0 - frameAlpha) / 10;
        }

        alphaAngle += .5f * Time.deltaTime;

        float a = .5f + .5f * Mathf.Sin(alphaAngle);

        Vector2 pivot = Vector2.zero;

        GUIX.beginRotate(pivot, angle);

        GUIX.beginOpacity(frameAlpha);

        if (img != null)
        {
            if (img.isLoaded())
            {
                GUIX.beginColor(Color.white);
                GUIX.drawTexture(region, img.getResource());
                GUIX.endColor();
            }
        }

        GUIX.beginOpacity(a);

        GUIX.beginOpacity(.75f);
        GUIX.fillRect(region, Color.black);
        GUIX.endOpacity();

        if (outline != null)
        {
            if (outline.isLoaded())
            {
                GUIX.beginColor(Color.white);
                GUIX.drawTexture(region, outline.getResource());
                GUIX.endColor();
            }
        }
        GUIX.endOpacity();

        GUIX.beginOpacity(1 - a);
        if (overlay != null)
        {
            if (overlay.isLoaded())
            {
                Texture2D tex = overlay.getResource();
                GUIX.drawTexture(region, tex);

                if (overlayPlane != null)
                {
                    MeshRenderer renderer = overlayPlane.GetComponent <MeshRenderer>();
                    renderer.material.shader      = shader;
                    renderer.material.mainTexture = tex;

                    float tw = tex.width, th = tex.height, f = tw / th, nf = th / tw;
                    float ss = .1f;
                    float xv = -ss, yv = ss, zv = -ss;

                    zv *= nf;

                    overlayPlane.transform.localScale = new Vector3(xv, yv, zv);
                }
            }
        }
        GUIX.endOpacity();

        GUIStyle style = new GUIStyle();

        GUIX.strokeRect(region, Color.white, 3);
        GUIX.endOpacity();

        if (!isMatching)
        {
            //TODO: Draw on screen too.
            GUIX.beginColor(Color.white);
            TextureUtility.drawTexture(new Rect(xOffset, yOffset, scrW, scrH), outline, AspectType.FIT_IN_REGION);
            GUIX.endColor();
        }

        if (debugMessage != null && debugMessage != "")
        {
            float x, y, w, h;
            w = scrW;
            h = 20;
            x = xOffset;
            y = yOffset + scrH - h;

            GUIX.fillRect(new Rect(x, y, w, h), Color.black);
            GUI.Label(new Rect(x, y, w, h), debugMessage);
        }

        GUIX.endRotate();
    }