plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent ed7b223c04
commit fd87a6ffd5
14441 changed files with 13711084 additions and 20 deletions

View File

@@ -0,0 +1,26 @@
using UnityEngine;
namespace GameKitController.Audio
{
public enum AudioPlayMethod
{
None,
UnityAudio,
External,
}
[System.Serializable]
public class AudioElement
{
public AudioPlayMethod audioPlayMethod = AudioPlayMethod.UnityAudio;
public string audioEventName;
public AudioClip clip;
public string audioSourceName;
public AudioSource audioSource;
public bool audioSourceAssigned;
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4305ce3c5006f074da3f6554bbdac065
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Audio/AudioElement.cs
uploadId: 814740

View File

@@ -0,0 +1,39 @@
using UnityEngine;
namespace GameKitController.Audio
{
public class AudioElementHolder : MonoBehaviour
{
public AudioElement audioElement;
public void Play ()
{
AudioPlayer.Play (audioElement, gameObject);
}
public void PlayOneShot (float volumeScale)
{
AudioPlayer.PlayOneShot (audioElement, gameObject, volumeScale);
}
public void PlayOneShot ()
{
PlayOneShot (1.0f);
}
public void Stop ()
{
AudioPlayer.Stop (audioElement, gameObject);
}
public void Pause ()
{
AudioPlayer.Pause (audioElement, gameObject);
}
public void UnPause ()
{
AudioPlayer.UnPause (audioElement, gameObject);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f85864c7cbfbfd34c8b9f16647cd5778
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Audio/AudioElementHolder.cs
uploadId: 814740

View File

@@ -0,0 +1,39 @@
using UnityEngine;
namespace GameKitController.Audio
{
public class AudioElementHolderPlayer : MonoBehaviour
{
public AudioElementHolder audioElementHolder;
public void Play ()
{
audioElementHolder.Play ();
}
public void PlayOneShot (float volumeScale)
{
audioElementHolder.PlayOneShot (volumeScale);
}
public void PlayOneShot ()
{
PlayOneShot (1.0f);
}
public void Stop ()
{
audioElementHolder.Stop ();
}
public void Pause ()
{
audioElementHolder.Pause ();
}
public void UnPause ()
{
audioElementHolder.UnPause ();
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2aaa1a98439a4f5fbf6eb76d6f2ebc50
timeCreated: 1668007958
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Audio/AudioElementHolderPlayer.cs
uploadId: 814740

View File

@@ -0,0 +1,31 @@
using UnityEngine;
namespace GameKitController.Audio
{
public class AudioManager : MonoBehaviour
{
public static AudioManager Instance { get; set; }
#if UNITY_2019_4_9_OR_NEWER
[RuntimeInitializeOnLoadMethod (RuntimeInitializeLoadType.SubsystemRegistration)]
#endif
private static void Init ()
{
Instance = null;
}
private void Awake ()
{
if (Instance == null)
Instance = this;
else if (Instance != this)
Destroy (this);
}
public IExternalAudioPlayer GetExternalAudioPlayer ()
{
return GetComponent<IExternalAudioPlayer> ();
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e7f72aad4f7a4aa9bb0bce1df3f9af5c
timeCreated: 1667567366
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Audio/AudioManager.cs
uploadId: 814740

View File

@@ -0,0 +1,152 @@
using UnityEngine;
namespace GameKitController.Audio
{
public class AudioPlayer
{
public static void Play (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
if (audioElement.clip != null) {
audioElement.audioSource.clip = audioElement.clip;
}
if (audioElement.audioSource.enabled) {
audioElement.audioSource.Play ();
}
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.Play (audioElement, gameObj);
}
}
public static void PlayOneShot (AudioElement audioElement, GameObject gameObj, float volumeScale = 1.0f)
{
if (audioElement == null)
return;
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned || audioElement.clip == null) {
return;
}
if (audioElement.audioSource.enabled) {
audioElement.audioSource.PlayOneShot (audioElement.clip, volumeScale);
}
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.PlayOneShot (audioElement, gameObj, volumeScale);
}
}
public static void Stop (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
audioElement.audioSource.Stop ();
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.Stop (audioElement, gameObj);
}
}
public static void Pause (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
audioElement.audioSource.Pause ();
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.Pause (audioElement, gameObj);
}
}
public static void UnPause (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
audioElement.audioSource.UnPause ();
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.UnPause (audioElement, gameObj);
}
}
private static void GetComponentAudioSourceIfNull (AudioElement audioElement, GameObject gameObj)
{
if (!audioElement.audioSourceAssigned) {
audioElement.audioSourceAssigned = audioElement.audioSource != null;
}
if (!audioElement.audioSourceAssigned) {
audioElement.audioSource = gameObj.GetComponent<AudioSource> ();
audioElement.audioSourceAssigned = audioElement.audioSource != null;
}
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c18ec1837d9c46b296ee5479933ea8ff
timeCreated: 1667490176
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Audio/AudioPlayer.cs
uploadId: 814740

View File

@@ -0,0 +1,17 @@
using UnityEngine;
namespace GameKitController.Audio
{
public interface IExternalAudioPlayer
{
void Play (AudioElement audioElement, GameObject gameObj);
void PlayOneShot (AudioElement audioElement, GameObject gameObj, float volumeScale = 1.0f);
void Stop (AudioElement audioElement, GameObject gameObj);
void Pause (AudioElement audioElement, GameObject gameObj);
void UnPause (AudioElement audioElement, GameObject gameObj);
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 5e61c5e5a1744e04aaadcb0be04ac0e4
timeCreated: 1667565191
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Audio/IExternalAudioPlayer.cs
uploadId: 814740