This commit is contained in:
2025-06-24 08:39:12 +08:00
commit 93adf7576f
712 changed files with 17535 additions and 0 deletions
@@ -0,0 +1,71 @@
using System;
using System.Runtime.InteropServices;
using UnityEngine;
public class BackgroundKey : MonoBehaviour
{
#region dll
[DllImport("Dwmapi.dll")]static extern uint DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins margins);
[DllImport("user32.dll")]static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
[DllImport("user32.dll")]public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
private struct Margins{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
#endregion dll
#region Private
private bool active = true;
[SerializeField]private Material _keyMaterial;
#endregion Private
void Start() {
transform.SetAsFirstSibling();
}
public void ActivateTransparency(IntPtr hWnd) {
active = true;
Color32 c =GetComponent<Camera>().backgroundColor;
GetComponent<Camera>().backgroundColor=new Color32(c.r,c.g,c.b,5);
#if !UNITY_EDITOR
var m = new Margins() { Left = -1 };
SetWindowLong(hWnd, -16, 0x80000000 | 0x10000000);
DwmExtendFrameIntoClientArea(hWnd, ref m);
#endif
}
public void DisableTransparency() {
active = false;
Color32 c = GetComponent<Camera>().backgroundColor;
GetComponent<Camera>().backgroundColor = new Color32(c.r, c.g, c.b, 255);
}
void OnRenderImage(RenderTexture a, RenderTexture n)
{
if (active) {
Graphics.Blit(a, n, _keyMaterial);
}
// else {
// Graphics.Blit(a, n);
// }
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c3808b38eeffeff4eb72dbddcad60761
timeCreated: 1459541451
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c6b634a35f2895141a4ef3c7bdb72d4e
timeCreated: 1459541451
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/BackgroundKeyShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_ColorKey ("Color Key", Color) = (0,0,0,1)
_ColorSensitivity ("Color Sensitivity", Float) = 0.6
}
SubShader {
Pass {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma vertex VertexShaderFunction
#pragma fragment FragmentShaderFunction
#include "UnityCG.cginc"
struct VertexData{
float4 position : POSITION;
float2 uvs : TEXCOORD0;
};
struct VertexToFragment {
float4 position : SV_POSITION;
float2 uvs : TEXCOORD0;
};
VertexToFragment VertexShaderFunction(VertexData input) {
VertexToFragment result;
result.position = UnityObjectToClipPos (input.position);
result.uvs = input.uvs;
return result;
}
sampler2D _MainTex;
float3 _ColorKey;
float _ColorSensitivity;
float4 FragmentShaderFunction(VertexToFragment input) : SV_Target {
float4 color = tex2D(_MainTex, input.uvs);
float R = abs(color.r - _ColorKey.r);
float G = abs(color.g - _ColorKey.g);
float B = abs(color.b - _ColorKey.b);
if (R < _ColorSensitivity && G < _ColorSensitivity && B < _ColorSensitivity){
return float4(0.0f, 0.0f, 0.0f, 0.0f);
}
return color;
}
ENDCG
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7bc350edc0d27db4f9c09e07fabc7ac7
timeCreated: 1459541451
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fae392461979ef54e9963845024aa16d
folderAsset: yes
timeCreated: 1460320288
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8dcd8931665df574b8544dad8abceaf0
timeCreated: 1458501145
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9caac2c457b3db44783922b7e523fecb
timeCreated: 1459801098
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour {
void Update () {
transform.Rotate(0,Time.deltaTime * 20,0);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5d9c08aa2495aec41bf701573e6fbe5c
timeCreated: 1459957281
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3b8441fae24f8904cac33031d035959c
timeCreated: 1460658780
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant: