diff --git a/UnityProject/Assembly-CSharp.csproj b/UnityProject/Assembly-CSharp.csproj index 9c53671..73f4f1e 100644 --- a/UnityProject/Assembly-CSharp.csproj +++ b/UnityProject/Assembly-CSharp.csproj @@ -69,6 +69,7 @@ + diff --git a/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity b/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity index 74b3e5b..9d55f96 100644 --- a/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity +++ b/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity @@ -311,6 +311,97 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &669316602 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 669316606} + - component: {fileID: 669316605} + - component: {fileID: 669316604} + - component: {fileID: 669316603} + m_Layer: 0 + m_Name: SyncedCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &669316603 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 669316602} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 68dd60d6601a3ca4491fc454f866bc36, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!23 &669316604 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 669316602} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &669316605 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 669316602} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &669316606 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 669316602} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 2.18, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &700239840 GameObject: m_ObjectHideFlags: 0 @@ -447,6 +538,17 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 669316603} + m_MethodName: onClockReceived + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 samplePlayback: 0 --- !u!4 &1261823481 Transform: diff --git a/UnityProject/Assets/Scenes/Examples/MIDI/script/CubeSync.cs b/UnityProject/Assets/Scenes/Examples/MIDI/script/CubeSync.cs index 83fbf9f..8b09076 100644 --- a/UnityProject/Assets/Scenes/Examples/MIDI/script/CubeSync.cs +++ b/UnityProject/Assets/Scenes/Examples/MIDI/script/CubeSync.cs @@ -17,7 +17,6 @@ public class CubeSync : MonoBehaviour counter_++; targetX_ = (counter_ - 12) * 0.2f; counter_ %= 24; - } public void Update() @@ -25,7 +24,6 @@ public class CubeSync : MonoBehaviour var timeSinceLastCallback = Time.realtimeSinceStartup - lastCallBack_; var elapsedRatio = timeSinceLastCallback / callbackInterval_; var animationX = Mathf.Lerp(currentX_, targetX_, elapsedRatio); - Debug.Log(elapsedRatio); transform.position = new Vector3(animationX, 0f, 0f); } } diff --git a/UnityProject/Assets/Scenes/Examples/Smoother.meta b/UnityProject/Assets/Scenes/Examples/Smoother.meta new file mode 100644 index 0000000..96e567c --- /dev/null +++ b/UnityProject/Assets/Scenes/Examples/Smoother.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d41cdb385a3a87f43b3fd823895bd492 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Scenes/Examples/Smoother/Smoother.unity b/UnityProject/Assets/Scenes/Examples/Smoother/Smoother.unity new file mode 100644 index 0000000..b221983 --- /dev/null +++ b/UnityProject/Assets/Scenes/Examples/Smoother/Smoother.unity @@ -0,0 +1,736 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &127705016 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 127705019} + - component: {fileID: 127705017} + m_Layer: 0 + m_Name: SpectrumBind + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &127705017 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 127705016} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 54ab37d032df403e881d6a7a78141815, type: 3} + m_Name: + m_EditorClassIdentifier: + pdBackend: {fileID: 987772533} + selection: + serializedVersion: 2 + x: 16.083769 + y: 75 + width: 97.84293 + height: 128 + energyChanged: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 428795648} + m_MethodName: + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + channel: 0 +--- !u!4 &127705019 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 127705016} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &267275365 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 267275368} + - component: {fileID: 267275367} + - component: {fileID: 267275366} + - component: {fileID: 267275369} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &267275366 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267275365} + m_Enabled: 1 +--- !u!20 &267275367 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267275365} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.019223925, g: 0.07044816, b: 0.1509434, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &267275368 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267275365} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1.85, z: -5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &267275369 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267275365} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 23c1ce4fb46143f46bc5cb5224c934f6, type: 3} + m_Name: + m_EditorClassIdentifier: + clearColorMode: 1 + backgroundColorHDR: {r: 0.025, g: 0.07, b: 0.19, a: 0} + clearDepth: 1 + volumeLayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + volumeAnchorOverride: {fileID: 0} + antialiasing: 0 + SMAAQuality: 2 + dithering: 0 + stopNaNs: 0 + physicalParameters: + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + flipYMode: 0 + fullscreenPassthrough: 0 + allowDynamicResolution: 0 + customRenderingSettings: 0 + invertFaceCulling: 0 + probeLayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPathCustomFrameSettings: + bitDatas: + data1: 69284256546589 + data2: 4539628424389459968 + lodBias: 1 + lodBiasMode: 0 + maximumLODLevel: 0 + maximumLODLevelMode: 0 + renderingPathCustomFrameSettingsOverrideMask: + mask: + data1: 0 + data2: 0 + defaultFrameSettings: 0 + m_Version: 5 + m_ObsoleteRenderingPath: 0 + m_ObsoleteFrameSettings: + overrides: 0 + enableShadow: 0 + enableContactShadows: 0 + enableShadowMask: 0 + enableSSR: 0 + enableSSAO: 0 + enableSubsurfaceScattering: 0 + enableTransmission: 0 + enableAtmosphericScattering: 0 + enableVolumetrics: 0 + enableReprojectionForVolumetrics: 0 + enableLightLayers: 0 + enableExposureControl: 1 + diffuseGlobalDimmer: 0 + specularGlobalDimmer: 0 + shaderLitMode: 0 + enableDepthPrepassWithDeferredRendering: 0 + enableTransparentPrepass: 0 + enableMotionVectors: 0 + enableObjectMotionVectors: 0 + enableDecals: 0 + enableRoughRefraction: 0 + enableTransparentPostpass: 0 + enableDistortion: 0 + enablePostprocess: 0 + enableOpaqueObjects: 0 + enableTransparentObjects: 0 + enableRealtimePlanarReflection: 0 + enableMSAA: 0 + enableAsyncCompute: 0 + runLightListAsync: 0 + runSSRAsync: 0 + runSSAOAsync: 0 + runContactShadowsAsync: 0 + runVolumeVoxelizationAsync: 0 + lightLoopSettings: + overrides: 0 + enableDeferredTileAndCluster: 0 + enableComputeLightEvaluation: 0 + enableComputeLightVariants: 0 + enableComputeMaterialVariants: 0 + enableFptlForForwardOpaque: 0 + enableBigTilePrepass: 0 + isFptlEnabled: 0 +--- !u!1 &409530998 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 409531002} + - component: {fileID: 409531001} + - component: {fileID: 409531000} + - component: {fileID: 409530999} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &409530999 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 409530998} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c6c2871f720b2af4e9210febdac74517, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 1 + shadowResolution: 512 + shadowDimmer: 1 + volumetricShadowDimmer: 1 + shadowFadeDistance: 10000 + contactShadows: 0 + shadowTint: {r: 0, g: 0, b: 0, a: 1} + viewBiasMin: 0.2 + viewBiasMax: 100 + viewBiasScale: 1 + normalBiasMin: 0.5 + normalBiasMax: 0.5 + normalBiasScale: 1 + sampleBiasScale: 0 + edgeLeakFixup: 1 + edgeToleranceNormal: 1 + edgeTolerance: 1 + shadowCascadeCount: 4 + shadowCascadeRatios: + - 0.05 + - 0.2 + - 0.3 + shadowCascadeBorders: + - 0.2 + - 0.2 + - 0.2 + - 0.2 + shadowAlgorithm: 0 + shadowVariant: 0 + shadowPrecision: 0 +--- !u!114 &409531000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 409530998} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 5 + m_Version: 5 + directionalIntensity: 3.1415927 + punctualIntensity: 600 + areaIntensity: 200 + enableSpotReflector: 0 + luxAtDistance: 1 + m_InnerSpotPercent: 0 + lightDimmer: 1 + m_VolumetricDimmer: 1 + lightUnit: 2 + fadeDistance: 10000 + affectDiffuse: 1 + affectSpecular: 1 + nonLightmappedOnly: 0 + lightTypeExtent: 0 + m_SpotLightShape: 0 + shapeWidth: 0.5 + shapeHeight: 0.5 + aspectRatio: 1 + shapeRadius: 0 + maxSmoothness: 0.99 + applyRangeAttenuation: 1 + useOldInspector: 0 + useVolumetric: 1 + featuresFoldout: 1 + showAdditionalSettings: 0 + displayLightIntensity: 1.5 + displayAreaLightEmissiveMesh: 0 + areaLightCookie: {fileID: 0} + areaLightShadowCone: 120 + useScreenSpaceShadows: 0 + evsmExponent: 15 + evsmLightLeakBias: 0 + evsmVarianceBias: 0.00001 + evsmBlurPasses: 0 + lightLayers: 1 + lightlayersMask: 1 + linkShadowLayers: 1 + shadowNearPlane: 0.1 + shadowSoftness: 0.5 + blockerSampleCount: 24 + filterSampleCount: 16 + minFilterSize: 0.00001 + kernelSize: 5 + lightAngle: 1 + maxDepthBias: 0.001 +--- !u!108 &409531001 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 409530998} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 1.5 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 0 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 2 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &409531002 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 409530998} + m_LocalRotation: {x: 0.3612835, y: 0.30189243, z: -0.2597361, w: 0.84313244} + m_LocalPosition: {x: 4.56, y: 43.75, z: 24.1} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 50, y: 30, z: -20} +--- !u!1 &428795648 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 428795652} + - component: {fileID: 428795651} + - component: {fileID: 428795650} + - component: {fileID: 428795653} + - component: {fileID: 428795649} + m_Layer: 0 + m_Name: BoomBall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &428795649 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428795648} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9de1490c361f2bd48b4a81ad0457a4e7, type: 3} + m_Name: + m_EditorClassIdentifier: + threshold: 20 + attackTime: 0.01 + releaseTime: 0.5 + holdTime: 0.2 + onSmoothProcessed: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 428795653} + m_MethodName: set_Size + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!23 &428795650 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428795648} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: f044463ea66a19c47aef13261142b54e, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &428795651 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428795648} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &428795652 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428795648} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 3.25} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &428795653 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428795648} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 87673687b9b5a10488287f6faecad9d0, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &987772532 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 987772534} + - component: {fileID: 987772533} + m_Layer: 0 + m_Name: PdBackend + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &987772533 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 987772532} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3ba69cee3466a304d9d570268f717413, type: 3} + m_Name: + m_EditorClassIdentifier: + midiMessageReceived: + m_PersistentCalls: + m_Calls: [] + midiClockReceived: + m_PersistentCalls: + m_Calls: [] + samplePlayback: 0 +--- !u!4 &987772534 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 987772532} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/UnityProject/Assets/Scenes/Examples/Smoother/Smoother.unity.meta b/UnityProject/Assets/Scenes/Examples/Smoother/Smoother.unity.meta new file mode 100644 index 0000000..212be08 --- /dev/null +++ b/UnityProject/Assets/Scenes/Examples/Smoother/Smoother.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bc61f808bfe68d8499bcc07977f79656 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Scripts/Math/Smoother.cs b/UnityProject/Assets/Scripts/Math/Smoother.cs new file mode 100644 index 0000000..c72b624 --- /dev/null +++ b/UnityProject/Assets/Scripts/Math/Smoother.cs @@ -0,0 +1,97 @@ +using System; +using UnityEngine; +using UnityEngine.Events; + +[Serializable] +public class UnitySmoothEvent : UnityEvent +{} + + +public class Smoother : MonoBehaviour +{ + [SerializeField] private float threshold; + [SerializeField] private float attackTime; + [SerializeField] private float releaseTime; + [SerializeField] private float holdTime; + [SerializeField] private UnitySmoothEvent onSmoothProcessed; + + enum State + { + StandBy, + Attack, + Hold, + Release + }; + + private State state_ = State.StandBy; + private float attackStart_ = 0f; + private float holdStart_ = 0f; + private float releaseStart_ = 0f; + private float attackValue_ = 0f; + private bool releaseReady_ = false; + + public void OnValueChanged(float value) + { + if (CanStartAttackPhase(value)) + { + state_ = State.Attack; + Debug.Log("Attack"); + attackStart_ = Time.time; + attackValue_ = value; + } + else if (CanStartReleasePhase(value)) + { + state_ = State.Release; + Debug.Log("Release"); + releaseStart_ = Time.time; + releaseReady_ = false; + } + } + + private void Update() + { + + var now = Time.time; + switch (state_) + { + case State.Attack: + { + var timeSinceAttackStart = now - attackStart_; + onSmoothProcessed.Invoke(attackValue_ * (timeSinceAttackStart / attackTime)); + + if (timeSinceAttackStart >= attackTime) + { + state_ = State.Hold; + Debug.Log("Hold"); + } + break; + } + case State.Hold: + { + releaseReady_ = (now - holdStart_) > holdTime; + onSmoothProcessed.Invoke(attackValue_); + break; + } + case State.Release: + { + var timeSinceReleaseStart = now - releaseStart_; + onSmoothProcessed.Invoke(attackValue_ * (1.0f - (timeSinceReleaseStart / releaseTime))); + if (timeSinceReleaseStart >= releaseTime) + { + state_ = State.StandBy; + } + break; + } + } + } + + private bool CanStartAttackPhase(float value) + { + return value < threshold && state_ == State.StandBy; + } + + private bool CanStartReleasePhase(float value) + { + return state_ == State.Hold && value < threshold && releaseReady_; + } +} diff --git a/UnityProject/Assets/Scripts/Math/Smoother.cs.meta b/UnityProject/Assets/Scripts/Math/Smoother.cs.meta new file mode 100644 index 0000000..2bb7f59 --- /dev/null +++ b/UnityProject/Assets/Scripts/Math/Smoother.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9de1490c361f2bd48b4a81ad0457a4e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: