Created
December 18, 2015 11:53
-
-
Save WizzardMaker/93be086fcbf333ab93ef to your computer and use it in GitHub Desktop.
This script adds a border to the top or the side, this scripts needs CameraSize.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
namespace StandardAssets{ | |
/// <summary> | |
/// Adds a border to the top or the side. | |
/// Add this one to the child camera! | |
/// </summary> | |
[ExecuteInEditMode] | |
public class CameraBorder : MonoBehaviour { | |
/// <summary> | |
/// The border Texture (a 1x1 black dot is enough) | |
/// </summary> | |
public Texture border; | |
void OnGUI() { | |
//Ensure were on the top | |
GUI.depth = 10; | |
//Not needed, but to be sure | |
GUI.color = Color.black; | |
if (!CameraSize.letterbox) { | |
GUI.DrawTexture(new Rect(0, 0, Camera.main.pixelRect.x, GetComponent<Camera>().pixelRect.height), border); | |
GUI.DrawTexture(new Rect(Camera.main.pixelRect.width + Camera.main.pixelRect.x, 0, GetComponent<Camera>().pixelRect.width - Camera.main.pixelRect.width, GetComponent<Camera>().pixelRect.height), border); | |
} else { | |
GUI.DrawTexture(new Rect(0, 0, Camera.main.pixelRect.width,Camera.main.pixelRect.y), border); | |
GUI.DrawTexture(new Rect(0,Maths.PixelToRect(Camera.main.pixelRect.y), Camera.main.pixelRect.width, Camera.main.pixelRect.y), border); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment