This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ABOUT: | |
* | |
* Simple script to convert Vector3 position to 2D panning position and distance | |
* attenuation based on the camera viewport. useful for 2D and isometric games. | |
* | |
* ############################################################ | |
* | |
* MIT License | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Usage: | |
* | |
* in some other script create an AudioVoices object | |
* | |
* public AudioVoices voiceLimiting = new AudioVoices(); | |
* | |
* then when playing a sound first add the AudioSource to the AudioVoices | |
* passing the maximum amount of instances and only play it if the source got added: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// UI inspector example implementation | |
Rect waveformRect = GUILayoutUtility.GetRect(waveformSize.x, waveformSize.y, GUIStyle.none); | |
EditorUtil.Waveform(waveformRect, clip, waveformSize); | |
float playMarker = 0f; // replace with a 0-1 seek position | |
if (playMarker >= 0f) { | |
Rect progressRect = new Rect(waveformRect); | |
float width = progressRect.width * playMarker; | |
progressRect.width = Mathf.Clamp(width, 6, width); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
public class HashedList<T> | |
{ | |
private List<T> _list; | |
private HashSet<T> _set; | |
public List<T> Elements { get { return _list; } } | |
public T this[int i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEngine; | |
using UnityEditor; | |
public class EditorHelper | |
{ | |
public static GUILayoutOption[] __buttonOptions = new GUILayoutOption[] { GUILayout.Width(120f), GUILayout.ExpandWidth(false) }; | |
public static void RandomRangeSlider(string propertyName, ref float val, ref float rand, ref bool randomEnabled, float min, float max, float resetValue) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CsvHandler | |
{ | |
public static void ExportStringData(string filename, string data, string defaultPath = "Assets/Debug/Log/") | |
{ | |
filename += "_" + MUtil.DateStamp(); | |
string path = defaultPath; | |
#if UNITY_EDITOR | |
path = UnityEditor.EditorUtility.SaveFilePanel("Save Data", defaultPath, filename, "csv"); | |
#else | |
path += filename + ".csv"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EditorUtils | |
{ | |
public static bool WarningDialog(string message = "") | |
{ | |
if (message == "") | |
message = "Are you sure you want to Continue?"; | |
if (EditorUtility.DisplayDialog("Continue ?", message, "Continue", "Cancel")) | |
{ | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MidiHelper | |
{ | |
static string[] __notesShatp = new string[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; | |
static string[] __notesFlat = new string[] { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" }; | |
public static string MidiCodeToString(int midiCode, bool flats = false) | |
{ | |
int octave = midiCode / 12 - 1; | |
if (octave < 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class BasicAudioConversions | |
{ | |
private static float twelfthRootOfTwo = Mathf.Pow(2, 1.0f / 12); | |
public static float St2pitch(float st) | |
{ | |
return Mathf.Clamp(Mathf.Pow(twelfthRootOfTwo, st), 0f, 4f); | |
} | |
public static float Pitch2st(float pitch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool WeightedPlaylist() | |
{ | |
bool playlistResult = false; | |
int playListLength = _playlist.Clips.Count; | |
int totalWeight = 0; | |
for (int i = 0; i < _playlist.Clips.Count; i++) { | |
totalWeight += _playlist.Weights[i]; | |
} | |
int choice = 0; |