コード例 #1
0
ファイル: OnScreenLog.cs プロジェクト: ryanmcgrail95/CRHC
    public void OnGUI()
    {
        GUIStyle   s = new GUIStyle();
        GUIContent c = new GUIContent();

        s.fixedHeight = 0;
        s.clipping    = TextClipping.Clip;
        s.wordWrap    = true;

        float y = 0, w = Screen.width, h, lh = 8;
        Rect  r = new Rect(0, 0, 0, 0), rb = new Rect(0, 0, 0, 0);

        foreach (string str in log)
        {
            GUIX.beginOpacity(.5f);
            c.text = str;
            h      = s.CalcHeight(c, w);
            h     += lh;

            r.Set(0, y, w, h);
            rb.Set(0, y, w, h - lh);

            GUIX.fillRect(rb, Color.black);
            GUI.Label(r, c);

            y += h - lh;
            GUIX.endOpacity();
        }
    }
コード例 #2
0
ファイル: Landmark.cs プロジェクト: ryanmcgrail95/CRHC
        public override bool draw(float w, float h)
        {
            bool  output = base.draw(w, h);
            float arrowW = CrhcConstants.SIZE_BACK_BUTTON.getAs(NumberType.PIXELS);
            float angle  = 180;

            //Vector2 pivot = ServiceLocator.getITouch().getTouchPosition(); // new Vector2(PADDING + arrowW / 2, AppRunner.getScreenWidth()-PADDING + arrowW / 2);
            Rect region = new Rect(PADDING, PADDING, arrowW, arrowW);

            int   count = (int)Math.Round(w / arrowW / 2);
            float sw    = (w - PADDING * 2) / count;

            for (int i = 0; i < count; i++)
            {
                float f = i / (count - 1f), o = (float)Math.Pow(1f / (i + 1), 1.2);
                Rect  subRegion = new Rect(region.x + sw * i + f * (sw - arrowW), region.y, region.width, region.height);

                GUIX.beginOpacity(o);
                TextureUtility.drawTexture(subRegion, arrowTexture, CrhcConstants.COLOR_GRAY_DARK, AspectType.FIT_IN_REGION, angle);
                GUIX.endOpacity();
            }

            drawTouchRing(new Rect(0, 0, w, h));

            return(output);
        }
コード例 #3
0
    public override void draw(float w, float h)
    {
        menu.draw(w, h);

        if (CrhcSettings.showAnimations && fadeAmount.get() < 1)
        {
            GUIX.beginOpacity(1 - fadeAmount.get());
            GUIX.fillRect(new Rect(0, 0, w, h), Color.black);
            GUIX.endOpacity();
        }
    }
コード例 #4
0
    public override void draw(float w, float h)
    {
        // TODO: Update outside of draw.
        // TODO: Incorporate deltaTime.
        // TODO: Make smooth deltaTime variables.

        //float fadeDis = menu.getHeight(w);
        fadeDis = w;

        float fadeAmount = this.fadeAmount.get();

        GUIX.fillRect(new Rect(0, 0, w, h), color);

        if (CrhcSettings.showAnimations)
        {
            GUIX.beginOpacity(fadeAmount);
        }

        /*float fadeY, menuH;
         * fadeY = -fadeDis * (1 - fadeInAmount);
         * menuH = h - fadeY;
         * Rect menuRect = new Rect(0, fadeY, w, menuH);*/
        float fadeX = 0, menuH;

        menuH = h;

        Rect menuRect;

        if (CrhcSettings.showAnimations)
        {
            if (!hasEntered || isClosing)
            {
                fadeX = fadeDis * (1 - fadeAmount);
            }
            else
            {
                fadeX = -fadeDis * (1 - fadeAmount);
            }
        }
        menuRect = new Rect(fadeX, 0, w, menuH);

        GUIX.beginClip(menuRect);
        menu.draw(w, menuH);
        GUIX.endClip();

        if (CrhcSettings.showAnimations)
        {
            GUIX.endOpacity();
        }
    }
コード例 #5
0
        public static Rect drawTexture(Rect drawRect, Reference <Texture2D> textureReference, AspectType aspectType, float angle)
        {
            if (textureReference.isLoaded())
            {
                return(drawTexture(drawRect, textureReference.getResource(), aspectType, angle));
            }
            else
            {
                Rect useRect = getUseRect(drawRect, textureReference.getResource(), aspectType);

                GUIX.beginOpacity(.5f);
                GUIX.strokeRect(useRect, 1);
                GUIX.fillRect(new Rect(useRect.x, useRect.y, useRect.width * textureReference.getLoadFraction(), useRect.height));
                GUIX.endOpacity();

                return(useRect);
            }
        }
コード例 #6
0
ファイル: TouchRing.cs プロジェクト: ryanmcgrail95/CRHC
    public void draw()
    {
        if (!CrhcSettings.showAnimations || number.isDone())
        {
            return;
        }

        number.update();

        float f = number.get(), s = CrhcConstants.SIZE_TOUCH_RING.getAs(general.number.NumberType.PIXELS) * f, b = 10000;

        GUIX.beginOpacity(1 - f);
        GUIX.drawTexture(new Rect(x - s / 2, y - s / 2, s, s), tex.getResource());
        GUIX.endOpacity();
        GUIX.beginOpacity(f * (1 - f));
        GUIX.fillRect(new Rect(-b / 2, -b / 2, b, b), Color.white);
        GUIX.endOpacity();
    }
コード例 #7
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();
    }
コード例 #8
0
    public override void draw(float w, float h)
    {
        // TODO: Pass w/h in via draw, or constructor??
        // might not work right?

        Rect clipRect = GUIX.getClipRect();

        h = Math.Min(h, clipRect.height);

        float menuH = menu.getPixelHeight(w), scrollY;
        float heightDiff = menuH - h;

        ITouch iTouch = ServiceLocator.getITouch();

        GUIX.fillRect(new Rect(0, 0, w, h), color);

        if (heightDiff > 0)
        {
            // Scroll menu.
            if (!float.IsInfinity(prevHeightDiff))
            {
                if (heightDiff != prevHeightDiff)
                {
                    scrollFrac = -prevScrollY / heightDiff;
                }
            }

            scrollFrac = Math.Max(0, Math.Min(scrollFrac, 1));
            scrollY    = -scrollFrac * heightDiff;
        }
        else
        {
            scrollY = 0;
        }

        prevHeightDiff = heightDiff;
        prevScrollY    = scrollY;

        Vector2 scrollPosition = new Vector2(0, scrollY);

        GUIX.beginClip(new Rect(0, 0, w, h), scrollPosition);
        menu.draw(w, h);
        GUIX.endClip();

        // Draw scrollbar.
        if (heightDiff > 0)
        {
            float PADDING = 8, scrollBarWidth = CrhcConstants.PADDING_H.getAs(general.number.NumberType.PIXELS) - PADDING * 2;
            float scrollRegion    = h - 4 * PADDING - 2 * scrollBarWidth;
            float scrollBarHeight = h / menuH * scrollRegion;

            if (CrhcSettings.showScrollbar)
            {
                GUIX.beginClip(new Rect(w - PADDING - scrollBarWidth, 0, scrollBarWidth, h));

                GUIX.beginOpacity(.5f);
                TextureUtility.drawTexture(new Rect(0, PADDING, scrollBarWidth, scrollBarWidth), arrowTexture, AspectType.FIT_IN_REGION, 90);

                float hh = scrollRegion - scrollBarHeight;
                GUIX.fillRect(new Rect(0, 2 * PADDING + scrollBarWidth + hh * scrollFrac, scrollBarWidth, scrollBarHeight));
                TextureUtility.drawTexture(new Rect(0, h - PADDING - scrollBarWidth, scrollBarWidth, scrollBarWidth), arrowTexture, AspectType.FIT_IN_REGION, -90);
                GUIX.endOpacity();
                GUIX.endClip();
            }

            scrollFrac -= (iTouch.getDragVector().y / heightDiff);
        }
    }