Insanely huge initial commit

This commit is contained in:
2026-02-21 16:40:15 -08:00
parent 208d626100
commit f74c547a13
33825 changed files with 5213498 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,213 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
using System.Collections.Generic;
using UnityEngine;
namespace Lofelt.NiceVibrations
{
public class CarDemoManager : DemoManager
{
[Header("Control")]
public MMKnob Knob;
public float MinimumKnobValue = 0.1f;
public float MaximumPowerDuration = 10f;
public float ChargingSpeed = 2f;
public float CarSpeed = 0f;
public float Power;
public float StartClickDuration = 0.2f;
public float DentDuration = 0.10f;
public List<float> Dents;
[Header("Car")]
public AudioSource CarEngineAudioSource;
public Transform LeftWheel;
public Transform RightWheel;
public RectTransform CarBody;
public Vector3 WheelRotationSpeed = new Vector3(0f, 0f, 50f);
[Header("UI")]
public GameObject ReloadingPrompt;
public AnimationCurve StartClickCurve;
public MMProgressBar PowerBar;
public List<PowerBarElement> SpeedBars;
public Color ActiveColor;
public Color InactiveColor;
[Header("Debug")]
public bool _carStarted = false;
public float _carStartedAt = 0f;
public float _lastStartClickAt = 0f;
protected float _knobValueLastFrame;
protected float _lastDentAt = 0f;
protected float _knobValue;
protected Vector3 _initialCarPosition;
protected Vector3 _carPosition;
protected virtual void Awake()
{
Power = MaximumPowerDuration;
ReloadingPrompt.SetActive(false);
_initialCarPosition = CarBody.localPosition;
}
protected virtual void Update()
{
HandlePower();
UpdateCar();
UpdateUI();
_knobValueLastFrame = Knob.Value;
}
protected virtual void HandlePower()
{
_knobValue = Knob.Active ? Knob.Value : 0f;
if (!_carStarted)
{
if ((_knobValue > MinimumKnobValue) && (Knob.Active))
{
_carStarted = true;
_carStartedAt = Time.time;
_lastStartClickAt = Time.time;
HapticPatterns.PlayConstant(_knobValue, _knobValue, MaximumPowerDuration);
CarEngineAudioSource.Play();
}
else
{
Power += Time.deltaTime * ChargingSpeed;
Power = Mathf.Clamp(Power, 0f, MaximumPowerDuration);
if (Power == MaximumPowerDuration)
{
Knob.SetActive(true);
Knob._rectTransform.localScale = Vector3.one;
ReloadingPrompt.SetActive(false);
}
else
{
if (!Knob.Active)
{
Knob.SetValue(CarSpeed);
}
}
}
}
else
{
if (Time.time - _carStartedAt > MaximumPowerDuration)
{
_carStarted = false;
Knob.SetActive(false);
Knob._rectTransform.localScale = Vector3.one * 0.9f;
ReloadingPrompt.SetActive(true);
}
else
{
if (_knobValue > MinimumKnobValue)
{
Power -= Time.deltaTime;
Power = Mathf.Clamp(Power, 0f, MaximumPowerDuration);
HapticController.clipLevel = _knobValue;
HapticController.clipFrequencyShift = _knobValue;
if (Power <= 0f)
{
_carStarted = false;
Knob.SetActive(false);
Knob._rectTransform.localScale = Vector3.one * 0.9f;
ReloadingPrompt.SetActive(true);
HapticController.Stop();
}
}
else
{
_carStarted = false;
_lastStartClickAt = Time.time;
HapticController.Stop();
}
}
}
}
protected virtual void UpdateCar()
{
float targetSpeed = _carStarted ? NiceVibrationsDemoHelpers.Remap(Knob.Value, MinimumKnobValue, 1f, 0f, 1f) : 0f;
CarSpeed = Mathf.Lerp(CarSpeed, targetSpeed, Time.deltaTime * 1f);
CarEngineAudioSource.volume = CarSpeed;
CarEngineAudioSource.pitch = NiceVibrationsDemoHelpers.Remap(CarSpeed, 0f, 1f, 0.5f, 1.25f);
LeftWheel.Rotate(CarSpeed * Time.deltaTime * WheelRotationSpeed, Space.Self);
RightWheel.Rotate(CarSpeed * Time.deltaTime * WheelRotationSpeed, Space.Self);
_carPosition.x = _initialCarPosition.x + 0f;
_carPosition.y = _initialCarPosition.y + 10 * CarSpeed * Mathf.PerlinNoise(Time.time * 10f, CarSpeed * 10f);
_carPosition.z = 0f;
CarBody.localPosition = _carPosition;
}
protected virtual void UpdateUI()
{
if (Knob.Active)
{
// start dent
if (Time.time - _lastStartClickAt < StartClickDuration)
{
float elapsedTime = StartClickCurve.Evaluate((Time.time - _lastStartClickAt) * (1 / StartClickDuration));
Knob._rectTransform.localScale = Vector3.one + Vector3.one * elapsedTime * 0.05f;
Knob._image.color = Color.Lerp(ActiveColor, Color.white, elapsedTime);
}
// other dents
foreach (float f in Dents)
{
if (((_knobValue >= f) && (_knobValueLastFrame < f)) || ((_knobValue <= f) && (_knobValueLastFrame > f)))
{
_lastDentAt = Time.time;
break;
}
}
if (Time.time - _lastDentAt < DentDuration)
{
float elapsedTime = StartClickCurve.Evaluate((Time.time - _lastDentAt) * (1 / DentDuration));
Knob._rectTransform.localScale = Vector3.one + Vector3.one * elapsedTime * 0.02f;
Knob._image.color = Color.Lerp(ActiveColor, Color.white, elapsedTime * 0.05f);
}
}
// gas bar
PowerBar.UpdateBar(Power, 0f, MaximumPowerDuration);
// power bars
if (CarSpeed <= 0.1f)
{
for (int i = 0; i < SpeedBars.Count; i++)
{
SpeedBars[i].SetActive(false);
}
}
else
{
int barsAmount = (int)(CarSpeed * 5f);
for (int i = 0; i < SpeedBars.Count; i++)
{
if (i <= barsAmount)
{
SpeedBars[i].SetActive(true);
}
else
{
SpeedBars[i].SetActive(false);
}
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,57 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Lofelt.NiceVibrations
{
public class PowerBarElement : MonoBehaviour
{
public float BumpDuration = 0.15f;
public Color NormalColor;
public Color InactiveColor;
public AnimationCurve Curve;
protected Image _image;
protected float _bumpDuration = 0f;
protected bool _active = false;
protected bool _activeLastFrame = false;
protected virtual void Awake()
{
_image = this.gameObject.GetComponent<Image>();
}
public virtual void SetActive(bool status)
{
_active = status;
_image.color = status ? NormalColor : InactiveColor;
}
protected virtual void Update()
{
if (_active && !_activeLastFrame)
{
StartCoroutine(ColorBump());
}
_activeLastFrame = _active;
}
protected virtual IEnumerator ColorBump()
{
_bumpDuration = 0f;
while (_bumpDuration < BumpDuration)
{
float curveValue = Curve.Evaluate(_bumpDuration / BumpDuration);
_image.color = Color.Lerp(NormalColor, Color.white, curveValue);
_bumpDuration += Time.deltaTime;
yield return null;
}
_image.color = NormalColor;
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 26f9f894c832e234e91a99e33cda5548
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

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