Browse Source

增加Bee3冰冻效果绑定

大爷 1 year ago
parent
commit
f041bd86b3

+ 55 - 9
Assets/Material/texture_main.mat → Assets/Material/Bee3_ice.mat

@@ -7,19 +7,24 @@ Material:
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
-  m_Name: texture_main
-  m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
+  m_Name: Bee3_ice
+  m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
   m_ValidKeywords: []
   m_InvalidKeywords: []
   m_LightmapFlags: 4
   m_EnableInstancingVariants: 0
   m_DoubleSidedGI: 0
   m_CustomRenderQueue: -1
-  stringTagMap: {}
+  stringTagMap:
+    RenderType: Opaque
   disabledShaderPasses: []
   m_SavedProperties:
     serializedVersion: 3
     m_TexEnvs:
+    - _BaseMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
     - _BumpMap:
         m_Texture: {fileID: 0}
         m_Scale: {x: 1, y: 1}
@@ -41,7 +46,7 @@ Material:
         m_Scale: {x: 1, y: 1}
         m_Offset: {x: 0, y: 0}
     - _MainTex:
-        m_Texture: {fileID: 2800000, guid: 6a723410d0cf74d7292e7cda057bebb9, type: 3}
+        m_Texture: {fileID: 0}
         m_Scale: {x: 1, y: 1}
         m_Offset: {x: 0, y: 0}
     - _MetallicGlossMap:
@@ -56,25 +61,66 @@ Material:
         m_Texture: {fileID: 0}
         m_Scale: {x: 1, y: 1}
         m_Offset: {x: 0, y: 0}
+    - _SpecGlossMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - unity_Lightmaps:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - unity_LightmapsInd:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - unity_ShadowMasks:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
     m_Ints: []
     m_Floats:
+    - _AlphaClip: 0
+    - _Blend: 0
     - _BumpScale: 1
+    - _ClearCoatMask: 0
+    - _ClearCoatSmoothness: 0
+    - _Cull: 2
     - _Cutoff: 0.5
+    - _DetailAlbedoMapScale: 1
     - _DetailNormalMapScale: 1
     - _DstBlend: 0
-    - _GlossMapScale: 1
+    - _EnvironmentReflections: 1
+    - _GlossMapScale: 0
     - _Glossiness: 0
-    - _GlossyReflections: 1
+    - _GlossyReflections: 0
     - _Metallic: 0
-    - _Mode: 0
     - _OcclusionStrength: 1
-    - _Parallax: 0.02
+    - _Parallax: 0.005
+    - _QueueOffset: 0
+    - _ReceiveShadows: 1
+    - _Smoothness: 0.5
     - _SmoothnessTextureChannel: 0
     - _SpecularHighlights: 1
     - _SrcBlend: 1
-    - _UVSec: 0
+    - _Surface: 0
+    - _WorkflowMode: 1
     - _ZWrite: 1
     m_Colors:
+    - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
     - _Color: {r: 1, g: 1, b: 1, a: 1}
     - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+    - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
   m_BuildTextureStacks: []
+--- !u!114 &7762963780523591459
+MonoBehaviour:
+  m_ObjectHideFlags: 11
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  version: 5

+ 1 - 1
Assets/Material/texture_main.mat.meta → Assets/Material/Bee3_ice.mat.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: e8c74e546714348a3ba77a865b7b3517
+guid: 268964984a47a4a4792e515bc690a296
 NativeFormatImporter:
   externalObjects: {}
   mainObjectFileID: 2100000

+ 14 - 0
Assets/Prefabs/Unit/Bee3.prefab

@@ -137,6 +137,7 @@ GameObject:
   m_Component:
   - component: {fileID: 7322206709290822141}
   - component: {fileID: 5461480092600792447}
+  - component: {fileID: 4545616464448127319}
   m_Layer: 0
   m_Name: Bee3
   m_TagString: Untagged
@@ -286,6 +287,19 @@ MonoBehaviour:
       _Clip: {fileID: 7400000, guid: 741d8bf4e5e82d245a1dde8701c64f77, type: 3}
       _Speed: 1
       _NormalizedStartTime: NaN
+--- !u!114 &4545616464448127319
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 7059921768780736673}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 00763eba6777c5e41b5a49b5e7acad6c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  IceMaterial: {fileID: 2100000, guid: 268964984a47a4a4792e515bc690a296, type: 2}
 --- !u!1001 &4276469643082368583
 PrefabInstance:
   m_ObjectHideFlags: 0

+ 21 - 3
Assets/Scripts/Codes/Mono/AnimationData.cs

@@ -1,6 +1,8 @@
-using Animancer;
+using ET;
+using Animancer;
 using UnityEngine;
 using System;
+using NLog.Targets.Wrappers;
 
 namespace Mono
 {
@@ -35,6 +37,8 @@ namespace Mono
         private Action aniEndcb;
         private AnimancerState notifyState;
 
+        public bool IsPauseStatus() { return !Animancer.Playable.IsGraphPlaying; }
+
         private void Awake ()
         {
             aniEndcb = null;
@@ -73,7 +77,12 @@ namespace Mono
 
         public void PlayAnimation(AnimationType type, Action endcb = null)
         {
-            //Log.Debug($"{this.gameObject.name} toplay ani:{type}");
+            if (!Animancer.Playable.IsGraphPlaying)
+            {
+                Log.Error( $"play ani({type}) @ froze status" );
+                return;
+            }
+            Log.Debug($"{this.gameObject.name} toplay ani:{type}");
             aniEndcb = endcb;
             var clip = GetClip(type);
             if (clip != null)
@@ -82,8 +91,17 @@ namespace Mono
             }
             else
             {
-                //Log.Error($"Not exist clip({type}) @{gameObject.name}");
+                Log.Error($"Not exist clip({type}) @{gameObject.name}");
             }
         }
+
+        public void Pause()
+        {
+            Animancer.Playable.PauseGraph();
+        }
+        public void Resume()
+        {
+            Animancer.Playable.UnpauseGraph();
+        }
     }
 }

+ 54 - 0
Assets/Scripts/Codes/Mono/IceFrozen.cs

@@ -0,0 +1,54 @@
+using ET;
+using UnityEngine;
+using System;
+
+namespace Mono
+{
+    public class IceFrozen : MonoBehaviour
+    {
+        [Header("冰冻效果材质")]
+        public Material IceMaterial;
+
+        public bool IsFroze { get; protected set; }
+
+        private SkinnedMeshRenderer Render;
+        private ListComponent<Material> NewMaterials = new();
+        private Material[] OriginMaterials = null;
+        private void Awake()
+        {
+            if(IceMaterial == null)
+            {
+                Log.Error($"Not set IceMaterial @{gameObject.name}");
+                return;
+            }
+
+            IsFroze = false;
+            Render = transform.GetComponentInChildren<SkinnedMeshRenderer>();
+            foreach(var mat in Render.sharedMaterials)
+            {
+                NewMaterials.Add( mat );
+            }
+            
+            OriginMaterials = Render.materials;
+            IceMaterial.SetFloat("_Frezz", 0.0f);
+        }
+
+        public void StartFroze()
+        {
+            if (IsFroze) return;
+
+            IsFroze = true;
+            NewMaterials.Add(IceMaterial);
+            Render.sharedMaterials = NewMaterials.ToArray();
+        }
+
+        public void ClearFroze()
+        {
+            if(!IsFroze) return;
+            IsFroze = false;
+
+            NewMaterials.Remove(IceMaterial);
+            Render.sharedMaterials = NewMaterials.ToArray();
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Codes/Mono/IceFrozen.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 00763eba6777c5e41b5a49b5e7acad6c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 103 - 0
Assets/Shader/CharactorShaderCullOff.shader

@@ -0,0 +1,103 @@
+
+Shader "Custom/CharactorShaderCullOff"
+{
+    Properties
+    {
+        _MainTex ("Base (RGB)", 2D) = "white" {}
+        _AlphaTex ("Base (RGB)", 2D) = "white" {}
+        _RandomTex ("Base (RGB)", 2D) = "white" {}
+        _RimColor ("Rim Color", Color) = (1, 0, 0, 1)
+        _Color("_Color", Color) = (0.5,0.5,0.5,1)
+        _Rampage("_Rampage", Float) = 0
+        _Frezz("_Frezz", Range(0, 1)) = 0
+    }
+
+    SubShader
+    {
+        Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 
+        Pass
+        {
+            cull off
+            Blend SrcAlpha OneMinusSrcAlpha
+            CGPROGRAM
+            // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members pos1) 
+         //   #pragma exclude_renderers d3d11 xbox360
+            #pragma target 2.0
+            #pragma vertex vert
+            #pragma fragment frag
+            #include "UnityCG.cginc"
+
+            struct appdata
+            {
+                float4 vertex : POSITION;
+                float3 normal : NORMAL;
+                float2 texcoord : TEXCOORD0;
+            };
+
+            struct v2f
+            {
+                half4 pos : SV_POSITION;
+                half2 uv : TEXCOORD0;
+                fixed3 color : COLOR;
+            };
+
+            uniform fixed4 _RimColor;
+            uniform fixed _Rampage;
+            uniform fixed _Frezz;
+
+            v2f vert(appdata_base v)
+            {
+                v2f o;
+                o.pos = UnityObjectToClipPos(v.vertex);
+                if (_Rampage == 1)
+                {
+                    fixed3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
+                    fixed dotProduct = 1 - dot(v.normal, viewDir);
+                    o.color = smoothstep(0, 1, dotProduct);
+                    o.color *= _RimColor;
+                }
+                float3 normal = mul(SCALED_NORMAL, (float3x3)unity_WorldToObject);
+                fixed dotProduct = dot(normal, fixed3(0, 1, 0)) / 2;
+                if (dotProduct <= 0)
+                {
+                    dotProduct = 0;
+                }
+                o.color += dotProduct.xxx;
+                o.uv = v.texcoord.xy;
+                return o;
+            }
+
+            uniform sampler2D _MainTex;
+            uniform sampler2D _AlphaTex;
+            uniform sampler2D _RandomTex;
+            uniform fixed4 _Color;
+            fixed4 frag(v2f i) : COLOR
+            {
+                fixed4 texcol = tex2D(_MainTex, i.uv);
+                fixed4 alpha = tex2D(_AlphaTex, i.uv);
+                float ClipTex = tex2D(_RandomTex, i.uv).r;
+                float ClipAmount = (_Frezz - ClipTex) / 2 + 0.5;
+                if (ClipAmount < 0)
+                {
+                    ClipAmount = 0;
+                }
+                if (ClipAmount > 1)
+                {
+                    ClipAmount = 1;
+                }
+                if (_Rampage == 1)
+                {
+                    texcol.rgb += i.color;
+                }
+                texcol = texcol * ClipAmount + alpha * (1 - ClipAmount);
+                texcol.a = alpha.a;
+                clip(texcol.a - 0.5);
+                texcol *= _Color;
+                return texcol;
+            }
+            ENDCG
+        }
+
+    }
+    FallBack "Legacy Shaders/Transparent/Cutout/VertexLit"
+}

+ 9 - 0
Assets/Shader/CharactorShaderCullOff.shader.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 044189b18bb54a94ab7b3e7f50d743b5
+ShaderImporter:
+  externalObjects: {}
+  defaultTextures: []
+  nonModifiableTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 103 - 0
Assets/Shader/IceFrozen.shader

@@ -0,0 +1,103 @@
+
+Shader "Omm/IceFrozen"
+{
+    Properties
+    {
+        _MainTex ("Base (RGB)", 2D) = "white" {}
+        _AlphaTex ("Base (RGB)", 2D) = "white" {}
+        _RandomTex ("Base (RGB)", 2D) = "white" {}
+        _RimColor ("Rim Color", Color) = (1, 0, 0, 1)
+        _Color("_Color", Color) = (0.5,0.5,0.5,1)
+        _Rampage("_Rampage", Float) = 0
+        _Frezz("_Frezz", Range(0, 1)) = 0
+    }
+
+    SubShader
+    {
+        Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 
+        Pass
+        {
+            cull off
+            Blend SrcAlpha OneMinusSrcAlpha
+            CGPROGRAM
+            // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members pos1) 
+         //   #pragma exclude_renderers d3d11 xbox360
+            #pragma target 2.0
+            #pragma vertex vert
+            #pragma fragment frag
+            #include "UnityCG.cginc"
+
+            struct appdata
+            {
+                float4 vertex : POSITION;
+                float3 normal : NORMAL;
+                float2 texcoord : TEXCOORD0;
+            };
+
+            struct v2f
+            {
+                half4 pos : SV_POSITION;
+                half2 uv : TEXCOORD0;
+                fixed3 color : COLOR;
+            };
+
+            uniform fixed4 _RimColor;
+            uniform fixed _Rampage;
+            uniform fixed _Frezz;
+
+            v2f vert(appdata_base v)
+            {
+                v2f o;
+                o.pos = UnityObjectToClipPos(v.vertex);
+                if (_Rampage == 1)
+                {
+                    fixed3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
+                    fixed dotProduct = 1 - dot(v.normal, viewDir);
+                    o.color = smoothstep(0, 1, dotProduct);
+                    o.color *= _RimColor;
+                }
+                float3 normal = mul(SCALED_NORMAL, (float3x3)unity_WorldToObject);
+                fixed dotProduct = dot(normal, fixed3(0, 1, 0)) / 2;
+                if (dotProduct <= 0)
+                {
+                    dotProduct = 0;
+                }
+                o.color += dotProduct.xxx;
+                o.uv = v.texcoord.xy;
+                return o;
+            }
+
+            uniform sampler2D _MainTex;
+            uniform sampler2D _AlphaTex;
+            uniform sampler2D _RandomTex;
+            uniform fixed4 _Color;
+            fixed4 frag(v2f i) : COLOR
+            {
+                fixed4 texcol = tex2D(_MainTex, i.uv);
+                fixed4 alpha = tex2D(_AlphaTex, i.uv);
+                float ClipTex = tex2D(_RandomTex, i.uv).r;
+                float ClipAmount = (_Frezz - ClipTex) / 2 + 0.5;
+                if (ClipAmount < 0)
+                {
+                    ClipAmount = 0;
+                }
+                if (ClipAmount > 1)
+                {
+                    ClipAmount = 1;
+                }
+                if (_Rampage == 1)
+                {
+                    texcol.rgb += i.color;
+                }
+                texcol = texcol * ClipAmount + alpha * (1 - ClipAmount);
+                texcol.a = alpha.a;
+                clip(texcol.a - 0.5);
+                texcol *= _Color;
+                return texcol;
+            }
+            ENDCG
+        }
+
+    }
+    FallBack "Legacy Shaders/Transparent/Cutout/VertexLit"
+}

+ 9 - 0
Assets/Shader/IceFrozen.shader.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 044189b18bb54a94ab7b3e7f50d743b5
+ShaderImporter:
+  externalObjects: {}
+  defaultTextures: []
+  nonModifiableTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/Texture/ice34.png


+ 140 - 0
Assets/Texture/ice34.png.meta

@@ -0,0 +1,140 @@
+fileFormatVersion: 2
+guid: b9d91d35e0b37514baa9773142b52f28
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 1
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: 1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: -1
+    aniso: 2
+    mipBias: -100
+    wrapU: 0
+    wrapV: 0
+    wrapW: 0
+  nPOTScale: 1
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 0
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 0
+  spriteTessellationDetail: -1
+  textureType: 0
+  textureShape: 1
+  singleChannelComponent: 0
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  applyGammaDecoding: 0
+  platformSettings:
+  - serializedVersion: 3
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 8192
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Standalone
+    maxTextureSize: 8192
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: iPhone
+    maxTextureSize: 8192
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Android
+    maxTextureSize: 8192
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Windows Store Apps
+    maxTextureSize: 8192
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites: []
+    outline: []
+    physicsShape: []
+    bones: []
+    spriteID: 
+    internalID: 0
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+    secondaryTextures: []
+  spritePackingTag: 
+  pSDRemoveMatte: 0
+  pSDShowRemoveMatteOption: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: