26 Commits

Author SHA1 Message Date
7745988457 MaterialUpdatement Config正在更新, 同时准备将其阻塞Load替换为与天空盒相同的逻辑 2025-12-19 17:51:33 +08:00
6c66a5c515 SubWorld与LookAtAnchor Config更新 2025-12-19 17:33:20 +08:00
a155e37c0a 继续推进Config更新, 并修复了打击效果中的Position未初始化的漏洞 2025-12-19 16:46:54 +08:00
a8b8b82e92 天空盒Config已更新 2025-12-19 15:54:51 +08:00
fd42a868d8 修复已知的Spline错误 2025-12-19 11:17:18 +08:00
b455d2572b Merge branch 'main' of http://www.liubai.site:3000/ninemine/Convention-Unity-Demo 2025-12-19 09:32:30 +08:00
63b762453a 继续推动Config更新(本机测试发生错误) 2025-12-19 01:01:25 +08:00
209df04d82 graph管线必须开启兼容模式 2025-12-18 17:57:10 +08:00
ab60b35be2 异步加载已修复, Config更新正推动 2025-12-18 15:11:33 +08:00
1436080fd6 CameraObject 2025-12-18 10:16:24 +08:00
be4cc888b5 DTT更改 2025-12-18 10:10:49 +08:00
04ad260824 推进修改 2025-12-18 10:06:49 +08:00
d6336faed0 Merge branch 'main' of http://www.liubai.site:3000/ninemine/Convention-Unity-Demo 2025-12-18 09:31:54 +08:00
0f831b8862 开始更新GameController入口 2025-12-18 00:04:41 +08:00
3714fa87e7 开始进行配置字段迁移 2025-12-17 17:55:45 +08:00
425198ab96 MD5缓存已添加 2025-12-17 16:28:34 +08:00
5a02de8c9c 完成Config初步 2025-12-17 15:50:03 +08:00
60df9a93aa 推动Config新增 2025-12-16 17:54:51 +08:00
39a051eacf 新增PrefabRootObjectConfig 2025-12-15 17:59:27 +08:00
0ca799ca34 Config类新增 2025-12-15 17:46:00 +08:00
65a5775647 命名空间迁移 2025-12-15 17:20:55 +08:00
88c15a43f2 时间线物体tab已更改为手动显示 2025-12-15 16:50:38 +08:00
8ed4f93e24 修复上下文bug 2025-12-15 11:54:58 +08:00
0c79cd874e 上下文加载优化 2025-12-15 11:39:46 +08:00
f724058cea 准备使用二进制缓存来全面实现高速加载 2025-12-12 17:46:15 +08:00
a3ea09c2a9 新增volume更新器 2025-12-12 15:54:16 +08:00
63 changed files with 2121 additions and 605 deletions

View File

@@ -4844,6 +4844,11 @@ ParticleSystemRenderer:
m_ReflectionProbeUsage: 0 m_ReflectionProbeUsage: 0
m_RayTracingMode: 0 m_RayTracingMode: 0
m_RayTraceProcedural: 0 m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 4294967295 m_RenderingLayerMask: 4294967295
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
@@ -4865,6 +4870,7 @@ ParticleSystemRenderer:
m_AutoUVMaxDistance: 0.5 m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0
@@ -9690,6 +9696,11 @@ ParticleSystemRenderer:
m_ReflectionProbeUsage: 0 m_ReflectionProbeUsage: 0
m_RayTracingMode: 0 m_RayTracingMode: 0
m_RayTraceProcedural: 0 m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 4294967295 m_RenderingLayerMask: 4294967295
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
@@ -9711,6 +9722,7 @@ ParticleSystemRenderer:
m_AutoUVMaxDistance: 0.5 m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0
@@ -14527,6 +14539,11 @@ ParticleSystemRenderer:
m_ReflectionProbeUsage: 0 m_ReflectionProbeUsage: 0
m_RayTracingMode: 0 m_RayTracingMode: 0
m_RayTraceProcedural: 0 m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 4294967295 m_RenderingLayerMask: 4294967295
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
@@ -14548,6 +14565,7 @@ ParticleSystemRenderer:
m_AutoUVMaxDistance: 0.5 m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0
@@ -14762,7 +14780,7 @@ ParticleSystem:
m_Curve: m_Curve:
- serializedVersion: 3 - serializedVersion: 3
time: 0 time: 0
value: 1 value: 0
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -14771,7 +14789,7 @@ ParticleSystem:
outWeight: 0.33333334 outWeight: 0.33333334
- serializedVersion: 3 - serializedVersion: 3
time: 1 time: 1
value: 1 value: 0
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -15463,7 +15481,7 @@ ParticleSystem:
m_Curve: m_Curve:
- serializedVersion: 3 - serializedVersion: 3
time: 0 time: 0
value: 1 value: 0
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -15472,7 +15490,7 @@ ParticleSystem:
outWeight: 0.33333334 outWeight: 0.33333334
- serializedVersion: 3 - serializedVersion: 3
time: 1 time: 1
value: 1 value: 0
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -15578,8 +15596,8 @@ ParticleSystem:
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
weightedMode: 0 weightedMode: 0
inWeight: 0 inWeight: 0.33333334
outWeight: 0 outWeight: 0.33333334
- serializedVersion: 3 - serializedVersion: 3
time: 1 time: 1
value: 1 value: 1
@@ -15587,8 +15605,8 @@ ParticleSystem:
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
weightedMode: 0 weightedMode: 0
inWeight: 0 inWeight: 0.33333334
outWeight: 0 outWeight: 0.33333334
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
@@ -15602,8 +15620,8 @@ ParticleSystem:
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
weightedMode: 0 weightedMode: 0
inWeight: 0 inWeight: 0.33333334
outWeight: 0 outWeight: 0.33333334
- serializedVersion: 3 - serializedVersion: 3
time: 1 time: 1
value: 1 value: 1
@@ -15611,8 +15629,8 @@ ParticleSystem:
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
weightedMode: 0 weightedMode: 0
inWeight: 0 inWeight: 0.33333334
outWeight: 0 outWeight: 0.33333334
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
@@ -15846,7 +15864,7 @@ ParticleSystem:
m_Curve: m_Curve:
- serializedVersion: 3 - serializedVersion: 3
time: 0 time: 0
value: 0 value: 1
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -15855,7 +15873,7 @@ ParticleSystem:
outWeight: 0.33333334 outWeight: 0.33333334
- serializedVersion: 3 - serializedVersion: 3
time: 1 time: 1
value: 0 value: 1
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -15899,7 +15917,7 @@ ParticleSystem:
m_Curve: m_Curve:
- serializedVersion: 3 - serializedVersion: 3
time: 0 time: 0
value: 1 value: 0
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -15908,7 +15926,7 @@ ParticleSystem:
outWeight: 0.33333334 outWeight: 0.33333334
- serializedVersion: 3 - serializedVersion: 3
time: 1 time: 1
value: 1 value: 0
inSlope: 0 inSlope: 0
outSlope: 0 outSlope: 0
tangentMode: 0 tangentMode: 0
@@ -19418,6 +19436,11 @@ ParticleSystemRenderer:
m_ReflectionProbeUsage: 0 m_ReflectionProbeUsage: 0
m_RayTracingMode: 0 m_RayTracingMode: 0
m_RayTraceProcedural: 0 m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1 m_RenderingLayerMask: 1
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
@@ -19439,6 +19462,7 @@ ParticleSystemRenderer:
m_AutoUVMaxDistance: 0.5 m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 09bf3e667692a1341a327b7560df35aa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,294 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6930818438622466647
MonoBehaviour:
m_ObjectHideFlags: 3
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: 6bd486065ce11414fa40e631affc4900, type: 3}
m_Name: ProbeVolumesOptions
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.ProbeVolumesOptions
active: 1
normalBias:
m_OverrideState: 0
m_Value: 0.05
viewBias:
m_OverrideState: 0
m_Value: 0.1
scaleBiasWithMinProbeDistance:
m_OverrideState: 0
m_Value: 0
samplingNoise:
m_OverrideState: 0
m_Value: 0.1
animateSamplingNoise:
m_OverrideState: 0
m_Value: 1
leakReductionMode:
m_OverrideState: 0
m_Value: 2
minValidDotProductValue:
m_OverrideState: 0
m_Value: 0.1
occlusionOnlyReflectionNormalization:
m_OverrideState: 0
m_Value: 1
intensityMultiplier:
m_OverrideState: 0
m_Value: 1
skyOcclusionIntensityMultiplier:
m_OverrideState: 0
m_Value: 1
worldOffset:
m_OverrideState: 0
m_Value: {x: 0, y: 0, z: 0}
--- !u!114 &-3285242745950591362
MonoBehaviour:
m_ObjectHideFlags: 3
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: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier:
active: 1
skipIterations:
m_OverrideState: 0
m_Value: 1
threshold:
m_OverrideState: 0
m_Value: 0.9
intensity:
m_OverrideState: 0
m_Value: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
clamp:
m_OverrideState: 0
m_Value: 65472
tint:
m_OverrideState: 1
m_Value: {r: 0, g: 0, b: 0, a: 1}
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
maxIterations:
m_OverrideState: 0
m_Value: 6
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dimension: 1
dirtIntensity:
m_OverrideState: 0
m_Value: 0
--- !u!114 &-2940743133789450860
MonoBehaviour:
m_ObjectHideFlags: 3
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: a074ec59f6e910b4e8c49f57e56cf95a, type: 3}
m_Name: VolumetricFogVolumeComponent
m_EditorClassIdentifier:
active: 1
distance:
m_OverrideState: 0
m_Value: 64
baseHeight:
m_OverrideState: 0
m_Value: 0
maximumHeight:
m_OverrideState: 0
m_Value: 50
enableGround:
m_OverrideState: 0
m_Value: 0
groundHeight:
m_OverrideState: 0
m_Value: 0
density:
m_OverrideState: 0
m_Value: 0.2
attenuationDistance:
m_OverrideState: 0
m_Value: 128
enableAPVContribution:
m_OverrideState: 0
m_Value: 0
APVContributionWeight:
m_OverrideState: 0
m_Value: 1
enableMainLightContribution:
m_OverrideState: 0
m_Value: 0
anisotropy:
m_OverrideState: 0
m_Value: 0.4
scattering:
m_OverrideState: 0
m_Value: 0.15
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
enableAdditionalLightsContribution:
m_OverrideState: 0
m_Value: 0
maxSteps:
m_OverrideState: 0
m_Value: 128
blurIterations:
m_OverrideState: 0
m_Value: 2
enabled:
m_OverrideState: 0
m_Value: 0
renderPassEvent:
m_OverrideState: 0
m_Value: 550
--- !u!114 &-2307326953841441124
MonoBehaviour:
m_ObjectHideFlags: 3
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: 97c23e3b12dc18c42a140437e53d3951, type: 3}
m_Name: Tonemapping
m_EditorClassIdentifier:
active: 1
mode:
m_OverrideState: 1
m_Value: 2
neutralHDRRangeReductionMode:
m_OverrideState: 0
m_Value: 2
acesPreset:
m_OverrideState: 0
m_Value: 3
hueShiftAmount:
m_OverrideState: 0
m_Value: 0
detectPaperWhite:
m_OverrideState: 0
m_Value: 0
paperWhite:
m_OverrideState: 0
m_Value: 300
detectBrightnessLimits:
m_OverrideState: 0
m_Value: 1
minNits:
m_OverrideState: 0
m_Value: 0.005
maxNits:
m_OverrideState: 0
m_Value: 1000
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Default
m_EditorClassIdentifier:
components:
- {fileID: -2940743133789450860}
- {fileID: -3285242745950591362}
- {fileID: 531387521984870518}
- {fileID: -2307326953841441124}
- {fileID: 4550874325240702303}
- {fileID: -6930818438622466647}
- {fileID: 6698165480939181587}
--- !u!114 &531387521984870518
MonoBehaviour:
m_ObjectHideFlags: 3
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: 66f335fb1ffd8684294ad653bf1c7564, type: 3}
m_Name: ColorAdjustments
m_EditorClassIdentifier:
active: 1
postExposure:
m_OverrideState: 0
m_Value: 0
contrast:
m_OverrideState: 0
m_Value: 0
colorFilter:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
hueShift:
m_OverrideState: 0
m_Value: 0
saturation:
m_OverrideState: 0
m_Value: 0
--- !u!114 &4550874325240702303
MonoBehaviour:
m_ObjectHideFlags: 3
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: 221518ef91623a7438a71fef23660601, type: 3}
m_Name: WhiteBalance
m_EditorClassIdentifier:
active: 1
temperature:
m_OverrideState: 0
m_Value: 0
tint:
m_OverrideState: 0
m_Value: 0
--- !u!114 &6698165480939181587
MonoBehaviour:
m_ObjectHideFlags: 3
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: ccf1aba9553839d41ae37dd52e9ebcce, type: 3}
m_Name: MotionBlur
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.MotionBlur
active: 1
mode:
m_OverrideState: 0
m_Value: 0
quality:
m_OverrideState: 0
m_Value: 0
intensity:
m_OverrideState: 1
m_Value: 0
clamp:
m_OverrideState: 0
m_Value: 0.05

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 25c4b60273b147748b67dfd9bd7a6a4d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -75,8 +75,8 @@ MonoBehaviour:
m_OverrideState: 0 m_OverrideState: 0
m_Value: 65472 m_Value: 65472
tint: tint:
m_OverrideState: 0 m_OverrideState: 1
m_Value: {r: 1, g: 1, b: 1, a: 1} m_Value: {r: 0, g: 0, b: 0, a: 1}
highQualityFiltering: highQualityFiltering:
m_OverrideState: 0 m_OverrideState: 0
m_Value: 0 m_Value: 0
@@ -261,7 +261,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c01700fd266d6914ababb731e09af2eb, type: 3} m_Script: {fileID: 11500000, guid: c01700fd266d6914ababb731e09af2eb, type: 3}
m_Name: DepthOfField m_Name: DepthOfField
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.DepthOfField m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.DepthOfField
active: 1 active: 0
mode: mode:
m_OverrideState: 1 m_OverrideState: 1
m_Value: 1 m_Value: 1

View File

@@ -616,7 +616,8 @@ PrefabInstance:
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects:
- {fileID: 8780852774427548101, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3}
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3} m_SourcePrefab: {fileID: 100100000, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3}

View File

@@ -1,5 +1,5 @@
--- ---
alwaysApply: true alwaysApply: false
--- ---
## RIPER-5 + O1 思维 + 代理执行协议 ## RIPER-5 + O1 思维 + 代理执行协议

View File

@@ -1,4 +1,4 @@
using Demo.Attr; using Demo.Game.Attr;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
[CustomEditor(typeof(Demo.ScriptableObject), true)] [CustomEditor(typeof(Demo.Game.ScriptableObject), true)]
public class SOEditor : Convention.AbstractCustomEditor public class SOEditor : Convention.AbstractCustomEditor
{ {

View File

@@ -1,10 +1,52 @@
using Demo.Attr; using Convention;
using Demo.Game.Attr;
using Demo.Game.ConfigType;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class PrefabRootObjectConfig : ScriptLoadableConfig
{
public Dictionary<string, List<string>> LoadedGameObjectNames = new();
public override void Deserialize(BinaryReader reader)
{
int count = BinarySerializeUtility.ReadInt(reader);
for (; count > 0;count--)
{
var temp = BinarySerializeUtility.DeserializeStringArray(reader);
var key = temp[0];
var value = temp[1..];
LoadedGameObjectNames.Add(key, value.ToList());
}
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, LoadedGameObjectNames.Count);
foreach (var (key,value) in LoadedGameObjectNames)
{
string[] temp = new string[value.Count + 1];
temp[0] = key;
for(int i=0,e=value.Count;i<e;i++)
{
temp[1 + i] = value[i];
}
BinarySerializeUtility.SerializeArray(writer, value.ToArray());
}
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class PrefabRootObject : ScriptableObject, IAssetBundleLoader public class PrefabRootObject : ScriptableObject, IAssetBundleLoader
{ {
@@ -13,15 +55,26 @@ namespace Demo.Game
return new GameObject().AddComponent<PrefabRootObject>(); return new GameObject().AddComponent<PrefabRootObject>();
} }
private readonly List<string> AssetBundles = new(); private int LoadingCounter = 0;
private readonly List<GameObject> Prefabs = new(); private Dictionary<string, List<string>> LoadedGameObjectNames => GetConfig<PrefabRootObjectConfig>().LoadedGameObjectNames;
private readonly List<GameObject> LoadedGameObjects = new();
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
yield return new WaitUntil(() => LoadingCounter == 0);
}
public override IEnumerator UnloadScript() public override IEnumerator UnloadScript()
{ {
yield return base.UnloadScript(); yield return base.UnloadScript();
foreach (var ab in AssetBundles) foreach (var obj in LoadedGameObjects)
{ {
yield return this.UnloadAssetBundle(ab); Destroy(obj);
}
foreach (var item in LoadedGameObjectNames)
{
yield return this.UnloadAssetBundle(item.Key);
} }
} }
@@ -31,31 +84,27 @@ namespace Demo.Game
/// <param name="ab"></param> /// <param name="ab"></param>
/// <param name="prefab"></param> /// <param name="prefab"></param>
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public IEnumerator Load(string ab, string prefab) public void Load(string ab, string prefab)
{
LoadingCounter++;
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, assetBundle =>
{ {
AssetBundle assetBundle = null;
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
GameObject prefabObject = null; GameObject prefabObject = null;
if (assetBundle != null) if (assetBundle != null)
{ {
var ir = assetBundle.LoadAssetAsync<GameObject>(prefab); prefabObject = Instantiate(assetBundle.LoadAsset<GameObject>(prefab));
yield return ir; LoadedGameObjects.Add(prefabObject);
if (ir.asset != null)
{
prefabObject = Instantiate(ir.asset as GameObject);
Prefabs.Add(prefabObject);
prefabObject.transform.SetParent(transform); prefabObject.transform.SetParent(transform);
AssetBundles.Add(ab); if (LoadedGameObjectNames.ContainsKey(ab) == false)
} LoadedGameObjectNames.Add(ab, new());
else LoadedGameObjectNames[ab].Add(prefab);
{
Debug.LogError($"Load Prefab failed", this);
}
} }
else else
{ {
Debug.LogError($"Load AssetBundle failed", this); Debug.LogError($"Load AssetBundle failed", this);
} }
LoadingCounter--;
}));
} }
} }
} }

View File

@@ -1,24 +1,93 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using Demo.Game.ConfigType;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class SkyUpdatementConfig : UpdatementIntConfig
{
public string SkyAssetBundlePath;
public string[] SkyNames;
public int[] SkyIndexs;
public override void Deserialize(BinaryReader reader)
{
SkyAssetBundlePath = BinarySerializeUtility.ReadString(reader);
SkyNames = BinarySerializeUtility.DeserializeStringArray(reader);
SkyIndexs = BinarySerializeUtility.DeserializeIntArray(reader);
base.Deserialize(reader);
var sky = (SkyUpdatement)target;
sky.Load(SkyAssetBundlePath);
for (int i = 0, e = SkyNames.Length; i < e; i++)
{
sky.NameCache.Add(SkyNames[i], SkyIndexs[i]);
sky.IndexCache.Add(SkyIndexs[i], SkyNames[i]);
sky.SkyAssetBundleLoaderStatus++;
IEnumerator Foo()
{
yield return new WaitUntil(() => sky.SkyAssetBundle != null);
var ir = sky.SkyAssetBundle.LoadAssetAsync<Material>(SkyNames[i]);
ir.completed += delegate
{
var mat = ir.asset as Material;
sky.MaterialCache[SkyIndexs[i]] = mat;
sky.SkyAssetBundleLoaderStatus--;
};
yield return ir;
}
ConventionUtility.StartCoroutine(Foo());
}
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteString(writer, SkyAssetBundlePath);
var sky = (SkyUpdatement)target;
int e = sky.NameCache.Count;
SkyNames =new string[e];
SkyIndexs=new int[e];
int i = 0;
foreach (var item in sky.NameCache)
{
SkyNames[i] = item.Key;
SkyIndexs[i] = item.Value;
}
BinarySerializeUtility.SerializeArray(writer, SkyNames);
BinarySerializeUtility.SerializeArray(writer, SkyIndexs);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class SkyUpdatement : Updatement<int>, IAssetBundleLoader public class SkyUpdatement : Updatement<int>, IAssetBundleLoader
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new SkyUpdatementConfig();
}
public static SkyUpdatement Make() public static SkyUpdatement Make()
{ {
return new GameObject().AddComponent<SkyUpdatement>(); return new GameObject().AddComponent<SkyUpdatement>();
} }
private int SkyAssetBundleLoaderStatus = 0; internal int SkyAssetBundleLoaderStatus = 0;
private readonly Dictionary<string, int> NameCache = new(); internal readonly Dictionary<string, int> NameCache = new();
private readonly Dictionary<int, Material> MaterialCache = new(); internal readonly Dictionary<int, string> IndexCache = new();
internal readonly Dictionary<int, Material> MaterialCache = new();
public string SkyAssetBundlePath; public string SkyAssetBundlePath
{
get => GetConfig<SkyUpdatementConfig>().SkyAssetBundlePath;
set => GetConfig<SkyUpdatementConfig>().SkyAssetBundlePath = value;
}
public AssetBundle SkyAssetBundle; public AssetBundle SkyAssetBundle;
protected override int Lerp(int begin, int end, float t) protected override int Lerp(int begin, int end, float t)
@@ -92,6 +161,7 @@ namespace Demo.Game
{ {
id = NameCache.Count; id = NameCache.Count;
NameCache[sky] = id; NameCache[sky] = id;
IndexCache[id] = sky;
} }
MaterialCache[id] = mat; MaterialCache[id] = mat;
ManualAddEntry(time, id, default); ManualAddEntry(time, id, default);

View File

@@ -1,7 +1,6 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game

View File

@@ -6,14 +6,117 @@ using Cinemachine;
#endif #endif
using Convention.WindowsUI.Variant; using Convention.WindowsUI.Variant;
using UnityEngine; using UnityEngine;
using Demo.Attr; using Demo.Game.Attr;
using System.IO;
using Convention;
using Demo.Game.ConfigType;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class CameraObjectConfig : ScriptLoadableConfig
{
public bool IsSetupOrthographic = false;
public bool orthographic;
public bool IsSetupFieldOfView = false;
public float fieldOfView;
public bool IsSetupOrthographicSize = false;
public float orthographicSize;
public bool IsSetupNearClipPlane = false;
public float nearClipPlane;
public bool IsSetupFarClipPlane = false;
public float farClipPlane;
public bool IsSetupDepth = false;
public float depth;
public bool IsSetupVirtualCameraFollow = false;
public int VirtualCameraFollow;
public bool IsSetupVirtualCameraLookAt = false;
public int VirtualCameraLookAt;
public bool IsSetupVirtualCameraFollowOffset = false;
public Vector3 VirtualCameraFollowOffset;
public bool IsSetupVirtualCameraLookAtDamping = false;
public Vector3 VirtualCameraLookAtDamping;
public override void Deserialize(BinaryReader reader)
{
IsSetupOrthographic =BinarySerializeUtility.ReadBool(reader);
orthographic = BinarySerializeUtility.ReadBool(reader);
IsSetupFieldOfView = BinarySerializeUtility.ReadBool(reader);
fieldOfView = BinarySerializeUtility.ReadFloat(reader);
IsSetupOrthographicSize = BinarySerializeUtility.ReadBool(reader);
orthographicSize = BinarySerializeUtility.ReadFloat(reader);
IsSetupNearClipPlane = BinarySerializeUtility.ReadBool(reader);
nearClipPlane = BinarySerializeUtility.ReadFloat(reader);
IsSetupFarClipPlane = BinarySerializeUtility.ReadBool(reader);
farClipPlane = BinarySerializeUtility.ReadFloat(reader);
IsSetupDepth = BinarySerializeUtility.ReadBool(reader);
depth = BinarySerializeUtility.ReadFloat(reader);
IsSetupVirtualCameraFollow = BinarySerializeUtility.ReadBool(reader);
VirtualCameraFollow = BinarySerializeUtility.ReadInt(reader);
IsSetupVirtualCameraLookAt = BinarySerializeUtility.ReadBool(reader);
VirtualCameraLookAt = BinarySerializeUtility.ReadInt(reader);
IsSetupVirtualCameraFollowOffset = BinarySerializeUtility.ReadBool(reader);
VirtualCameraFollowOffset = BinarySerializeUtility.ReadVec3(reader);
IsSetupVirtualCameraLookAtDamping = BinarySerializeUtility.ReadBool(reader);
VirtualCameraLookAtDamping = BinarySerializeUtility.ReadVec3(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteBool(writer, IsSetupOrthographic);
BinarySerializeUtility.WriteBool(writer, orthographic);
BinarySerializeUtility.WriteBool(writer, IsSetupFieldOfView);
BinarySerializeUtility.WriteFloat(writer, fieldOfView);
BinarySerializeUtility.WriteBool(writer, IsSetupOrthographicSize);
BinarySerializeUtility.WriteFloat(writer, orthographicSize);
BinarySerializeUtility.WriteBool(writer, IsSetupNearClipPlane);
BinarySerializeUtility.WriteFloat(writer, nearClipPlane);
BinarySerializeUtility.WriteBool(writer, IsSetupFarClipPlane);
BinarySerializeUtility.WriteFloat(writer, farClipPlane);
BinarySerializeUtility.WriteBool(writer, IsSetupDepth);
BinarySerializeUtility.WriteFloat(writer, depth);
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraFollow);
BinarySerializeUtility.WriteInt(writer, VirtualCameraFollow);
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraLookAt);
BinarySerializeUtility.WriteInt(writer,VirtualCameraLookAt);
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraFollowOffset);
BinarySerializeUtility.WriteVec3(writer, VirtualCameraFollowOffset);
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraLookAtDamping);
BinarySerializeUtility.WriteVec3(writer, VirtualCameraLookAtDamping);
base.Serialize(writer);
}
}
}
[Scriptable(nameof(MakeCameraObject))] [Scriptable(nameof(MakeCameraObject))]
public class CameraObject : ScriptableObject public class CameraObject : ScriptableObject
{ {
private Camera MainCamera => Camera.main; protected override ScriptLoadableConfig MakeConfig()
{
return new CameraObjectConfig();
}
internal Camera MainCamera => Camera.main;
private CinemachineCamera m_VirtualCamera; private CinemachineCamera m_VirtualCamera;
private CinemachineCamera VirtualCamera private CinemachineCamera VirtualCamera
{ {
@@ -51,7 +154,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetOrthographic(bool orthographic) public void SetOrthographic(bool orthographic)
{ {
MainCamera.orthographic = orthographic; GetConfig<CameraObjectConfig>().IsSetupOrthographic = true;
GetConfig<CameraObjectConfig>().orthographic = MainCamera.orthographic = orthographic;
} }
/// <summary> /// <summary>
@@ -60,7 +164,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetFieldOfView(float fieldOfView) public void SetFieldOfView(float fieldOfView)
{ {
MainCamera.fieldOfView = fieldOfView; GetConfig<CameraObjectConfig>().IsSetupFieldOfView = true;
GetConfig<CameraObjectConfig>().fieldOfView = MainCamera.fieldOfView = fieldOfView;
} }
/// <summary> /// <summary>
@@ -69,7 +174,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetOrthographicSize(float orthographicSize) public void SetOrthographicSize(float orthographicSize)
{ {
MainCamera.orthographicSize = orthographicSize; GetConfig<CameraObjectConfig>().IsSetupOrthographicSize = true;
GetConfig<CameraObjectConfig>().orthographicSize = MainCamera.orthographicSize = orthographicSize;
} }
/// <summary> /// <summary>
@@ -78,7 +184,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetNearClipPlane(float nearClipPlane) public void SetNearClipPlane(float nearClipPlane)
{ {
MainCamera.nearClipPlane = nearClipPlane; GetConfig<CameraObjectConfig>().IsSetupNearClipPlane = true;
GetConfig<CameraObjectConfig>().nearClipPlane = MainCamera.nearClipPlane = nearClipPlane;
} }
/// <summary> /// <summary>
@@ -87,7 +194,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetFarClipPlane(float farClipPlane) public void SetFarClipPlane(float farClipPlane)
{ {
MainCamera.farClipPlane = farClipPlane; GetConfig<CameraObjectConfig>().IsSetupFarClipPlane = true;
GetConfig<CameraObjectConfig>().farClipPlane = MainCamera.farClipPlane = farClipPlane;
} }
/// <summary> /// <summary>
@@ -96,7 +204,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetDepth(float depth) public void SetDepth(float depth)
{ {
MainCamera.depth = depth; GetConfig<CameraObjectConfig>().IsSetupDepth = true;
GetConfig<CameraObjectConfig>().depth = MainCamera.depth = depth;
} }
/// <summary> /// <summary>
@@ -105,6 +214,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetVirtualCameraFollow(ScriptableObject target) public void SetVirtualCameraFollow(ScriptableObject target)
{ {
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraFollow = true;
GetConfig<CameraObjectConfig>().VirtualCameraFollow = GetRoot().FindIndex(target);
VirtualCamera.Follow = target.transform; VirtualCamera.Follow = target.transform;
} }
@@ -114,6 +225,8 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetVirtualCameraLookAt(ScriptableObject target) public void SetVirtualCameraLookAt(ScriptableObject target)
{ {
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraLookAt = true;
GetConfig<CameraObjectConfig>().VirtualCameraLookAt = GetRoot().FindIndex(target);
VirtualCamera.LookAt = target.transform; VirtualCamera.LookAt = target.transform;
} }
@@ -129,28 +242,12 @@ namespace Demo.Game
var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow; var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow;
if (body != null) if (body != null)
{ {
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraFollowOffset = true;
GetConfig<CameraObjectConfig>().VirtualCameraFollowOffset = new Vector3(x, y, z);
body.FollowOffset = new Vector3(x, y, z); body.FollowOffset = new Vector3(x, y, z);
} }
} }
/// <summary>
/// 设置虚拟相机跟随阻尼
/// </summary>
/// <param name="x">X轴阻尼</param>
/// <param name="y">Y轴阻尼</param>
/// <param name="z">Z轴阻尼</param>
//[Convention.RScript.Variable.Attr.Method]
//public void SetVirtualCameraFollowDamping(float x, float y, float z)
//{
// var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow;
// if (body != null)
// {
// body.XDamping = x;
// body.YDamping = y;
// body.ZDamping = z;
// }
//}
/// <summary> /// <summary>
/// 设置虚拟相机观察阻尼 /// 设置虚拟相机观察阻尼
/// </summary> /// </summary>
@@ -163,6 +260,8 @@ namespace Demo.Game
var aim = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineRotationComposer; var aim = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineRotationComposer;
if (aim != null) if (aim != null)
{ {
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraLookAtDamping = true;
GetConfig<CameraObjectConfig>().VirtualCameraLookAtDamping = new Vector3(x, y, z);
aim.Damping = new(x, y); aim.Damping = new(x, y);
} }
} }

View File

@@ -1,8 +1,7 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.IO; using System.IO;
using Unity.Collections; using Unity.Collections;
using UnityEngine; using UnityEngine;
@@ -10,25 +9,53 @@ using UnityEngine.Rendering;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class DDTConfig : ScriptLoadableConfig
{
[Content] public NativeArray<float> Datas = new(128, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
[Content] public int Count = 0;
public override void Deserialize(BinaryReader reader)
{
BinarySerializeUtility.DeserializeNativeArray(reader, ref Datas);
Count = Datas.Length;
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
var newArray = new NativeArray<float>(Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
NativeArray<float>.Copy(Datas, newArray, Count);
Datas = newArray;
BinarySerializeUtility.SerializeNativeArray(writer, Datas);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class DDT : ScriptableObject public class DDT : ScriptableObject
{ {
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new ConfigType.DDTConfig();
}
protected override bool IsSelfEnableUpdate => false; protected override bool IsSelfEnableUpdate => false;
public static DDT Make() public static DDT Make()
{ {
return new GameObject().AddComponent<DDT>(); return new GameObject().AddComponent<DDT>();
} }
public NativeArray<float> Datas = new(128, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
public int Count { get; private set; } = 0;
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void Add(float value) public void Add(float value)
{ {
if (Count >= Datas.Length) int Count = GetConfig<ConfigType.DDTConfig>().Count;
Datas.ResizeArray(Mathf.FloorToInt(Count * 1.5f)); if (Count >= GetConfig<ConfigType.DDTConfig>().Datas.Length)
Datas[Count] = value; GetConfig<ConfigType.DDTConfig>().Datas.ResizeArray(Mathf.FloorToInt(Count * 1.5f));
Count++; GetConfig<ConfigType.DDTConfig>().Datas[Count] = value;
GetConfig<ConfigType.DDTConfig>().Count++;
} }
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
@@ -40,27 +67,24 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public float At(int index) public float At(int index)
{ {
int Count = GetConfig<ConfigType.DDTConfig>().Count;
if (index < 0) if (index < 0)
index = Count + index; index = Count + index;
if (index < 0 || index >= Count) if (index < 0 || index >= Count)
throw new IndexOutOfRangeException($"{index} is out of [0, {Count})"); throw new IndexOutOfRangeException($"{index} is out of [0, {Count})");
return Datas[index]; return GetConfig<ConfigType.DDTConfig>().Datas[index];
} }
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
/// </summary>
/// <returns></returns>
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public int GetCount() public int GetCount()
{ {
return Count; return GetConfig<ConfigType.DDTConfig>().Count;
} }
private void OnDestroy() private void OnDestroy()
{ {
if (Datas.IsCreated) if (GetConfig<ConfigType.DDTConfig>().Datas.IsCreated)
Datas.Dispose(); GetConfig<ConfigType.DDTConfig>().Datas.Dispose();
} }
#region Serialize #region Serialize
@@ -71,36 +95,25 @@ namespace Demo.Game
yield return this.ParseScript2Expr(scriptFile.LoadAsText()); yield return this.ParseScript2Expr(scriptFile.LoadAsText());
using var stream = File.OpenWrite(cacheFile.GetFullPath()); using var stream = File.OpenWrite(cacheFile.GetFullPath());
using var writer = new BinaryWriter(stream); using var writer = new BinaryWriter(stream);
writer.Write(Count); writer.Write(GetConfig<ConfigType.DDTConfig>().Count);
for (int i = 0; i < Count; i++) for (int i = 0, e = GetConfig<ConfigType.DDTConfig>().Count; i < e; i++)
{ {
writer.Write(Datas[i]); writer.Write(GetConfig<ConfigType.DDTConfig>().Datas[i]);
} }
} }
protected override IEnumerator LoadFromImptCacheFile(ToolFile cacheFile) protected override IEnumerator LoadFromImptCacheFile(ToolFile cacheFile)
{ {
using var stream = File.OpenRead(cacheFile.GetFullPath()); using var stream = File.OpenRead(cacheFile.GetFullPath());
using var reader = new BinaryReader(stream); using var reader = new BinaryReader(stream);
Count = reader.ReadInt32(); GetConfig<ConfigType.DDTConfig>().Count = reader.ReadInt32();
Datas.ResizeArray(Mathf.Max(128, Count)); GetConfig<ConfigType.DDTConfig>().Datas.ResizeArray(Mathf.Max(128, GetConfig<ConfigType.DDTConfig>().Count));
for (int i = 0; i < Count; i++) for (int i = 0, e = GetConfig<ConfigType.DDTConfig>().Count; i < e; i++)
{ {
Datas[i] = reader.ReadSingle(); GetConfig<ConfigType.DDTConfig>().Datas[i] = reader.ReadSingle();
} }
yield break; yield break;
} }
#endregion #endregion
#if UNITY_EDITOR
[Setting, SerializeField] private List<float> d_Datas = new();
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
for (int i = 0; i < Count; i++)
d_Datas.Add(Datas[i]);
}
#endif
} }
} }

View File

@@ -59,7 +59,7 @@ namespace Demo.Editor
{ {
foreach (var type in asm.GetTypes()) foreach (var type in asm.GetTypes())
{ {
if (typeof(ScriptableObject).IsAssignableFrom(type) && type.IsAbstract == false) if (typeof(Demo.Game.ScriptableObject).IsAssignableFrom(type) && type.IsAbstract == false)
{ {
result.Add(type.Name, type); result.Add(type.Name, type);
} }
@@ -378,6 +378,7 @@ namespace Demo.Editor
private void RegisterVariableGenerater() private void RegisterVariableGenerater()
{ {
// Generate Framework // Generate Framework
Debug.Log(nameof(RegisterVariableGenerater), this);
var generaters = DefaultInstantiate.GetScriptableObjectInstantiate(); var generaters = DefaultInstantiate.GetScriptableObjectInstantiate();
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{ {
@@ -390,7 +391,7 @@ namespace Demo.Editor
{ {
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, () => generater(), null, filename).Register(); new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, () => generater(), null, filename).Register();
} }
else if (typeof(ScriptableObject).IsAssignableFrom(type)) else if (typeof(Demo.Game.ScriptableObject).IsAssignableFrom(type))
{ {
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, null, null, filename).Register(); new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, null, null, filename).Register();
} }
@@ -420,7 +421,7 @@ namespace Demo.Editor
helperHeaderDir.MustExistsPath(); helperHeaderDir.MustExistsPath();
foreach (var (name, variable) in Convention.RScript.Variable.RScriptInjectVariableGenerater.AllRScriptInjectVariables) foreach (var (name, variable) in Convention.RScript.Variable.RScriptInjectVariableGenerater.AllRScriptInjectVariables)
{ {
(helperHeaderDir | name).SaveAsText(variable.scriptIndicator); (helperHeaderDir | name.Replace('<', '[').Replace('>', ']')).SaveAsText(variable.scriptIndicator);
} }
// Reset // Reset

View File

@@ -1,10 +1,9 @@
using Convention;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Convention;
using Unity.Cinemachine; using Unity.Cinemachine;
using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
@@ -52,8 +51,101 @@ namespace Demo.Game
[Header("Environment")] [Header("Environment")]
[Resources] public Transform GlobalLight; [Resources] public Transform GlobalLight;
private bool IsGameLoading = false;
private IEnumerator LoadWithRecompile(RootObject rootGameObject,
ToolFile rootObject,
Dictionary<string, string> projectHash,
ToolFile projectHashFile,
ToolFile cacheDir)
{
static IEnumerator Foo(IEnumerator ir)
{
Stack<IEnumerator> loadingTask = new();
loadingTask.Push(ir);
while (loadingTask.Count > 0)
{
if (loadingTask.Peek().MoveNext())
{
if (loadingTask.Peek().Current is IEnumerator next)
loadingTask.Push(next);
else if (loadingTask.Peek().Current is ScriptableObject)
yield return null;
}
else
{
loadingTask.Pop();
}
}
yield break;
}
yield return ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject));
int applyDownCount = 0;
void NDFS(ScriptableObject current)
{
foreach (var child in current.Childs)
{
NDFS(child);
}
if (current.IsScriptApply == false)
{
applyDownCount++;
IEnumerator NDFSFoo()
{
yield return current.ApplyScript();
current.ResetEnterGameStatus();
applyDownCount--;
}
ConventionUtility.StartCoroutine(NDFSFoo());
}
}
NDFS(rootGameObject);
yield return new WaitUntil(() => applyDownCount == 0);
projectHash.Clear();
foreach (var path in rootGameObject.LoadedScriptSet)
{
projectHash.Add(path, new ToolFile(path).CalculateHash());
}
// 哈希缓存
projectHashFile.SaveAsJson(projectHash);
// 编译结果
var projectBinaryFile = cacheDir | "project.dat";
using var stream = new FileInfo(projectBinaryFile).OpenWrite();
using var writer = new BinaryWriter(stream);
rootGameObject.Config.Serialize(writer);
}
private IEnumerator LoadFromCompiled(RootObject rootGameObject, ToolFile cacheDir)
{
// 加载
var projectBinaryFile = cacheDir | "project.dat";
using var stream = new FileInfo(projectBinaryFile).OpenRead();
using var reader = new BinaryReader(stream);
rootGameObject.Config.Deserialize(reader);
int applyDownCount = 0;
void NDFS(ScriptableObject current)
{
foreach (var child in current.Childs)
{
NDFS(child);
}
if (current.IsScriptApply == false)
{
applyDownCount++;
IEnumerator NDFSFoo()
{
yield return current.ApplyScript();
current.ResetEnterGameStatus();
applyDownCount--;
}
ConventionUtility.StartCoroutine(NDFSFoo());
}
}
NDFS(rootGameObject);
yield return new WaitUntil(() => applyDownCount == 0);
}
public IEnumerator GameInit() public IEnumerator GameInit()
{ {
IsGameLoading = true;
float gameInitStartTime = Time.realtimeSinceStartup; float gameInitStartTime = Time.realtimeSinceStartup;
try try
{ {
@@ -200,46 +292,43 @@ namespace Demo.Game
var rootFileName = (string)MainConfig.FindItem("root"); var rootFileName = (string)MainConfig.FindItem("root");
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName)); var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
rootObject.MustExistsPath(); rootObject.MustExistsPath();
// 缓存MD5与重编译检查
var rootObjectDir = rootObject.GetParentDir();
ToolFile cacheDir = rootObjectDir | ".cache";
var projectHashFile = cacheDir | "projectHash.json";
Dictionary<string, string> projectHash = new();
bool isRecompile = true;
if (!!projectHashFile)
{
projectHash = projectHashFile.LoadAsJson<Dictionary<string, string>>();
foreach (var (file, md5) in projectHash)
{
var scriptFile = new ToolFile(file);
if (scriptFile.Exists() == false || scriptFile.CalculateHash() != md5)
{
isRecompile = true;
break;
}
}
}
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>(); var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
MainObject = rootGameObject; MainObject = rootGameObject;
rootGameObject.transform.SetParent(transform); rootGameObject.transform.SetParent(transform);
rootGameObject.ScriptName = rootObject.GetName(true); rootGameObject.ScriptName = rootObject.GetName(true);
rootGameObject.audioSystem = MainAudio; rootGameObject.audioSystem = MainAudio;
rootGameObject.LoadedScriptSet.Add(rootObject);
rootGameObject.EnableScript(content.RootSourceDir, this); rootGameObject.EnableScript(content.RootSourceDir, this);
rootGameObject.SetContent(nameof(SongOffset), SongOffset); rootGameObject.SetContent(nameof(SongOffset), SongOffset);
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0); rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length); rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
static IEnumerator Foo(IEnumerator ir) if (isRecompile)
{ {
Stack<IEnumerator> loadingTask = new(); yield return LoadWithRecompile(rootGameObject, rootObject, projectHash, projectHashFile, cacheDir);
loadingTask.Push(ir);
while (loadingTask.Count > 0)
{
if (loadingTask.Peek().MoveNext())
{
if (loadingTask.Peek().Current is IEnumerator next)
loadingTask.Push(next);
else if (loadingTask.Peek().Current is ScriptableObject)
yield return null;
} }
else else
{ {
loadingTask.Pop(); yield return LoadFromCompiled(rootGameObject, cacheDir);
} }
}
yield break;
}
yield return Foo(rootGameObject.ParseFromScriptFile2Expr(rootObject));//ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject));
static void NDFS(ScriptableObject current)
{
foreach (var child in current.Childs)
{
NDFS(child);
}
if (current.IsScriptApply == false)
ConventionUtility.StartCoroutine(current.ApplyScript());
}
NDFS(rootGameObject);
float loadRootObjectEndTime = Time.realtimeSinceStartup; float loadRootObjectEndTime = Time.realtimeSinceStartup;
float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f; float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f;
Debug.Log($"[GameInit] Load Root Object 耗时: {loadRootObjectElapsed:F2} ms", this); Debug.Log($"[GameInit] Load Root Object 耗时: {loadRootObjectElapsed:F2} ms", this);
@@ -250,6 +339,7 @@ namespace Demo.Game
MainConfig.SaveProperties(); MainConfig.SaveProperties();
float gameInitEndTime = Time.realtimeSinceStartup; float gameInitEndTime = Time.realtimeSinceStartup;
float gameInitElapsed = (gameInitEndTime - gameInitStartTime) * 1000f; float gameInitElapsed = (gameInitEndTime - gameInitStartTime) * 1000f;
IsGameLoading = false;
Debug.Log($"[GameInit] 总耗时: {gameInitElapsed:F2} ms", this); Debug.Log($"[GameInit] 总耗时: {gameInitElapsed:F2} ms", this);
} }
} }
@@ -266,7 +356,8 @@ namespace Demo.Game
{ {
yield return null; yield return null;
IsEnableUpdate = true; IsEnableUpdate = true;
yield return new WaitUntil(() => MainObject != null); yield return new WaitUntil(() => MainObject != null && IsGameLoading == false);
yield return null;
MainObject.ScriptUpdate(SongOffset, Time.deltaTime, ScriptableObject.TickType.Reset); MainObject.ScriptUpdate(SongOffset, Time.deltaTime, ScriptableObject.TickType.Reset);
} }

View File

@@ -3,6 +3,8 @@ using Convention.WindowsUI.Variant;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
@@ -16,7 +18,56 @@ namespace Demo.Game
[Content] public GameController RootGameController; [Content] public GameController RootGameController;
public string SourcePath; [Setting] public string SourcePath;
[Header("GlobalConfig")]
public readonly HashSet<string> LoadedScriptSet = new();
public readonly Dictionary<int, ScriptableObject> LoadedScriptIndex = new();
public readonly Dictionary<ScriptableObject, int> LoadedScriptRIndex = new();
private int LoadedScriptCnt = 0;
/// <summary>
/// 被用于自动生成
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public int PushLoadedScriptObject(ScriptableObject obj)
{
while (LoadedScriptIndex.TryAdd(LoadedScriptCnt, obj) == false)
LoadedScriptCnt++;
LoadedScriptRIndex.Add(obj, LoadedScriptCnt);
return LoadedScriptCnt++;
}
/// <summary>
/// 被用于从缓存中生成
/// </summary>
/// <param name="obj"></param>
/// <param name="index"></param>
/// <returns></returns>
public int PushLoadedScriptObject(ScriptableObject obj, int index)
{
LoadedScriptIndex.Add(index, obj);
LoadedScriptRIndex.Add(obj, index);
return index;
}
/// <summary>
/// 通过序列号获得物体
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public ScriptableObject FindWithIndex(int index)
{
if (index < 0)
return null;
return LoadedScriptIndex[index];
}
/// <summary>
/// 通过物体获得序列号
/// </summary>
/// <param name="obj"></param>
/// <returns>若无法找到将返回-1</returns>
public int FindIndex(ScriptableObject obj)
{
return LoadedScriptRIndex.TryGetValue(obj, out var index) ? index : -1;
}
protected override IEnumerator DoSomethingDuringApplyScript() protected override IEnumerator DoSomethingDuringApplyScript()
{ {

View File

@@ -1,19 +1,15 @@
using Convention; using Convention;
using Convention.RScript;
using Convention.WindowsUI.Variant; using Convention.WindowsUI.Variant;
using Demo.Attr;
using Demo.Game;
using Dreamteck.Splines;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Unity.VisualScripting; using Unity.Collections;
using UnityEngine; using UnityEngine;
namespace Demo namespace Demo.Game
{ {
public interface IScriptableObject public interface IScriptableObject
{ {
@@ -36,6 +32,63 @@ namespace Demo
} }
} }
namespace ConfigType
{
[Serializable]
public class ScriptLoadableConfig
{
[Content] public int UID = -1;
[Content] public Vector3 EnterGameLocalPosition = Vector3.zero, EnterGameEulerAngles = Vector3.zero, EnterGameLocalScaling = Vector3.one;
[Content] public bool IsSetObjectDisable = false;
[Content] public int UpdatePerFrame = 1;
private int[] ChildTypes = null;
private string[] ChildNames = null;
private ScriptLoadableConfig[] childs = null;
[Setting] public ScriptableObject target;
public virtual void Deserialize(BinaryReader reader)
{
UID = BinarySerializeUtility.ReadInt(reader);
EnterGameLocalPosition = BinarySerializeUtility.ReadVec3(reader);
EnterGameEulerAngles = BinarySerializeUtility.ReadVec3(reader);
EnterGameLocalScaling = BinarySerializeUtility.ReadVec3(reader);
IsSetObjectDisable = BinarySerializeUtility.ReadBool(reader);
UpdatePerFrame = BinarySerializeUtility.ReadInt(reader);
ChildTypes = BinarySerializeUtility.DeserializeIntArray(reader);
ChildNames = BinarySerializeUtility.DeserializeStringArray(reader);
int childCount = ChildTypes.Length;
childs = new ScriptLoadableConfig[childCount];
for (int i = 0; i < childCount; i++)
{
var scriptObject = target.NewSubScript(DefaultInstantiate.ScriptableObjectID2Typename[ChildTypes[i]], ChildNames[i]);
childs[i] = scriptObject.Config;
childs[i].Deserialize(reader);
}
}
public virtual void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, UID);
BinarySerializeUtility.WriteVec3(writer, EnterGameLocalPosition);
BinarySerializeUtility.WriteVec3(writer, EnterGameEulerAngles);
BinarySerializeUtility.WriteVec3(writer, EnterGameLocalScaling);
BinarySerializeUtility.WriteBool(writer, IsSetObjectDisable);
BinarySerializeUtility.WriteInt(writer, UpdatePerFrame);
childs = (from child in target.Childs select child.Config).ToArray();
ChildTypes = (from child in childs select DefaultInstantiate.ScriptableObjectTypename2ID[child.target.GetType().Name]).ToArray();
ChildNames = (from child in childs select child.target.ScriptName).ToArray();
BinarySerializeUtility.SerializeArray(writer, ChildTypes);
BinarySerializeUtility.SerializeArray(writer, ChildNames);
foreach (var child in childs)
{
child.Serialize(writer);
}
}
}
}
public partial class ScriptableObject : IScriptableObject public partial class ScriptableObject : IScriptableObject
{ {
/// <summary> /// <summary>
@@ -49,13 +102,28 @@ namespace Demo
/// </summary> /// </summary>
public partial class ScriptableObject public partial class ScriptableObject
{ {
[Content, SerializeField] protected virtual ConfigType.ScriptLoadableConfig MakeConfig()
private Vector3 {
EnterGameLocalPosition = Vector3.zero, return new ConfigType.ScriptLoadableConfig();
EnterGameEulerAngles = Vector3.zero, }
EnterGameLocalScaling = Vector3.one; [Setting, SerializeField] private ConfigType.ScriptLoadableConfig m_Config = null;
[Content, SerializeField] private bool IsSetObjectDisable = false; public ConfigType.ScriptLoadableConfig Config
[Content] public int UpdatePerFrame = 1; {
// 懒加载生成Config
get
{
if (m_Config == null)
{
m_Config = MakeConfig();
m_Config.target = this;
}
return m_Config;
}
}
public ConfigT GetConfig<ConfigT>() where ConfigT : ConfigType.ScriptLoadableConfig
{
return (ConfigT)Config;
}
/// <summary> /// <summary>
/// 设置坐标 /// 设置坐标
@@ -66,7 +134,7 @@ namespace Demo
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetLocalPosition(float x, float y, float z) public void SetLocalPosition(float x, float y, float z)
{ {
EnterGameLocalPosition = new(x, y, z); Config.EnterGameLocalPosition = transform.localPosition = new(x, y, z);
} }
/// <summary> /// <summary>
/// 设置欧拉角 /// 设置欧拉角
@@ -77,7 +145,7 @@ namespace Demo
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetLocalEulerAngles(float x, float y, float z) public void SetLocalEulerAngles(float x, float y, float z)
{ {
EnterGameEulerAngles = new(x, y, z); Config.EnterGameEulerAngles = transform.localEulerAngles = new(x, y, z);
} }
/// <summary> /// <summary>
/// 设置缩放 /// 设置缩放
@@ -88,7 +156,7 @@ namespace Demo
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetLocalScaling(float x, float y, float z) public void SetLocalScaling(float x, float y, float z)
{ {
EnterGameLocalScaling = new(x, y, z); Config.EnterGameLocalScaling = transform.localScale= new(x, y, z);
} }
/// <summary> /// <summary>
@@ -98,7 +166,8 @@ namespace Demo
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetObjectDisable() public void SetObjectDisable()
{ {
IsSetObjectDisable = true; Config.IsSetObjectDisable = true;
gameObject.SetActive(false);
} }
/// <summary> /// <summary>
@@ -109,15 +178,15 @@ namespace Demo
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetUpdatePerFrame(int frame) public void SetUpdatePerFrame(int frame)
{ {
UpdatePerFrame = Mathf.Max(1, frame); Config.UpdatePerFrame = Mathf.Max(1, frame);
} }
private void ScriptableObjectDoReset() private void ScriptableObjectDoReset()
{ {
transform.localPosition = EnterGameLocalPosition; transform.localPosition = Config.EnterGameLocalPosition;
transform.localEulerAngles = EnterGameEulerAngles; transform.localEulerAngles = Config.EnterGameEulerAngles;
transform.localScale = EnterGameLocalScaling; transform.localScale = Config.EnterGameLocalScaling;
gameObject.SetActive(IsSetObjectDisable == false); gameObject.SetActive(Config.IsSetObjectDisable == false);
} }
} }
@@ -126,12 +195,12 @@ namespace Demo
/// </summary> /// </summary>
public partial class ScriptableObject public partial class ScriptableObject
{ {
public readonly Dictionary<string, float> ScriptableObjectContents = new(); private NativeHashMap<int, float> ScriptableObjectContents;
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public float GetContent(string key) public float GetContent(string key)
{ {
if (ScriptableObjectContents.TryGetValue(key, out var result)) if (ScriptableObjectContents.IsCreated && ScriptableObjectContents.TryGetValue(key.GetHashCode(), out var result))
{ {
return result; return result;
} }
@@ -141,7 +210,11 @@ namespace Demo
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public float SetContent(string key, float value) public float SetContent(string key, float value)
{ {
ScriptableObjectContents[key] = value; if (ScriptableObjectContents.IsCreated == false)
{
ScriptableObjectContents = new(8, AllocatorManager.Persistent);
}
ScriptableObjectContents[key.GetHashCode()] = value;
return value; return value;
} }
} }
@@ -155,7 +228,7 @@ namespace Demo
public static float OneBarTime = 60; public static float OneBarTime = 60;
private bool isEnableScript = false; private bool isEnableScript = false;
public string ScriptName = ""; [Setting] public string ScriptName;
private string s_ScriptType = null; private string s_ScriptType = null;
public string m_ScriptType public string m_ScriptType
{ {
@@ -170,19 +243,24 @@ namespace Demo
public ScriptableObject Parent; public ScriptableObject Parent;
public readonly List<ScriptableObject> Childs = new(); public readonly List<ScriptableObject> Childs = new();
private RootObject rootObjectCache = null;
/// <summary> /// <summary>
/// 获取根脚本对象 /// 获取根脚本对象
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public RootObject GetRoot() public RootObject GetRoot()
{
if (rootObjectCache == null)
{ {
if (Parent == null) if (Parent == null)
return this as RootObject; rootObjectCache = this as RootObject;
if (Parent is RootObject result) else if (Parent is RootObject result)
return result; rootObjectCache = result;
else else
return Parent.GetRoot(); rootObjectCache = Parent.GetRoot();
}
return rootObjectCache;
} }
@@ -265,11 +343,25 @@ namespace Demo
return; return;
} }
this.Parent = parent; this.Parent = parent;
if (parent != null) if (parent != null && parent.ScriptableObjectContents.IsCreated)
this.ScriptableObjectContents.AddRange(parent.ScriptableObjectContents); {
if (ScriptableObjectContents.IsCreated == false)
{
ScriptableObjectContents = new(parent.ScriptableObjectContents.Count, AllocatorManager.Persistent);
}
foreach (var item in parent.ScriptableObjectContents)
{
this.ScriptableObjectContents[item.Key] = item.Value;
}
}
this.name = ScriptName; this.name = ScriptName;
if (Config.UID < 0)
Config.UID = GetRoot().PushLoadedScriptObject(this);
else
GetRoot().PushLoadedScriptObject(this, Config.UID);
isEnableScript = true; isEnableScript = true;
// 只有RootObject的parent会是空的 // 只有RootObject的parent会是空的
if (parent != null) if (parent != null)
@@ -347,6 +439,7 @@ namespace Demo
// 获取文件 // 获取文件
var file = new ToolFile(GetRoot().SourcePath); var file = new ToolFile(GetRoot().SourcePath);
file = file | path; file = file | path;
GetRoot().LoadedScriptSet.Add(file);
// 找不到脚本 // 找不到脚本
if (file.Exists() == false) if (file.Exists() == false)
{ {
@@ -459,7 +552,7 @@ namespace Demo
else else
{ {
// UpdateTicks // UpdateTicks
if (ScriptUpdateCounter % UpdatePerFrame == 0) if (ScriptUpdateCounter % Config.UpdatePerFrame == 0)
UpdateTicks(currentTime, deltaTime, tickType); UpdateTicks(currentTime, deltaTime, tickType);
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0; ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
} }
@@ -554,7 +647,8 @@ namespace Demo
} }
// 释放资源 // 释放资源
{ {
this.ScriptableObjectContents.Clear(); if (this.ScriptableObjectContents.IsCreated)
this.ScriptableObjectContents.Dispose();
} }
IsScriptApply = true; IsScriptApply = true;
} }
@@ -583,11 +677,14 @@ namespace Demo
MyHierarchyItem.Release(); MyHierarchyItem.Release();
MyHierarchyItem = null; MyHierarchyItem = null;
} }
if (this /*防假空*/)
{
this.isEnableScript = false; this.isEnableScript = false;
this.Parent = null; this.Parent = null;
this.name = "<Unload>"; this.name = "<Unload>";
} }
} }
}
public virtual void ResetEnterGameStatus() public virtual void ResetEnterGameStatus()
{ {
@@ -714,31 +811,28 @@ namespace Demo
public static PropertiesWindow TimelineWindow; public static PropertiesWindow TimelineWindow;
private PropertiesWindow.ItemEntry MyTimelineEntry; private PropertiesWindow.ItemEntry MyTimelineEntry;
private Editor.UI.TimelineItem MyTimelineItem; private Editor.UI.TimelineItem MyTimelineItem;
//[SerializeField] private bool IsTimelineItemShow = false;
private static List<TimelineScriptObject> TimelineScriptObjectWhichOnShow = new();
private static UnityEngine.UI.Image CacheLastFocusImage; private static UnityEngine.UI.Image CacheLastFocusImage;
private static Color CacheLastFocusImageOriginColor = new(1, 1, 1, 0.01f); private static Color CacheLastFocusImageOriginColor = new(1, 1, 1, 0.01f);
private static Color FocusImageColor = new(1f, 47f / 51f, 0.0156862754f, 0.1f); private static Color FocusImageColor = new(1f, 47f / 51f, 0.0156862754f, 0.1f);
[Content, SerializeField] private bool IsEnableTimelineItem = false; public override IEnumerator UnloadScript()
[Convention.RScript.Variable.Attr.Method]
public void EnableTimelineItem()
{ {
IsEnableTimelineItem = true; yield return base.UnloadScript();
// 这里的两处判空是因为如果抛出错误就会打断了逻辑, 所以这里需要判断
if (MyTimelineItem != null)
{
MyTimelineItem.RawButton.onClick.RemoveAllListeners();
MyTimelineItem = null;
}
} }
protected override IEnumerator DoSomethingDuringApplyScript() public override void OnHierarchyItemClick(HierarchyItem item)
{
yield return base.DoSomethingDuringApplyScript();
if (IsEnableTimelineItem)
{ {
if (MyTimelineEntry == null) if (MyTimelineEntry == null)
{ {
MyTimelineEntry = TimelineWindow.CreateRootItemEntries(1)[0]; MyTimelineEntry = TimelineWindow.CreateRootItemEntries(1)[0];
MyTimelineItem = MyTimelineEntry.ref_value.GetComponent<Editor.UI.TimelineItem>(); MyTimelineItem = MyTimelineEntry.ref_value.GetComponent<Editor.UI.TimelineItem>();
}
MyTimelineItem.title = ScriptName; MyTimelineItem.title = ScriptName;
MyTimelineItem.RawButton.onClick.RemoveAllListeners(); MyTimelineItem.RawButton.onClick.RemoveAllListeners();
MyTimelineItem.AddListener(() => MyTimelineItem.AddListener(() =>
@@ -750,45 +844,21 @@ namespace Demo
CacheLastFocusImage.color = FocusImageColor; CacheLastFocusImage.color = FocusImageColor;
}); });
SetupTimelineItem(MyTimelineItem); SetupTimelineItem(MyTimelineItem);
TimelineScriptObjectWhichOnShow.Add(this);
} }
} else if (MyTimelineEntry != null)
public override IEnumerator UnloadScript()
{
yield return base.UnloadScript();
// 这里的两处判空是因为如果抛出错误就会打断了逻辑, 所以这里需要判断
if (MyTimelineItem != null)
{
MyTimelineItem.RawButton.onClick.RemoveAllListeners();
MyTimelineItem = null;
}
if (MyTimelineEntry != null)
{ {
MyTimelineEntry.Release(); MyTimelineEntry.Release();
MyTimelineEntry = null; MyTimelineEntry = null;
} }
} }
public override void OnHierarchyItemClick(HierarchyItem item)
{
}
private float UIResizeOnTimelineCount = 0;
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType) protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
{ {
base.UpdateTicks(currentTime, deltaTime, tickType); base.UpdateTicks(currentTime, deltaTime, tickType);
// 存在严重的性能开销, 在解决之前将不会允许其快速自动更新 if (MyTimelineEntry != null)
if (IsEnableTimelineItem)
{ {
if (UIResizeOnTimelineCount > 0.1 || tickType != TickType.Update)
{
UIResizeOnTimelineCount = 0;
MyTimelineItem.ResizeOnTimeline(); MyTimelineItem.ResizeOnTimeline();
} }
UIResizeOnTimelineCount += deltaTime;
}
} }
protected abstract void SetupTimelineItem(Editor.UI.TimelineItem item); protected abstract void SetupTimelineItem(Editor.UI.TimelineItem item);

View File

@@ -7,6 +7,7 @@ using Dreamteck.Splines;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@@ -32,26 +33,33 @@ namespace Demo
SharedModule.instance.OpenCustomMenu(item, result.ToArray()); SharedModule.instance.OpenCustomMenu(item, result.ToArray());
} }
private static Dictionary<string, Func<ScriptableObject>> s_ScriptableObjectInstantiate; static DefaultInstantiate()
public static Dictionary<string, Func<ScriptableObject>> GetScriptableObjectInstantiate()
{
//return s_ScriptableObjectInstantiate ??= new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate
// .Union(DDTInstantiate)
// .Union(TickUpdatementInstantiate)
// .Union(MaterialUpdatementInstantiate)
// .Union(SplineInstantiate)
// .Union(JudgementInstantiate)
// .Union(SingleVolumeInstantiate));
if (s_ScriptableObjectInstantiate == null)
{ {
s_ScriptableObjectInstantiate = new(); s_ScriptableObjectInstantiate = new();
ScriptableObjectTypename2ID = new();
ScriptableObjectID2Typename = new();
int cnt = 0;
foreach (var type in Utility.SeekType(x => x.IsSubclassOf(typeof(ScriptableObject)) && x.GetCustomAttribute<Attr.ScriptableAttribute>() != null)) foreach (var type in Utility.SeekType(x => x.IsSubclassOf(typeof(ScriptableObject)) && x.GetCustomAttribute<Attr.ScriptableAttribute>() != null))
{ {
var attr = type.GetCustomAttribute<Attr.ScriptableAttribute>(); var attr = type.GetCustomAttribute<Attr.ScriptableAttribute>();
s_ScriptableObjectInstantiate.Add(type.Name, () => (ScriptableObject)ConventionUtility.InvokeMember(type.GetMethod(attr.generaterName), null)); s_ScriptableObjectInstantiate.Add(type.Name, () => (ScriptableObject)ConventionUtility.InvokeMember(type.GetMethod(attr.generaterName), null));
} }
var typelist = s_ScriptableObjectInstantiate.Keys.ToList();
typelist.Sort();
foreach (var type in typelist)
{
ScriptableObjectTypename2ID.Add(type, cnt);
ScriptableObjectID2Typename.Add(cnt, type);
cnt++;
} }
}
private static Dictionary<string, Func<ScriptableObject>> s_ScriptableObjectInstantiate;
public readonly static Dictionary<string, int> ScriptableObjectTypename2ID;
public readonly static Dictionary<int, string> ScriptableObjectID2Typename;
public static Dictionary<string, Func<ScriptableObject>> GetScriptableObjectInstantiate()
{
return s_ScriptableObjectInstantiate; return s_ScriptableObjectInstantiate;
} }
} }
@@ -159,6 +167,8 @@ namespace Demo
} }
} }
namespace Game
{
public partial class ScriptableObject public partial class ScriptableObject
{ {
protected virtual bool IsImptSerialize => false; protected virtual bool IsImptSerialize => false;
@@ -296,4 +306,5 @@ namespace Demo
} }
} }
} }
}
} }

View File

@@ -1,5 +1,5 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -8,25 +8,51 @@ using UnityEngine.SceneManagement;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
// SubWorld 配置
public class SubWorldConfig : ScriptLoadableConfig
{
public string project;
public override void Deserialize(BinaryReader reader)
{
project = BinarySerializeUtility.ReadString(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteString(writer, project);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class SubWorld : ScriptableObject public class SubWorld : ScriptableObject
{ {
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new ConfigType.SubWorldConfig();
}
public static SubWorld Make() public static SubWorld Make()
{ {
return new GameObject().AddComponent<SubWorld>(); return new GameObject().AddComponent<SubWorld>();
} }
[Content, SerializeField] private string project;
[Content, SerializeField] private GameController SubWorldGameController; [Content, SerializeField] private GameController SubWorldGameController;
protected override IEnumerator DoSomethingDuringApplyScript() protected override IEnumerator DoSomethingDuringApplyScript()
{ {
yield return base.DoSomethingDuringApplyScript(); yield return base.DoSomethingDuringApplyScript();
if (string.IsNullOrEmpty(GetConfig<ConfigType.SubWorldConfig>().project))
yield break;
var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive); var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive);
ir.completed += x => ir.completed += x =>
{ {
SubWorldGameController = (from controller in FindObjectsOfType<GameController>() SubWorldGameController = (from controller in FindObjectsByType<GameController>(FindObjectsSortMode.None)
where controller.RootSourcePath == project where controller.RootSourcePath == GetConfig<ConfigType.SubWorldConfig>().project
select controller).First(); select controller).First();
ConventionUtility.StartCoroutine(SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch)); ConventionUtility.StartCoroutine(SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch));
}; };
@@ -45,7 +71,7 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void Load(string project) public void Load(string project)
{ {
this.project = project; GetConfig<ConfigType.SubWorldConfig>().project = project;
} }
} }
} }

View File

@@ -1,13 +1,112 @@
using Convention; using Convention;
using Demo.Editor.UI; using Demo.Editor.UI;
using Demo.Game.ConfigType;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using Unity.Collections; using Unity.Collections;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public abstract class UpdatementConfig<DataType>: ScriptLoadableConfig where DataType : struct
{
public NativeArray<float> TimePoints;
public NativeArray<DataType> Positions;
public NativeArray<MathExtension.EaseCurveType> EaseCurveTypes;
protected abstract void DeserializePositions(BinaryReader reader, ref NativeArray<DataType> positions);
protected abstract void SerializePositions(BinaryWriter writer, in NativeArray<DataType> positions);
public override void Deserialize(BinaryReader reader)
{
BinarySerializeUtility.DeserializeNativeArray(reader, ref TimePoints);
DeserializePositions(reader, ref Positions);
{
NativeArray<int> temp = new(EaseCurveTypes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
BinarySerializeUtility.DeserializeNativeArray(reader, ref temp);
for (int i = 0, e = EaseCurveTypes.Length; i < e; i++)
{
EaseCurveTypes[i] = (MathExtension.EaseCurveType)temp[i];
}
temp.Dispose();
}
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.SerializeNativeArray(writer, TimePoints);
SerializePositions(writer, Positions);
{
NativeArray<int> temp = new(EaseCurveTypes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
for (int i = 0, e = EaseCurveTypes.Length; i < e; i++)
{
temp[i] = (int)EaseCurveTypes[i];
}
BinarySerializeUtility.SerializeNativeArray(writer, temp);
temp.Dispose();
}
base.Serialize(writer);
}
}
public class UpdatementIntConfig : UpdatementConfig<int>
{
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<int> positions)
{
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
}
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<int> positions)
{
BinarySerializeUtility.SerializeNativeArray(writer, positions);
}
}
public class UpdatementFloatConfig : UpdatementConfig<float>
{
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<float> positions)
{
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
}
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<float> positions)
{
BinarySerializeUtility.SerializeNativeArray(writer, positions);
}
}
public class UpdatementVec2Config : UpdatementConfig<Vector2>
{
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<Vector2> positions)
{
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
}
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<Vector2> positions)
{
BinarySerializeUtility.SerializeNativeArray(writer, positions);
}
}
public class UpdatementVec3Config : UpdatementConfig<Vector3>
{
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<Vector3> positions)
{
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
}
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<Vector3> positions)
{
BinarySerializeUtility.SerializeNativeArray(writer, positions);
}
}
}
public abstract class Updatement<DataType> : TimelineScriptObject where DataType : struct public abstract class Updatement<DataType> : TimelineScriptObject where DataType : struct
{ {
[Serializable] [Serializable]
@@ -17,39 +116,9 @@ namespace Demo.Game
public DataType Position = default; public DataType Position = default;
public MathExtension.EaseCurveType easeCurveType = MathExtension.EaseCurveType.Linear; public MathExtension.EaseCurveType easeCurveType = MathExtension.EaseCurveType.Linear;
} }
[Serializable]
public struct UpdatementCompiledEntries: IDisposable
{
public NativeArray<float> TimePoints;
public NativeArray<DataType> Positions;
public NativeArray<MathExtension.EaseCurveType> EaseCurveTypes;
public readonly int Count;
public UpdatementCompiledEntries(NativeArray<float> timePoints,
NativeArray<DataType> positions,
NativeArray<MathExtension.EaseCurveType> easeCurveTypes,
int count)
{
TimePoints = timePoints;
Positions = positions;
EaseCurveTypes = easeCurveTypes;
Count = count;
}
public void Dispose()
{
if (TimePoints.IsCreated)
TimePoints.Dispose();
if (Positions.IsCreated)
Positions.Dispose();
if (EaseCurveTypes.IsCreated)
EaseCurveTypes.Dispose();
}
}
public int Content = 0; public int Content = 0;
private readonly List<UpdatementEntry> Entries = new(); private readonly List<UpdatementEntry> Entries = new();
public UpdatementCompiledEntries CompiledEntries;
protected abstract void UpdateData(DataType data); protected abstract void UpdateData(DataType data);
protected abstract DataType Lerp(DataType begin, DataType end, float t); protected abstract DataType Lerp(DataType begin, DataType end, float t);
@@ -72,18 +141,15 @@ namespace Demo.Game
private void BuildupCompiledEntriesAndReleaseEntries() private void BuildupCompiledEntriesAndReleaseEntries()
{ {
Entries.Sort((x, y) => x.TimePoint.CompareTo(y.TimePoint)); Entries.Sort((x, y) => x.TimePoint.CompareTo(y.TimePoint));
CompiledEntries = new( GetConfig<UpdatementConfig<DataType>>().TimePoints = new NativeArray<float>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
new NativeArray<float>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory), GetConfig<UpdatementConfig<DataType>>().Positions = new NativeArray<DataType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
new NativeArray<DataType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory), GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes = new NativeArray<MathExtension.EaseCurveType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
new NativeArray<MathExtension.EaseCurveType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
Entries.Count
);
int index = 0; int index = 0;
foreach (var item in Entries) foreach (var item in Entries)
{ {
CompiledEntries.TimePoints[index] = item.TimePoint; GetConfig<UpdatementConfig<DataType>>().TimePoints[index] = item.TimePoint;
CompiledEntries.Positions[index] = item.Position; GetConfig<UpdatementConfig<DataType>>().Positions[index] = item.Position;
CompiledEntries.EaseCurveTypes[index] = item.easeCurveType; GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes[index] = item.easeCurveType;
index++; index++;
} }
Entries.Clear(); Entries.Clear();
@@ -92,10 +158,10 @@ namespace Demo.Game
private void UpdateEntry(int start, float percent) private void UpdateEntry(int start, float percent)
{ {
int head = start; int head = start;
int tail = Mathf.Min(start + 1, CompiledEntries.Count - 1); int tail = Mathf.Min(start + 1, GetConfig<UpdatementConfig<DataType>>().TimePoints.Length - 1);
UpdateData(Lerp(CompiledEntries.Positions[start], UpdateData(Lerp(GetConfig<UpdatementConfig<DataType>>().Positions[start],
CompiledEntries.Positions[tail], GetConfig<UpdatementConfig<DataType>>().Positions[tail],
MathExtension.Evaluate(Mathf.Clamp01(percent), CompiledEntries.EaseCurveTypes[head]))); MathExtension.Evaluate(Mathf.Clamp01(percent), GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes[head])));
} }
protected override IEnumerator DoSomethingDuringApplyScript() protected override IEnumerator DoSomethingDuringApplyScript()
@@ -111,7 +177,7 @@ namespace Demo.Game
public override void ResetEnterGameStatus() public override void ResetEnterGameStatus()
{ {
base.ResetEnterGameStatus(); base.ResetEnterGameStatus();
if (CompiledEntries.Count <= 1) if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length <= 1)
return; return;
UpdateEntry(0, 0); UpdateEntry(0, 0);
} }
@@ -119,7 +185,9 @@ namespace Demo.Game
public override IEnumerator UnloadScript() public override IEnumerator UnloadScript()
{ {
Content = 0; Content = 0;
CompiledEntries = default; GetConfig<UpdatementConfig<DataType>>().TimePoints.Dispose();
GetConfig<UpdatementConfig<DataType>>().Positions.Dispose();
GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes.Dispose();
yield return base.UnloadScript(); yield return base.UnloadScript();
} }
@@ -129,12 +197,12 @@ namespace Demo.Game
float GetPercentValue() float GetPercentValue()
{ {
if (Content + 1 == CompiledEntries.Count) if (Content + 1 == GetConfig<UpdatementConfig<DataType>>().TimePoints.Length)
return 1; return 1;
return (currentTime - CompiledEntries.TimePoints[Content]) / (CompiledEntries.TimePoints[Content + 1] - CompiledEntries.TimePoints[Content]); return (currentTime - GetConfig<UpdatementConfig<DataType>>().TimePoints[Content]) / (GetConfig<UpdatementConfig<DataType>>().TimePoints[Content + 1] - GetConfig<UpdatementConfig<DataType>>().TimePoints[Content]);
} }
if (CompiledEntries.Count <= 1) if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length <= 1)
return; return;
switch (tickType) switch (tickType)
{ {
@@ -142,17 +210,17 @@ namespace Demo.Game
case TickType.Start: case TickType.Start:
{ {
Content = 0; Content = 0;
while (Content + 1 < CompiledEntries.Count && CompiledEntries.TimePoints[Content + 1] < currentTime) while (Content + 1 < GetConfig<UpdatementConfig<DataType>>().TimePoints.Length && GetConfig<UpdatementConfig<DataType>>().TimePoints[Content + 1] < currentTime)
Content++; Content++;
UpdateEntry(Content, GetPercentValue()); UpdateEntry(Content, GetPercentValue());
} }
break; break;
default: default:
if (CompiledEntries.TimePoints[0] > currentTime) if (GetConfig<UpdatementConfig<DataType>>().TimePoints[0] > currentTime)
return; return;
if (Content + 1 < CompiledEntries.Count && CompiledEntries.TimePoints[Content + 1] < currentTime) if (Content + 1 < GetConfig<UpdatementConfig<DataType>>().TimePoints.Length && GetConfig<UpdatementConfig<DataType>>().TimePoints[Content + 1] < currentTime)
Content++; Content++;
if (Content + 1 > CompiledEntries.Count) if (Content + 1 > GetConfig<UpdatementConfig<DataType>>().TimePoints.Length)
return; return;
UpdateEntry(Content, GetPercentValue()); UpdateEntry(Content, GetPercentValue());
break; break;
@@ -161,21 +229,22 @@ namespace Demo.Game
public DataType Evaluate(float time) public DataType Evaluate(float time)
{ {
if (CompiledEntries.Count == 0) if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length == 0)
return default; return default;
if (CompiledEntries.Count == 1) if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length == 1)
return CompiledEntries.Positions[0]; return GetConfig<UpdatementConfig<DataType>>().Positions[0];
if (time < CompiledEntries.TimePoints[0]) if (time < GetConfig<UpdatementConfig<DataType>>().TimePoints[0])
return CompiledEntries.Positions[0]; return GetConfig<UpdatementConfig<DataType>>().Positions[0];
for (int i = 1; i < CompiledEntries.Count; i++) for (int i = 1; i < GetConfig<UpdatementConfig<DataType>>().TimePoints.Length; i++)
{ {
if (CompiledEntries.TimePoints[i - 1] <= time && CompiledEntries.TimePoints[i] > time) if (GetConfig<UpdatementConfig<DataType>>().TimePoints[i - 1] <= time && GetConfig<UpdatementConfig<DataType>>().TimePoints[i] > time)
{ {
return Lerp(CompiledEntries.Positions[i - 1], CompiledEntries.Positions[i], return Lerp(GetConfig<UpdatementConfig<DataType>>().Positions[i - 1], GetConfig<UpdatementConfig<DataType>>().Positions[i],
(time - CompiledEntries.TimePoints[i - 1]) / (CompiledEntries.TimePoints[i] - CompiledEntries.TimePoints[i - 1])); (time - GetConfig<UpdatementConfig<DataType>>().TimePoints[i - 1]) /
(GetConfig<UpdatementConfig<DataType>>().TimePoints[i] - GetConfig<UpdatementConfig<DataType>>().TimePoints[i - 1]));
} }
} }
return CompiledEntries.Positions[^1]; return GetConfig<UpdatementConfig<DataType>>().Positions[^1];
} }
[Content] public GameObject UpdateTarget; [Content] public GameObject UpdateTarget;
@@ -195,15 +264,20 @@ namespace Demo.Game
/// <param name="item">实例在父类中控制</param> /// <param name="item">实例在父类中控制</param>
protected override void SetupTimelineItem(TimelineItem item) protected override void SetupTimelineItem(TimelineItem item)
{ {
if (CompiledEntries.Count == 0) if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length == 0)
return; return;
item.SetupDuration(new(CompiledEntries.TimePoints[0], CompiledEntries.TimePoints[^1]), GetTimelineItemColor()); item.SetupDuration(new(GetConfig<UpdatementConfig<DataType>>().TimePoints[0], GetConfig<UpdatementConfig<DataType>>().TimePoints[^1]), GetTimelineItemColor());
} }
private void OnDestroy() private void OnDestroy()
{ {
CompiledEntries.Dispose(); if (GetConfig<UpdatementConfig<DataType>>().TimePoints.IsCreated)
GetConfig<UpdatementConfig<DataType>>().TimePoints.Dispose();
if (GetConfig<UpdatementConfig<DataType>>().Positions.IsCreated)
GetConfig<UpdatementConfig<DataType>>().Positions.Dispose();
if (GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes.IsCreated)
GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes.Dispose();
} }
} }
} }

View File

@@ -1,12 +1,47 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class ParticleEffectConfig : IEffectHookObjectConfig
{
public Dictionary<string, string[]> AssetBundles;
public override void Deserialize(BinaryReader reader)
{
int count = BinarySerializeUtility.ReadInt(reader);
while(count-->0)
{
var temp = BinarySerializeUtility.DeserializeStringArray(reader);
var key = temp[0];
var value = temp[1..];
AssetBundles.Add(key, value);
}
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, AssetBundles.Count);
foreach (var (key, value) in AssetBundles)
{
string[] temp = new string[value.Length + 1];
temp[0] = key;
Array.Copy(value, 0, temp, 1, value.Length);
BinarySerializeUtility.SerializeArray(writer, value.ToArray());
}
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class ParticleEffect : IEffectHookObject, IAssetBundleLoader public class ParticleEffect : IEffectHookObject, IAssetBundleLoader
{ {
@@ -15,15 +50,14 @@ namespace Demo.Game
return new GameObject().AddComponent<ParticleEffect>(); return new GameObject().AddComponent<ParticleEffect>();
} }
private Dictionary<string,bool> AssetBundleLoaders = new(); private int AssetBundleLoadingCounter = 0;
private readonly List<string> AssetBundles = new(); private readonly Dictionary<string,List<string>> AssetBundles = new();
private readonly List<GameObject> Prefabs = new(); private readonly List<GameObject> Prefabs = new();
protected override IEnumerator DoSomethingDuringApplyScript() protected override IEnumerator DoSomethingDuringApplyScript()
{ {
yield return base.DoSomethingDuringApplyScript(); yield return base.DoSomethingDuringApplyScript();
while (AssetBundleLoaders.Any(x => x.Value == false)) yield return new WaitUntil(() => AssetBundleLoadingCounter == 0);
yield return null;
} }
public override IEnumerator UnloadScript() public override IEnumerator UnloadScript()
@@ -31,7 +65,7 @@ namespace Demo.Game
yield return base.UnloadScript(); yield return base.UnloadScript();
foreach (var ab in AssetBundles) foreach (var ab in AssetBundles)
{ {
yield return this.UnloadAssetBundle(ab); yield return this.UnloadAssetBundle(ab.Key);
} }
} }
@@ -43,16 +77,18 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void Load(string ab, string prefab) public void Load(string ab, string prefab)
{ {
AssetBundleLoaders.TryAdd(ab, false); AssetBundleLoadingCounter++;
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x => ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x =>
{ {
GameObject sub = Instantiate(x.LoadAsset<GameObject>(prefab)); GameObject sub = Instantiate(x.LoadAsset<GameObject>(prefab));
sub.SetActive(false);
Prefabs.Add(sub); Prefabs.Add(sub);
sub.transform.SetParent(transform); sub.transform.SetParent(transform);
sub.transform.localPosition = Vector3.zero; sub.transform.localPosition = Vector3.zero;
AssetBundles.Add(ab); sub.SetActive(false);
AssetBundleLoaders[ab] = true; if(AssetBundles.ContainsKey(ab)==false)
AssetBundles.Add(ab, new());
AssetBundles[ab].Add(prefab);
AssetBundleLoadingCounter--;
})); }));
} }

View File

@@ -1,10 +1,35 @@
using System; using System;
using System.Collections; using System.Collections;
using System.IO;
using Convention; using Convention;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
// IEffectHookObject 配置抽象基类Config
public class IEffectHookObjectConfig : ScriptLoadableConfig
{
public int MyInteractionModule;
public IEffectHookObject.InteractiveEffectType MyInteractiveLevel;
public override void Deserialize(BinaryReader reader)
{
MyInteractionModule = BinarySerializeUtility.ReadInt(reader);
MyInteractiveLevel = (IEffectHookObject.InteractiveEffectType)BinarySerializeUtility.ReadInt(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, MyInteractionModule);
BinarySerializeUtility.WriteInt(writer, (int)MyInteractiveLevel);
base.Serialize(writer);
}
}
}
public abstract class IEffectHookObject : ScriptableObject, IHookInteraction public abstract class IEffectHookObject : ScriptableObject, IHookInteraction
{ {
public enum InteractiveEffectType public enum InteractiveEffectType

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.IO;
using Convention; using Convention;
using Demo.Editor.UI; using Demo.Editor.UI;
using UnityEngine; using UnityEngine;
@@ -7,6 +8,35 @@ using UnityEngine.Events;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class IInteractionConfig : ScriptLoadableConfig
{
public Vector2 VisibleDuration;
public Vector2 InteractiveDuration;
public Vector2 InteractableScoreInterval;
public Vector2 InteractableIntervalThatCanScoreBest;
public override void Deserialize(BinaryReader reader)
{
VisibleDuration = BinarySerializeUtility.ReadVec2(reader);
InteractiveDuration = BinarySerializeUtility.ReadVec2(reader);
InteractableScoreInterval = BinarySerializeUtility.ReadVec2(reader);
InteractableIntervalThatCanScoreBest = BinarySerializeUtility.ReadVec2(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteVec2(writer, VisibleDuration);
BinarySerializeUtility.WriteVec2(writer, InteractiveDuration);
BinarySerializeUtility.WriteVec2(writer, InteractableScoreInterval);
BinarySerializeUtility.WriteVec2(writer, InteractableIntervalThatCanScoreBest);
base.Serialize(writer);
}
}
}
public interface IHookInteraction public interface IHookInteraction
{ {

View File

@@ -1,9 +1,28 @@
using System.Collections; using System.Collections;
using System.IO;
using Convention; using Convention;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
// IJudgementHookObject 配置抽象基类Config
public class IJudgementHookObjectConfig : ScriptLoadableConfig
{
public int MyInteractionModule;
public override void Deserialize(BinaryReader reader)
{
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
base.Serialize(writer);
}
}
}
public abstract class IJudgementHookObject : ScriptableObject, IHookInteraction public abstract class IJudgementHookObject : ScriptableObject, IHookInteraction
{ {
@@ -33,11 +52,10 @@ namespace Demo.Game
/// <summary> /// <summary>
/// 绑定IInteraction对象若不手动绑定则会自动绑定到父物体的IInteraction /// 绑定IInteraction对象若不手动绑定则会自动绑定到父物体的IInteraction
/// </summary> /// </summary>
/// <param name="path"></param>
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void Bind(string path) public void Bind(IInteraction module)
{ {
MyInteractionModule = FindWithPath(path) as IInteraction; MyInteractionModule = module;
} }
public override IEnumerator UnloadScript() public override IEnumerator UnloadScript()

View File

@@ -1,9 +1,31 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
// FullScreenInteraction 配置
public class FullScreenInteractionConfig : IInteractionConfig
{
public bool IsNeedTap;
public override void Deserialize(BinaryReader reader)
{
IsNeedTap = BinarySerializeUtility.ReadBool(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteBool(writer, IsNeedTap);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class FullScreenInteraction : IInteraction public class FullScreenInteraction : IInteraction
{ {

View File

@@ -1,12 +1,49 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using NUnit.Framework.Internal; using System.Linq;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class ParticleJudgement : IJudgementHookObjectConfig
{
public bool IsZooming;
public MathExtension.EaseCurveType ZoomCurve = MathExtension.EaseCurveType.OutCubic;
public IInteraction.JudgementLevel[] LevelArray;
public string[] AssetBundles;
public string[] Prefabs;
public float[] Durations;
public override void Deserialize(BinaryReader reader)
{
IsZooming = BinarySerializeUtility.ReadBool(reader);
ZoomCurve = (MathExtension.EaseCurveType)BinarySerializeUtility.ReadInt(reader);
var temp = BinarySerializeUtility.DeserializeIntArray(reader);
LevelArray = (from item in temp select (IInteraction.JudgementLevel)item).ToArray();
AssetBundles = BinarySerializeUtility.DeserializeStringArray(reader);
Prefabs = BinarySerializeUtility.DeserializeStringArray(reader);
Durations = BinarySerializeUtility.DeserializeFloatArray(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteBool(writer, IsZooming);
BinarySerializeUtility.WriteInt(writer, (int)ZoomCurve);
BinarySerializeUtility.SerializeArray(writer, (from item in LevelArray select (int)item).ToArray());
BinarySerializeUtility.SerializeArray(writer, AssetBundles);
BinarySerializeUtility.SerializeArray(writer, Prefabs);
BinarySerializeUtility.SerializeArray(writer, Durations);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class ParticleJudgement : IJudgementHookObject, IAssetBundleLoader public class ParticleJudgement : IJudgementHookObject, IAssetBundleLoader
{ {
@@ -65,6 +102,7 @@ namespace Demo.Game
sub.SetActive(false); sub.SetActive(false);
Prefabs.Add(levelId, sub); Prefabs.Add(levelId, sub);
sub.transform.SetParent(transform); sub.transform.SetParent(transform);
sub.transform.localPosition = Vector3.zero;
AssetBundles.Add(levelId, ab); AssetBundles.Add(levelId, ab);
Durations.Add(levelId, duration); Durations.Add(levelId, duration);
})); }));

View File

@@ -1,14 +1,37 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System.Collections; using Demo.Game.ConfigType;
using System.Collections.Generic; using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class LookAtAnchorConfig : UpdatementIntConfig
{
[Content] public bool IsEnableUpdateEveryTick = false;
public override void Deserialize(BinaryReader reader)
{
IsEnableUpdateEveryTick = BinarySerializeUtility.ReadBool(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteBool(writer, IsEnableUpdateEveryTick);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class LookAtAnchor : Updatement<int> public class LookAtAnchor : Updatement<int>
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new UpdatementIntConfig();
}
public static LookAtAnchor Make() public static LookAtAnchor Make()
{ {
return new GameObject().AddComponent<LookAtAnchor>(); return new GameObject().AddComponent<LookAtAnchor>();
@@ -19,17 +42,19 @@ namespace Demo.Game
return begin; return begin;
} }
private readonly List<ScriptableObject> LookAtCache = new(); public int LookAtObjectCache;
public bool IsEnableUpdateEveryTick
[Content] public int LookAtObject; {
[Content] public bool IsEnableUpdateEveryTick = false; get => GetConfig<LookAtAnchorConfig>().IsEnableUpdateEveryTick;
set => GetConfig<LookAtAnchorConfig>().IsEnableUpdateEveryTick = value;
}
protected override void UpdateData(int data) protected override void UpdateData(int data)
{ {
ScriptableObject target = LookAtCache[LookAtObject]; ScriptableObject target = GetRoot().FindWithIndex(data);
if (data != LookAtObject) if (data != LookAtObjectCache)
{ {
LookAtObject = data; LookAtObjectCache = data;
if (target != null) if (target != null)
transform.LookAt(target.transform); transform.LookAt(target.transform);
} }
@@ -46,8 +71,7 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void Add(float time, ScriptableObject target) public void Add(float time, ScriptableObject target)
{ {
LookAtCache.Add(target); ManualAddEntry(time, GetRoot().FindIndex(target), default);
ManualAddEntry(time, LookAtCache.Count - 1, default);
} }
/// <summary> /// <summary>

View File

@@ -1,24 +1,69 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using Demo.Game.ConfigType;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering.LookDev;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class MaterialUpdatementConfig : UpdatementIntConfig
{
public string MaterialAssetBundlePath;
public string[] MaterialNames;
public int[] MaterialIndexs;
public override void Deserialize(BinaryReader reader)
{
MaterialAssetBundlePath = BinarySerializeUtility.ReadString(reader);
MaterialNames = BinarySerializeUtility.DeserializeStringArray(reader);
MaterialIndexs = BinarySerializeUtility.DeserializeIntArray(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteString(writer, MaterialAssetBundlePath);
var uo = (MaterialUpdatement)target;
int e = uo.NameCache.Count;
int i = 0;
MaterialNames = new string[e];
MaterialIndexs = new int[e];
foreach (var item in uo.NameCache)
{
MaterialNames[i] = item.Key;
MaterialIndexs[i] = item.Value;
}
BinarySerializeUtility.SerializeArray(writer, MaterialNames);
BinarySerializeUtility.SerializeArray(writer, MaterialIndexs);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class MaterialUpdatement : Updatement<int>, IAssetBundleLoader public class MaterialUpdatement : Updatement<int>, IAssetBundleLoader
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new MaterialUpdatementConfig();
}
public static MaterialUpdatement Make() public static MaterialUpdatement Make()
{ {
return new GameObject().AddComponent<MaterialUpdatement>(); return new GameObject().AddComponent<MaterialUpdatement>();
} }
private readonly Dictionary<string, int> NameCache = new(); internal readonly Dictionary<string, int> NameCache = new();
private readonly Dictionary<int, Material> MaterialCache = new(); internal readonly Dictionary<int, Material> IndexCache = new();
internal readonly Dictionary<int, Material> MaterialCache = new();
public string MaterialAssetBundlePath = null; public string MaterialAssetBundlePath
{
get => GetConfig<MaterialUpdatementConfig>().MaterialAssetBundlePath;
set => GetConfig<MaterialUpdatementConfig>().MaterialAssetBundlePath = value;
}
public AssetBundle MaterialAssetBundle = null; public AssetBundle MaterialAssetBundle = null;
protected override int Lerp(int begin, int end, float t) protected override int Lerp(int begin, int end, float t)

View File

@@ -1,12 +1,38 @@
using Convention;
using Demo.Game.ConfigType;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Convention; using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class BaseOnMaterialUpdatementConfig : UpdatementFloatConfig
{
public int TargetMeshRenderer;
public override void Deserialize(BinaryReader reader)
{
TargetMeshRenderer = BinarySerializeUtility.ReadInt(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, TargetMeshRenderer);
base.Serialize(writer);
}
}
}
public abstract class BaseOnMaterialUpdatement : Updatement<float> public abstract class BaseOnMaterialUpdatement : Updatement<float>
{ {
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new BaseOnMaterialUpdatementConfig();
}
public abstract string TargetFieldName { get; } public abstract string TargetFieldName { get; }
protected override float Lerp(float begin, float end, float t) protected override float Lerp(float begin, float end, float t)
@@ -27,13 +53,9 @@ namespace Demo.Game
/// </summary> /// </summary>
/// <param name="path">脚本位置</param> /// <param name="path">脚本位置</param>
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void Load(string path) public void Load(ScriptableObject obj)
{ {
var so = FindWithPath(path, false); TargetMeshRenderer = obj.GetComponent<MeshRenderer>();
if (so != null)
{
TargetMeshRenderer = so.GetComponent<MeshRenderer>();
}
} }
} }
} }

View File

@@ -1,11 +1,13 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Convention; using Convention;
using Demo.Game.Attr;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
[Scriptable]
public class ColorUpdatement : BaseOnMaterialUpdatement public class ColorUpdatement : BaseOnMaterialUpdatement
{ {
public static ColorUpdatement Make() public static ColorUpdatement Make()

View File

@@ -1,11 +1,13 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Convention; using Convention;
using Demo.Game.Attr;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
[Scriptable]
public class EmissionColorUpdatement : BaseOnMaterialUpdatement public class EmissionColorUpdatement : BaseOnMaterialUpdatement
{ {
public static EmissionColorUpdatement Make() public static EmissionColorUpdatement Make()

View File

@@ -1,26 +1,79 @@
using System;
using System.Collections;
using Convention; using Convention;
using Demo.Game.ConfigType;
using Dreamteck.Splines; using Dreamteck.Splines;
using System.Collections;
using System.IO;
using Unity.Collections;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering;
namespace Demo.Game namespace Demo.Game
{ {
public interface IDependOnSplineRenderer namespace ConfigType
{ {
public class BasicSplineRendererConfig : UpdatementConfig<SplineClipDuration>
{
public int MySplineCore;
public string LinesAssetBundlePath;
public string MyDefaultMaterial;
public override void Deserialize(BinaryReader reader)
{
MySplineCore = BinarySerializeUtility.ReadInt(reader);
LinesAssetBundlePath = BinarySerializeUtility.ReadString(reader);
MyDefaultMaterial = BinarySerializeUtility.ReadString(reader);
base.Deserialize(reader);
} }
public static class DependOnSplineRendererUtility public override void Serialize(BinaryWriter writer)
{ {
public static BasicSplineRenderer LoadSplineRendererTool(this IDependOnSplineCore self, string path) BinarySerializeUtility.WriteInt(writer, MySplineCore);
BinarySerializeUtility.WriteString(writer, LinesAssetBundlePath);
BinarySerializeUtility.WriteString(writer, MyDefaultMaterial);
base.Serialize(writer);
}
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<SplineClipDuration> positions)
{ {
return self.SharedInterfaceScriptObject.FindWithPath(path, true) as BasicSplineRenderer; NativeArray<Vector2> temp = new(0, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
int e = BinarySerializeUtility.DeserializeNativeArray(reader, ref temp);
positions.ResizeArray(e);
for (int i = 0; i < e; i++)
{
positions[i] = new(temp[i].x, temp[i].y);
}
temp.Dispose();
}
protected override void SerializePositions(BinaryWriter writer, in NativeArray<SplineClipDuration> positions)
{
NativeArray<Vector2> temp = new(positions.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
for (int i = 0, e=positions.Length; i < e; i++)
{
temp[i] = new(positions[i].ClipFrom, positions[i].ClipTo);
}
BinarySerializeUtility.SerializeNativeArray(writer, temp);
temp.Dispose();
}
} }
} }
public abstract class BasicSplineRenderer : Updatement<SplineClipDuration>, IAssetBundleLoader, IDependOnSplineCore public abstract class BasicSplineRenderer : Updatement<SplineClipDuration>, IAssetBundleLoader, IDependOnSplineCore
{ {
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new BasicSplineRendererConfig();
}
/// <summary>
/// 加载并绑定到新样条线
/// </summary>
/// <param name="path">对象路径, 不存在时则立刻加载</param>
[Convention.RScript.Variable.Attr.Method]
public void LoadSpline(SplineCore core)
{
MySplineCore = core;
}
[Content] public SplineCore MySplineCore { get; set; } [Content] public SplineCore MySplineCore { get; set; }
[Content] private MeshFilter m_MeshFilter; [Content] private MeshFilter m_MeshFilter;
[Content] private MeshRenderer m_MyMeshRenderer; [Content] private MeshRenderer m_MyMeshRenderer;
@@ -60,7 +113,10 @@ namespace Demo.Game
get get
{ {
if (m_MyMeshRenderer == null) if (m_MyMeshRenderer == null)
{
m_MyMeshRenderer = this.GetOrAddComponent<MeshRenderer>(); m_MyMeshRenderer = this.GetOrAddComponent<MeshRenderer>();
m_MyMeshRenderer.material = StaticCacheDefaultMaterial;
}
return m_MyMeshRenderer; return m_MyMeshRenderer;
} }
} }
@@ -94,19 +150,6 @@ namespace Demo.Game
ManualAddEntry(time, new(from, to), curveType); ManualAddEntry(time, new(from, to), curveType);
} }
[Convention.RScript.Variable.Attr.Method]
public void LoadSpline(string path)
{
this.LoadSplineTool(path);
}
[Convention.RScript.Variable.Attr.Method]
public void LoadSpline(SplineCore spline)
{
this.MySplineCore = spline;
}
/// <summary> /// <summary>
/// 加载对应ab包并加载指定材质 /// 加载对应ab包并加载指定材质
/// </summary> /// </summary>

View File

@@ -1,4 +1,4 @@
using Demo.Attr; using Demo.Game.Attr;
using Dreamteck.Splines; using Dreamteck.Splines;
using System.Collections; using System.Collections;
using UnityEngine; using UnityEngine;

View File

@@ -1,4 +1,4 @@
using Demo.Attr; using Demo.Game.Attr;
using Dreamteck.Splines; using Dreamteck.Splines;
using System.Collections; using System.Collections;
using UnityEngine; using UnityEngine;

View File

@@ -1,5 +1,5 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using Dreamteck.Splines; using Dreamteck.Splines;
using System; using System;
using System.Collections; using System.Collections;

View File

@@ -1,15 +1,46 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using Demo.Game.ConfigType;
using Dreamteck.Splines; using Dreamteck.Splines;
using System; using System;
using System.Collections; using System.Collections;
using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class SplineTubeRendererConfig : BasicSplineJustFollowConfig
{
public const bool DefaultIsDoubleSide = true;
public const int DefaultSidesCount = 12;
public bool IsDoubleSide = DefaultIsDoubleSide;
public int SidesCount = DefaultSidesCount;
public override void Deserialize(BinaryReader reader)
{
IsDoubleSide = BinarySerializeUtility.ReadBool(reader);
SidesCount = BinarySerializeUtility.ReadInt(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteBool(writer, IsDoubleSide);
BinarySerializeUtility.WriteInt(writer, SidesCount);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class SplineTubeRenderer : BasicSplineRenderer<TubeGenerator> public class SplineTubeRenderer : BasicSplineRenderer<TubeGenerator>
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new SplineTubeRendererConfig();
}
public static SplineTubeRenderer Make() public static SplineTubeRenderer Make()
{ {
return new GameObject().AddComponent<SplineTubeRenderer>(); return new GameObject().AddComponent<SplineTubeRenderer>();

View File

@@ -1,13 +1,52 @@
using Demo.Attr; using Convention;
using Demo.Game.Attr;
using System; using System;
using System.Collections; using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
[Scriptable] namespace ConfigType
public class SplineAnchor : ScriptableObject, IDependOnSplineCore, IDependOnSplineRenderer
{ {
public class SplineAnchorConfig : ScriptLoadableConfig
{
public int MySplineCore, MySplineRenderer;
public bool isFollowPosition, isFollowRotation;
public float MySplineOffset;
public override void Deserialize(BinaryReader reader)
{
MySplineCore = BinarySerializeUtility.ReadInt(reader);
MySplineRenderer = BinarySerializeUtility.ReadInt(reader);
isFollowPosition = BinarySerializeUtility.ReadBool(reader);
isFollowRotation = BinarySerializeUtility.ReadBool(reader);
MySplineOffset = BinarySerializeUtility.ReadFloat(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, MySplineCore);
BinarySerializeUtility.WriteInt(writer, MySplineRenderer);
BinarySerializeUtility.WriteBool(writer, isFollowPosition);
BinarySerializeUtility.WriteBool(writer, isFollowRotation);
BinarySerializeUtility.WriteFloat(writer, MySplineOffset);
base.Serialize(writer);
}
}
}
[Scriptable]
public class SplineAnchor : ScriptableObject, IDependOnSplineCore
{
/// <summary>
/// 加载并绑定到新样条线
/// </summary>
/// <param name="path">对象路径, 不存在时则立刻加载</param>
[Convention.RScript.Variable.Attr.Method]
public void LoadSpline(SplineCore core)
{
MySplineCore = core;
}
public static SplineAnchor Make() public static SplineAnchor Make()
{ {
return new GameObject().AddComponent<SplineAnchor>(); return new GameObject().AddComponent<SplineAnchor>();
@@ -24,16 +63,6 @@ namespace Demo.Game
Updater?.Invoke(); Updater?.Invoke();
} }
/// <summary>
/// 加载并绑定到新样条线
/// </summary>
/// <param name="path">对象路径, 不存在时则立刻加载</param>
[Convention.RScript.Variable.Attr.Method]
public void LoadSpline(string path)
{
this.LoadSplineTool(path);
}
/// <summary> /// <summary>
/// 必须先执行LoadSpline加载样条线 /// 必须先执行LoadSpline加载样条线
/// </summary> /// </summary>

View File

@@ -1,13 +1,41 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using Dreamteck.Splines; using Dreamteck.Splines;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
// SplineCore 配置
public class SplineCoreConfig : ScriptLoadableConfig
{
public SplineComputer.SampleMode MySampleMode;
public Spline.Type MyType;
public bool IsClose;
public override void Deserialize(BinaryReader reader)
{
MySampleMode = (SplineComputer.SampleMode)BinarySerializeUtility.ReadInt(reader);
MyType = (Spline.Type)BinarySerializeUtility.ReadInt(reader);
IsClose = BinarySerializeUtility.ReadBool(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, (int)MySampleMode);
BinarySerializeUtility.WriteInt(writer, (int)MyType);
BinarySerializeUtility.WriteBool(writer, IsClose);
base.Serialize(writer);
}
}
}
public struct SplineClipDuration public struct SplineClipDuration
{ {
public float ClipFrom; public float ClipFrom;
@@ -23,30 +51,7 @@ namespace Demo.Game
public interface IDependOnSplineCore : IScriptableObject public interface IDependOnSplineCore : IScriptableObject
{ {
SplineCore MySplineCore { get; set; } SplineCore MySplineCore { get; set; }
void LoadSpline(string path); void LoadSpline(SplineCore core);
}
public static class DependOnSplineCoreUtility
{
public const string LoadSplineDescription = @"
<summary>
加载并绑定到新样条线
</summary>
<param name=""path"">对象相对路径,若对象不存在则作为脚本相对路径加载</param>
";
/// <summary>
/// 加载并绑定到新样条线
/// </summary>
/// <param name="path">对象相对路径,若对象不存在则作为脚本相对路径加载</param>
public static SplineCore LoadSplineTool(this IDependOnSplineCore self, string path)
{
var spline = self.SharedInterfaceScriptObject.FindWithPath(path, false);
if (spline == null)
spline = self.SharedInterfaceScriptObject.LoadSubScript(nameof(SplineCore), new ToolFile(path).GetFilename(true), path);
self.MySplineCore = (SplineCore)spline;
return self.MySplineCore;
}
} }
[Scriptable] [Scriptable]
@@ -71,14 +76,6 @@ namespace Demo.Game
public bool IsClose = false; public bool IsClose = false;
public SplineComputer MySplineComputer => m_MySplineComputer; public SplineComputer MySplineComputer => m_MySplineComputer;
//{
// get
// {
// if (m_MySplineComputer == null)
// m_MySplineComputer = this.GetComponent<SplineComputer>();
// return m_MySplineComputer;
// }
//}
/// <summary> /// <summary>
/// <see cref="SplineCore"/>需要在子<see cref="SplineNode"/>都添加后再应用脚本才能使得节点生效 /// <see cref="SplineCore"/>需要在子<see cref="SplineNode"/>都添加后再应用脚本才能使得节点生效

View File

@@ -1,11 +1,43 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using Dreamteck.Splines; using Dreamteck.Splines;
using System.Collections; using System.Collections;
using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
public class SplineNodeConfig : ScriptLoadableConfig
{
public float NodeSize = 1;
public Color NodeColor = Color.white;
public bool IsSetupNodeRotation = false;
public Vector3 NodeRotation = Vector3.zero;
public int[] LinkSplineCores;
public override void Deserialize(BinaryReader reader)
{
NodeSize = BinarySerializeUtility.ReadFloat(reader);
NodeColor = BinarySerializeUtility.ReadColor(reader);
IsSetupNodeRotation = BinarySerializeUtility.ReadBool(reader);
NodeRotation = BinarySerializeUtility.ReadVec3(reader);
LinkSplineCores = BinarySerializeUtility.DeserializeIntArray(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteFloat(writer, NodeSize);
BinarySerializeUtility.WriteColor(writer, NodeColor);
BinarySerializeUtility.WriteBool(writer, IsSetupNodeRotation);
BinarySerializeUtility.WriteVec3(writer, NodeRotation);
BinarySerializeUtility.SerializeArray(writer, LinkSplineCores);
base.Serialize(writer);
}
}
}
[Scriptable] [Scriptable]
public class SplineNode : ScriptableObject public class SplineNode : ScriptableObject
{ {
@@ -19,21 +51,30 @@ namespace Demo.Game
} }
private Node m_MyNode; private Node m_MyNode;
public bool IsSetupNodeSize = false;
public float NodeSize = 1; public float NodeSize = 1;
public Color NodeColor = Color.white; public Color NodeColor = Color.white;
public bool IsSetupNodeRotation = false; public bool IsSetupNodeRotation = false;
public Vector3 NodeRotation = Vector3.zero; public Vector3 NodeRotation = Vector3.zero;
public int MyNodeContent = 0;
public Node MyNode => m_MyNode; public Node MyNode => m_MyNode;
public void AddTo(SplineCore core) public void AddTo(SplineCore core)
{ {
MyNodeContent = core.NodeContent; int MyNodeContent = core.NodeContent;
core.MySplineComputer.SetPointColor(MyNodeContent, NodeColor); MyNode.transformSize = !IsSetupNodeSize;
core.MySplineComputer.SetPointSize(MyNodeContent, NodeSize); core.MySplineComputer.SetPointSize(MyNodeContent, NodeSize);
core.MySplineComputer.SetPointNormal(MyNodeContent, IsSetupNodeRotation ? NodeRotation.normalized : transform.up); if (IsSetupNodeRotation)
{
MyNode.transformNormals = false;
core.MySplineComputer.SetPointNormal(MyNodeContent, NodeRotation.normalized);
}
else
{
core.MySplineComputer.SetPointNormal(MyNodeContent, transform.up);
}
core.MySplineComputer.SetPointColor(MyNodeContent, NodeColor);
MyNode.AddConnection(core.MySplineComputer, MyNodeContent); MyNode.AddConnection(core.MySplineComputer, MyNodeContent);
} }
@@ -44,6 +85,7 @@ namespace Demo.Game
[Convention.RScript.Variable.Attr.Method] [Convention.RScript.Variable.Attr.Method]
public void SetNodeSize(float size) public void SetNodeSize(float size)
{ {
IsSetupNodeSize = true;
NodeSize = size; NodeSize = size;
} }
@@ -70,7 +112,7 @@ namespace Demo.Game
public void SetNodeRotation(float x, float y, float z) public void SetNodeRotation(float x, float y, float z)
{ {
IsSetupNodeRotation = true; IsSetupNodeRotation = true;
this.transform.localEulerAngles = NodeRotation = new(x, y, z); NodeRotation = new(x, y, z);
} }
} }
} }

View File

@@ -1,13 +1,47 @@
using Convention;
using Demo.Game.ConfigType;
using System; using System;
using System.Collections; using System.Collections;
using Convention; using System.IO;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
{ {
public abstract class BasicSplineJustFollow : Updatement<float> namespace ConfigType
{ {
public SplineCore MySplineCore; public class BasicSplineJustFollowConfig : UpdatementFloatConfig
{
public int MySplineCore;
public override void Deserialize(BinaryReader reader)
{
MySplineCore = BinarySerializeUtility.ReadInt(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, MySplineCore);
base.Serialize(writer);
}
}
}
public abstract class BasicSplineJustFollow : Updatement<float>, IDependOnSplineCore
{
protected override ConfigType.ScriptLoadableConfig MakeConfig()
{
return new BasicSplineJustFollowConfig();
}
/// <summary>
/// 加载并绑定到新样条线
/// </summary>
/// <param name="path">对象路径, 不存在时则立刻加载</param>
[Convention.RScript.Variable.Attr.Method]
public void LoadSpline(SplineCore core)
{
MySplineCore = core;
}
public SplineCore MySplineCore { get; set; }
protected override float Lerp(float begin, float end, float t) protected override float Lerp(float begin, float end, float t)
{ {
@@ -33,15 +67,5 @@ namespace Demo.Game
{ {
ManualAddEntry(time, value, curveType); ManualAddEntry(time, value, curveType);
} }
/// <summary>
/// 绑定到样条线
/// </summary>
/// <param name="path">脚本位置</param>
[Convention.RScript.Variable.Attr.Method]
public void Load(SplineCore splineCore)
{
MySplineCore = splineCore;
}
} }
} }

View File

@@ -1,8 +1,4 @@
using Convention; using Demo.Game.Attr;
using Convention.WindowsUI.Variant;
using Demo.Attr;
using Dreamteck.Splines;
using System.Collections;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game

View File

@@ -1,9 +1,4 @@
using Convention; using Demo.Game.Attr;
using Convention.WindowsUI.Variant;
using Demo.Attr;
using Dreamteck.Splines;
using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game

View File

@@ -1,7 +1,4 @@
using Convention; using Demo.Game.Attr;
using Demo.Attr;
using System;
using System.Collections;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game

View File

@@ -1,4 +1,4 @@
using Demo.Attr; using Demo.Game.Attr;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game

View File

@@ -1,9 +1,6 @@
using Convention; using Convention;
using Convention.WindowsUI.Variant; using Demo.Game.Attr;
using Demo.Attr; using Demo.Game.ConfigType;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
@@ -11,6 +8,10 @@ namespace Demo.Game
[Scriptable] [Scriptable]
public class TickMovement : Updatement<Vector3> public class TickMovement : Updatement<Vector3>
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new UpdatementVec3Config();
}
public static TickMovement Make() public static TickMovement Make()
{ {
return new GameObject().AddComponent<TickMovement>(); return new GameObject().AddComponent<TickMovement>();

View File

@@ -1,6 +1,6 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System; using Demo.Game.ConfigType;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
@@ -8,6 +8,10 @@ namespace Demo.Game
[Scriptable] [Scriptable]
public class TickRotation : Updatement<Vector3> public class TickRotation : Updatement<Vector3>
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new UpdatementVec3Config();
}
public static TickRotation Make() public static TickRotation Make()
{ {
return new GameObject().AddComponent<TickRotation>(); return new GameObject().AddComponent<TickRotation>();

View File

@@ -1,6 +1,6 @@
using Convention; using Convention;
using Demo.Attr; using Demo.Game.Attr;
using System; using Demo.Game.ConfigType;
using UnityEngine; using UnityEngine;
namespace Demo.Game namespace Demo.Game
@@ -8,6 +8,10 @@ namespace Demo.Game
[Scriptable] [Scriptable]
public class TickScaling : Updatement<Vector3> public class TickScaling : Updatement<Vector3>
{ {
protected override ScriptLoadableConfig MakeConfig()
{
return new UpdatementVec3Config();
}
public static TickScaling Make() public static TickScaling Make()
{ {
return new GameObject().AddComponent<TickScaling>(); return new GameObject().AddComponent<TickScaling>();

View File

@@ -1,6 +1,7 @@
using Convention; using Convention;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering; using UnityEngine.Rendering;
@@ -60,6 +61,14 @@ namespace Demo.Game
return false; return false;
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance); return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
} }
public bool TrySetOverrideField<FieldType>(string type, string name, FieldType value)
{
var component = GetOverride(type);
if (component == null)
return false;
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
}
} }
public abstract class BaseForSingleVolume<T> : BaseVolume where T : VolumeComponent public abstract class BaseForSingleVolume<T> : BaseVolume where T : VolumeComponent

View File

@@ -1,9 +1,14 @@
using Demo.Attr; using Demo.Game.Attr;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering.Universal; using UnityEngine.Rendering.Universal;
namespace Demo.Game namespace Demo.Game
{ {
namespace ConfigType
{
}
[Scriptable] [Scriptable]
public class MotionBlurVolume : BaseForSingleVolume<MotionBlur> public class MotionBlurVolume : BaseForSingleVolume<MotionBlur>
{ {

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6817d5ed5f3f2ba46b718a0003027dee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using Convention;
using Demo.Game.Attr;
using System.Collections;
using System.IO;
using UnityEngine;
namespace Demo.Game
{
namespace ConfigType
{
public class BaseVolumeUpdatementConfig:ScriptLoadableConfig
{
public int target;
public string updateOverride;
public string updateField;
public override void Deserialize(BinaryReader reader)
{
target = BinarySerializeUtility.ReadInt(reader);
updateOverride = BinarySerializeUtility.ReadString(reader);
updateField = BinarySerializeUtility.ReadString(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, target);
BinarySerializeUtility.WriteString(writer, updateOverride);
BinarySerializeUtility.WriteString(writer, updateField);
base.Serialize(writer);
}
}
}
public abstract class BaseVolumeUpdatement<T> : Updatement<T> where T : unmanaged
{
[Content, SerializeField] private BaseVolume target;
[Content, SerializeField] private string updateOverride;
[Content, SerializeField] private string updateField;
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
if (target == null)
{
target = this.UpdateTarget.SeekComponent<BaseVolume>();
}
}
protected override void UpdateData(T data)
{
target.TrySetOverrideField<T>(updateOverride, updateField, data);
}
[Convention.RScript.Variable.Attr.Method]
public void SetUpdateOverrideAndField(string updateOverride, string updateField)
{
this.updateOverride = updateOverride;
this.updateField = updateField;
}
/// <summary>
/// 新增
/// </summary>
/// <param name="time">插值时间</param>
/// <param name="value">值</param>
/// <param name="curveType">缓动曲线</param>
[Convention.RScript.Variable.Attr.Method]
public void Add(float time, T value, MathExtension.EaseCurveType curveType)
{
ManualAddEntry(time, value, curveType);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3310713d1026b944facb4c172ad38bb1

View File

@@ -0,0 +1,21 @@
using Convention;
using Demo.Game.Attr;
using System.Collections;
using UnityEngine;
namespace Demo.Game
{
[Scriptable]
public class VolumeFloatUpdatement : BaseVolumeUpdatement<float>
{
public static VolumeFloatUpdatement Make()
{
return new GameObject().AddComponent<VolumeFloatUpdatement>();
}
protected override float Lerp(float begin, float end, float t)
{
return Mathf.Lerp(begin, end, t);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6b3813d5ec8404345bcbd745281e2671

View File

@@ -0,0 +1,19 @@
using Demo.Game.Attr;
using UnityEngine;
namespace Demo.Game
{
[Scriptable]
public class VolumeIntUpdatement : BaseVolumeUpdatement<int>
{
public static VolumeIntUpdatement Make()
{
return new GameObject().AddComponent<VolumeIntUpdatement>();
}
protected override int Lerp(int begin, int end, float t)
{
return Mathf.FloorToInt(Mathf.Lerp(begin, end, t));
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 600cb8d3ed5900d4baa30e5d8aafa66e

View File

@@ -0,0 +1,67 @@
using Convention;
using Demo.Game.Attr;
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Rendering;
namespace Demo.Game
{
namespace ConfigType
{
// VolumeObject 配置
public class VolumeObjectConfig : ScriptLoadableConfig
{
public string MyAssetBundle, MyProfile;
public override void Deserialize(BinaryReader reader)
{
MyAssetBundle = BinarySerializeUtility.ReadString(reader);
MyProfile = BinarySerializeUtility.ReadString(reader);
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteString(writer, MyAssetBundle);
BinarySerializeUtility.WriteString(writer, MyProfile);
base.Serialize(writer);
}
}
}
[Scriptable]
public class VolumeObject : BaseVolume, IAssetBundleLoader
{
public static VolumeObject Make()
{
return new GameObject().AddComponent<VolumeObject>();
}
private bool IsLoading = false;
[Content, SerializeField] private string MyAssetBundle, MyProfile;
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
yield return new WaitUntil(() => !IsLoading);
if (MyVolume.profile == null)
{
MyVolume.profile = Resources.Load<VolumeProfile>("Volume/Default");
}
}
[Convention.RScript.Variable.Attr.Method]
public void Load(string ab, string profile)
{
IsLoading = true;
MyAssetBundle = ab;
MyProfile = profile;
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x =>
{
MyVolume.profile = x.LoadAsset<VolumeProfile>(profile);
IsLoading = false;
}));
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6905b41c61f830c4fac86087660118e4

View File

@@ -35,7 +35,7 @@ MonoBehaviour:
- line: '| useOnDemandResources: 0' - line: '| useOnDemandResources: 0'
- line: '| accelerometerFrequency: 60' - line: '| accelerometerFrequency: 60'
- line: '| companyName: LiuBai' - line: '| companyName: LiuBai'
- line: '| productName: Murmur-Resonance-Editor' - line: '| productName: ScriptableObject-Editor'
- line: '| defaultCursor: {instanceID: 0}' - line: '| defaultCursor: {instanceID: 0}'
- line: '| cursorHotspot: {x: 0, y: 0}' - line: '| cursorHotspot: {x: 0, y: 0}'
- line: '| m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: - line: '| m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b:
@@ -165,7 +165,7 @@ MonoBehaviour:
- line: '| loadStoreDebugModeEnabled: 0' - line: '| loadStoreDebugModeEnabled: 0'
- line: '| visionOSBundleVersion: 1.0' - line: '| visionOSBundleVersion: 1.0'
- line: '| tvOSBundleVersion: 1.0' - line: '| tvOSBundleVersion: 1.0'
- line: '| bundleVersion: 1.0' - line: '| bundleVersion: 1.1'
- line: '| preloadedAssets:' - line: '| preloadedAssets:'
- line: '| - {instanceID: 0}' - line: '| - {instanceID: 0}'
- line: '| - {instanceID: 0}' - line: '| - {instanceID: 0}'
@@ -422,7 +422,7 @@ MonoBehaviour:
- line: '| - m_BuildTarget: ' - line: '| - m_BuildTarget: '
- line: '| m_Icons:' - line: '| m_Icons:'
- line: '| - serializedVersion: 2' - line: '| - serializedVersion: 2'
- line: '| m_Icon: {fileID: 2800000, guid: 8a1e37e4b2571444b95d20abbea33454, - line: '| m_Icon: {fileID: 2800000, guid: e7fd089a9ebf1be4589638221dc0a006,
type: 3}' type: 3}'
- line: '| m_Width: 128' - line: '| m_Width: 128'
- line: '| m_Height: 128' - line: '| m_Height: 128'
@@ -1139,9 +1139,9 @@ MonoBehaviour:
- rid: 4324738286741356696 - rid: 4324738286741356696
type: {class: WindowsPlatformSettings, ns: UnityEditor.WindowsStandalone, asm: UnityEditor.WindowsStandalone.Extensions} type: {class: WindowsPlatformSettings, ns: UnityEditor.WindowsStandalone, asm: UnityEditor.WindowsStandalone.Extensions}
data: data:
m_Development: 0 m_Development: 1
m_ConnectProfiler: 0 m_ConnectProfiler: 0
m_BuildWithDeepProfilingSupport: 0 m_BuildWithDeepProfilingSupport: 1
m_AllowDebugging: 0 m_AllowDebugging: 0
m_WaitForManagedDebugger: 0 m_WaitForManagedDebugger: 0
m_ManagedDebuggerFixedPort: 0 m_ManagedDebuggerFixedPort: 0

View File

@@ -63,19 +63,7 @@ MonoBehaviour:
- rid: 4324738240734560283 - rid: 4324738240734560283
- rid: 4324738240734560284 - rid: 4324738240734560284
m_RuntimeSettings: m_RuntimeSettings:
m_List: m_List: []
- rid: 4324738240734560258
- rid: 4324738240734560260
- rid: 4324738240734560262
- rid: 4324738240734560264
- rid: 4324738240734560267
- rid: 4324738240734560268
- rid: 4324738240734560269
- rid: 4324738240734560275
- rid: 4324738240734560276
- rid: 4324738240734560280
- rid: 4324738240734560281
- rid: 4324738240734560282
m_AssetVersion: 8 m_AssetVersion: 8
m_ObsoleteDefaultVolumeProfile: {fileID: 0} m_ObsoleteDefaultVolumeProfile: {fileID: 0}
m_RenderingLayerNames: m_RenderingLayerNames: