您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

62 行
1.7 KiB

using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
[RequireComponent (typeof(Camera))]
[AddComponentMenu ("Image Effects/Other/Screen Overlay")]
class ScreenOverlay : PostEffectsBase {
internal enum OverlayBlendMode {
Additive = 0,
ScreenBlend = 1,
Multiply = 2,
Overlay = 3,
AlphaBlend = 4,
}
public OverlayBlendMode blendMode = OverlayBlendMode.Overlay;
public float intensity = 1.0f;
public Texture2D texture = null;
public Shader overlayShader = null;
private Material overlayMaterial = null;
public override bool CheckResources (){
CheckSupport (false);
overlayMaterial = CheckShaderAndCreateMaterial (overlayShader, overlayMaterial);
if (!isSupported)
ReportAutoDisable ();
return isSupported;
}
void OnRenderImage ( RenderTexture source , RenderTexture destination ){
if (CheckResources() == false) {
Graphics.Blit (source, destination);
return;
}
Vector4 UV_Transform = new Vector4(1, 0, 0, 1);
#if UNITY_WP8
// WP8 has no OS support for rotating screen with device orientation,
// so we do those transformations ourselves.
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
UV_Transform = new Vector4(0, -1, 1, 0);
}
if (Screen.orientation == ScreenOrientation.LandscapeRight) {
UV_Transform = new Vector4(0, 1, -1, 0);
}
if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) {
UV_Transform = new Vector4(-1, 0, 0, -1);
}
#endif
overlayMaterial.SetVector("_UV_Transform", UV_Transform);
overlayMaterial.SetFloat ("_Intensity", intensity);
overlayMaterial.SetTexture ("_Overlay", texture);
Graphics.Blit (source, destination, overlayMaterial, (int) blendMode);
}
}