当前位置: 首页 > news >正文

网站建设职员seo赚钱项目

网站建设职员,seo赚钱项目,建站软件2017,安阳县政府网前言: 由于最近在做游戏魔改,很多功能在游戏里面没法实现(没错,说的就是排行榜),所以准备用Unity3D开发一个类似于桌面精灵的功能部件,实现效果如下: PS:有需要定制的老…

前言:

由于最近在做游戏魔改,很多功能在游戏里面没法实现(没错,说的就是排行榜),所以准备用Unity3D开发一个类似于桌面精灵的功能部件,实现效果如下:

PS:有需要定制的老板请私信联系

要实现这个效果,需要分两步:

1,背景透明

2,程序始终在前面

一,背景透明实现核心代码

using System;
using System.Runtime.InteropServices;
using UnityEngine;public class TransparentWindow : MonoBehaviour
{[SerializeField]private Material m_Material;private struct MARGINS{public int cxLeftWidth;public int cxRightWidth;public int cyTopHeight;public int cyBottomHeight;}// Define function signatures to import from Windows APIs[DllImport("user32.dll")]private static extern IntPtr GetActiveWindow();[DllImport("user32.dll")]private static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);[DllImport("Dwmapi.dll")]private static extern uint DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS margins);// Definitions of window stylesconst int GWL_STYLE = -16;const uint WS_POPUP = 0x80000000;const uint WS_VISIBLE = 0x10000000;void Start(){//return;
#if !UNITY_EDITORvar margins = new MARGINS() { cxLeftWidth = -1 };// Get a handle to the windowvar hwnd = GetActiveWindow();// Set properties of the window// See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspxSetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);// Extend the window into the client area//See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa969512%28v=vs.85%29.aspx DwmExtendFrameIntoClientArea(hwnd, ref margins);
#endif}// Pass the output of the camera to the custom material// for chroma replacementvoid OnRenderImage(RenderTexture from, RenderTexture to){Graphics.Blit(from, to, m_Material);}}

shader代码如下:

Shader "Custom/ChromakeyTransparent" {Properties{_MainTex("Base (RGB)", 2D) = "white" {}_TransparentColourKey("Transparent Colour Key", Color) = (0,0,0,1)_TransparencyTolerance("Transparency Tolerance", Float) = 0.01}SubShader{Pass{Tags{ "RenderType" = "Opaque" }LOD 200CGPROGRAM#pragma vertex vert#pragma fragment frag#include "UnityCG.cginc"struct a2v{float4 pos : POSITION;float2 uv : TEXCOORD0;};struct v2f{float4 pos : SV_POSITION;float2 uv : TEXCOORD0;};v2f vert(a2v input){v2f output;output.pos = UnityObjectToClipPos(input.pos);output.uv = input.uv;return output;}sampler2D _MainTex;float3 _TransparentColourKey;float _TransparencyTolerance;float4 frag(v2f input) : SV_Target{// What is the colour that *would* be rendered here?float4 colour = tex2D(_MainTex, input.uv);// Calculate the different in each component from the chosen transparency colourfloat deltaR = abs(colour.r - _TransparentColourKey.r);float deltaG = abs(colour.g - _TransparentColourKey.g);float deltaB = abs(colour.b - _TransparentColourKey.b);// If colour is within tolerance, write a transparent pixelif (deltaR < _TransparencyTolerance && deltaG < _TransparencyTolerance && deltaB < _TransparencyTolerance){return float4(0.0f, 0.0f, 0.0f, 0.0f);}// Otherwise, return the regular colourreturn colour;}ENDCG}}
}

将脚本绑定在摄像机上,并用该shader创建材质A,放到脚本下。

摄像机渲染模式改为只渲染颜色,颜色和材质A一样。

二,程序始终在前面核心代码

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;public class C
{public delegate bool WNDENUMPROC(IntPtr hwnd, uint lParam);[DllImport("user32.dll", SetLastError = true)]public static extern bool EnumWindows(WNDENUMPROC lpEnumFunc, uint lParam);[DllImport("user32.dll", SetLastError = true)]public static extern IntPtr GetParent(IntPtr hWnd);[DllImport("user32.dll")]public static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref uint lpdwProcessId);[DllImport("kernel32.dll")]public static extern void SetLastError(uint dwErrCode);public static IntPtr GetProcessWnd(){IntPtr ptrWnd = IntPtr.Zero;uint pid = (uint)Process.GetCurrentProcess().Id;  // 当前进程 ID  bool bResult = EnumWindows(new WNDENUMPROC(delegate (IntPtr hwnd, uint lParam){uint id = 0;if (GetParent(hwnd) == IntPtr.Zero){GetWindowThreadProcessId(hwnd, ref id);if (id == lParam)    // 找到进程对应的主窗口句柄  {ptrWnd = hwnd;   // 把句柄缓存起来  SetLastError(0);    // 设置无错误  return false;   // 返回 false 以终止枚举窗口  }}return true;}), pid);return (!bResult && Marshal.GetLastWin32Error() == 0) ? ptrWnd : IntPtr.Zero;}
}
  [DllImport("User32.dll")]extern static bool SetForegroundWindow(IntPtr hWnd);[DllImport("User32.dll")]extern static bool ShowWindow(IntPtr hWnd, short State);[DllImport("user32.dll ")]public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);const UInt32 SWP_NOSIZE = 0x0001;const UInt32 SWP_NOMOVE = 0x0002;IntPtr hWnd;//public float Wait = 0;//延迟执行//public float Rate = 1;//更新频率public bool KeepForeground = true;//保持最前/// <summary>/// 激活窗口/// </summary>void Active(){if (KeepForeground){ShowWindow(hWnd, 1);SetForegroundWindow(hWnd);SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);}}
  hWnd = C.GetProcessWnd();Active();

三,打包设置如下

四,优化扩展

步骤和道理同上

using System;
using System.Runtime.InteropServices;
using UnityEngine;public class TransparentWindow : MonoBehaviour
{[SerializeField] private Material m_Material;private struct MARGINS{public int cxLeftWidth;public int cxRightWidth;public int cyTopHeight;public int cyBottomHeight;}[DllImport("user32.dll")]private static extern IntPtr GetActiveWindow();[DllImport("user32.dll")]private static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);[DllImport("Dwmapi.dll")]private static extern uint DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS margins);[DllImport("user32.dll", EntryPoint = "SetWindowPos")]private static extern int SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int cx, int cy,int uFlags);[DllImport("user32.dll")]static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);[DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")]static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, int dwFlags);[DllImport("User32.dll")]private static extern bool SetForegroundWindow(IntPtr hWnd);const int GWL_STYLE = -16;const int GWL_EXSTYLE = -20;const uint WS_POPUP = 0x80000000;const uint WS_VISIBLE = 0x10000000;const uint WS_EX_TOPMOST = 0x00000008;const uint WS_EX_LAYERED = 0x00080000;const uint WS_EX_TRANSPARENT = 0x00000020;const int SWP_FRAMECHANGED = 0x0020;const int SWP_SHOWWINDOW = 0x0040;const int LWA_ALPHA = 2;private IntPtr HWND_TOPMOST = new IntPtr(-1);private IntPtr _hwnd;void Start(){
//#if !UNITY_EDITORMARGINS margins = new MARGINS() { cxLeftWidth = -1 };_hwnd = GetActiveWindow();int fWidth = Screen.width;int fHeight = Screen.height;SetWindowLong(_hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);SetWindowLong(_hwnd, GWL_EXSTYLE, WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TRANSPARENT);//若想鼠标穿透,则将这个注释恢复即可DwmExtendFrameIntoClientArea(_hwnd, ref margins);SetWindowPos(_hwnd, HWND_TOPMOST, 0, 0, fWidth, fHeight, SWP_FRAMECHANGED | SWP_SHOWWINDOW); ShowWindowAsync(_hwnd, 3); //Forces window to show in case of unresponsive app    // SW_SHOWMAXIMIZED(3)
//#endif}void OnRenderImage(RenderTexture from, RenderTexture to){Graphics.Blit(from, to, m_Material);}
}
Shader "Custom/MakeTransparent" {Properties {_MainTex ("Base (RGB)", 2D) = "white" {}_TransparentColorKey ("Transparent Color Key", Color) = (0,1,0,1)_TransparencyMargin ("Transparency Margin", Float) = 0.01 }SubShader {Pass {Tags { "RenderType"="Opaque" }LOD 200CGPROGRAM#pragma vertex VertexShaderFunction#pragma fragment PixelShaderFunction#include "UnityCG.cginc"struct VertexData{float4 position : POSITION;float2 uv : TEXCOORD0;};struct VertexToPixelData{float4 position : SV_POSITION;float2 uv : TEXCOORD0;};VertexToPixelData VertexShaderFunction(VertexData input){VertexToPixelData output;output.position = UnityObjectToClipPos (input.position);output.uv = input.uv;return output;}sampler2D _MainTex;float3 _TransparentColorKey;float _TransparencyMargin;float4 PixelShaderFunction(VertexToPixelData input) : SV_Target{float4 color = tex2D(_MainTex, input.uv);float deltaR = abs(color.r - _TransparentColorKey.r);float deltaG = abs(color.g - _TransparentColorKey.g);float deltaB = abs(color.b - _TransparentColorKey.b);if (deltaR < _TransparencyMargin && deltaG < _TransparencyMargin && deltaB < _TransparencyMargin){return float4(0.0f, 0.0f, 0.0f, 0.0f);}return color;}ENDCG}}
}


文章转载自:
http://damnatory.nLkm.cn
http://angling.nLkm.cn
http://responder.nLkm.cn
http://rugger.nLkm.cn
http://disconformity.nLkm.cn
http://caressing.nLkm.cn
http://acoustoelectric.nLkm.cn
http://microvessel.nLkm.cn
http://sowbug.nLkm.cn
http://housebreak.nLkm.cn
http://gerentocratic.nLkm.cn
http://railroad.nLkm.cn
http://lameness.nLkm.cn
http://neurasthenic.nLkm.cn
http://ascolichen.nLkm.cn
http://assegai.nLkm.cn
http://whimsy.nLkm.cn
http://purpuric.nLkm.cn
http://roboticized.nLkm.cn
http://pathogenesis.nLkm.cn
http://ziff.nLkm.cn
http://abasable.nLkm.cn
http://mercurialism.nLkm.cn
http://unadvisable.nLkm.cn
http://climber.nLkm.cn
http://characterless.nLkm.cn
http://safebreaking.nLkm.cn
http://suffocating.nLkm.cn
http://translatability.nLkm.cn
http://ecdysterone.nLkm.cn
http://emaciate.nLkm.cn
http://leucovorin.nLkm.cn
http://underprepared.nLkm.cn
http://reinaugurate.nLkm.cn
http://mainframe.nLkm.cn
http://nickeline.nLkm.cn
http://gdmo.nLkm.cn
http://opaque.nLkm.cn
http://peridiole.nLkm.cn
http://calumniator.nLkm.cn
http://tousle.nLkm.cn
http://appointee.nLkm.cn
http://megaversity.nLkm.cn
http://thermogram.nLkm.cn
http://copemate.nLkm.cn
http://booklearned.nLkm.cn
http://pigpen.nLkm.cn
http://alienator.nLkm.cn
http://parishioner.nLkm.cn
http://dizzying.nLkm.cn
http://hectogram.nLkm.cn
http://allometric.nLkm.cn
http://velvet.nLkm.cn
http://connect.nLkm.cn
http://holoparasite.nLkm.cn
http://traveling.nLkm.cn
http://desmosine.nLkm.cn
http://aeromap.nLkm.cn
http://latinesque.nLkm.cn
http://acquirable.nLkm.cn
http://narcotine.nLkm.cn
http://saint.nLkm.cn
http://inadequate.nLkm.cn
http://dashing.nLkm.cn
http://beforetime.nLkm.cn
http://monophagia.nLkm.cn
http://electrocardiogram.nLkm.cn
http://viny.nLkm.cn
http://acoustician.nLkm.cn
http://memsahib.nLkm.cn
http://fiscality.nLkm.cn
http://mapai.nLkm.cn
http://diatonic.nLkm.cn
http://circuitous.nLkm.cn
http://putrescible.nLkm.cn
http://unsoiled.nLkm.cn
http://impluvium.nLkm.cn
http://kiwanian.nLkm.cn
http://corrie.nLkm.cn
http://condensable.nLkm.cn
http://anthracitic.nLkm.cn
http://moorstone.nLkm.cn
http://backslap.nLkm.cn
http://biforked.nLkm.cn
http://upclimb.nLkm.cn
http://devilry.nLkm.cn
http://intent.nLkm.cn
http://bellywhop.nLkm.cn
http://disqualify.nLkm.cn
http://cdp.nLkm.cn
http://angulate.nLkm.cn
http://turnout.nLkm.cn
http://dehydrogenation.nLkm.cn
http://saliva.nLkm.cn
http://mithridatic.nLkm.cn
http://replicate.nLkm.cn
http://diplegic.nLkm.cn
http://diligent.nLkm.cn
http://phantom.nLkm.cn
http://jn.nLkm.cn
http://www.hrbkazy.com/news/76316.html

相关文章:

  • 网站怎么做定时任务百度推广的方式有哪些
  • 做的网站 v2ex品牌推广策略
  • wordpress设置爬虫页面深圳排名seo公司
  • 中国住房和城乡建设部招标网站拼多多网店代运营要多少费用
  • 北京网页设计与制作公司网站首页seo关键词布局
  • 网站建设官网网站seo怎么做
  • fizz wordpress长春网络优化哪个公司在做
  • 信用网站建设工作总结营销公司网站
  • 做网站收费吗百度推广的渠道有哪些
  • 外贸网站该怎么做高手优化网站
  • 深圳微商城网站制作联系电话软文经典案例
  • 北京网站托管维护如何让百度快速收录
  • 武汉定制网站建设怎么查找关键词排名
  • 利用对象储存做网站比较好网站制作公司
  • 附近广告设计与制作seo优化工作内容
  • 网站建设开发工具网店推广常用的方法
  • 怎么去找做网站的百度代理加盟
  • 济南房产网新开楼盘seo推广需要多少钱
  • 先备案还是先做网站肇庆网站推广排名
  • 做视频网站把视频放在哪里找网络推广公司十大排名
  • 做阿里妈妈推广需要网站沈阳百度快照优化公司
  • 国外被动收入网站做的好的缅甸新闻最新消息
  • 学院门户网站建设自评郑州网络公司
  • 网站怎么拿百度收入qq推广软件
  • 济南做网站公司电话百度推广有哪些形式
  • dedecms网站后台友链交易
  • 专门做服装批发的网站吗短链接在线生成
  • 企业网站建设亮点汕头seo网站建设
  • 上海阿里巴巴网站建设网站维护一年一般多少钱?
  • 高级网站开发培训天津seo方案