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,98 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Lofelt.NiceVibrations
{
[Serializable]
public class HapticClipsDemoItem
{
public string Name;
public HapticClip HapticClip;
public Sprite AssociatedSprite;
public AudioSource AssociatedSound;
}
public class HapticClipsDemoManager : DemoManager
{
[Header("Image")]
public Image IconImage;
public Animator IconImageAnimator;
public List<HapticClipsDemoItem> DemoItems;
protected WaitForSeconds _iconChangeDelay;
protected int _idleAnimationParameter;
protected virtual void Awake()
{
_iconChangeDelay = new WaitForSeconds(0.02f);
_idleAnimationParameter = Animator.StringToHash("Idle");
IconImageAnimator.SetBool(_idleAnimationParameter, true);
}
// Haptic Clip -----------------------------------------------------------------------------
public virtual void PlayHapticClip(int index)
{
Logo.Shaking = true;
HapticController.fallbackPreset = HapticPatterns.PresetType.LightImpact;
HapticController.Play(DemoItems[index].HapticClip);
DemoItems[index].AssociatedSound.Play();
StopAllCoroutines();
StartCoroutine(ChangeIcon(DemoItems[index].AssociatedSprite));
}
// ICON ------------------------------------------------------------------------------------
protected virtual IEnumerator ChangeIcon(Sprite newSprite)
{
IconImageAnimator.SetBool(_idleAnimationParameter, false);
yield return _iconChangeDelay;
IconImage.sprite = newSprite;
}
// CALLBACKS -------------------------------------------------------------------------------
protected virtual IEnumerator BackToIdle()
{
Logo.Shaking = false;
IconImageAnimator.SetBool(_idleAnimationParameter, true);
yield return _iconChangeDelay;
IconImage.sprite = DemoItems[0].AssociatedSprite;
}
void OnHapticsStopped()
{
StartCoroutine(BackToIdle());
}
void OnDisable()
{
HapticController.PlaybackStopped -= OnHapticsStopped;
if (HapticController.IsPlaying())
{
HapticController.Stop();
}
}
void OnEnable()
{
HapticController.PlaybackStopped += OnHapticsStopped;
StartCoroutine(BackToIdle());
}
void OnApplicationFocus(bool hasFocus)
{
if (hasFocus)
{
StartCoroutine(BackToIdle());
}
}
}
}

View File

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

View File

@@ -0,0 +1,26 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Lofelt.NiceVibrations
{
/// <summary>
/// A minimal, demo only class, used to rotate an image in the demo's UI
/// </summary>
public class HapticClipsDemoRotator : MonoBehaviour
{
/// the speed at which the image should rotate
public Vector3 RotationSpeed = new Vector3(0, 0, 100f);
/// <summary>
/// On Update we rotate our image
/// </summary>
protected void Update()
{
this.transform.Rotate(RotationSpeed * Time.deltaTime, Space.Self);
}
}
}

View File

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