public override void draw(float w, float h) { // TODO: Update outside of draw. // TODO: Incorporate deltaTime. // TODO: Make smooth deltaTime variables. float headerFrac = .3f, menuFrac = 1 - headerFrac; GUIX.beginClip(new Rect(0, h * headerFrac, w, h * menuFrac)); menu.draw(w, h * menuFrac); GUIX.endClip(); // Draw BG. Rect bgRect = new Rect(0, 0, w, h * headerFrac); GUIX.beginClip(bgRect); GUIX.beginColor(Color.white); TextureUtility.drawTexture(bgRect, bg, AspectType.CROP_IN_REGION); GUIX.endColor(); GUIX.endClip(); // Draw logo. float aspect = TextureUtility.getAspectRatio(logo); float logoW = w / 3, logoH = logoW / aspect; Rect logoRegion = new Rect(w - logoW, 0, logoW, logoH); logoRegion = TextureUtility.drawTexture(logoRegion, logo, AspectType.FIT_IN_REGION); if (GUIX.didTapInsideRect(logoRegion)) { onClick(); Application.OpenURL("https://www.iusb.edu/civil-rights/"); } drawTouchRing(logoRegion); }
public static Rect drawTexture(Rect drawRect, Texture2D texture, Color color, AspectType aspectType) { GUIX.beginColor(color); Rect useRect = drawTexture(drawRect, texture, aspectType); GUIX.endColor(); return(useRect); }
public static Rect drawTexture(Rect drawRect, Reference <Texture2D> textureReference, Color color, AspectType aspectType, float angle) { GUIX.beginColor(color); Rect useRect = drawTexture(drawRect, textureReference, aspectType, angle); GUIX.endColor(); return(useRect); }
public override bool draw(float w, float h) { bool output = base.draw(w, h); if (tex.isLoaded()) { GUIX.beginColor(Color.white); GUIX.drawTexture(new Rect(0, 0, w / 4, w / 4), tex.getResource()); GUIX.endColor(); } return(output); }
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(); }