首页 > 编程知识 正文

unity 全景图,unity360全景

时间:2023-05-03 12:33:31 阅读:179983 作者:3443

来自http://www.tai dous.com/thread-52133-1-1.html shader ' unlit/pano 360 shader ' { properties } _ maintex (base ) 0.5 )子着色器(tags (render type ) Opaque ) )/thisisusedtoprintthetextureinsideofthespherecullfrontcgprogram # pragmasurfacesurfsimplelamberthalf4lightingsimplelambert (surface outputs,half3 lightDir,half atten ) { half4 c; c.rgb=s.Albedo; 返回c; }sampler2D _MainTex; struct Input{ float2 uv_MainTex; 浮动4 my color : color; (; fixed3 _Color; voidsurf(inputin,inout SurfaceOutput o )//thisisusedtomirrortheimagecorrectlywhenpringitinsideofthespherein.uv _ ) o.Albedo=result.rgb; o .阿尔法=1; }ENDCG}Fallback 'Diffuse'}遮罩Shader [AppleScript]纯文本显示复制代码shader ' image effect/mask icon ' { properties { [ ppplescript } _mask(base(RGB ),2D )='white({}_Color ),color )=(1,1,1 ) ) _stint ) ) )。 Float(8_stencil )、Float (=0_ stencil op )、stenciloperation ()、float (=0_ stencilwritemask )、float ) ) floa float (255 _ stencilreadmask (stencilreadmask ),float () 255 _ colormask (color mask ) color mask ),float () 15 [ toggle (ungle (uned (unctid ) )

"RenderType" = "Transparent" "PreviewType" = "Plane" "CanUseSpriteAtlas" = "True" } Stencil { Ref[_Stencil] Comp[_StencilComp] Pass[_StencilOp] ReadMask[_StencilReadMask] WriteMask[_StencilWriteMask] } Cull Off Lighting Off ZWrite Off ZTest[unity_GUIZTestMode] Blend SrcAlpha OneMinusSrcAlpha ColorMask[_ColorMask] Pass { CGPROGRAM#pragma vertex vert#pragma fragment frag#include "UnityCG.cginc"#include "UnityUI.cginc"#pragma multi_compile __ UNITY_UI_ALPHACLIP struct a2v { fixed2 uv : TEXCOORD0; half4 vertex : POSITION; float4 color : COLOR; }; fixed4 _Color; struct v2f { fixed2 uv : TEXCOORD0; half4 vertex : SV_POSITION; float4 color : COLOR; }; sampler2D _MainTex; sampler2D _Mask; v2f vert(a2v i) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, i.vertex); o.uv = i.uv; o.color = i.color * _Color; return o; } fixed4 frag(v2f i) : COLOR { half4 color = tex2D(_MainTex, i.uv) * i.color; half4 mask = tex2D(_Mask, i.uv); color.a *= mask.a; return color; } ENDCG } }}

C#代码
[AppleScript]  纯文本查看  复制代码 using System.Collections;using System.Collections.Generic;using UnityEngine;public class Pano360 : MonoBehaviour { public Transform container; float turnSpeedMouse=50; /// <summary> /// 第一次按下的位置 /// </summary> private Vector2 first = Vector2.zero; /// <summary> /// 鼠标的拖拽位置(第二次的位置) /// </summary> private Vector2 second = Vector2.zero; /// <summary> /// 旋转的角度 /// </summary> private float angle = 3f; void OnGUI() { if (Event.current.type == EventType.MouseDown) { //记录鼠标按下的位置    first = Event.current.mousePosition; } if (Event.current.type == EventType.MouseDrag) { //记录鼠标拖动的位置    second = Event.current.mousePosition; if (second.x < first.x) { //拖动的位置的x坐标比按下的位置的x坐标小时,响应向左事件    this.transform.Rotate(Vector3.up , angle); container.Rotate(new Vector3(0 , angle * (-1) , 0f) * Time.deltaTime * turnSpeedMouse); transform.Rotate(new Vector3(angle , 0 , 0) * Time.deltaTime * turnSpeedMouse); } if (second.x > first.x) { //拖动的位置的x坐标比按下的位置的x坐标大时,响应向右事件    this.transform.Rotate(Vector3.down , angle); container.Rotate(new Vector3(0 , angle * (1) , 0f) * Time.deltaTime * turnSpeedMouse); transform.Rotate(new Vector3(angle , 0 , 0) * Time.deltaTime * turnSpeedMouse); } first = second; } }}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。