1.全阶段异步加载与AB包预加载2.node加载无效的问题依然存在
This commit is contained in:
@@ -8,129 +8,58 @@ Material:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Default
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Shader: {fileID: 4800000, guid: 84c10c50c4215074ea659b2fe4bb6c31, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 1
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 2000
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 5, y: 5}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 0.2, y: 0.2}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 5, y: 5}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 5, y: 5}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
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:
|
||||
- _GlowMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Alpha: 0
|
||||
- _CoreIntensity: 0
|
||||
- _CorePulse: 0
|
||||
- _CoreWidth: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.117
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0.603
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.117
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _Distortion: 0
|
||||
- _DstBlend: 10
|
||||
- _EdgeGlowIntensity: 0
|
||||
- _EdgeGlowWidth: 0.01
|
||||
- _FlowFrequency: 0.1
|
||||
- _FlowNoise: 0
|
||||
- _FlowSpeed: 0
|
||||
- _FresnelIntensity: 0
|
||||
- _FresnelPower: 0.1
|
||||
- _GlowIntensity: 0
|
||||
- _SplineFade: 0
|
||||
- _SplineLength: 0
|
||||
- _SplineProgress: 0
|
||||
- _SplineWidth: 0
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 1.4980394, g: 1.4980394, b: 1.4980394, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
- _BaseMapTiling: {r: 1, g: 1, b: 0, a: 0}
|
||||
- _CoreColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EdgeGlowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _FlowDirection: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _GlowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowMapTiling: {r: 1, g: 1, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &3756280554008477935
|
||||
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: 7
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62630902117bdea46892bb1b9658beec
|
||||
guid: 75b8d3692d377b041b5c449a88279e85
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
|
||||
136
Assets/Assets/Resources/Tube/LegacyDefault.mat
Normal file
136
Assets/Assets/Resources/Tube/LegacyDefault.mat
Normal file
@@ -0,0 +1,136 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: LegacyDefault
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 1
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 2000
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 5, y: 5}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 0.2, y: 0.2}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 5, y: 5}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 5, y: 5}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
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
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.117
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0.603
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.117
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 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: 1.4980394, g: 1.4980394, b: 1.4980394, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &3756280554008477935
|
||||
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: 7
|
||||
8
Assets/Assets/Resources/Tube/LegacyDefault.mat.meta
Normal file
8
Assets/Assets/Resources/Tube/LegacyDefault.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62630902117bdea46892bb1b9658beec
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Assets/Shader.meta
Normal file
8
Assets/Assets/Shader.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b21ffd3a6414194bb77db4cae91b90b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Custom_SplineGlowTubeSplineOptimized
|
||||
m_Shader: {fileID: 4800000, guid: 84c10c50c4215074ea659b2fe4bb6c31, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _GlowMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Alpha: 0
|
||||
- _CoreIntensity: 0
|
||||
- _CorePulse: 0
|
||||
- _CoreWidth: 0
|
||||
- _Cull: 2
|
||||
- _Distortion: 0
|
||||
- _DstBlend: 10
|
||||
- _EdgeGlowIntensity: 0
|
||||
- _EdgeGlowWidth: 0.01
|
||||
- _FlowFrequency: 0.1
|
||||
- _FlowNoise: 0
|
||||
- _FlowSpeed: 0
|
||||
- _FresnelIntensity: 0
|
||||
- _FresnelPower: 0.1
|
||||
- _GlowIntensity: 0
|
||||
- _SplineFade: 0
|
||||
- _SplineLength: 0
|
||||
- _SplineProgress: 0
|
||||
- _SplineWidth: 0
|
||||
- _SrcBlend: 1
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _BaseMapTiling: {r: 1, g: 1, b: 0, a: 0}
|
||||
- _CoreColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EdgeGlowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _FlowDirection: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _GlowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowMapTiling: {r: 1, g: 1, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 940e2ccb7a734374597d87762baed94f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
345
Assets/Assets/Shader/SplineGlowTubeSplineOptimized.shader
Normal file
345
Assets/Assets/Shader/SplineGlowTubeSplineOptimized.shader
Normal file
@@ -0,0 +1,345 @@
|
||||
Shader "Custom/SplineGlowTubeSplineOptimized"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Base Properties)]
|
||||
_BaseColor ("Base Color", Color) = (0.2, 0.4, 1, 1)
|
||||
_BaseMap ("Base Map", 2D) = "white" {}
|
||||
_BaseMapTiling ("Base Map Tiling", Vector) = (1, 1, 0, 0)
|
||||
|
||||
[Header(Glow Properties)]
|
||||
_GlowColor ("Glow Color", Color) = (0, 1, 1, 1)
|
||||
_GlowIntensity ("Glow Intensity", Range(0, 10)) = 3
|
||||
_GlowMap ("Glow Map", 2D) = "white" {}
|
||||
_GlowMapTiling ("Glow Map Tiling", Vector) = (1, 1, 0, 0)
|
||||
|
||||
[Header(Flow Animation)]
|
||||
_FlowSpeed ("Flow Speed", Range(0, 5)) = 1.5
|
||||
_FlowDirection ("Flow Direction", Vector) = (1, 0, 0, 0)
|
||||
_FlowNoise ("Flow Noise", Range(0, 1)) = 0.2
|
||||
_FlowFrequency ("Flow Frequency", Range(0.1, 5)) = 1
|
||||
|
||||
[Header(Edge Glow)]
|
||||
_EdgeGlowColor ("Edge Glow Color", Color) = (1, 0.5, 0, 1)
|
||||
_EdgeGlowIntensity ("Edge Glow Intensity", Range(0, 5)) = 2
|
||||
_EdgeGlowWidth ("Edge Glow Width", Range(0, 1)) = 0.15
|
||||
|
||||
[Header(Energy Core)]
|
||||
_CoreColor ("Core Color", Color) = (1, 1, 1, 1)
|
||||
_CoreIntensity ("Core Intensity", Range(0, 5)) = 1
|
||||
_CoreWidth ("Core Width", Range(0, 1)) = 0.3
|
||||
_CorePulse ("Core Pulse Speed", Range(0, 5)) = 2
|
||||
|
||||
[Header(Spline Specific)]
|
||||
_SplineLength ("Spline Length", Float) = 1
|
||||
_SplineProgress ("Spline Progress", Range(0, 1)) = 0
|
||||
_SplineFade ("Spline Fade", Range(0, 1)) = 0.1
|
||||
_SplineWidth ("Spline Width", Range(0, 1)) = 0.5
|
||||
|
||||
[Header(Advanced)]
|
||||
_Alpha ("Alpha", Range(0, 1)) = 0.8
|
||||
_FresnelPower ("Fresnel Power", Range(0.1, 5)) = 2
|
||||
_FresnelIntensity ("Fresnel Intensity", Range(0, 2)) = 1
|
||||
_Distortion ("Distortion", Range(0, 0.1)) = 0.02
|
||||
|
||||
[Header(Rendering)]
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Src Blend", Float) = 1
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Dst Blend", Float) = 10
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 0
|
||||
[Toggle] _ZWrite ("Z Write", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"Queue" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode" = "UniversalForward" }
|
||||
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
ZWrite [_ZWrite]
|
||||
Cull [_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
float4 tangentOS : TANGENT;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 positionWS : TEXCOORD1;
|
||||
float3 normalWS : TEXCOORD2;
|
||||
float3 viewDirWS : TEXCOORD3;
|
||||
float3 tangentWS : TEXCOORD4;
|
||||
float3 bitangentWS : TEXCOORD5;
|
||||
float4 color : COLOR;
|
||||
float fogCoord : TEXCOORD6;
|
||||
float splineProgress : TEXCOORD7;
|
||||
float splineWidth : TEXCOORD8;
|
||||
};
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseColor;
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseMapTiling;
|
||||
float4 _GlowColor;
|
||||
float _GlowIntensity;
|
||||
float4 _GlowMap_ST;
|
||||
float4 _GlowMapTiling;
|
||||
float _FlowSpeed;
|
||||
float4 _FlowDirection;
|
||||
float _FlowNoise;
|
||||
float _FlowFrequency;
|
||||
float4 _EdgeGlowColor;
|
||||
float _EdgeGlowIntensity;
|
||||
float _EdgeGlowWidth;
|
||||
float4 _CoreColor;
|
||||
float _CoreIntensity;
|
||||
float _CoreWidth;
|
||||
float _CorePulse;
|
||||
float _SplineLength;
|
||||
float _SplineProgress;
|
||||
float _SplineFade;
|
||||
float _SplineWidth;
|
||||
float _Alpha;
|
||||
float _FresnelPower;
|
||||
float _FresnelIntensity;
|
||||
float _Distortion;
|
||||
CBUFFER_END
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
TEXTURE2D(_GlowMap);
|
||||
SAMPLER(sampler_GlowMap);
|
||||
|
||||
// 改进的噪声函数
|
||||
float2 Random2(float2 st)
|
||||
{
|
||||
st = float2(dot(st, float2(127.1, 311.7)), dot(st, float2(269.5, 183.3)));
|
||||
return -1.0 + 2.0 * frac(sin(st) * 43758.5453123);
|
||||
}
|
||||
|
||||
float Noise(float2 st)
|
||||
{
|
||||
float2 i = floor(st);
|
||||
float2 f = frac(st);
|
||||
|
||||
float2 u = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
return lerp(lerp(dot(Random2(i), f),
|
||||
dot(Random2(i + float2(1.0, 0.0)), f - float2(1.0, 0.0)), u.x),
|
||||
lerp(dot(Random2(i + float2(0.0, 1.0)), f - float2(0.0, 1.0)),
|
||||
dot(Random2(i + float2(1.0, 1.0)), f - float2(1.0, 1.0)), u.x), u.y);
|
||||
}
|
||||
|
||||
float FBM(float2 st)
|
||||
{
|
||||
float value = 0.0;
|
||||
float amplitude = 0.5;
|
||||
float frequency = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
value += amplitude * Noise(st);
|
||||
st *= 2.0;
|
||||
amplitude *= 0.5;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(input.normalOS, input.tangentOS);
|
||||
|
||||
output.positionCS = positionInputs.positionCS;
|
||||
output.positionWS = positionInputs.positionWS;
|
||||
output.normalWS = normalInputs.normalWS;
|
||||
output.tangentWS = normalInputs.tangentWS;
|
||||
output.bitangentWS = normalInputs.bitangentWS;
|
||||
output.viewDirWS = GetCameraPositionWS() - positionInputs.positionWS;
|
||||
output.uv = input.uv;
|
||||
output.color = input.color;
|
||||
output.fogCoord = ComputeFogFactor(positionInputs.positionCS.z);
|
||||
|
||||
// 计算Spline进度(基于UV.x,这是Spline Mesh的标准UV布局)
|
||||
output.splineProgress = input.uv.x;
|
||||
|
||||
// 计算Spline宽度(基于UV.y)
|
||||
output.splineWidth = input.uv.y;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
// 计算流动UV
|
||||
float2 flowUV = input.uv;
|
||||
float time = _Time.y * _FlowSpeed;
|
||||
|
||||
// 添加流动动画 - 沿着Spline方向流动
|
||||
flowUV.x += _FlowDirection.x * time;
|
||||
flowUV.y += _FlowDirection.y * time * 0.1; // 垂直方向流动较少
|
||||
|
||||
// 添加复杂的噪声扰动
|
||||
float noise = FBM(flowUV * _FlowFrequency + time * 0.3) * _FlowNoise;
|
||||
flowUV += noise * 0.1;
|
||||
|
||||
// 添加扭曲效果
|
||||
float2 distortion = float2(
|
||||
sin(flowUV.y * 10 + time) * _Distortion,
|
||||
cos(flowUV.x * 8 + time * 1.2) * _Distortion
|
||||
);
|
||||
flowUV += distortion;
|
||||
|
||||
// 采样基础纹理
|
||||
float2 baseUV = TRANSFORM_TEX(flowUV, _BaseMap) * _BaseMapTiling.xy;
|
||||
half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, baseUV);
|
||||
|
||||
// 采样发光纹理
|
||||
float2 glowUV = TRANSFORM_TEX(flowUV, _GlowMap) * _GlowMapTiling.xy;
|
||||
half4 glowMap = SAMPLE_TEXTURE2D(_GlowMap, sampler_GlowMap, glowUV);
|
||||
|
||||
// 计算菲涅尔效果
|
||||
float3 viewDir = normalize(input.viewDirWS);
|
||||
float3 normal = normalize(input.normalWS);
|
||||
float fresnel = 1.0 - saturate(dot(viewDir, normal));
|
||||
fresnel = pow(fresnel, _FresnelPower) * _FresnelIntensity;
|
||||
|
||||
// 计算边缘发光
|
||||
float edgeGlow = 1.0 - saturate(dot(normal, viewDir));
|
||||
edgeGlow = pow(edgeGlow, 1.0 / _EdgeGlowWidth);
|
||||
|
||||
// 计算核心发光(基于UV.y的径向距离)
|
||||
float coreDistance = abs(input.splineWidth - 0.5) * 2.0; // 0到1的距离
|
||||
float coreMask = 1.0 - smoothstep(0, _CoreWidth, coreDistance);
|
||||
|
||||
// 核心脉冲效果
|
||||
float pulse = sin(time * _CorePulse) * 0.5 + 0.5;
|
||||
coreMask *= (0.5 + pulse * 0.5);
|
||||
|
||||
// Spline进度效果 - 创建能量波沿着Spline传播
|
||||
float splineMask = 1.0;
|
||||
if (_SplineProgress > 0)
|
||||
{
|
||||
float progressDiff = abs(input.splineProgress - _SplineProgress);
|
||||
splineMask = 1.0 - smoothstep(0, _SplineFade, progressDiff);
|
||||
|
||||
// 添加能量波的尾迹效果
|
||||
float trail = exp(-progressDiff * 10) * 0.3;
|
||||
splineMask += trail;
|
||||
}
|
||||
|
||||
// 添加Spline宽度遮罩
|
||||
float widthMask = 1.0 - smoothstep(_SplineWidth, 1.0, input.splineWidth);
|
||||
widthMask = smoothstep(0, _SplineWidth, input.splineWidth);
|
||||
|
||||
// 组合颜色
|
||||
half3 baseColor = _BaseColor.rgb * baseMap.rgb;
|
||||
half3 glowColor = _GlowColor.rgb * glowMap.rgb * _GlowIntensity;
|
||||
half3 edgeGlowColor = _EdgeGlowColor.rgb * _EdgeGlowIntensity;
|
||||
half3 coreColor = _CoreColor.rgb * _CoreIntensity;
|
||||
|
||||
// 最终颜色计算
|
||||
half3 finalColor = baseColor;
|
||||
finalColor += glowColor * glowMap.a;
|
||||
finalColor += edgeGlowColor * edgeGlow;
|
||||
finalColor += coreColor * coreMask;
|
||||
finalColor += fresnel * _GlowColor.rgb * 0.3;
|
||||
|
||||
// 应用顶点颜色
|
||||
finalColor *= input.color.rgb;
|
||||
|
||||
// 应用Spline进度遮罩
|
||||
finalColor *= splineMask;
|
||||
|
||||
// 应用宽度遮罩
|
||||
finalColor *= widthMask;
|
||||
|
||||
// 计算最终透明度
|
||||
half finalAlpha = _Alpha * _BaseColor.a * baseMap.a * input.color.a;
|
||||
finalAlpha += glowMap.a * _GlowColor.a * 0.4;
|
||||
finalAlpha += edgeGlow * _EdgeGlowColor.a * 0.3;
|
||||
finalAlpha += coreMask * _CoreColor.a * 0.2;
|
||||
finalAlpha *= splineMask;
|
||||
finalAlpha *= widthMask;
|
||||
|
||||
half4 color = half4(finalColor, finalAlpha);
|
||||
|
||||
// 应用雾效
|
||||
color.rgb = MixFog(color.rgb, input.fogCoord);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// 阴影投射Pass
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull [_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// 深度Only Pass
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode" = "DepthOnly" }
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull [_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Hidden/Universal Render Pipeline/FallbackError"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84c10c50c4215074ea659b2fe4bb6c31
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Submodule Assets/Convention updated: 344260266c...3c962267ab
File diff suppressed because one or more lines are too long
8
Assets/Scripts/Editor.meta
Normal file
8
Assets/Scripts/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 200725c262851254db49e0c1a5729c77
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Scripts/Editor/SOEditor.cs
Normal file
10
Assets/Scripts/Editor/SOEditor.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(Demo.ScriptableObject), true)]
|
||||
public class SOEditor : Convention.AbstractCustomEditor
|
||||
{
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Editor/SOEditor.cs.meta
Normal file
11
Assets/Scripts/Editor/SOEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4af2f5018ef1934cb4055d18185a75c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,18 +11,8 @@ namespace Demo.Game
|
||||
return new GameObject().AddComponent<PrefabRootObject>();
|
||||
}
|
||||
|
||||
private List<IEnumerator> AssetBundleLoadings = new();
|
||||
private List<string> AssetBundles = new();
|
||||
private List<GameObject> Prefabs = new();
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
foreach (var loading in AssetBundleLoadings)
|
||||
{
|
||||
yield return loading;
|
||||
}
|
||||
}
|
||||
private readonly List<string> AssetBundles = new();
|
||||
private readonly List<GameObject> Prefabs = new();
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
@@ -45,36 +35,31 @@ namespace Demo.Game
|
||||
<param name=""ab""></param>
|
||||
<param name=""prefab""></param>
|
||||
")]
|
||||
public void Load(string ab, string prefab)
|
||||
public IEnumerator Load(string ab, string prefab)
|
||||
{
|
||||
IEnumerator Foo()
|
||||
AssetBundle assetBundle = null;
|
||||
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
|
||||
GameObject prefabObject = null;
|
||||
if (assetBundle != null)
|
||||
{
|
||||
AssetBundle assetBundle = null;
|
||||
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
|
||||
GameObject prefabObject = null;
|
||||
if (assetBundle != null)
|
||||
var ir = assetBundle.LoadAssetAsync<GameObject>(prefab);
|
||||
yield return ir;
|
||||
if (ir.asset != null)
|
||||
{
|
||||
var ir = assetBundle.LoadAssetAsync<GameObject>(prefab);
|
||||
yield return ir;
|
||||
if (ir.asset != null)
|
||||
{
|
||||
prefabObject = Instantiate(ir.asset as GameObject);
|
||||
Prefabs.Add(prefabObject);
|
||||
prefabObject.transform.SetParent(transform);
|
||||
AssetBundles.Add(ab);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Load Prefab failed", this);
|
||||
}
|
||||
prefabObject = Instantiate(ir.asset as GameObject);
|
||||
Prefabs.Add(prefabObject);
|
||||
prefabObject.transform.SetParent(transform);
|
||||
AssetBundles.Add(ab);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Load AssetBundle failed", this);
|
||||
Debug.LogError($"Load Prefab failed", this);
|
||||
}
|
||||
}
|
||||
|
||||
AssetBundleLoadings.Add(Foo());
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Load AssetBundle failed", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace Demo.Game
|
||||
</summary>
|
||||
<param name=""ab""></param>
|
||||
")]
|
||||
public void Load(string ab)
|
||||
public IEnumerator Load(string ab)
|
||||
{
|
||||
SkyAssetBundleLoading = this.LoadAssetBundle(ab, x =>
|
||||
yield return this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
SkyAssetBundlePath = ab;
|
||||
SkyAssetBundle = x;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Demo.Game
|
||||
|
||||
yield return null;
|
||||
|
||||
// Setup Game Rules
|
||||
// Setup Game Rules (Main)
|
||||
if (Editor.EditorController.instance.MainGameController == this)
|
||||
{
|
||||
ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen;
|
||||
@@ -126,11 +126,23 @@ namespace Demo.Game
|
||||
SongOffset = (float)MainConfig.FindItem(nameof(SongOffset), SongOffset);
|
||||
SetupSongDuration = GameContent.instance.SetupSongDuration;
|
||||
SetSongCurrentTime = GameContent.instance.SetSongCurrentTime;
|
||||
}
|
||||
// Setup Game Rules
|
||||
{
|
||||
foreach (var ab in ((string)MainConfig.FindItem(nameof(AssetBundle), "")).Split(';'))
|
||||
{
|
||||
if (string.IsNullOrEmpty(ab))
|
||||
continue;
|
||||
StartCoroutine(AssetBundlesLoadHelper.LoadAssetBundleAsync(ab.Trim(), null));
|
||||
}
|
||||
IsHideTrackRender = (bool)MainConfig.FindItem(nameof(IsHideTrackRender), false);
|
||||
IsAutoPlay = GameContent.instance.IsAutoPlay;
|
||||
WhichOpenScript = (string)MainConfig.FindItem(nameof(WhichOpenScript), WhichOpenScript);
|
||||
// Open Project
|
||||
WhichOpenProject = (string)MainConfig.FindItem(nameof(WhichOpenProject), WhichOpenProject);
|
||||
if (string.IsNullOrEmpty(WhichOpenProject) == false)
|
||||
{
|
||||
string path = string.Format($"{WhichOpenProject}", $"\"{Editor.EditorController.instance.PersistentDataPath}\"") ;
|
||||
string path = string.Format($"{WhichOpenProject}", $"\"{Editor.EditorController.instance.PersistentDataPath}\"");
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process.Start(path);
|
||||
@@ -141,55 +153,51 @@ namespace Demo.Game
|
||||
Debug.LogException(ex, this);
|
||||
}
|
||||
}
|
||||
CurrentProjectDefaultFileStyle = content.CurrentProjectDefaultFileStyle;
|
||||
}
|
||||
|
||||
|
||||
MainConfig.SaveProperties();
|
||||
|
||||
yield return null;
|
||||
|
||||
// Load Root Object
|
||||
{
|
||||
while (MainConfig.Contains("root") == false)
|
||||
{
|
||||
IsHideTrackRender = (bool)MainConfig.FindItem(nameof(IsHideTrackRender), false);
|
||||
IsAutoPlay = GameContent.instance.IsAutoPlay;
|
||||
WhichOpenScript = (string)MainConfig.FindItem(nameof(WhichOpenScript), WhichOpenScript);
|
||||
CurrentProjectDefaultFileStyle = content.CurrentProjectDefaultFileStyle;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
MainConfig.SaveProperties();
|
||||
|
||||
// Load Root Object
|
||||
{
|
||||
while (MainConfig.Contains("root") == false)
|
||||
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
|
||||
{
|
||||
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
|
||||
ProjectDefaultFileStyle.PY => ".py",
|
||||
_ => ".cpp"
|
||||
};
|
||||
if (content.IsCreateNewProject)
|
||||
{
|
||||
MainConfig["root"] = defaultRootPath;
|
||||
if (MainConfig.CreateFile(defaultRootPath))
|
||||
{
|
||||
ProjectDefaultFileStyle.PY => ".py",
|
||||
_ => ".cpp"
|
||||
};
|
||||
if (content.IsCreateNewProject)
|
||||
{
|
||||
MainConfig["root"] = defaultRootPath;
|
||||
if (MainConfig.CreateFile(defaultRootPath))
|
||||
{
|
||||
MainConfig.SaveProperties();
|
||||
break;
|
||||
}
|
||||
MainConfig.SaveProperties();
|
||||
break;
|
||||
}
|
||||
Debug.LogError($"{nameof(defaultRootPath)} is cannt create or config's root property is not exist", this);
|
||||
StartCoroutine(GameExit());
|
||||
yield break;
|
||||
}
|
||||
var rootFileName = (string)MainConfig.FindItem("root");
|
||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||
rootObject.MustExistsPath();
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.EnableScript(content.RootSourceDir, rootObject.GetFullPath(), this);
|
||||
try
|
||||
{
|
||||
yield return rootGameObject.LoadScript(rootObject.LoadAsText());
|
||||
}
|
||||
finally
|
||||
{
|
||||
MainObject = rootGameObject;
|
||||
}
|
||||
Debug.LogError($"{nameof(defaultRootPath)} is cannt create or config's root property is not exist", this);
|
||||
StartCoroutine(GameExit());
|
||||
yield break;
|
||||
}
|
||||
var rootFileName = (string)MainConfig.FindItem("root");
|
||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||
rootObject.MustExistsPath();
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.EnableScript(content.RootSourceDir, rootObject.GetFullPath(), this);
|
||||
try
|
||||
{
|
||||
yield return rootGameObject.LoadScript(rootObject.LoadAsText());
|
||||
}
|
||||
finally
|
||||
{
|
||||
MainObject = rootGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,6 +569,9 @@ namespace Demo
|
||||
MyHierarchyItem.GetHierarchyItem().title = this.ScriptName + $"<{scriptType}>";
|
||||
MyHierarchyItem.GetHierarchyItem().target = this;
|
||||
MyHierarchyItem.GetHierarchyItem().ButtonGameObject.GetComponent<Editor.UI.RightClick>().ScriptObjectMenu = OnHierarchyItemRightClick;
|
||||
var parentHierarchyItem = MyHierarchyItem.GetParent();
|
||||
if (parentHierarchyItem != null)
|
||||
parentHierarchyItem.GetPropertyListItem().RefreshChilds();
|
||||
}
|
||||
|
||||
public ScriptableObject FindWithPath(string path, bool isMustExist = true)
|
||||
@@ -639,6 +642,48 @@ namespace Demo
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerator LoadSubScriptAsync([In] string type, [In] string path, [Opt] Action<ScriptableObject> callback)
|
||||
{
|
||||
// 判断类型是否合法
|
||||
if (DefaultInstantiate.GetScriptableObjectInstantiate().TryGetValue(type, out var creater) == false)
|
||||
{
|
||||
Debug.LogError($"{type} is not exist or {type}'s Instantiater is not valid", this);
|
||||
callback?.Invoke(null);
|
||||
yield break;
|
||||
}
|
||||
// 生成对象
|
||||
var child = creater();
|
||||
// 路径预处理
|
||||
if (path.Replace('\\', '/').ToLower().StartsWith("project/"))
|
||||
path = $"{new ToolFile(GetRoot().SourcePath) | path[5..]}";
|
||||
// 获取文件
|
||||
ToolFile file;
|
||||
if (File.Exists(path))
|
||||
file = new(path);
|
||||
else
|
||||
file = new ToolFile(SourcePath) | path;
|
||||
// 找不到脚本
|
||||
if (file.Exists() == false)
|
||||
{
|
||||
Debug.LogError($"{file}<{path}> is not found", this);
|
||||
callback?.Invoke(null);
|
||||
yield break;
|
||||
}
|
||||
child.ScriptName = file.GetName(true);
|
||||
child.transform.SetParent(this.transform);
|
||||
child.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
child.transform.localScale = Vector3.one;
|
||||
child.EnableScript(file.GetCurrentDirName(), Path.Combine(file.GetCurrentDirName(), file.GetName(false)), type, this);
|
||||
|
||||
// Add Child
|
||||
Childs.Add(child);
|
||||
|
||||
// Load Child Script
|
||||
yield return child.LoadScript(file.LoadAsText());
|
||||
|
||||
callback?.Invoke(child);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载子脚本
|
||||
/// </summary>
|
||||
@@ -651,49 +696,9 @@ namespace Demo
|
||||
<param name=""type"">指定类型</param>
|
||||
<param name=""path"">指定脚本,可用决定路径或与当前脚本目录的相对路径</param>
|
||||
")]
|
||||
[return:ReturnMayNull]
|
||||
public ScriptableObject LoadSubScript(string type, string path)
|
||||
public IEnumerator LoadSubScript([In] string type, [In] string path)
|
||||
{
|
||||
// 判断类型是否合法
|
||||
if (DefaultInstantiate.GetScriptableObjectInstantiate().TryGetValue(type, out var creater) == false)
|
||||
{
|
||||
Debug.LogError($"{type} is not exist or {type}'s Instantiater is not valid", this);
|
||||
return null;
|
||||
}
|
||||
// 生成对象
|
||||
var child = creater();
|
||||
// 路径预处理
|
||||
if (path.Replace('\\', '/').ToLower().StartsWith("project/"))
|
||||
path = $"{new ToolFile(GetRoot().SourcePath) | path[5..]}";
|
||||
// 获取文件
|
||||
ToolFile file;
|
||||
if (File.Exists(path))
|
||||
file = new(path);
|
||||
else
|
||||
file = new ToolFile(SourcePath)| path;
|
||||
// 找不到脚本
|
||||
if (file.Exists() == false)
|
||||
{
|
||||
Debug.LogError($"{file}<{path}> is not found", this);
|
||||
return null;
|
||||
}
|
||||
child.ScriptName = file.GetName(true);
|
||||
child.transform.SetParent(this.transform);
|
||||
child.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
child.transform.localScale = Vector3.one;
|
||||
child.EnableScript(file.GetCurrentDirName(), Path.Combine(file.GetCurrentDirName(), file.GetName(false)), type, this);
|
||||
|
||||
// Add Child
|
||||
Childs.Add(child);
|
||||
|
||||
// Load Child Script
|
||||
if (gameObject.activeInHierarchy)
|
||||
StartCoroutine(child.LoadScript(file.LoadAsText()));
|
||||
else
|
||||
GetRoot().GetComponent<MonoBehaviour>().StartCoroutine(child.LoadScript(file.LoadAsText()));
|
||||
|
||||
|
||||
return child;
|
||||
yield return LoadSubScriptAsync(type, path, null);
|
||||
}
|
||||
|
||||
public object DynamicBindingTarget { get; protected set; } = null;
|
||||
@@ -705,6 +710,8 @@ namespace Demo
|
||||
Break
|
||||
}
|
||||
|
||||
// TODO : 过多的逻辑都挤在这里, 需要拆分
|
||||
// TODO : 如何统计整个游戏关卡是否加载完成, 尤其是此处的resultEnumerator与ILoadAssetBundle, 将会同时存在多条异步加载的时间线
|
||||
private IEnumerator ParseScript2Expr(string script)
|
||||
{
|
||||
// 预处理
|
||||
@@ -816,9 +823,21 @@ namespace Demo
|
||||
MethodInvokerCache[this.GetType()].Add(command, commandInfo);
|
||||
}
|
||||
Debug.Log($"in line \"{expr}\" of \"{ScriptPath}\", {command} is try to invoke", this);
|
||||
IEnumerator resultEnumerator = null;
|
||||
try
|
||||
{
|
||||
if (ConventionUtility.TryInvokeMember(commandInfo, this, out var _, paramsList) == false)
|
||||
// 调用成功
|
||||
if (ConventionUtility.TryInvokeMember(commandInfo, this, out var invokeResult, paramsList) == true)
|
||||
{
|
||||
Debug.Log($"in line \"{expr}\" of \"{ScriptPath}\", {command} is invoke succeed", this);
|
||||
// 尤其用于加载子类时
|
||||
if (invokeResult != null && invokeResult is IEnumerator _resultEnumerator)
|
||||
{
|
||||
resultEnumerator = _resultEnumerator;
|
||||
}
|
||||
}
|
||||
// 调用失败
|
||||
else
|
||||
{
|
||||
MethodInvokerCache[this.GetType()].Remove(command);
|
||||
var attr = commandInfo.GetCustomAttribute<ScriptableCallAttribute>();
|
||||
@@ -827,10 +846,6 @@ namespace Demo
|
||||
else
|
||||
Debug.LogError($"in line \"{expr}\" of \"{ScriptPath}\", {command} is failed to invoke, see: {attr.Description}", this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"in line \"{expr}\" of \"{ScriptPath}\", {command} is invoke succeed", this);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -838,7 +853,7 @@ namespace Demo
|
||||
Debug.LogException(ex, this);
|
||||
yield break;
|
||||
}
|
||||
yield return null;
|
||||
yield return resultEnumerator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -988,13 +1003,12 @@ namespace Demo
|
||||
private static Dictionary<string, IEnumerator> AssetBundleLoading = new();
|
||||
private static PropertiesWindow.ItemEntry AssetBundlesItemEntry = null;
|
||||
|
||||
public static IEnumerator LoadAssetBundle(this IAssetBundleLoader self, string ab, Action<AssetBundle> callback)
|
||||
public static IEnumerator LoadAssetBundleAsync(string ab, Action<AssetBundle> callback)
|
||||
{
|
||||
Debug.Log($"{self.SharedInterfaceScriptObject.ScriptName}.{nameof(LoadAssetBundle)}({ab})", self.SharedInterfaceScriptObject);
|
||||
if (AssetBundleCounter.TryGetValue(ab, out var result))
|
||||
{
|
||||
result.referenceCounter++;
|
||||
callback(result.assetBundle);
|
||||
callback?.Invoke(result.assetBundle);
|
||||
yield break;
|
||||
}
|
||||
if (AssetBundleLoading.TryGetValue(ab, out var tir))
|
||||
@@ -1003,7 +1017,7 @@ namespace Demo
|
||||
if (AssetBundleCounter.TryGetValue(ab, out result))
|
||||
{
|
||||
result.referenceCounter++;
|
||||
callback(result.assetBundle);
|
||||
callback?.Invoke(result.assetBundle);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
@@ -1047,13 +1061,19 @@ namespace Demo
|
||||
loadingHierarchyItem.title = $"{ab}<Failed>";
|
||||
}
|
||||
AssetBundleLoading.Remove(ab);
|
||||
callback(x);
|
||||
callback?.Invoke(x);
|
||||
});
|
||||
AssetBundleLoading.Add(ab, ir);
|
||||
yield return ir;
|
||||
AssetBundleLoading.Remove(ab);
|
||||
}
|
||||
|
||||
public static IEnumerator LoadAssetBundle(this IAssetBundleLoader self, string ab, Action<AssetBundle> callback)
|
||||
{
|
||||
Debug.Log($"{self.SharedInterfaceScriptObject.ScriptName}.{nameof(LoadAssetBundle)}({ab})", self.SharedInterfaceScriptObject);
|
||||
yield return LoadAssetBundleAsync(ab, callback);
|
||||
}
|
||||
|
||||
public static IEnumerator UnloadAssetBundle(this IAssetBundleLoader self, string ab)
|
||||
{
|
||||
// Editor中暂时忽略卸载功能
|
||||
|
||||
@@ -128,17 +128,19 @@ namespace Demo.Game
|
||||
childFileStream.Close();
|
||||
}
|
||||
//不刷新世界,直接加载
|
||||
var targetChildSO = so.LoadSubScript(type, childFile);
|
||||
// 打开手动编辑
|
||||
try
|
||||
so.StartCoroutine(so.LoadSubScriptAsync(type, childFile, targetChildSO =>
|
||||
{
|
||||
DefaultScriptUtility.OpenScriptFile(targetChildSO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Cannt open {childFile}", so);
|
||||
Debug.LogException(ex, so);
|
||||
}
|
||||
// 打开手动编辑
|
||||
try
|
||||
{
|
||||
DefaultScriptUtility.OpenScriptFile(targetChildSO);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Cannt open {childFile}", so);
|
||||
Debug.LogException(ex, so);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -56,6 +56,12 @@ namespace Demo.Game
|
||||
}
|
||||
}
|
||||
|
||||
public override void ResetEnterGameStatus()
|
||||
{
|
||||
base.ResetEnterGameStatus();
|
||||
UpdateEntry(0, 0);
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
Content = 0;
|
||||
@@ -71,18 +77,8 @@ namespace Demo.Game
|
||||
return (currentTime - Entries[Content].TimePoint) / (Entries[Content + 1].TimePoint - Entries[Content].TimePoint);
|
||||
}
|
||||
|
||||
if (Entries.Count == 0)
|
||||
if (Entries.Count <= 1)
|
||||
return;
|
||||
if (Entries.Count == 1)
|
||||
{
|
||||
UpdateEntry(0, 0);
|
||||
return;
|
||||
}
|
||||
// TODO : 删除后存在问题
|
||||
if (Entries[0].TimePoint <= 0 && tickType == TickType.Reset)
|
||||
{
|
||||
UpdateEntry(0, 0);
|
||||
}
|
||||
switch (tickType)
|
||||
{
|
||||
case TickType.Reset:
|
||||
|
||||
@@ -11,18 +11,8 @@ namespace Demo.Game
|
||||
return new GameObject().AddComponent<ParticleEffect>();
|
||||
}
|
||||
|
||||
private List<IEnumerator> AssetBundleLoadings = new();
|
||||
private List<string> AssetBundles = new();
|
||||
private List<GameObject> Prefabs = new();
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
foreach (var loading in AssetBundleLoadings)
|
||||
{
|
||||
yield return loading;
|
||||
}
|
||||
}
|
||||
private readonly List<string> AssetBundles = new();
|
||||
private readonly List<GameObject> Prefabs = new();
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
@@ -45,9 +35,9 @@ namespace Demo.Game
|
||||
<param name=""ab""></param>
|
||||
<param name=""prefab""></param>
|
||||
")]
|
||||
public void Load(string ab, string prefab)
|
||||
public IEnumerator Load(string ab, string prefab)
|
||||
{
|
||||
AssetBundleLoadings.Add(this.LoadAssetBundle(ab, x =>
|
||||
yield return this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
GameObject sub = Instantiate(x.LoadAsset<GameObject>(prefab));
|
||||
sub.SetActive(false);
|
||||
@@ -55,7 +45,7 @@ namespace Demo.Game
|
||||
sub.transform.SetParent(transform);
|
||||
sub.transform.localPosition = Vector3.zero;
|
||||
AssetBundles.Add(ab);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnBegin()
|
||||
|
||||
@@ -12,18 +12,10 @@ namespace Demo.Game
|
||||
return new GameObject().AddComponent<ParticleJudgement>();
|
||||
}
|
||||
|
||||
private List<IEnumerator> AssetBundleLoadings = new();
|
||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, string> AssetBundles = new();
|
||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, GameObject> Prefabs = new();
|
||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, float> Durations = new();
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
foreach (var loading in AssetBundleLoadings)
|
||||
yield return loading;
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
yield return base.UnloadScript();
|
||||
@@ -47,26 +39,20 @@ namespace Demo.Game
|
||||
<param name=""prefab""></param>
|
||||
<param name=""duration"">判定效果会现形的持续时间</param>
|
||||
")]
|
||||
public void Load(string level, string ab, string prefab, string duration)
|
||||
public IEnumerator Load(string level, string ab, string prefab, string duration)
|
||||
{
|
||||
var levelId = (IInteraction.JudgementLevel)int.Parse(level);
|
||||
|
||||
IEnumerator Foo()
|
||||
{
|
||||
AssetBundle assetBundle = null;
|
||||
var ir = this.LoadAssetBundle(ab, x => assetBundle = x);
|
||||
yield return ir;
|
||||
var req = assetBundle.LoadAssetAsync<GameObject>(prefab);
|
||||
yield return req;
|
||||
GameObject sub = Instantiate(req.asset as GameObject);
|
||||
sub.SetActive(false);
|
||||
Prefabs.Add(levelId, sub);
|
||||
sub.transform.SetParent(transform);
|
||||
AssetBundles.Add(levelId, ab);
|
||||
Durations.Add(levelId, float.Parse(duration));
|
||||
}
|
||||
|
||||
AssetBundleLoadings.Add(Foo());
|
||||
AssetBundle assetBundle = null;
|
||||
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
|
||||
var req = assetBundle.LoadAssetAsync<GameObject>(prefab);
|
||||
yield return req;
|
||||
GameObject sub = Instantiate(req.asset as GameObject);
|
||||
sub.SetActive(false);
|
||||
Prefabs.Add(levelId, sub);
|
||||
sub.transform.SetParent(transform);
|
||||
AssetBundles.Add(levelId, ab);
|
||||
Durations.Add(levelId, float.Parse(duration));
|
||||
}
|
||||
|
||||
private void CreateParticle(GameObject prefab)
|
||||
|
||||
@@ -52,17 +52,13 @@ namespace Demo.Game
|
||||
</summary>
|
||||
<param name=""ab""></param>
|
||||
")]
|
||||
public void Load(string ab)
|
||||
public IEnumerator Load(string ab)
|
||||
{
|
||||
var ir = this.LoadAssetBundle(ab, x =>
|
||||
yield return this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
MaterialAssetBundlePath = ab;
|
||||
MaterialAssetBundle = x;
|
||||
});
|
||||
if (gameObject.activeInHierarchy)
|
||||
StartCoroutine(ir);
|
||||
else
|
||||
GetRoot().StartCoroutine(ir);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Demo.Game
|
||||
[Content] public AssetBundle LinesAssetBundle;
|
||||
[Content] public string LineMaterial;
|
||||
[Content] public Material MyLineMaterial;
|
||||
IEnumerator AssetBundleLoading;
|
||||
|
||||
public abstract Vector3 EvaluateClipFromPosition(float time);
|
||||
|
||||
@@ -42,7 +41,6 @@ namespace Demo.Game
|
||||
this.GetOrAddComponent<MeshFilter>();
|
||||
MyMeshRenderer = this.GetOrAddComponent<MeshRenderer>();
|
||||
MyMeshRenderer.enabled = true;
|
||||
yield return AssetBundleLoading;
|
||||
if (string.IsNullOrEmpty(LinesAssetBundlePath) == false)
|
||||
{
|
||||
var ir = LinesAssetBundle.LoadAssetAsync<Material>(LineMaterial);
|
||||
@@ -85,9 +83,9 @@ namespace Demo.Game
|
||||
}
|
||||
|
||||
[ScriptableCall(DependOnSplineCoreUtility.LoadSplineDescription)]
|
||||
public void LoadSpline(string path)
|
||||
public IEnumerator LoadSpline(string path)
|
||||
{
|
||||
this.LoadSplineTool(path);
|
||||
yield return this.LoadSplineTool(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,9 +101,9 @@ namespace Demo.Game
|
||||
<param name=""ab""></param>
|
||||
<param name=""material""></param>
|
||||
")]
|
||||
public void LoadMaterial(string ab, string material)
|
||||
public IEnumerator LoadMaterial(string ab, string material)
|
||||
{
|
||||
AssetBundleLoading = this.LoadAssetBundle(ab, x =>
|
||||
yield return this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
LinesAssetBundlePath = ab;
|
||||
LinesAssetBundle = x;
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Demo.Game
|
||||
/// </summary>
|
||||
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
||||
[ScriptableCall(DependOnSplineCoreUtility.LoadSplineDescription)]
|
||||
public void LoadSpline(string path)
|
||||
public IEnumerator LoadSpline(string path)
|
||||
{
|
||||
this.LoadSplineTool(path);
|
||||
yield return this.LoadSplineTool(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Demo.Game
|
||||
public interface IDependOnSplineCore : IScriptableObject
|
||||
{
|
||||
SplineCore MySplineCore { get; set; }
|
||||
void LoadSpline(string path);
|
||||
IEnumerator LoadSpline(string path);
|
||||
}
|
||||
|
||||
public static class DependOnSplineCoreUtility
|
||||
@@ -38,14 +38,14 @@ namespace Demo.Game
|
||||
/// 加载并绑定到新样条线
|
||||
/// </summary>
|
||||
/// <param name="path">对象相对路径,若对象不存在则作为脚本相对路径加载</param>
|
||||
public static void LoadSplineTool(this IDependOnSplineCore self, string path)
|
||||
public static IEnumerator LoadSplineTool(this IDependOnSplineCore self, string path)
|
||||
{
|
||||
var spline = self.SharedInterfaceScriptObject.FindWithPath(path, false);
|
||||
if (spline == null)
|
||||
spline = self.SharedInterfaceScriptObject.LoadSubScript(nameof(SplineCore), path);
|
||||
if (spline != null)
|
||||
yield return self.SharedInterfaceScriptObject.LoadSubScriptAsync(nameof(SplineCore), path, x => spline = x);
|
||||
if (spline is SplineCore sc)
|
||||
{
|
||||
self.MySplineCore = spline as SplineCore;
|
||||
self.MySplineCore = sc;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -158,13 +158,15 @@ namespace Demo.Game
|
||||
</summary>
|
||||
<param name=""path"">脚本位置</param>
|
||||
")]
|
||||
public void LoadNode(string path)
|
||||
public IEnumerator LoadNode(string path)
|
||||
{
|
||||
var node = LoadSubScript(nameof(SplineNode), path);
|
||||
if (node != null)
|
||||
yield return LoadSubScriptAsync(nameof(SplineNode), path, node =>
|
||||
{
|
||||
MySplineNodes.Add(node as SplineNode);
|
||||
}
|
||||
if (node != null)
|
||||
{
|
||||
MySplineNodes.Add(node as SplineNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace Demo.Game
|
||||
|
||||
protected override abstract void UpdateData(float data);
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
MySplineCore = null;
|
||||
@@ -51,14 +56,15 @@ namespace Demo.Game
|
||||
</summary>
|
||||
<param name=""path"">脚本位置</param>
|
||||
")]
|
||||
public void Load(string path)
|
||||
public IEnumerator Load(string path)
|
||||
{
|
||||
var spline = FindWithPath(path, false);
|
||||
if (spline == null)
|
||||
spline = LoadSubScript(nameof(SplineCore), path);
|
||||
if (spline != null)
|
||||
MySplineCore = FindWithPath(path, false) as SplineCore;
|
||||
if (MySplineCore == null)
|
||||
{
|
||||
MySplineCore = spline as SplineCore;
|
||||
yield return LoadSubScriptAsync(nameof(SplineCore), path, x =>
|
||||
{
|
||||
MySplineCore = x as SplineCore;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user