├── .gitignore ├── README.md ├── build └── usfxr.zip ├── samples ├── SpaceGame │ ├── .gitignore │ ├── Assets │ │ ├── Resources.meta │ │ ├── Resources │ │ │ ├── Prefabs.meta │ │ │ └── Prefabs │ │ │ │ ├── Bullet.prefab │ │ │ │ ├── Bullet.prefab.meta │ │ │ │ ├── Enemy.prefab │ │ │ │ ├── Enemy.prefab.meta │ │ │ │ ├── WhiteMaterial.mat │ │ │ │ └── WhiteMaterial.mat.meta │ │ ├── Scenes.meta │ │ ├── Scenes │ │ │ ├── Main.unity │ │ │ └── Main.unity.meta │ │ ├── Scripts.meta │ │ └── Scripts │ │ │ ├── Bullet.cs │ │ │ ├── Bullet.cs.meta │ │ │ ├── Enemy.cs │ │ │ ├── Enemy.cs.meta │ │ │ ├── Main.cs │ │ │ ├── Main.cs.meta │ │ │ ├── PlayerCube.cs │ │ │ ├── PlayerCube.cs.meta │ │ │ ├── usfxr.meta │ │ │ └── usfxr │ │ │ ├── Editor.meta │ │ │ ├── Editor │ │ │ └── SfxrGenerator.cs │ │ │ ├── SfxrAudioPlayer.cs │ │ │ ├── SfxrAudioPlayer.cs.meta │ │ │ ├── SfxrCacheSurrogate.cs │ │ │ ├── SfxrCacheSurrogate.cs.meta │ │ │ ├── SfxrParams.cs │ │ │ ├── SfxrParams.cs.meta │ │ │ ├── SfxrSynth.cs │ │ │ └── SfxrSynth.cs.meta │ └── ProjectSettings │ │ ├── AudioManager.asset │ │ ├── DynamicsManager.asset │ │ ├── EditorBuildSettings.asset │ │ ├── EditorSettings.asset │ │ ├── InputManager.asset │ │ ├── NavMeshLayers.asset │ │ ├── NetworkManager.asset │ │ ├── ProjectSettings.asset │ │ ├── QualitySettings.asset │ │ ├── TagManager.asset │ │ └── TimeManager.asset ├── benchmark │ ├── .gitignore │ ├── Assets │ │ ├── Scene.unity │ │ ├── Scene.unity.meta │ │ ├── Scripts.meta │ │ └── Scripts │ │ │ ├── Main.cs │ │ │ ├── Main.cs.meta │ │ │ ├── usfxr.meta │ │ │ └── usfxr │ │ │ ├── Editor.meta │ │ │ ├── Editor │ │ │ ├── SfxrGenerator.cs │ │ │ └── SfxrGenerator.cs.meta │ │ │ ├── SfxrAudioPlayer.cs │ │ │ ├── SfxrAudioPlayer.cs.meta │ │ │ ├── SfxrCacheSurrogate.cs │ │ │ ├── SfxrCacheSurrogate.cs.meta │ │ │ ├── SfxrParams.cs │ │ │ ├── SfxrParams.cs.meta │ │ │ ├── SfxrSynth.cs │ │ │ └── SfxrSynth.cs.meta │ └── ProjectSettings │ │ ├── AudioManager.asset │ │ ├── DynamicsManager.asset │ │ ├── EditorBuildSettings.asset │ │ ├── EditorSettings.asset │ │ ├── GraphicsSettings.asset │ │ ├── InputManager.asset │ │ ├── NavMeshLayers.asset │ │ ├── NetworkManager.asset │ │ ├── Physics2DSettings.asset │ │ ├── ProjectSettings.asset │ │ ├── QualitySettings.asset │ │ ├── TagManager.asset │ │ └── TimeManager.asset └── main │ ├── .gitignore │ ├── Assets │ ├── Scenes.meta │ ├── Scenes │ │ ├── main.unity │ │ └── main.unity.meta │ ├── Scripts.meta │ └── Scripts │ │ ├── Main.cs │ │ ├── Main.cs.meta │ │ ├── usfxr.meta │ │ └── usfxr │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── SfxrGenerator.cs │ │ └── SfxrGenerator.cs.meta │ │ ├── SfxrAudioPlayer.cs │ │ ├── SfxrAudioPlayer.cs.meta │ │ ├── SfxrCacheSurrogate.cs │ │ ├── SfxrCacheSurrogate.cs.meta │ │ ├── SfxrParams.cs │ │ ├── SfxrParams.cs.meta │ │ ├── SfxrSynth.cs │ │ └── SfxrSynth.cs.meta │ └── ProjectSettings │ ├── AudioManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshLayers.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── QualitySettings.asset │ ├── TagManager.asset │ └── TimeManager.asset └── source ├── Editor ├── SfxrGenerator.cs └── SfxrSoundEditor.cs ├── SfxrAudioPlayer.cs ├── SfxrCacheSurrogate.cs ├── SfxrParams.cs ├── SfxrSound.cs ├── SfxrSoundContainer.cs └── SfxrSynth.cs /.gitignore: -------------------------------------------------------------------------------- 1 | _temp 2 | _assets 3 | _package 4 | _todo.txt 5 | _*.bat 6 | samples/main/Assets/AssetStoreTools 7 | samples/main/Assets/AssetStoreTools.* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | usfxr 2 | ===== 3 | 4 | usfxr is a C# library used to generate and play game-like procedural audio effects inside Unity. With usfxr, one can easily design and synthesize original sound in real time for actions such as item pickups, jumps, lasers, hits, explosions, and more, without ever leaving the Unity editor. 5 | 6 | usfxr comes with code that allows for real-time audio synthesizing in games, and an in-editor interface for creating and testing effects before you use them in your code. 7 | 8 | usfxr is a port of Thomas Vian's [as3sfxr](https://code.google.com/p/as3sfxr/), which itself is an ActionScript 3 port of Tomas Pettersson's [sfxr](http://www.drpetter.se/project_sfxr.html). And as if the acronym collection is not enough, it also supports additional features first introduced by [BFXR](http://www.bfxr.net/) such as new waveform types and filters. 9 | 10 | [This video](https://vimeo.com/15769163) explains the ideas behind as3sfxr, and the ideas supported by usfxr. 11 | 12 | 13 | Introduction 14 | ------------ 15 | 16 | First things first: if you're just looking for a few good (but static) 16 bit-style sound effects to use in games, anyone can use sound files generated by [the original sfxr](http://www.drpetter.se/project_sfxr.html) or [as3sfxr's online version](http://www.superflashbros.net/as3sfxr/) without any changes, since both applications generate ready-to-be-used audio files. 17 | 18 | However, by using a runtime library like usfxr, you can generate the same audio samples in real time, or re-synthesize effects generated in any of those tools by using a small list of parameters (encoded as a short string). The advantages of this approach are twofold: 19 | 20 | * Audio is generated in real time; there's no storage of audio files as assets necessary, making compiled project sizes smaller 21 | * Easily play variations of every sound you play; adds more flavor to the gameplay experience 22 | 23 | And while the library was meant to be used in real time, without static assets, the editor can also generate static WAV files that can be used in your games. That way, nothing is synthesized in real time, but one still has the advantage of using an interface to generate original audio effects. 24 | 25 | I make no claims in regards to the source code or interface, since it was simply adapted from Thomas Vian's own code and (elegant) as3sfxr interface, as well as Stephen Lavelle's BFXR additional features. As such, usfxr contains the same features offered by these two ports, such as caching of generated audio and ability to play sounds with variations. But because the code is adapted to work on a different platform (Unity), it has advantages of its own: 26 | 27 | * Fast audio synthesis 28 | * Ability to cache sounds the first time they're played 29 | * Completely asynchronous caching and playback: sound is generated on a separate, non-blocking thread with minimal impact on gameplay 30 | * Minimal setup: as a full code-based solution, no drag-and-drop or additional game object placement is necessary 31 | * In-editor interface to test and generate audio parameters 32 | 33 | Installation 34 | ------------ 35 | 36 | Download the latest "usfxr" zip file from the "/build" folder of the GitHub repository and extract the contents of this file into the "Scripts" (or equivalent) folder of your Unity project. Alternatively, you can also download and install usfxr [from the asset store](https://www.assetstore.unity3d.com/en/#!/content/18619). 37 | 38 | After doing that, you should have the usfxr interface available inside Unity, as well as being able to instantiate and play SfxrSyth objects inside your project. 39 | 40 | 41 | Usage 42 | ----- 43 | 44 | Typically, the workflow for using usfxr inside a project is as such: 45 | 46 | 1. Use the menu "Window" > "Generate usfxr Sound Effects" to open the sound effects window 47 | 48 | [](http://hosted.zehfernando.com/ludumdare/usfxr/images/usfxr_img1.png) 49 | 50 | 2. Play around with the sound parameters until you generate a sound effect that you want to use 51 | 52 | [](http://hosted.zehfernando.com/ludumdare/usfxr/images/usfxr_img2.png) 53 | 54 | 3. Click "COPY" to copy the effect parameters to the clipboard (as a string) 55 | 4. Write some code to store your sound effect, pasting the correct string 56 | 57 | 58 | 59 | SfxrSynth synth = new SfxrSynth(); 60 | synth.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); 61 | 62 | Finally, to play your audio effect, you call its `Play()` method where appropriate: 63 | 64 | synth.Play(); 65 | 66 | With usfxr, all audio data is generated and cached internally the first time an effect is played, in real time. That way, any potential heavy load in generating audio doesn't have to be repeated the next time the sound is played, since it will already be in memory. 67 | 68 | Because of that, while it's possible to generate new SfxrSynth instances every time they need to be played, it's usually a better idea to keep them around and reuse them as needed. 69 | 70 | It's also important to notice that audio data generation does not occur all at once. This is a good thing: the audio data is generated as necessary, in batches, before playback of each 20ms chunk (more or less), so long audio effects won't take a lot of time to be generated. Audio is also generated on a separate thread, so impact on actual game execution should be minimal. Check [`OnAudioFilterRead`](http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnAudioFilterRead.html) for more details on how this happens. 71 | 72 | Notice that, alternatively, you can also use the [online version of as3sfxr](http://www.superflashbros.net/as3sfxr/) to generate the parameter string that can be used when creating SfxrSynth instances. Strings generated by as3sfxr use the same format as usfxr so they're interchangeable. 73 | 74 | #### Advanced usage: caching 75 | 76 | Although this is rare, in case of long or numerous audio effects, it may make sense to cache them first, before they are allowed to be played. This is done by calling the cacheSound() method first, as in: 77 | 78 | SfxrSynth synth = new SfxrSynth(); 79 | synth.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); 80 | synth.CacheSound(); 81 | ... 82 | synth.Play(); 83 | 84 | This caches the audio synchronously, that is, code execution is interrupted until `synth.CacheSound()` is completed. However, it's also possible to execute caching asynchronously, if you provide a callback function. Like so: 85 | 86 | SfxrSynth synth = new SfxrSynth(); 87 | synth.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); 88 | synth.CacheSound(() => synth.Play()); 89 | 90 | In the above case, the `CacheSound()` method will immediately return, and audio start to be generated in parallel with other code (as a coroutine). When the audio is cached, the callback function (`Play()`, in this case) will be called. 91 | 92 | As a reference, it typically takes around 7ms-70ms for an audio effect to be cached on a desktop, depending on its length and complexity. Therefore, sometimes it's better to let the game cache audio as it's played, or to stack the caching of all audio in the beginning of the gameplay, such as before a level starts. 93 | 94 | An important notice when comparing to as3sfxr: the ActionScript 3 virtual machine doesn't normally support multi-threading, or parallel execution of code. Because of this, the asynchronous caching methods of as3sfxr are somewhat different from what is adopted with usfxr, since Unity does execute code in parallel (using [Coroutines](http://docs.unity3d.com/Documentation//ScriptReference/index.Coroutines_26_Yield.html)) or in a separate thread entirely (using [`OnAudioFilterRead`](http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnAudioFilterRead.html)). As such, your caching strategy on Unity normally won't have to be as robust as an ActionScript 3 project; in the vast majority of the cases, it's better to ignore caching altogether and let the library handle it itself by using `Play()` with no custom caching calls. 95 | 96 | 97 | #### Advanced usage: setting the audio position 98 | 99 | By default, all audio is attached to the first main `Camera` available (that is, [`Camera.main`](http://docs.unity3d.com/Documentation/ScriptReference/Camera-main.html)). If you want to attach your audio playback to a different game object - and thus produce positional audio - you use `SetParentTransform` on your `SfxrSynth` instance, as in: 100 | 101 | synth.SetParentTransform(gameObject.transform); 102 | 103 | This attaches the audio to an specific game object. See the documentation for more details. 104 | 105 | 106 | Samples 107 | ------- 108 | 109 | Other than the source code to usfxr, the Git repository contains a few example projects using the library. The intention is to provide examples of how to properly use usfxr by solving common patterns that emerge in game development when it comes down to playing audio. The currently available sample projects are as such 110 | 111 | 112 | #### Benchmark 113 | 114 | This is a C# project that serves as a benchmark of the audio generation code. Run this example in different platforms to get an idea of how long it takes for that system to generate each audio sample. Because the audio is generated in real time the first time it has to be played, heavy audio generation can have a negative impact on game performance, so one must keep the results of this test in mind when deciding on a procedural audio solution for a game. A performance hit in audio generation may mean that you have to generate audio caches before a level is started, or in a worst case even abandoning the idea of using procedural audio. 115 | 116 | 117 | #### Main 118 | 119 | A simple example of audio generation and playback. Press keys A-E to generate audio in different ways, and check Unity's console log for more information on what was generated. 120 | 121 | 122 | #### SpaceGame 123 | 124 | A very simple game with basic objects: use the W, A, S and D (or arrow) keys to move around a cube in space. Press SPACE to shoot bullets. Enemy circles will spawn on the right of the screen; hit them with bullets to destroy them. 125 | 126 | In this game prototype, all audio - bullets, enemy spawns, and enemy explosions - are handled by usfxr. Since all audio effects are played in their "mutated" form, this example shows how the same audio can be played with little variation, adding some flavor to the lo-fi audio emitted by the game. 127 | 128 | Press the Z key to toggle mutated audio on and off. When off, the original audio is played. Try playing the game in both modes and notice the difference in regards to audio repetition when mutated mode is off. 129 | 130 | Play this sample online [here](http://hosted.zehfernando.com/ludumdare/usfxr/). 131 | 132 | 133 | To-do/ideas 134 | ----------- 135 | 136 | * Create button to copy code 137 | * Test in Javascript/create example 138 | * Create button to export to Unity sound clip/game object 139 | * Show waveform in GUI 140 | * Add stats such as memory and build time to GUI 141 | * Show effect duration in GUI 142 | * Undo/Redo 143 | * Add option to "lock" GUI items like BFXR 144 | * Automatic static caching? 145 | * Allow clip/game objects to be edited/re-synthesized? 146 | * Add more presets like SFMaker: http://www.leshylabs.com/apps/sfMaker/ 147 | 148 | 149 | Acknowledgments 150 | --------------- 151 | 152 | * Tomas Pettersson created the original [sfxr](http://www.drpetter.se/project_sfxr.html), where all the concepts for usfxr come from. 153 | * Thomas Vian created [as3sfxr](https://code.google.com/p/as3sfxr/), the original code that was ported to C# for usfxr. 154 | * [Tiaan Geldenhuys](http://tiaan.com/) contributed to usfxr by cleaning the code and creating the original version of the in-editor window that I bastardized later. 155 | * [Stephen Lavelle](http://www.increpare.com/) created [BFXR](http://www.bfxr.net/), an AS3 port of SFXR with several new features of its own, many of which have been adopted by usfxr. 156 | * Michael Bailey contributed with bug fixes. 157 | * Owen Roberts contributed with bug reports. 158 | * [Enrique J. Gil](https://github.com/Elideb) created the sound list saving/loading feature (SfxrSound) and its UI. 159 | 160 | Other notes 161 | ----------- 162 | 163 | * If you want a C#/.Net port of sfxr that is not heavily coupled with Unity, [nsfxr](https://github.com/nathanchere/nsfxr) by Nathan Chere is what you're looking for. 164 | 165 | 166 | Changelog (stable versions) 167 | --------------------------- 168 | 169 | #### 2014-12-17 ([1.4](https://github.com/zeh/usfxr/releases/tag/1.4)) 170 | 171 | * Editor: Audio plays correctly when using the editor window in non-play mode in Unity 5 beta 172 | 173 | #### 2014-08-02 ([1.3](https://github.com/zeh/usfxr/releases/tag/1.3)) 174 | 175 | * Editor: SfxrGameObject instances are properly removed when switching between play and edit mode (no more leftover objects) 176 | 177 | #### 2014-08-01 178 | 179 | * Editor: The same SfxrSynth instance is reused when generating test sounds, rather than creating new instances on every change (better memory use) 180 | 181 | #### 2014-07-28 182 | 183 | * Fixed showstopping error that prevented publishing in non-PC platforms 184 | 185 | #### 2014-07-17 186 | 187 | * Added option to export WAV file to SfxrSynth (and the GUI) 188 | 189 | #### 2014-07-12 ([1.2](https://github.com/zeh/usfxr/releases/tag/1.2)) 190 | 191 | * Added support for BFXR's new filters: compression, harmonics, and bitcrusher 192 | * Added support for BFXR's expanded pitch jump effects 193 | * Added support for BFXR's parameter strings (standard SFXR parameter strings still work) 194 | 195 | #### 2014-07-08 196 | 197 | * Added support for BFXR's new waveform types: triangle, breaker, tan, whistle, and pink noise 198 | 199 | #### 2014-06-10 ([1.1](https://github.com/zeh/usfxr/releases/tag/v2014-06-10)) 200 | 201 | * Small internal optimizations: generates audio samples in about 9% less time 202 | 203 | #### 2014-06-04 204 | 205 | * Modified SfxrSynth and SfxrAudioPlayer to properly allow sound playing running the editor in edit mode 206 | * Added an editor window to generate sound parameters right inside Unity 207 | 208 | #### 2013-04-21 209 | 210 | * Modified SfxrSynth to use the (safer) system-based random number generator (fixes errors thrown when attempting to generate noise from separate threads) 211 | * Samples: "SpaceGame" has enemies that collide with bullets (taking damage and making bullets disappear) and explode when health reaches 0 212 | * Samples: "SpaceGame" has a toggle for mutated audio mode 213 | 214 | #### 2013-04-14 215 | 216 | * Added movable enemies (spheres) to SpaceGame 217 | 218 | #### 2013-04-07 219 | 220 | * Added asynchronous generation (with callbacks) for CacheSound() and CacheMutations() 221 | * Code cleanup and removal of useless files 222 | * Samples: "Main" is a bit more user-friendly 223 | * Samples: Added initial SpaceGame 224 | 225 | #### 2013-04-06 226 | 227 | * Users can now set the parent transform of the audio (for proper audio positioning) with `SetParentTransform()` 228 | * Replaced `Random.value` calls with a more correct `getRandom()` function 229 | * Added `SfxrSynth.CacheMutations()` (fixes #12) 230 | * Removed legacy code for WAV generation (closes #16 and fixes #17, #18) 231 | 232 | For a list of things that need to be done, check the [issues](https://github.com/zeh/usfxr/issues) tab. 233 | -------------------------------------------------------------------------------- /build/usfxr.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/build/usfxr.zip -------------------------------------------------------------------------------- /samples/SpaceGame/.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | Temp/ 5 | Library/ 6 | 7 | # ===================================== # 8 | # Visual Studio / MonoDevelop generated # 9 | # ===================================== # 10 | ExportedObj/ 11 | obj/ 12 | *.svd 13 | *.userprefs 14 | /*.csproj 15 | *.pidb 16 | *.suo 17 | /*.sln 18 | *.user 19 | *.unityproj 20 | *.booproj 21 | 22 | # ============ # 23 | # OS generated # 24 | # ============ # 25 | .DS_Store 26 | .DS_Store? 27 | ._* 28 | .Spotlight-V100 29 | .Trashes 30 | ehthumbs.db 31 | Thumbs.db 32 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f5ef5fa9043feb44920e995edb5010a 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd35c60ffe0b59d43b859d38e56fc7f5 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs/Bullet.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/Assets/Resources/Prefabs/Bullet.prefab -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs/Bullet.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0af69cc31ff1afc42a7be10d732578cb 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs/Enemy.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/Assets/Resources/Prefabs/Enemy.prefab -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs/Enemy.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efc47f6ac415e3043b6aa953200f23f7 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs/WhiteMaterial.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/Assets/Resources/Prefabs/WhiteMaterial.mat -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Resources/Prefabs/WhiteMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 704917e0d45329e4e8f38b000ad45a27 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec4cd9f6a6e7026459fa2b9e26f9a24b 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scenes/Main.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/Assets/Scenes/Main.unity -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scenes/Main.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32edc4c1594875c42a9d5920146d6368 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96e3ba3314c70894db0b167002da02db 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/Bullet.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Bullet : MonoBehaviour { 5 | 6 | private const int SPEED = 60; // units per second 7 | private const float TIME_TO_LIVE = 3; // In seconds 8 | 9 | private float spawnTime; 10 | 11 | void Start() { 12 | // Rotates the bullet a little bit 13 | transform.Rotate(0, 0, (Random.value - 0.5f) * 10 + 90); 14 | 15 | spawnTime = Time.realtimeSinceStartup; 16 | } 17 | 18 | void Update() { 19 | float speedPassed = Time.deltaTime; 20 | 21 | transform.Translate(0, SPEED * -speedPassed, 0); 22 | 23 | if (Time.realtimeSinceStartup > spawnTime + TIME_TO_LIVE) { 24 | Die(); 25 | } 26 | } 27 | 28 | public void Die() { 29 | UnityEngine.Object.Destroy(gameObject); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/Bullet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1ea261ba03f6924aa4802ead3cc8bfc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/Enemy.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Enemy : MonoBehaviour { 5 | 6 | private const float TIME_TO_FULL_SCALE = 0.8f; 7 | private const float TIME_TO_FULL_SPEED = 5; 8 | private const int MIN_SPEED = 60; // units per second 9 | private const float TIME_TO_LIVE = 30; // In seconds 10 | private const float BASE_HEALTH = 1; 11 | private const float TIME_TO_EXPLODE = 1; 12 | 13 | private float scale; 14 | private int health; 15 | private float speed; 16 | private bool isAlive; 17 | 18 | private float spawnTime; 19 | private float explodeTime; 20 | 21 | void Start() { 22 | scale = 0.5f + (Random.value * 0.5f); 23 | scale *= scale; 24 | scale *= transform.localScale.x; 25 | 26 | health = (int)Mathf.Round(BASE_HEALTH * scale * 0.5f); 27 | isAlive = true; 28 | 29 | spawnTime = Time.realtimeSinceStartup; 30 | 31 | speed = MIN_SPEED / scale; 32 | 33 | transform.localScale = new Vector3(0, 0, 0); 34 | 35 | SfxrSynth synthSpawn = new SfxrSynth(); 36 | synthSpawn.parameters.SetSettingsString("0,0.03,0.23,0.05,0.42,0.15,0.07,-0.04,-0.02,,,0.02,0.05,0.11,0.1799,0.03,-0.4599,0.3999,0.38,,0.11,0.02,-0.02,0.5"); 37 | if (Main.isModeMutated) { 38 | synthSpawn.PlayMutated(0.05f); 39 | } else { 40 | synthSpawn.Play(); 41 | } 42 | } 43 | 44 | void Update() { 45 | float speedPassed = Time.deltaTime; 46 | 47 | float speedMult = (Time.realtimeSinceStartup - spawnTime) / TIME_TO_FULL_SPEED; 48 | if (speedMult > 1) speedMult = 1; 49 | 50 | float scaleMult = (Time.realtimeSinceStartup - spawnTime) / TIME_TO_FULL_SCALE; 51 | if (scaleMult > 1) scaleMult = 1; 52 | transform.localScale = new Vector3(scale * scaleMult, scale * scaleMult, scale * scaleMult); 53 | 54 | transform.Translate(speed * -speedPassed * speedMult, 0, 0); 55 | 56 | if (Time.realtimeSinceStartup > spawnTime + TIME_TO_LIVE) Destroy(); 57 | 58 | if (!isAlive) { 59 | if (Time.realtimeSinceStartup > explodeTime + TIME_TO_EXPLODE) { 60 | // Already exploded 61 | Destroy(); 62 | } else { 63 | // Exploding 64 | float explodePhase = (Time.realtimeSinceStartup - explodeTime) / TIME_TO_EXPLODE; 65 | 66 | float explodePhaseColor = 1-((1-explodePhase) * (1-explodePhase) * (1-explodePhase)); 67 | transform.renderer.material.color = new Color(1, 0, 0, 0.8f * (1-explodePhaseColor)); 68 | //transform.renderer.material.color = new Color(currentColor.r, currentColor.g, currentColor.b, 0.5f * (1-explodePhaseColor)); 69 | //transform.renderer.material.color = new Color(currentColor.r, currentColor.g, currentColor.b, 1-explodePhaseColor); 70 | 71 | float explodePhaseScale = 1-((1-explodePhase) * (1-explodePhase) * (1-explodePhase)); 72 | explodePhaseScale *= scale * 2; 73 | 74 | transform.localScale += new Vector3(explodePhaseScale, explodePhaseScale, explodePhaseScale); 75 | } 76 | } 77 | 78 | } 79 | 80 | private void Explode() { 81 | if (isAlive) { 82 | isAlive = false; 83 | explodeTime = Time.realtimeSinceStartup; 84 | 85 | SfxrSynth synth = new SfxrSynth(); 86 | synth.parameters.SetSettingsString("3,0.0228,0.2553,0.186,0.4243,0.0935,,0.0139,0.0292,0.0346,0.0599,-0.3396,0.7684,,-0.0209,,-0.0302,,1,-0.0272,0.0043,,0.0493,0.5"); 87 | if (Main.isModeMutated) { 88 | synth.PlayMutated(); 89 | } else { 90 | synth.Play(); 91 | } 92 | 93 | } 94 | } 95 | 96 | private void Destroy() { 97 | UnityEngine.Object.Destroy(gameObject); 98 | } 99 | 100 | void OnTriggerEnter(Collider __collider) { 101 | if (isAlive) { 102 | // Hacky way to determine what is it hitting 103 | if (__collider.gameObject.tag == "DamageEnemies") { 104 | // Hit by a bullet 105 | health--; 106 | __collider.gameObject.GetComponent().Die(); 107 | 108 | if (health <= 0) { 109 | Explode(); 110 | } 111 | } 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/Enemy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 712095bf170f4db45b8e68d0d5561d54 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/Main.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Main : MonoBehaviour { 5 | 6 | private const float TIME_ENEMY_SPAWN_INTERVAL_START = 2; // In seconds 7 | private const float TIME_ENEMY_SPAWN_INTERVAL_MIN = 0.5f; // In seconds 8 | 9 | private float timeEnemySpawned; 10 | private float timeEnemySpawnInterval; 11 | 12 | public static bool isModeMutated; 13 | 14 | void Start() { 15 | timeEnemySpawnInterval = TIME_ENEMY_SPAWN_INTERVAL_START; 16 | isModeMutated = true; 17 | UpdateGUI(); 18 | } 19 | 20 | void Update() { 21 | if (Time.realtimeSinceStartup > timeEnemySpawned + timeEnemySpawnInterval) { 22 | timeEnemySpawnInterval *= 0.97f; // Makes it go faster and faster over time 23 | if (timeEnemySpawnInterval < TIME_ENEMY_SPAWN_INTERVAL_MIN) timeEnemySpawnInterval = TIME_ENEMY_SPAWN_INTERVAL_MIN; 24 | SpawnEnemy(); 25 | } 26 | 27 | if (Input.GetKeyDown(KeyCode.Z)) { 28 | Main.isModeMutated = !isModeMutated; 29 | UpdateGUI(); 30 | } 31 | } 32 | 33 | private void UpdateGUI() { 34 | GUIText guiText = (GUIText) GameObject.Find("GUIText").GetComponent("GUIText"); 35 | guiText.text = "Z: Mutated mode [" + (isModeMutated ? "ON" : "OFF") + "]"; 36 | } 37 | 38 | private void SpawnEnemy() { 39 | // Creates a random enemy 40 | timeEnemySpawned = Time.realtimeSinceStartup; 41 | 42 | Instantiate(Resources.Load("Prefabs/Enemy"), transform.position + new Vector3(35, (Random.value - 0.5f) * 46f, 0), Quaternion.identity); 43 | } 44 | } -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/Main.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8cd03fbe29e2e46419233598e688260a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/PlayerCube.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class PlayerCube : MonoBehaviour { 5 | 6 | private const int PLAYER_SPEED = 50; // units per second 7 | private const int SHOTS_PER_SECOND = 20; 8 | private const int SHOTS_WITH_AUDIO_PER_SECOND = 10; // Doesn't play audio on EVERY shot otherwise it's just a cacophony of audio effects 9 | 10 | private SfxrSynth synthFire; 11 | private float lastTimeFired; 12 | private float lastTimeFiredAudio; 13 | 14 | void Start() { 15 | synthFire = new SfxrSynth(); 16 | synthFire.parameters.SetSettingsString("2,,0.2563,0.3007,0.0251,0.7527,,-0.3176,,,,,,,,,-0.0929,-0.0095,1,,,,,0.5"); 17 | } 18 | 19 | void Update() { 20 | float speedPassed = Time.deltaTime; 21 | if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) transform.Translate(0, PLAYER_SPEED * speedPassed, 0); 22 | if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) transform.Translate(0, PLAYER_SPEED * -speedPassed, 0); 23 | if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) transform.Translate(PLAYER_SPEED * -speedPassed, 0, 0); 24 | if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) transform.Translate(PLAYER_SPEED * speedPassed, 0, 0); 25 | 26 | if (Input.GetKey(KeyCode.Space) && Time.realtimeSinceStartup > lastTimeFired + 1f/SHOTS_PER_SECOND) SpawnBullet(); 27 | } 28 | 29 | private void SpawnBullet() { 30 | // Fire 31 | float now = Time.realtimeSinceStartup; 32 | 33 | Instantiate(Resources.Load("Prefabs/Bullet"), transform.position, Quaternion.identity); 34 | lastTimeFired = now; 35 | 36 | if (now > lastTimeFiredAudio + 1f/SHOTS_WITH_AUDIO_PER_SECOND) { 37 | if (Main.isModeMutated) { 38 | synthFire.PlayMutated(0.08f, 15); 39 | } else { 40 | synthFire.Play(); 41 | } 42 | lastTimeFiredAudio = now; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/PlayerCube.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe1c354d0a548564fbfa0661d92880d1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad5306a474616524b87dcd37c41e0f5c 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01861723f9311e04294de55915397c62 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/Editor/SfxrGenerator.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // SfxrEditor implements a Unity window to generate sounds with usfxr 4 | // using a more friendly GUI. 5 | // 6 | // 7 | // Copyright 2013 Tiaan Geldenhuys, 2014 Zeh Fernando 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | //----------------------------------------------------------------------- 22 | using System; 23 | using System.IO; 24 | using UnityEditor; 25 | using UnityEngine; 26 | 27 | /// 28 | /// Implements a Unity window to generate sounds and their parameters with usfxr. 29 | /// 30 | /// 31 | /// Open the generator from the Window menu. You can then create a sound and 32 | /// when you are ready, copy the equivalent parameters to the clipboard to be 33 | /// used inside your game. 34 | /// 35 | public class SfxrGenerator : EditorWindow { 36 | 37 | /// 38 | /// Open the usfxr's sound-effects generator window. 39 | /// 40 | 41 | // Enums 42 | public enum WaveType : uint { 43 | Square = 0, 44 | Sawtooth = 1, 45 | Sine = 2, 46 | Noise = 3, 47 | Triangle = 4, 48 | PinkNoise = 5, 49 | Tan = 6, 50 | Whistle = 7, 51 | Breaker = 8 52 | } 53 | 54 | // Properties 55 | private Vector2 scrollPosition; // Position of the scroll window 56 | private Vector2 scrollPositionRoot; 57 | private SfxrParams soundParameters; 58 | 59 | private string suggestedName; 60 | 61 | private SfxrSynth synth; 62 | 63 | // ================================================================================================================ 64 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 65 | 66 | [MenuItem("Window/Generate usfxr Sound Effects")] 67 | public static void Initialize() { 68 | var window = ScriptableObject.CreateInstance(); 69 | window.title = window.name = "Sound Effects"; 70 | window.Show(); 71 | } 72 | 73 | protected virtual void OnGUI() { 74 | // Initializations 75 | if (soundParameters == null) { 76 | soundParameters = new SfxrParams(); 77 | soundParameters.Randomize(); 78 | } 79 | 80 | if (synth == null) { 81 | synth = new SfxrSynth(); 82 | } 83 | 84 | bool soundChanged = false; 85 | 86 | // Begin UI 87 | scrollPositionRoot = GUILayout.BeginScrollView(scrollPositionRoot); 88 | GUILayout.BeginHorizontal(); 89 | 90 | // Left column (generator buttons, copy & paste) 91 | soundChanged = RenderLeftColumn(soundParameters) || soundChanged; 92 | 93 | // Main settings column 94 | soundChanged = RenderSettingsColumn(soundParameters) || soundChanged; 95 | 96 | // Ends the UI 97 | GUILayout.EndHorizontal(); 98 | GUILayout.EndScrollView(); 99 | 100 | // Play sound if necessary 101 | if (soundChanged) { 102 | synth.parameters.SetSettingsString(soundParameters.GetSettingsString()); 103 | PlaySound(); 104 | CreateWavePreview(); 105 | } 106 | 107 | } 108 | 109 | public void PlaySound() { 110 | // Just play the current sound 111 | synth.Play(); 112 | } 113 | 114 | public void CreateWavePreview() { 115 | // Creates an image with a preview of the wave 116 | 117 | /* 118 | // Create the texture and set its colour. 119 | Texture2D blackTexture = new Texture2D(1,1); 120 | blackTexture.SetPixel(0,0,Color.black); 121 | blackTexture.Apply(); 122 | ... 123 | // Use the texture. 124 | GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), blackTexture); 125 | 126 | // Anti alias line: http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm 127 | */ 128 | 129 | } 130 | 131 | public bool RenderLeftColumn(SfxrParams parameters) { 132 | bool soundChanged = false; 133 | 134 | // Begin generator column 135 | GUILayout.BeginVertical("box", GUILayout.Width(110)); 136 | GUILayout.Label("GENERATOR", EditorStyles.boldLabel); 137 | GUILayout.Space(8); 138 | 139 | if (GUILayout.Button("PICKUP/COIN")) { 140 | suggestedName = "PickupCoin"; 141 | parameters.GeneratePickupCoin(); 142 | soundChanged = true; 143 | } 144 | if (GUILayout.Button("LASER/SHOOT")) { 145 | suggestedName = "LaserShoot"; 146 | parameters.GenerateLaserShoot(); 147 | soundChanged = true; 148 | } 149 | if (GUILayout.Button("EXPLOSION")) { 150 | suggestedName = "Explosion"; 151 | parameters.GenerateExplosion(); 152 | soundChanged = true; 153 | } 154 | if (GUILayout.Button("POWERUP")) { 155 | suggestedName = "Powerup"; 156 | parameters.GeneratePowerup(); 157 | soundChanged = true; 158 | } 159 | if (GUILayout.Button("HIT/HURT")) { 160 | suggestedName = "HitHurt"; 161 | parameters.GenerateHitHurt(); 162 | soundChanged = true; 163 | } 164 | if (GUILayout.Button("JUMP")) { 165 | suggestedName = "Jump"; 166 | parameters.GenerateJump(); 167 | soundChanged = true; 168 | } 169 | if (GUILayout.Button("BLIP/SELECT")) { 170 | suggestedName = "BlipSelect"; 171 | parameters.GenerateBlipSelect(); 172 | soundChanged = true; 173 | } 174 | 175 | GUILayout.Space(30); 176 | 177 | if (GUILayout.Button("MUTATE")) { 178 | parameters.Mutate(); 179 | soundChanged = true; 180 | } 181 | if (GUILayout.Button("RANDOMIZE")) { 182 | suggestedName = "Random"; 183 | parameters.Randomize(); 184 | soundChanged = true; 185 | } 186 | 187 | GUILayout.Space(30); 188 | 189 | if (GUILayout.Button("COPY (OLD)")) { 190 | EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); 191 | } 192 | if (GUILayout.Button("COPY")) { 193 | EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); 194 | } 195 | if (GUILayout.Button("PASTE")) { 196 | suggestedName = null; 197 | parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); 198 | soundChanged = true; 199 | } 200 | 201 | GUILayout.Space(30); 202 | 203 | if (GUILayout.Button("PLAY SOUND")) { 204 | PlaySound(); 205 | } 206 | 207 | GUILayout.Space(30); 208 | 209 | if (GUILayout.Button("EXPORT WAV")) { 210 | var path = EditorUtility.SaveFilePanel("Export as WAV", "", getSuggestedName() + ".wav", "wav"); 211 | if (path.Length != 0) { 212 | SfxrSynth synth = new SfxrSynth(); 213 | synth.parameters.SetSettingsString(parameters.GetSettingsString()); 214 | File.WriteAllBytes(path, synth.GetWavFile()); 215 | } 216 | } 217 | 218 | // End generator column 219 | GUILayout.FlexibleSpace(); 220 | GUILayout.EndVertical(); 221 | 222 | return soundChanged; 223 | } 224 | 225 | public bool RenderSettingsColumn(SfxrParams parameters) { 226 | bool soundChanged = false; 227 | 228 | // Begin manual settings column 229 | GUILayout.BeginVertical("box"); 230 | GUILayout.Label("MANUAL SETTINGS", EditorStyles.boldLabel); 231 | GUILayout.Space(8); 232 | 233 | scrollPosition = GUILayout.BeginScrollView(scrollPosition); 234 | soundChanged = RenderParameters(soundParameters) || soundChanged; 235 | GUILayout.EndScrollView(); 236 | 237 | // End manual settings column 238 | GUILayout.FlexibleSpace(); 239 | GUILayout.EndVertical(); 240 | 241 | return soundChanged; 242 | } 243 | 244 | /// 245 | /// Renders the specified SFXR parameters in the editor. 246 | /// 247 | /// The current parameters to be rendered. 248 | /// 249 | /// This method is called automatically for the standalone editor window 250 | /// when a game-object with parameters is selected. However, this public 251 | /// method can also be called by CustomEditor implementations for specific 252 | /// game-components to render the editor in the Inspector window 253 | /// (see UnityEditor.Editor for details). Also, this method can be used 254 | /// from PropertyDrawer implementations; future releases of the code may 255 | /// include such a default drawer (once SfxrSynth and SfxrParams supports 256 | /// native serialization for Unity). 257 | /// 258 | public bool RenderParameters(SfxrParams parameters) { 259 | bool soundChanged = false; 260 | 261 | GUIStyle waveTypeStyle = EditorStyles.popup; 262 | waveTypeStyle.fontSize = 12; 263 | waveTypeStyle.fixedHeight = 22; 264 | 265 | EditorGUI.BeginChangeCheck(); 266 | try { 267 | WaveType waveTypeAsEnum = (WaveType)parameters.waveType; 268 | waveTypeAsEnum = (WaveType)EditorGUILayout.EnumPopup(new GUIContent("Wave Type", "Shape of the wave"), waveTypeAsEnum, waveTypeStyle); 269 | parameters.waveType = (uint)waveTypeAsEnum; 270 | GUILayout.Space(12); 271 | 272 | //RenderPopup(waveTypeOptions, ((int)(parameters.waveType)), (value => parameters.waveType = ((uint)(value))), new GUIContent("Wave Type", "Shape of the wave")); 273 | bool isSquareWaveType = (parameters.waveType == 0); 274 | RenderSlider(+0, +1, parameters.masterVolume, (value => parameters.masterVolume = value), new GUIContent("Volume", "Overall volume of the sound (0 to 1)")); 275 | 276 | RenderHeading("Wave Envelope"); 277 | RenderSlider(+0, +1, parameters.attackTime, (value => parameters.attackTime = value), new GUIContent("Attack Time", "Length of the volume envelope attack (0 to 1)")); 278 | RenderSlider(+0, +1, parameters.sustainTime, (value => parameters.sustainTime = value), new GUIContent("Sustain Time", "Length of the volume envelope sustain (0 to 1)")); 279 | RenderSlider(+0, +1, parameters.sustainPunch, (value => parameters.sustainPunch = value), new GUIContent("Sustain Punch", "Tilts the sustain envelope for more 'pop' (0 to 1)")); 280 | RenderSlider(+0, +1, parameters.decayTime, (value => parameters.decayTime = value), new GUIContent("Decay Time", "Length of the volume envelope decay (yes, I know it's called release) (0 to 1)")); 281 | 282 | // BFXR 283 | RenderSlider(+0, +1, parameters.compressionAmount, (value => parameters.compressionAmount = value), new GUIContent("Compression", "Pushes amplitudes together into a narrower range to make them stand out more. Very good for sound effects, where you want them to stick out against background music (0 to 1)")); 284 | 285 | RenderHeading("Frequency"); 286 | RenderSlider(+0, +1, parameters.startFrequency, (value => parameters.startFrequency = value), new GUIContent("Start Frequency", "Base note of the sound (0 to 1)")); 287 | RenderSlider(+0, +1, parameters.minFrequency, (value => parameters.minFrequency = value), new GUIContent("Minimum Frequency", "If sliding, the sound will stop at this frequency, to prevent really low notes (0 to 1)")); 288 | RenderSlider(-1, +1, parameters.slide, (value => parameters.slide = value), new GUIContent("Slide", "Slides the note up or down (-1 to 1)")); 289 | RenderSlider(-1, +1, parameters.deltaSlide, (value => parameters.deltaSlide = value), new GUIContent("Delta Slide", "Accelerates the slide (-1 to 1)")); 290 | RenderSlider(+0, +1, parameters.vibratoDepth, (value => parameters.vibratoDepth = value), new GUIContent("Vibrato Depth", "Strength of the vibrato effect (0 to 1)")); 291 | RenderSlider(+0, +1, parameters.vibratoSpeed, (value => parameters.vibratoSpeed = value), new GUIContent("Vibrato Speed", "Speed of the vibrato effect (i.e. frequency) (0 to 1)")); 292 | 293 | // BFXR 294 | RenderSlider(+0, +1, parameters.overtones, (value => parameters.overtones = value), new GUIContent("Harmonics", "Overlays copies of the waveform with copies and multiples of its frequency. Good for bulking out or otherwise enriching the texture of the sounds (warning: this is the number 1 cause of usfxr slowdown!) (0 to 1)")); 295 | RenderSlider(+0, +1, parameters.overtoneFalloff, (value => parameters.overtoneFalloff = value), new GUIContent("Harmonics falloff", "The rate at which higher overtones should decay (0 to 1)")); 296 | 297 | RenderHeading("Tone Change/Pitch Jump"); 298 | // BFXR 299 | RenderSlider(+0, +1, parameters.changeRepeat, (value => parameters.changeRepeat = value), new GUIContent("Change Repeat Speed", "Larger Values means more pitch jumps, which can be useful for arpeggiation (0 to 1)")); 300 | 301 | RenderSlider(-1, +1, parameters.changeAmount, (value => parameters.changeAmount = value), new GUIContent("Change Amount 1", "Shift in note, either up or down (-1 to 1)")); 302 | RenderSlider(+0, +1, parameters.changeSpeed, (value => parameters.changeSpeed = value), new GUIContent("Change Speed 1", "How fast the note shift happens (only happens once) (0 to 1)")); 303 | 304 | // BFXR 305 | RenderSlider(-1, +1, parameters.changeAmount2, (value => parameters.changeAmount2 = value), new GUIContent("Change Amount 2", "Shift in note, either up or down (-1 to 1)")); 306 | RenderSlider(+0, +1, parameters.changeSpeed2, (value => parameters.changeSpeed2 = value), new GUIContent("Change Speed 2", "How fast the note shift happens (only happens once) (0 to 1)")); 307 | 308 | RenderHeading("Square Waves"); 309 | RenderSlider(+0, +1, parameters.squareDuty, (value => parameters.squareDuty = value), new GUIContent("Square Duty", "Controls the ratio between the up and down states of the square wave, changing the tibre (0 to 1)"), isSquareWaveType); 310 | RenderSlider(-1, +1, parameters.dutySweep, (value => parameters.dutySweep = value), new GUIContent("Duty Sweep", "Sweeps the duty up or down (-1 to 1)"), isSquareWaveType); 311 | 312 | RenderHeading("Repeats"); 313 | RenderSlider(+0, +1, parameters.repeatSpeed, (value => parameters.repeatSpeed = value), new GUIContent("Repeat Speed", "Speed of the note repeating - certain variables are reset each time (0 to 1)")); 314 | 315 | RenderHeading("Phaser"); 316 | RenderSlider(-1, +1, parameters.phaserOffset, (value => parameters.phaserOffset = value), new GUIContent("Phaser Offset", "Offsets a second copy of the wave by a small phase, changing the tibre (-1 to 1)")); 317 | RenderSlider(-1, +1, parameters.phaserSweep, (value => parameters.phaserSweep = value), new GUIContent("Phaser Sweep", "Sweeps the phase up or down (-1 to 1)")); 318 | 319 | RenderHeading("Filters"); 320 | RenderSlider(+0, +1, parameters.lpFilterCutoff, (value => parameters.lpFilterCutoff = value), new GUIContent("Low-Pass Cutoff", "Frequency at which the low-pass filter starts attenuating higher frequencies (0 to 1)")); 321 | RenderSlider(-1, +1, parameters.lpFilterCutoffSweep, (value => parameters.lpFilterCutoffSweep = value), new GUIContent("Low-Pass Cutoff Sweep", "Sweeps the low-pass cutoff up or down (-1 to 1)")); 322 | RenderSlider(+0, +1, parameters.lpFilterResonance, (value => parameters.lpFilterResonance = value), new GUIContent("Low-Pass Resonance", "Changes the attenuation rate for the low-pass filter, changing the timbre (0 to 1)")); 323 | RenderSlider(+0, +1, parameters.hpFilterCutoff, (value => parameters.hpFilterCutoff = value), new GUIContent("High-Pass Cutoff", "Frequency at which the high-pass filter starts attenuating lower frequencies (0 to 1)")); 324 | RenderSlider(-1, +1, parameters.hpFilterCutoffSweep, (value => parameters.hpFilterCutoffSweep = value), new GUIContent("High-Pass Cutoff Sweep", "Sweeps the high-pass cutoff up or down (-1 to 1)")); 325 | 326 | RenderHeading("Bit Crushing"); 327 | 328 | // BFXR 329 | RenderSlider(+0, +1, parameters.bitCrush, (value => parameters.bitCrush = value), new GUIContent("Bit Crush", "Resamples the audio at a lower frequency (0 to 1)")); 330 | RenderSlider(-1, +1, parameters.bitCrushSweep, (value => parameters.bitCrushSweep = value), new GUIContent("Bit Crush Sweep", "Sweeps the Bit Crush filter up or down (-1 to 1)")); 331 | } finally { 332 | if (EditorGUI.EndChangeCheck()) { 333 | parameters.paramsDirty = true; 334 | soundChanged = true; 335 | } 336 | } 337 | 338 | return soundChanged; 339 | } 340 | 341 | protected static void RenderHeading(string heading) { 342 | EditorGUILayout.LabelField(heading, EditorStyles.boldLabel); 343 | } 344 | 345 | protected static bool RenderButton( 346 | GUIContent content = null, 347 | Action valueChangeAction = null, 348 | bool? isEnabled = null, 349 | params GUILayoutOption[] options) 350 | { 351 | if (content == null) 352 | { 353 | content = GUIContent.none; 354 | } 355 | 356 | bool isClicked = false; 357 | return RenderGenericEditor( 358 | ref isClicked, 359 | () => GUILayout.Button(content, options), 360 | valueChangeAction, 361 | isEnabled); 362 | } 363 | 364 | protected static bool RenderButton( 365 | string text, 366 | Action valueChangeAction = null, 367 | bool? isEnabled = null, 368 | params GUILayoutOption[] options) 369 | { 370 | return RenderButton( 371 | new GUIContent(text), valueChangeAction, isEnabled, options); 372 | } 373 | 374 | protected static bool RenderPopup( 375 | GUIContent[] selectionOptions, 376 | int value, 377 | Action valueChangeAction = null, 378 | GUIContent label = null, 379 | bool? isEnabled = null) 380 | { 381 | if (label == null) 382 | { 383 | label = GUIContent.none; 384 | } 385 | 386 | return RenderGenericEditor( 387 | ref value, 388 | () => EditorGUILayout.Popup(label, value, selectionOptions), 389 | valueChangeAction, 390 | isEnabled); 391 | } 392 | 393 | protected static bool RenderSlider( 394 | float minValue, 395 | float maxValue, 396 | float value, 397 | Action valueChangeAction = null, 398 | GUIContent label = null, 399 | bool? isEnabled = null) 400 | { 401 | if (label == null) 402 | { 403 | label = GUIContent.none; 404 | } 405 | 406 | return RenderGenericEditor( 407 | ref value, 408 | () => EditorGUILayout.Slider(label, value, minValue, maxValue), 409 | valueChangeAction, 410 | isEnabled); 411 | } 412 | 413 | private static bool RenderGenericEditor( 414 | ref T value, 415 | Func valueEditFunction, 416 | Action valueChangeAction = null, 417 | bool? isEnabled = null) 418 | { 419 | bool isChanged; 420 | if (valueEditFunction == null) 421 | { 422 | isChanged = false; 423 | } 424 | else 425 | { 426 | bool? wasEnabled; 427 | if (isEnabled.HasValue) 428 | { 429 | wasEnabled = GUI.enabled; 430 | GUI.enabled = isEnabled.Value; 431 | } 432 | else 433 | { 434 | wasEnabled = null; 435 | } 436 | 437 | try 438 | { 439 | EditorGUI.BeginChangeCheck(); 440 | try 441 | { 442 | value = valueEditFunction(); 443 | } 444 | finally 445 | { 446 | isChanged = EditorGUI.EndChangeCheck(); 447 | } 448 | 449 | if (isChanged 450 | && (valueChangeAction != null)) 451 | { 452 | valueChangeAction(value); 453 | } 454 | } 455 | finally 456 | { 457 | if (wasEnabled.HasValue) 458 | { 459 | GUI.enabled = wasEnabled.Value; 460 | } 461 | } 462 | } 463 | 464 | return isChanged; 465 | } 466 | 467 | private static bool RenderGenericEditor( 468 | ref T value, 469 | Func valueEditFunction, 470 | Action valueChangeAction, 471 | bool? isEnabled = null) 472 | { 473 | Action valueChangeActionWrapped = null; 474 | if (valueChangeAction != null) 475 | { 476 | valueChangeActionWrapped = (dummyValue) => valueChangeAction(); 477 | } 478 | 479 | return RenderGenericEditor( 480 | ref value, valueEditFunction, valueChangeActionWrapped, isEnabled); 481 | } 482 | 483 | private string getSuggestedName() { 484 | return suggestedName != null && suggestedName.Length > 0 ? suggestedName : "Audio"; 485 | } 486 | } 487 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/SfxrAudioPlayer.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | #endif 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | [ExecuteInEditMode] 8 | #endif 9 | public class SfxrAudioPlayer : MonoBehaviour { 10 | 11 | /** 12 | * usfxr 13 | * 14 | * Copyright 2013 Zeh Fernando 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | */ 29 | 30 | /** 31 | * SfxrAudioPlayer 32 | * This is the (internal) behavior script responsible for streaming audio to the engine 33 | * 34 | * @author Zeh Fernando 35 | */ 36 | 37 | 38 | // Properties 39 | private bool isDestroyed = false; // If true, this instance has been destroyed and shouldn't do anything yes 40 | private bool needsToDestroy = false; // If true, it has been scheduled for destruction (from outside the main thread) 41 | private bool runningInEditMode = false; // If true, it is running from the editor and NOT playing 42 | 43 | // Instances 44 | private SfxrSynth sfxrSynth; // SfxrSynth instance that will generate the audio samples used by this 45 | 46 | 47 | // ================================================================================================================ 48 | // INTERNAL INTERFACE --------------------------------------------------------------------------------------------- 49 | 50 | void Start() { 51 | // Creates an empty audio source so this GameObject can receive audio events 52 | AudioSource soundSource = gameObject.AddComponent(); 53 | soundSource.clip = new AudioClip(); 54 | soundSource.volume = 1f; 55 | soundSource.pitch = 1f; 56 | soundSource.priority = 128; 57 | soundSource.Play(); 58 | } 59 | 60 | void Update() { 61 | // Destroys self in case it has been queued for deletion 62 | if (sfxrSynth == null) { 63 | // Rogue object (leftover) 64 | // When switching between play and edit mode while the sound is playing, the object is restarted 65 | // So, queues for destruction 66 | needsToDestroy = true; 67 | } 68 | 69 | if (needsToDestroy) { 70 | needsToDestroy = false; 71 | Destroy(); 72 | } 73 | } 74 | 75 | void OnAudioFilterRead(float[] __data, int __channels) { 76 | // Requests the generation of the needed audio data from SfxrSynth 77 | 78 | if (!isDestroyed && !needsToDestroy && sfxrSynth != null) { 79 | bool hasMoreSamples = sfxrSynth.GenerateAudioFilterData(__data, __channels); 80 | 81 | // If no more samples are needed, there's no more need for this GameObject so schedule a destruction (cannot do this in this thread) 82 | if (!hasMoreSamples) { 83 | needsToDestroy = true; 84 | if (runningInEditMode) { 85 | // When running in edit mode, Update() is not called on every frame 86 | // We can't call Destroy() directly either, since Destroy() must be ran from the main thread 87 | // So we just attach our Update() to the editor's update event 88 | #if UNITY_EDITOR 89 | EditorApplication.update += Update; 90 | #endif 91 | } 92 | } 93 | } 94 | } 95 | 96 | 97 | // ================================================================================================================ 98 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 99 | 100 | public void SetSfxrSynth(SfxrSynth __sfxrSynth) { 101 | // Sets the SfxrSynth instance that will generate the audio samples used by this 102 | sfxrSynth = __sfxrSynth; 103 | } 104 | 105 | public void SetRunningInEditMode(bool __runningInEditMode) { 106 | // Sets the SfxrSynth instance that will generate the audio samples used by this 107 | runningInEditMode = __runningInEditMode; 108 | } 109 | 110 | public void Destroy() { 111 | // Stops audio immediately and destroys self 112 | if (!isDestroyed) { 113 | isDestroyed = true; 114 | sfxrSynth = null; 115 | if (runningInEditMode || !Application.isPlaying) { 116 | // Since we're running in the editor, we need to remove the update event, AND destroy immediately 117 | #if UNITY_EDITOR 118 | EditorApplication.update -= Update; 119 | #endif 120 | UnityEngine.Object.DestroyImmediate(gameObject); 121 | } else { 122 | UnityEngine.Object.Destroy(gameObject); 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/SfxrAudioPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1391218c99011a54ba31211b0719c854 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/SfxrCacheSurrogate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | public class SfxrCacheSurrogate : MonoBehaviour { 6 | 7 | /** 8 | * usfxr 9 | * 10 | * Copyright 2013 Zeh Fernando 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | */ 25 | 26 | /** 27 | * SfxrCacheSurrogate 28 | * This is the (internal) behavior script responsible for calling Coroutines for asynchronous audio generation 29 | * 30 | * @author Zeh Fernando 31 | */ 32 | 33 | // ================================================================================================================ 34 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 35 | 36 | public void CacheSound(SfxrSynth __synth, Action __callback) { 37 | StartCoroutine(CacheSoundAsynchronously(__synth, __callback)); 38 | } 39 | 40 | private IEnumerator CacheSoundAsynchronously(SfxrSynth __synth, Action __callback) { 41 | yield return null; 42 | __synth.CacheSound(null, true); 43 | __callback(); 44 | UnityEngine.Object.Destroy(gameObject); 45 | } 46 | 47 | public void CacheMutations(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 48 | StartCoroutine(CacheMutationsAsynchronously(__synth, __mutationsNum, __mutationAmount, __callback)); 49 | } 50 | 51 | private IEnumerator CacheMutationsAsynchronously(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 52 | yield return null; 53 | __synth.CacheMutations(__mutationsNum, __mutationAmount, null, true); 54 | __callback(); 55 | UnityEngine.Object.Destroy(gameObject); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/SfxrCacheSurrogate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c93e3356d5ec50149a067137955fe714 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/SfxrParams.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1949eec19485d034c930f2dadaf19c5c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/Assets/Scripts/usfxr/SfxrSynth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e5486432d46adc4eba1190e78534a0f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /samples/SpaceGame/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeh/usfxr/63cd954d4db4ec4ae4899aa31501941614894b6c/samples/SpaceGame/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /samples/benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | Temp/ 5 | Library/ 6 | 7 | # ===================================== # 8 | # Visual Studio / MonoDevelop generated # 9 | # ===================================== # 10 | ExportedObj/ 11 | obj/ 12 | *.svd 13 | *.userprefs 14 | /*.csproj 15 | *.pidb 16 | *.suo 17 | /*.sln 18 | *.user 19 | *.unityproj 20 | *.booproj 21 | 22 | # ============ # 23 | # OS generated # 24 | # ============ # 25 | .DS_Store 26 | .DS_Store? 27 | ._* 28 | .Spotlight-V100 29 | .Trashes 30 | ehthumbs.db 31 | Thumbs.db 32 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | SceneSettings: 5 | m_ObjectHideFlags: 0 6 | m_PVSData: 7 | m_PVSObjectsArray: [] 8 | m_PVSPortalsArray: [] 9 | m_OcclusionBakeSettings: 10 | smallestOccluder: 5 11 | smallestHole: .25 12 | backfaceThreshold: 100 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_Fog: 0 16 | m_FogColor: {r: .5, g: .5, b: .5, a: 1} 17 | m_FogMode: 3 18 | m_FogDensity: .00999999978 19 | m_LinearFogStart: 0 20 | m_LinearFogEnd: 300 21 | m_AmbientLight: {r: .200000003, g: .200000003, b: .200000003, a: 1} 22 | m_SkyboxMaterial: {fileID: 0} 23 | m_HaloStrength: .5 24 | m_FlareStrength: 1 25 | m_FlareFadeSpeed: 3 26 | m_HaloTexture: {fileID: 0} 27 | m_SpotCookie: {fileID: 0} 28 | m_ObjectHideFlags: 0 29 | --- !u!127 &3 30 | LevelGameManager: 31 | m_ObjectHideFlags: 0 32 | --- !u!157 &4 33 | LightmapSettings: 34 | m_ObjectHideFlags: 0 35 | m_LightProbes: {fileID: 0} 36 | m_Lightmaps: [] 37 | m_LightmapsMode: 1 38 | m_BakedColorSpace: 0 39 | m_UseDualLightmapsInForward: 0 40 | m_LightmapEditorSettings: 41 | m_Resolution: 50 42 | m_LastUsedResolution: 0 43 | m_TextureWidth: 1024 44 | m_TextureHeight: 1024 45 | m_BounceBoost: 1 46 | m_BounceIntensity: 1 47 | m_SkyLightColor: {r: .860000014, g: .930000007, b: 1, a: 1} 48 | m_SkyLightIntensity: 0 49 | m_Quality: 0 50 | m_Bounces: 1 51 | m_FinalGatherRays: 1000 52 | m_FinalGatherContrastThreshold: .0500000007 53 | m_FinalGatherGradientThreshold: 0 54 | m_FinalGatherInterpolationPoints: 15 55 | m_AOAmount: 0 56 | m_AOMaxDistance: .100000001 57 | m_AOContrast: 1 58 | m_LODSurfaceMappingDistance: 1 59 | m_Padding: 0 60 | m_TextureCompression: 0 61 | m_LockAtlas: 0 62 | --- !u!196 &5 63 | NavMeshSettings: 64 | m_ObjectHideFlags: 0 65 | m_BuildSettings: 66 | agentRadius: .5 67 | agentHeight: 2 68 | agentSlope: 45 69 | agentClimb: .400000006 70 | ledgeDropHeight: 0 71 | maxJumpAcrossDistance: 0 72 | accuratePlacement: 0 73 | minRegionArea: 2 74 | widthInaccuracy: 16.666666 75 | heightInaccuracy: 10 76 | m_NavMesh: {fileID: 0} 77 | --- !u!1 &321955848 78 | GameObject: 79 | m_ObjectHideFlags: 0 80 | m_PrefabParentObject: {fileID: 0} 81 | m_PrefabInternal: {fileID: 0} 82 | serializedVersion: 4 83 | m_Component: 84 | - 4: {fileID: 321955849} 85 | - 132: {fileID: 321955850} 86 | m_Layer: 0 87 | m_Name: CameraText 88 | m_TagString: Untagged 89 | m_Icon: {fileID: 0} 90 | m_NavMeshLayer: 0 91 | m_StaticEditorFlags: 0 92 | m_IsActive: 1 93 | --- !u!4 &321955849 94 | Transform: 95 | m_ObjectHideFlags: 0 96 | m_PrefabParentObject: {fileID: 0} 97 | m_PrefabInternal: {fileID: 0} 98 | m_GameObject: {fileID: 321955848} 99 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 100 | m_LocalPosition: {x: .5, y: .5, z: 0} 101 | m_LocalScale: {x: 1, y: 1, z: 1} 102 | m_Children: [] 103 | m_Father: {fileID: 815654112} 104 | --- !u!132 &321955850 105 | GUIText: 106 | m_ObjectHideFlags: 0 107 | m_PrefabParentObject: {fileID: 0} 108 | m_PrefabInternal: {fileID: 0} 109 | m_GameObject: {fileID: 321955848} 110 | m_Enabled: 1 111 | serializedVersion: 3 112 | m_Text: '{CameraText}' 113 | m_Anchor: 4 114 | m_Alignment: 1 115 | m_PixelOffset: {x: 0, y: 0} 116 | m_LineSpacing: 1 117 | m_TabSize: 4 118 | m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} 119 | m_Material: {fileID: 0} 120 | m_FontSize: 0 121 | m_FontStyle: 0 122 | m_Color: 123 | serializedVersion: 2 124 | rgba: 4294967295 125 | m_PixelCorrect: 1 126 | m_RichText: 1 127 | --- !u!1 &386303146 128 | GameObject: 129 | m_ObjectHideFlags: 0 130 | m_PrefabParentObject: {fileID: 0} 131 | m_PrefabInternal: {fileID: 0} 132 | serializedVersion: 4 133 | m_Component: 134 | - 4: {fileID: 386303147} 135 | - 114: {fileID: 386303148} 136 | m_Layer: 0 137 | m_Name: Main 138 | m_TagString: Untagged 139 | m_Icon: {fileID: 0} 140 | m_NavMeshLayer: 0 141 | m_StaticEditorFlags: 0 142 | m_IsActive: 1 143 | --- !u!4 &386303147 144 | Transform: 145 | m_ObjectHideFlags: 0 146 | m_PrefabParentObject: {fileID: 0} 147 | m_PrefabInternal: {fileID: 0} 148 | m_GameObject: {fileID: 386303146} 149 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 150 | m_LocalPosition: {x: 0, y: 0, z: 0} 151 | m_LocalScale: {x: 1, y: 1, z: 1} 152 | m_Children: [] 153 | m_Father: {fileID: 0} 154 | --- !u!114 &386303148 155 | MonoBehaviour: 156 | m_ObjectHideFlags: 0 157 | m_PrefabParentObject: {fileID: 0} 158 | m_PrefabInternal: {fileID: 0} 159 | m_GameObject: {fileID: 386303146} 160 | m_Enabled: 1 161 | m_EditorHideFlags: 0 162 | m_Script: {fileID: 11500000, guid: 348e8d6c5de7b3e49b220abd82a8985d, type: 3} 163 | m_Name: 164 | m_EditorClassIdentifier: 165 | --- !u!1 &815654107 166 | GameObject: 167 | m_ObjectHideFlags: 0 168 | m_PrefabParentObject: {fileID: 0} 169 | m_PrefabInternal: {fileID: 0} 170 | serializedVersion: 4 171 | m_Component: 172 | - 4: {fileID: 815654112} 173 | - 20: {fileID: 815654111} 174 | - 92: {fileID: 815654110} 175 | - 124: {fileID: 815654109} 176 | - 81: {fileID: 815654108} 177 | m_Layer: 0 178 | m_Name: Main Camera 179 | m_TagString: MainCamera 180 | m_Icon: {fileID: 0} 181 | m_NavMeshLayer: 0 182 | m_StaticEditorFlags: 0 183 | m_IsActive: 1 184 | --- !u!81 &815654108 185 | AudioListener: 186 | m_ObjectHideFlags: 0 187 | m_PrefabParentObject: {fileID: 0} 188 | m_PrefabInternal: {fileID: 0} 189 | m_GameObject: {fileID: 815654107} 190 | m_Enabled: 1 191 | --- !u!124 &815654109 192 | Behaviour: 193 | m_ObjectHideFlags: 0 194 | m_PrefabParentObject: {fileID: 0} 195 | m_PrefabInternal: {fileID: 0} 196 | m_GameObject: {fileID: 815654107} 197 | m_Enabled: 1 198 | --- !u!92 &815654110 199 | Behaviour: 200 | m_ObjectHideFlags: 0 201 | m_PrefabParentObject: {fileID: 0} 202 | m_PrefabInternal: {fileID: 0} 203 | m_GameObject: {fileID: 815654107} 204 | m_Enabled: 1 205 | --- !u!20 &815654111 206 | Camera: 207 | m_ObjectHideFlags: 0 208 | m_PrefabParentObject: {fileID: 0} 209 | m_PrefabInternal: {fileID: 0} 210 | m_GameObject: {fileID: 815654107} 211 | m_Enabled: 1 212 | serializedVersion: 2 213 | m_ClearFlags: 1 214 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 215 | m_NormalizedViewPortRect: 216 | serializedVersion: 2 217 | x: 0 218 | y: 0 219 | width: 1 220 | height: 1 221 | near clip plane: .300000012 222 | far clip plane: 1000 223 | field of view: 60 224 | orthographic: 0 225 | orthographic size: 100 226 | m_Depth: -1 227 | m_CullingMask: 228 | serializedVersion: 2 229 | m_Bits: 4294967295 230 | m_RenderingPath: -1 231 | m_TargetTexture: {fileID: 0} 232 | m_HDR: 0 233 | m_OcclusionCulling: 1 234 | --- !u!4 &815654112 235 | Transform: 236 | m_ObjectHideFlags: 0 237 | m_PrefabParentObject: {fileID: 0} 238 | m_PrefabInternal: {fileID: 0} 239 | m_GameObject: {fileID: 815654107} 240 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 241 | m_LocalPosition: {x: 0, y: 0, z: 0} 242 | m_LocalScale: {x: 1, y: 1, z: 1} 243 | m_Children: 244 | - {fileID: 321955849} 245 | m_Father: {fileID: 0} 246 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 062626695a3f0c7468baff32deab1d56 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab73c39e0dc4a6b4abc616a3ee184da5 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/Main.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Main : MonoBehaviour { 5 | 6 | private GUIText cameraGuiText; 7 | 8 | private float timeShort = 0; 9 | private float timeLong = 0; 10 | private int timesRan = 0; 11 | 12 | void Start () { 13 | cameraGuiText = (GUIText) GameObject.Find("CameraText").GetComponent("GUIText"); 14 | 15 | cameraGuiText.text = "Press A to start benchmarking sound generation"; 16 | } 17 | 18 | void Update () { 19 | if (Input.GetKeyDown("a")) { 20 | // Start benchmarking 21 | cameraGuiText.text = "Benchmarking..."; 22 | 23 | string completeText = ""; 24 | completeText += "Output sample rate: " + AudioSettings.outputSampleRate + "\n"; 25 | completeText += "\n"; 26 | 27 | int i; 28 | float ti; 29 | SfxrSynth synth; 30 | 31 | int count = 100; 32 | 33 | // Complete short sound caching 34 | ti = Time.realtimeSinceStartup; 35 | for (i = 0; i < count; i++) { 36 | synth = new SfxrSynth(); 37 | synth.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); 38 | synth.CacheSound(); 39 | } 40 | float newTimeShort = Time.realtimeSinceStartup - ti; 41 | completeText += "Time to generate short sound " + count + " times: " + newTimeShort + " seconds (" + (newTimeShort*1000/count) + " ms/sound)\n"; 42 | 43 | // Complete long sound caching 44 | ti = Time.realtimeSinceStartup; 45 | for (i = 0; i < count; i++) { 46 | synth = new SfxrSynth(); 47 | synth.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); 48 | synth.CacheSound(); 49 | } 50 | float newTimeLong = Time.realtimeSinceStartup - ti; 51 | completeText += "Time to generate long sound " + count + " times: " + newTimeLong + " seconds (" + (newTimeLong*1000/count) + " ms/sound)\n"; 52 | 53 | timeShort += newTimeShort; 54 | timeLong += newTimeLong; 55 | timesRan++; 56 | 57 | if (timesRan > 1) { 58 | completeText += "\n"; 59 | completeText += "Averages after " + timesRan + " tests ran:\n"; 60 | completeText += "Time to generate short sound " + count + " times: " + (timeShort / timesRan) + " seconds (" + ((timeShort / timesRan)*1000/count) + " ms/sound)\n"; 61 | completeText += "Time to generate long sound " + count + " times: " + (timeLong / timesRan) + " seconds (" + ((timeLong / timesRan)*1000/count) + " ms/sound)\n"; 62 | } 63 | 64 | completeText += "\n"; 65 | completeText += "Press A to benchmark again"; 66 | cameraGuiText.text = completeText; 67 | } 68 | /* 69 | if (newIsCDown && !isCDown) { 70 | Debug.Log("Key: C"); 71 | 72 | SfxrSynth synthC = null; 73 | if (synthC == null) { 74 | synthC = new SfxrSynth(); 75 | // Laser 76 | synthC.parameters.SetSettingsString("0,,0.1783,,0.3898,0.7523,0.2,-0.2617,,,,,,0.261,0.0356,,,,1,,,0.2466,,0.5"); 77 | 78 | // Hit 79 | //synthC.paramss.setSettingsString("2,,0.1702,,0.1689,0.7793,0.0224,-0.4882,,,,,,0.271,0.1608,,,,1,,,,,0.5"); 80 | } 81 | 82 | synthC.PlayMutated(0.05f); 83 | //synthC.play(); 84 | } 85 | */ 86 | 87 | //isADown = newIsADown; 88 | //isBDown = newIsBDown; 89 | //isCDown = newIsCDown; 90 | } 91 | } -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/Main.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 348e8d6c5de7b3e49b220abd82a8985d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 684b14e9baa6dcc40965f37b1ea52e04 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01861723f9311e04294de55915397c62 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/Editor/SfxrGenerator.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // SfxrEditor implements a Unity window to generate sounds with usfxr 4 | // using a more friendly GUI. 5 | // 6 | // 7 | // Copyright 2013 Tiaan Geldenhuys, 2014 Zeh Fernando 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | //----------------------------------------------------------------------- 22 | using System; 23 | using System.IO; 24 | using UnityEditor; 25 | using UnityEngine; 26 | 27 | /// 28 | /// Implements a Unity window to generate sounds and their parameters with usfxr. 29 | /// 30 | /// 31 | /// Open the generator from the Window menu. You can then create a sound and 32 | /// when you are ready, copy the equivalent parameters to the clipboard to be 33 | /// used inside your game. 34 | /// 35 | public class SfxrGenerator : EditorWindow { 36 | 37 | /// 38 | /// Open the usfxr's sound-effects generator window. 39 | /// 40 | 41 | // Enums 42 | public enum WaveType : uint { 43 | Square = 0, 44 | Sawtooth = 1, 45 | Sine = 2, 46 | Noise = 3, 47 | Triangle = 4, 48 | PinkNoise = 5, 49 | Tan = 6, 50 | Whistle = 7, 51 | Breaker = 8 52 | } 53 | 54 | // Properties 55 | private Vector2 scrollPosition; // Position of the scroll window 56 | private Vector2 scrollPositionRoot; 57 | private SfxrParams soundParameters; 58 | 59 | private string suggestedName; 60 | 61 | private SfxrSynth synth; 62 | 63 | // ================================================================================================================ 64 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 65 | 66 | [MenuItem("Window/Generate usfxr Sound Effects")] 67 | public static void Initialize() { 68 | var window = ScriptableObject.CreateInstance(); 69 | window.title = window.name = "Sound Effects"; 70 | window.Show(); 71 | } 72 | 73 | protected virtual void OnGUI() { 74 | // Initializations 75 | if (soundParameters == null) { 76 | soundParameters = new SfxrParams(); 77 | soundParameters.Randomize(); 78 | } 79 | 80 | if (synth == null) { 81 | synth = new SfxrSynth(); 82 | } 83 | 84 | bool soundChanged = false; 85 | 86 | // Begin UI 87 | scrollPositionRoot = GUILayout.BeginScrollView(scrollPositionRoot); 88 | GUILayout.BeginHorizontal(); 89 | 90 | // Left column (generator buttons, copy & paste) 91 | soundChanged = RenderLeftColumn(soundParameters) || soundChanged; 92 | 93 | // Main settings column 94 | soundChanged = RenderSettingsColumn(soundParameters) || soundChanged; 95 | 96 | // Ends the UI 97 | GUILayout.EndHorizontal(); 98 | GUILayout.EndScrollView(); 99 | 100 | // Play sound if necessary 101 | if (soundChanged) { 102 | synth.parameters.SetSettingsString(soundParameters.GetSettingsString()); 103 | PlaySound(); 104 | CreateWavePreview(); 105 | } 106 | 107 | } 108 | 109 | public void PlaySound() { 110 | // Just play the current sound 111 | synth.Play(); 112 | } 113 | 114 | public void CreateWavePreview() { 115 | // Creates an image with a preview of the wave 116 | 117 | /* 118 | // Create the texture and set its colour. 119 | Texture2D blackTexture = new Texture2D(1,1); 120 | blackTexture.SetPixel(0,0,Color.black); 121 | blackTexture.Apply(); 122 | ... 123 | // Use the texture. 124 | GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), blackTexture); 125 | 126 | // Anti alias line: http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm 127 | */ 128 | 129 | } 130 | 131 | public bool RenderLeftColumn(SfxrParams parameters) { 132 | bool soundChanged = false; 133 | 134 | // Begin generator column 135 | GUILayout.BeginVertical("box", GUILayout.Width(110)); 136 | GUILayout.Label("GENERATOR", EditorStyles.boldLabel); 137 | GUILayout.Space(8); 138 | 139 | if (GUILayout.Button("PICKUP/COIN")) { 140 | suggestedName = "PickupCoin"; 141 | parameters.GeneratePickupCoin(); 142 | soundChanged = true; 143 | } 144 | if (GUILayout.Button("LASER/SHOOT")) { 145 | suggestedName = "LaserShoot"; 146 | parameters.GenerateLaserShoot(); 147 | soundChanged = true; 148 | } 149 | if (GUILayout.Button("EXPLOSION")) { 150 | suggestedName = "Explosion"; 151 | parameters.GenerateExplosion(); 152 | soundChanged = true; 153 | } 154 | if (GUILayout.Button("POWERUP")) { 155 | suggestedName = "Powerup"; 156 | parameters.GeneratePowerup(); 157 | soundChanged = true; 158 | } 159 | if (GUILayout.Button("HIT/HURT")) { 160 | suggestedName = "HitHurt"; 161 | parameters.GenerateHitHurt(); 162 | soundChanged = true; 163 | } 164 | if (GUILayout.Button("JUMP")) { 165 | suggestedName = "Jump"; 166 | parameters.GenerateJump(); 167 | soundChanged = true; 168 | } 169 | if (GUILayout.Button("BLIP/SELECT")) { 170 | suggestedName = "BlipSelect"; 171 | parameters.GenerateBlipSelect(); 172 | soundChanged = true; 173 | } 174 | 175 | GUILayout.Space(30); 176 | 177 | if (GUILayout.Button("MUTATE")) { 178 | parameters.Mutate(); 179 | soundChanged = true; 180 | } 181 | if (GUILayout.Button("RANDOMIZE")) { 182 | suggestedName = "Random"; 183 | parameters.Randomize(); 184 | soundChanged = true; 185 | } 186 | 187 | GUILayout.Space(30); 188 | 189 | if (GUILayout.Button("COPY (OLD)")) { 190 | EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); 191 | } 192 | if (GUILayout.Button("COPY")) { 193 | EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); 194 | } 195 | if (GUILayout.Button("PASTE")) { 196 | suggestedName = null; 197 | parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); 198 | soundChanged = true; 199 | } 200 | 201 | GUILayout.Space(30); 202 | 203 | if (GUILayout.Button("PLAY SOUND")) { 204 | PlaySound(); 205 | } 206 | 207 | GUILayout.Space(30); 208 | 209 | if (GUILayout.Button("EXPORT WAV")) { 210 | var path = EditorUtility.SaveFilePanel("Export as WAV", "", getSuggestedName() + ".wav", "wav"); 211 | if (path.Length != 0) { 212 | SfxrSynth synth = new SfxrSynth(); 213 | synth.parameters.SetSettingsString(parameters.GetSettingsString()); 214 | File.WriteAllBytes(path, synth.GetWavFile()); 215 | } 216 | } 217 | 218 | // End generator column 219 | GUILayout.FlexibleSpace(); 220 | GUILayout.EndVertical(); 221 | 222 | return soundChanged; 223 | } 224 | 225 | public bool RenderSettingsColumn(SfxrParams parameters) { 226 | bool soundChanged = false; 227 | 228 | // Begin manual settings column 229 | GUILayout.BeginVertical("box"); 230 | GUILayout.Label("MANUAL SETTINGS", EditorStyles.boldLabel); 231 | GUILayout.Space(8); 232 | 233 | scrollPosition = GUILayout.BeginScrollView(scrollPosition); 234 | soundChanged = RenderParameters(soundParameters) || soundChanged; 235 | GUILayout.EndScrollView(); 236 | 237 | // End manual settings column 238 | GUILayout.FlexibleSpace(); 239 | GUILayout.EndVertical(); 240 | 241 | return soundChanged; 242 | } 243 | 244 | /// 245 | /// Renders the specified SFXR parameters in the editor. 246 | /// 247 | /// The current parameters to be rendered. 248 | /// 249 | /// This method is called automatically for the standalone editor window 250 | /// when a game-object with parameters is selected. However, this public 251 | /// method can also be called by CustomEditor implementations for specific 252 | /// game-components to render the editor in the Inspector window 253 | /// (see UnityEditor.Editor for details). Also, this method can be used 254 | /// from PropertyDrawer implementations; future releases of the code may 255 | /// include such a default drawer (once SfxrSynth and SfxrParams supports 256 | /// native serialization for Unity). 257 | /// 258 | public bool RenderParameters(SfxrParams parameters) { 259 | bool soundChanged = false; 260 | 261 | GUIStyle waveTypeStyle = EditorStyles.popup; 262 | waveTypeStyle.fontSize = 12; 263 | waveTypeStyle.fixedHeight = 22; 264 | 265 | EditorGUI.BeginChangeCheck(); 266 | try { 267 | WaveType waveTypeAsEnum = (WaveType)parameters.waveType; 268 | waveTypeAsEnum = (WaveType)EditorGUILayout.EnumPopup(new GUIContent("Wave Type", "Shape of the wave"), waveTypeAsEnum, waveTypeStyle); 269 | parameters.waveType = (uint)waveTypeAsEnum; 270 | GUILayout.Space(12); 271 | 272 | //RenderPopup(waveTypeOptions, ((int)(parameters.waveType)), (value => parameters.waveType = ((uint)(value))), new GUIContent("Wave Type", "Shape of the wave")); 273 | bool isSquareWaveType = (parameters.waveType == 0); 274 | RenderSlider(+0, +1, parameters.masterVolume, (value => parameters.masterVolume = value), new GUIContent("Volume", "Overall volume of the sound (0 to 1)")); 275 | 276 | RenderHeading("Wave Envelope"); 277 | RenderSlider(+0, +1, parameters.attackTime, (value => parameters.attackTime = value), new GUIContent("Attack Time", "Length of the volume envelope attack (0 to 1)")); 278 | RenderSlider(+0, +1, parameters.sustainTime, (value => parameters.sustainTime = value), new GUIContent("Sustain Time", "Length of the volume envelope sustain (0 to 1)")); 279 | RenderSlider(+0, +1, parameters.sustainPunch, (value => parameters.sustainPunch = value), new GUIContent("Sustain Punch", "Tilts the sustain envelope for more 'pop' (0 to 1)")); 280 | RenderSlider(+0, +1, parameters.decayTime, (value => parameters.decayTime = value), new GUIContent("Decay Time", "Length of the volume envelope decay (yes, I know it's called release) (0 to 1)")); 281 | 282 | // BFXR 283 | RenderSlider(+0, +1, parameters.compressionAmount, (value => parameters.compressionAmount = value), new GUIContent("Compression", "Pushes amplitudes together into a narrower range to make them stand out more. Very good for sound effects, where you want them to stick out against background music (0 to 1)")); 284 | 285 | RenderHeading("Frequency"); 286 | RenderSlider(+0, +1, parameters.startFrequency, (value => parameters.startFrequency = value), new GUIContent("Start Frequency", "Base note of the sound (0 to 1)")); 287 | RenderSlider(+0, +1, parameters.minFrequency, (value => parameters.minFrequency = value), new GUIContent("Minimum Frequency", "If sliding, the sound will stop at this frequency, to prevent really low notes (0 to 1)")); 288 | RenderSlider(-1, +1, parameters.slide, (value => parameters.slide = value), new GUIContent("Slide", "Slides the note up or down (-1 to 1)")); 289 | RenderSlider(-1, +1, parameters.deltaSlide, (value => parameters.deltaSlide = value), new GUIContent("Delta Slide", "Accelerates the slide (-1 to 1)")); 290 | RenderSlider(+0, +1, parameters.vibratoDepth, (value => parameters.vibratoDepth = value), new GUIContent("Vibrato Depth", "Strength of the vibrato effect (0 to 1)")); 291 | RenderSlider(+0, +1, parameters.vibratoSpeed, (value => parameters.vibratoSpeed = value), new GUIContent("Vibrato Speed", "Speed of the vibrato effect (i.e. frequency) (0 to 1)")); 292 | 293 | // BFXR 294 | RenderSlider(+0, +1, parameters.overtones, (value => parameters.overtones = value), new GUIContent("Harmonics", "Overlays copies of the waveform with copies and multiples of its frequency. Good for bulking out or otherwise enriching the texture of the sounds (warning: this is the number 1 cause of usfxr slowdown!) (0 to 1)")); 295 | RenderSlider(+0, +1, parameters.overtoneFalloff, (value => parameters.overtoneFalloff = value), new GUIContent("Harmonics falloff", "The rate at which higher overtones should decay (0 to 1)")); 296 | 297 | RenderHeading("Tone Change/Pitch Jump"); 298 | // BFXR 299 | RenderSlider(+0, +1, parameters.changeRepeat, (value => parameters.changeRepeat = value), new GUIContent("Change Repeat Speed", "Larger Values means more pitch jumps, which can be useful for arpeggiation (0 to 1)")); 300 | 301 | RenderSlider(-1, +1, parameters.changeAmount, (value => parameters.changeAmount = value), new GUIContent("Change Amount 1", "Shift in note, either up or down (-1 to 1)")); 302 | RenderSlider(+0, +1, parameters.changeSpeed, (value => parameters.changeSpeed = value), new GUIContent("Change Speed 1", "How fast the note shift happens (only happens once) (0 to 1)")); 303 | 304 | // BFXR 305 | RenderSlider(-1, +1, parameters.changeAmount2, (value => parameters.changeAmount2 = value), new GUIContent("Change Amount 2", "Shift in note, either up or down (-1 to 1)")); 306 | RenderSlider(+0, +1, parameters.changeSpeed2, (value => parameters.changeSpeed2 = value), new GUIContent("Change Speed 2", "How fast the note shift happens (only happens once) (0 to 1)")); 307 | 308 | RenderHeading("Square Waves"); 309 | RenderSlider(+0, +1, parameters.squareDuty, (value => parameters.squareDuty = value), new GUIContent("Square Duty", "Controls the ratio between the up and down states of the square wave, changing the tibre (0 to 1)"), isSquareWaveType); 310 | RenderSlider(-1, +1, parameters.dutySweep, (value => parameters.dutySweep = value), new GUIContent("Duty Sweep", "Sweeps the duty up or down (-1 to 1)"), isSquareWaveType); 311 | 312 | RenderHeading("Repeats"); 313 | RenderSlider(+0, +1, parameters.repeatSpeed, (value => parameters.repeatSpeed = value), new GUIContent("Repeat Speed", "Speed of the note repeating - certain variables are reset each time (0 to 1)")); 314 | 315 | RenderHeading("Phaser"); 316 | RenderSlider(-1, +1, parameters.phaserOffset, (value => parameters.phaserOffset = value), new GUIContent("Phaser Offset", "Offsets a second copy of the wave by a small phase, changing the tibre (-1 to 1)")); 317 | RenderSlider(-1, +1, parameters.phaserSweep, (value => parameters.phaserSweep = value), new GUIContent("Phaser Sweep", "Sweeps the phase up or down (-1 to 1)")); 318 | 319 | RenderHeading("Filters"); 320 | RenderSlider(+0, +1, parameters.lpFilterCutoff, (value => parameters.lpFilterCutoff = value), new GUIContent("Low-Pass Cutoff", "Frequency at which the low-pass filter starts attenuating higher frequencies (0 to 1)")); 321 | RenderSlider(-1, +1, parameters.lpFilterCutoffSweep, (value => parameters.lpFilterCutoffSweep = value), new GUIContent("Low-Pass Cutoff Sweep", "Sweeps the low-pass cutoff up or down (-1 to 1)")); 322 | RenderSlider(+0, +1, parameters.lpFilterResonance, (value => parameters.lpFilterResonance = value), new GUIContent("Low-Pass Resonance", "Changes the attenuation rate for the low-pass filter, changing the timbre (0 to 1)")); 323 | RenderSlider(+0, +1, parameters.hpFilterCutoff, (value => parameters.hpFilterCutoff = value), new GUIContent("High-Pass Cutoff", "Frequency at which the high-pass filter starts attenuating lower frequencies (0 to 1)")); 324 | RenderSlider(-1, +1, parameters.hpFilterCutoffSweep, (value => parameters.hpFilterCutoffSweep = value), new GUIContent("High-Pass Cutoff Sweep", "Sweeps the high-pass cutoff up or down (-1 to 1)")); 325 | 326 | RenderHeading("Bit Crushing"); 327 | 328 | // BFXR 329 | RenderSlider(+0, +1, parameters.bitCrush, (value => parameters.bitCrush = value), new GUIContent("Bit Crush", "Resamples the audio at a lower frequency (0 to 1)")); 330 | RenderSlider(-1, +1, parameters.bitCrushSweep, (value => parameters.bitCrushSweep = value), new GUIContent("Bit Crush Sweep", "Sweeps the Bit Crush filter up or down (-1 to 1)")); 331 | } finally { 332 | if (EditorGUI.EndChangeCheck()) { 333 | parameters.paramsDirty = true; 334 | soundChanged = true; 335 | } 336 | } 337 | 338 | return soundChanged; 339 | } 340 | 341 | protected static void RenderHeading(string heading) { 342 | EditorGUILayout.LabelField(heading, EditorStyles.boldLabel); 343 | } 344 | 345 | protected static bool RenderButton( 346 | GUIContent content = null, 347 | Action valueChangeAction = null, 348 | bool? isEnabled = null, 349 | params GUILayoutOption[] options) 350 | { 351 | if (content == null) 352 | { 353 | content = GUIContent.none; 354 | } 355 | 356 | bool isClicked = false; 357 | return RenderGenericEditor( 358 | ref isClicked, 359 | () => GUILayout.Button(content, options), 360 | valueChangeAction, 361 | isEnabled); 362 | } 363 | 364 | protected static bool RenderButton( 365 | string text, 366 | Action valueChangeAction = null, 367 | bool? isEnabled = null, 368 | params GUILayoutOption[] options) 369 | { 370 | return RenderButton( 371 | new GUIContent(text), valueChangeAction, isEnabled, options); 372 | } 373 | 374 | protected static bool RenderPopup( 375 | GUIContent[] selectionOptions, 376 | int value, 377 | Action valueChangeAction = null, 378 | GUIContent label = null, 379 | bool? isEnabled = null) 380 | { 381 | if (label == null) 382 | { 383 | label = GUIContent.none; 384 | } 385 | 386 | return RenderGenericEditor( 387 | ref value, 388 | () => EditorGUILayout.Popup(label, value, selectionOptions), 389 | valueChangeAction, 390 | isEnabled); 391 | } 392 | 393 | protected static bool RenderSlider( 394 | float minValue, 395 | float maxValue, 396 | float value, 397 | Action valueChangeAction = null, 398 | GUIContent label = null, 399 | bool? isEnabled = null) 400 | { 401 | if (label == null) 402 | { 403 | label = GUIContent.none; 404 | } 405 | 406 | return RenderGenericEditor( 407 | ref value, 408 | () => EditorGUILayout.Slider(label, value, minValue, maxValue), 409 | valueChangeAction, 410 | isEnabled); 411 | } 412 | 413 | private static bool RenderGenericEditor( 414 | ref T value, 415 | Func valueEditFunction, 416 | Action valueChangeAction = null, 417 | bool? isEnabled = null) 418 | { 419 | bool isChanged; 420 | if (valueEditFunction == null) 421 | { 422 | isChanged = false; 423 | } 424 | else 425 | { 426 | bool? wasEnabled; 427 | if (isEnabled.HasValue) 428 | { 429 | wasEnabled = GUI.enabled; 430 | GUI.enabled = isEnabled.Value; 431 | } 432 | else 433 | { 434 | wasEnabled = null; 435 | } 436 | 437 | try 438 | { 439 | EditorGUI.BeginChangeCheck(); 440 | try 441 | { 442 | value = valueEditFunction(); 443 | } 444 | finally 445 | { 446 | isChanged = EditorGUI.EndChangeCheck(); 447 | } 448 | 449 | if (isChanged 450 | && (valueChangeAction != null)) 451 | { 452 | valueChangeAction(value); 453 | } 454 | } 455 | finally 456 | { 457 | if (wasEnabled.HasValue) 458 | { 459 | GUI.enabled = wasEnabled.Value; 460 | } 461 | } 462 | } 463 | 464 | return isChanged; 465 | } 466 | 467 | private static bool RenderGenericEditor( 468 | ref T value, 469 | Func valueEditFunction, 470 | Action valueChangeAction, 471 | bool? isEnabled = null) 472 | { 473 | Action valueChangeActionWrapped = null; 474 | if (valueChangeAction != null) 475 | { 476 | valueChangeActionWrapped = (dummyValue) => valueChangeAction(); 477 | } 478 | 479 | return RenderGenericEditor( 480 | ref value, valueEditFunction, valueChangeActionWrapped, isEnabled); 481 | } 482 | 483 | private string getSuggestedName() { 484 | return suggestedName != null && suggestedName.Length > 0 ? suggestedName : "Audio"; 485 | } 486 | } 487 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/Editor/SfxrGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50bb92228e0f62b45a5291233fa3854b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/SfxrAudioPlayer.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | #endif 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | [ExecuteInEditMode] 8 | #endif 9 | public class SfxrAudioPlayer : MonoBehaviour { 10 | 11 | /** 12 | * usfxr 13 | * 14 | * Copyright 2013 Zeh Fernando 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | */ 29 | 30 | /** 31 | * SfxrAudioPlayer 32 | * This is the (internal) behavior script responsible for streaming audio to the engine 33 | * 34 | * @author Zeh Fernando 35 | */ 36 | 37 | 38 | // Properties 39 | private bool isDestroyed = false; // If true, this instance has been destroyed and shouldn't do anything yes 40 | private bool needsToDestroy = false; // If true, it has been scheduled for destruction (from outside the main thread) 41 | private bool runningInEditMode = false; // If true, it is running from the editor and NOT playing 42 | 43 | // Instances 44 | private SfxrSynth sfxrSynth; // SfxrSynth instance that will generate the audio samples used by this 45 | 46 | 47 | // ================================================================================================================ 48 | // INTERNAL INTERFACE --------------------------------------------------------------------------------------------- 49 | 50 | void Start() { 51 | // Creates an empty audio source so this GameObject can receive audio events 52 | AudioSource soundSource = gameObject.AddComponent(); 53 | soundSource.clip = new AudioClip(); 54 | soundSource.volume = 1f; 55 | soundSource.pitch = 1f; 56 | soundSource.priority = 128; 57 | soundSource.Play(); 58 | } 59 | 60 | void Update() { 61 | // Destroys self in case it has been queued for deletion 62 | if (sfxrSynth == null) { 63 | // Rogue object (leftover) 64 | // When switching between play and edit mode while the sound is playing, the object is restarted 65 | // So, queues for destruction 66 | needsToDestroy = true; 67 | } 68 | 69 | if (needsToDestroy) { 70 | needsToDestroy = false; 71 | Destroy(); 72 | } 73 | } 74 | 75 | void OnAudioFilterRead(float[] __data, int __channels) { 76 | // Requests the generation of the needed audio data from SfxrSynth 77 | 78 | if (!isDestroyed && !needsToDestroy && sfxrSynth != null) { 79 | bool hasMoreSamples = sfxrSynth.GenerateAudioFilterData(__data, __channels); 80 | 81 | // If no more samples are needed, there's no more need for this GameObject so schedule a destruction (cannot do this in this thread) 82 | if (!hasMoreSamples) { 83 | needsToDestroy = true; 84 | if (runningInEditMode) { 85 | // When running in edit mode, Update() is not called on every frame 86 | // We can't call Destroy() directly either, since Destroy() must be ran from the main thread 87 | // So we just attach our Update() to the editor's update event 88 | #if UNITY_EDITOR 89 | EditorApplication.update += Update; 90 | #endif 91 | } 92 | } 93 | } 94 | } 95 | 96 | 97 | // ================================================================================================================ 98 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 99 | 100 | public void SetSfxrSynth(SfxrSynth __sfxrSynth) { 101 | // Sets the SfxrSynth instance that will generate the audio samples used by this 102 | sfxrSynth = __sfxrSynth; 103 | } 104 | 105 | public void SetRunningInEditMode(bool __runningInEditMode) { 106 | // Sets the SfxrSynth instance that will generate the audio samples used by this 107 | runningInEditMode = __runningInEditMode; 108 | } 109 | 110 | public void Destroy() { 111 | // Stops audio immediately and destroys self 112 | if (!isDestroyed) { 113 | isDestroyed = true; 114 | sfxrSynth = null; 115 | if (runningInEditMode || !Application.isPlaying) { 116 | // Since we're running in the editor, we need to remove the update event, AND destroy immediately 117 | #if UNITY_EDITOR 118 | EditorApplication.update -= Update; 119 | #endif 120 | UnityEngine.Object.DestroyImmediate(gameObject); 121 | } else { 122 | UnityEngine.Object.Destroy(gameObject); 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/SfxrAudioPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f59cf3184c1e4347833fde7507e8bfc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/SfxrCacheSurrogate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | public class SfxrCacheSurrogate : MonoBehaviour { 6 | 7 | /** 8 | * usfxr 9 | * 10 | * Copyright 2013 Zeh Fernando 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | */ 25 | 26 | /** 27 | * SfxrCacheSurrogate 28 | * This is the (internal) behavior script responsible for calling Coroutines for asynchronous audio generation 29 | * 30 | * @author Zeh Fernando 31 | */ 32 | 33 | // ================================================================================================================ 34 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 35 | 36 | public void CacheSound(SfxrSynth __synth, Action __callback) { 37 | StartCoroutine(CacheSoundAsynchronously(__synth, __callback)); 38 | } 39 | 40 | private IEnumerator CacheSoundAsynchronously(SfxrSynth __synth, Action __callback) { 41 | yield return null; 42 | __synth.CacheSound(null, true); 43 | __callback(); 44 | UnityEngine.Object.Destroy(gameObject); 45 | } 46 | 47 | public void CacheMutations(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 48 | StartCoroutine(CacheMutationsAsynchronously(__synth, __mutationsNum, __mutationAmount, __callback)); 49 | } 50 | 51 | private IEnumerator CacheMutationsAsynchronously(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 52 | yield return null; 53 | __synth.CacheMutations(__mutationsNum, __mutationAmount, null, true); 54 | __callback(); 55 | UnityEngine.Object.Destroy(gameObject); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/SfxrCacheSurrogate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0216fe69f722f8141874a04a7bbb44ea 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/SfxrParams.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 847b3b03630aa1445af7a648d1df86dd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/benchmark/Assets/Scripts/usfxr/SfxrSynth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2aaf75046af8d6d4598b2ecc6808c6ff 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | m_SpeedOfSound: 347 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_DSPBufferSize: 0 12 | m_DisableAudio: 0 13 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepVelocity: .150000006 10 | m_SleepAngularVelocity: .140000001 11 | m_MaxAngularVelocity: 7 12 | m_MinPenetrationForPenalty: .00999999978 13 | m_SolverIterationCount: 6 14 | m_RaycastsHitTriggers: 1 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 0 13 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | m_AlwaysIncludedShaders: 7 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 8 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | m_Axes: 7 | - serializedVersion: 3 8 | m_Name: Horizontal 9 | descriptiveName: 10 | descriptiveNegativeName: 11 | negativeButton: left 12 | positiveButton: right 13 | altNegativeButton: a 14 | altPositiveButton: d 15 | gravity: 3 16 | dead: .00100000005 17 | sensitivity: 3 18 | snap: 1 19 | invert: 0 20 | type: 0 21 | axis: 0 22 | joyNum: 0 23 | - serializedVersion: 3 24 | m_Name: Vertical 25 | descriptiveName: 26 | descriptiveNegativeName: 27 | negativeButton: down 28 | positiveButton: up 29 | altNegativeButton: s 30 | altPositiveButton: w 31 | gravity: 3 32 | dead: .00100000005 33 | sensitivity: 3 34 | snap: 1 35 | invert: 0 36 | type: 0 37 | axis: 0 38 | joyNum: 0 39 | - serializedVersion: 3 40 | m_Name: Fire1 41 | descriptiveName: 42 | descriptiveNegativeName: 43 | negativeButton: 44 | positiveButton: left ctrl 45 | altNegativeButton: 46 | altPositiveButton: mouse 0 47 | gravity: 1000 48 | dead: .00100000005 49 | sensitivity: 1000 50 | snap: 0 51 | invert: 0 52 | type: 0 53 | axis: 0 54 | joyNum: 0 55 | - serializedVersion: 3 56 | m_Name: Fire2 57 | descriptiveName: 58 | descriptiveNegativeName: 59 | negativeButton: 60 | positiveButton: left alt 61 | altNegativeButton: 62 | altPositiveButton: mouse 1 63 | gravity: 1000 64 | dead: .00100000005 65 | sensitivity: 1000 66 | snap: 0 67 | invert: 0 68 | type: 0 69 | axis: 0 70 | joyNum: 0 71 | - serializedVersion: 3 72 | m_Name: Fire3 73 | descriptiveName: 74 | descriptiveNegativeName: 75 | negativeButton: 76 | positiveButton: left cmd 77 | altNegativeButton: 78 | altPositiveButton: mouse 2 79 | gravity: 1000 80 | dead: .00100000005 81 | sensitivity: 1000 82 | snap: 0 83 | invert: 0 84 | type: 0 85 | axis: 0 86 | joyNum: 0 87 | - serializedVersion: 3 88 | m_Name: Jump 89 | descriptiveName: 90 | descriptiveNegativeName: 91 | negativeButton: 92 | positiveButton: space 93 | altNegativeButton: 94 | altPositiveButton: 95 | gravity: 1000 96 | dead: .00100000005 97 | sensitivity: 1000 98 | snap: 0 99 | invert: 0 100 | type: 0 101 | axis: 0 102 | joyNum: 0 103 | - serializedVersion: 3 104 | m_Name: Mouse X 105 | descriptiveName: 106 | descriptiveNegativeName: 107 | negativeButton: 108 | positiveButton: 109 | altNegativeButton: 110 | altPositiveButton: 111 | gravity: 0 112 | dead: 0 113 | sensitivity: .100000001 114 | snap: 0 115 | invert: 0 116 | type: 1 117 | axis: 0 118 | joyNum: 0 119 | - serializedVersion: 3 120 | m_Name: Mouse Y 121 | descriptiveName: 122 | descriptiveNegativeName: 123 | negativeButton: 124 | positiveButton: 125 | altNegativeButton: 126 | altPositiveButton: 127 | gravity: 0 128 | dead: 0 129 | sensitivity: .100000001 130 | snap: 0 131 | invert: 0 132 | type: 1 133 | axis: 1 134 | joyNum: 0 135 | - serializedVersion: 3 136 | m_Name: Mouse ScrollWheel 137 | descriptiveName: 138 | descriptiveNegativeName: 139 | negativeButton: 140 | positiveButton: 141 | altNegativeButton: 142 | altPositiveButton: 143 | gravity: 0 144 | dead: 0 145 | sensitivity: .100000001 146 | snap: 0 147 | invert: 0 148 | type: 1 149 | axis: 2 150 | joyNum: 0 151 | - serializedVersion: 3 152 | m_Name: Horizontal 153 | descriptiveName: 154 | descriptiveNegativeName: 155 | negativeButton: 156 | positiveButton: 157 | altNegativeButton: 158 | altPositiveButton: 159 | gravity: 0 160 | dead: .189999998 161 | sensitivity: 1 162 | snap: 0 163 | invert: 0 164 | type: 2 165 | axis: 0 166 | joyNum: 0 167 | - serializedVersion: 3 168 | m_Name: Vertical 169 | descriptiveName: 170 | descriptiveNegativeName: 171 | negativeButton: 172 | positiveButton: 173 | altNegativeButton: 174 | altPositiveButton: 175 | gravity: 0 176 | dead: .189999998 177 | sensitivity: 1 178 | snap: 0 179 | invert: 1 180 | type: 2 181 | axis: 1 182 | joyNum: 0 183 | - serializedVersion: 3 184 | m_Name: Fire1 185 | descriptiveName: 186 | descriptiveNegativeName: 187 | negativeButton: 188 | positiveButton: joystick button 0 189 | altNegativeButton: 190 | altPositiveButton: 191 | gravity: 1000 192 | dead: .00100000005 193 | sensitivity: 1000 194 | snap: 0 195 | invert: 0 196 | type: 0 197 | axis: 0 198 | joyNum: 0 199 | - serializedVersion: 3 200 | m_Name: Fire2 201 | descriptiveName: 202 | descriptiveNegativeName: 203 | negativeButton: 204 | positiveButton: joystick button 1 205 | altNegativeButton: 206 | altPositiveButton: 207 | gravity: 1000 208 | dead: .00100000005 209 | sensitivity: 1000 210 | snap: 0 211 | invert: 0 212 | type: 0 213 | axis: 0 214 | joyNum: 0 215 | - serializedVersion: 3 216 | m_Name: Fire3 217 | descriptiveName: 218 | descriptiveNegativeName: 219 | negativeButton: 220 | positiveButton: joystick button 2 221 | altNegativeButton: 222 | altPositiveButton: 223 | gravity: 1000 224 | dead: .00100000005 225 | sensitivity: 1000 226 | snap: 0 227 | invert: 0 228 | type: 0 229 | axis: 0 230 | joyNum: 0 231 | - serializedVersion: 3 232 | m_Name: Jump 233 | descriptiveName: 234 | descriptiveNegativeName: 235 | negativeButton: 236 | positiveButton: joystick button 3 237 | altNegativeButton: 238 | altPositiveButton: 239 | gravity: 1000 240 | dead: .00100000005 241 | sensitivity: 1000 242 | snap: 0 243 | invert: 0 244 | type: 0 245 | axis: 0 246 | joyNum: 0 247 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_RaycastsHitTriggers: 1 11 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 12 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | AndroidProfiler: 0 8 | defaultScreenOrientation: 0 9 | targetDevice: 2 10 | targetGlesGraphics: 1 11 | targetResolution: 0 12 | accelerometerFrequency: 60 13 | companyName: DefaultCompany 14 | productName: benchmark 15 | defaultCursor: {fileID: 0} 16 | cursorHotspot: {x: 0, y: 0} 17 | defaultScreenWidth: 1024 18 | defaultScreenHeight: 768 19 | defaultScreenWidthWeb: 960 20 | defaultScreenHeightWeb: 600 21 | m_RenderingPath: 1 22 | m_MobileRenderingPath: 1 23 | m_ActiveColorSpace: 0 24 | m_MTRendering: 1 25 | m_MobileMTRendering: 0 26 | m_UseDX11: 0 27 | iosShowActivityIndicatorOnLoading: -1 28 | androidShowActivityIndicatorOnLoading: -1 29 | displayResolutionDialog: 1 30 | allowedAutorotateToPortrait: 1 31 | allowedAutorotateToPortraitUpsideDown: 1 32 | allowedAutorotateToLandscapeRight: 1 33 | allowedAutorotateToLandscapeLeft: 1 34 | useOSAutorotation: 1 35 | use32BitDisplayBuffer: 1 36 | use24BitDepthBuffer: 0 37 | defaultIsFullScreen: 0 38 | defaultIsNativeResolution: 1 39 | runInBackground: 0 40 | captureSingleScreen: 0 41 | Override IPod Music: 0 42 | Prepare IOS For Recording: 0 43 | enableHWStatistics: 1 44 | usePlayerLog: 1 45 | stripPhysics: 0 46 | forceSingleInstance: 0 47 | resizableWindow: 0 48 | useMacAppStoreValidation: 0 49 | gpuSkinning: 0 50 | xboxPIXTextureCapture: 0 51 | xboxEnableAvatar: 0 52 | xboxEnableKinect: 0 53 | xboxEnableKinectAutoTracking: 0 54 | xboxEnableFitness: 0 55 | macFullscreenMode: 2 56 | xboxSpeechDB: 0 57 | xboxEnableHeadOrientation: 0 58 | xboxEnableGuest: 0 59 | wiiHio2Usage: -1 60 | wiiLoadingScreenRectPlacement: 0 61 | wiiLoadingScreenBackground: {r: 1, g: 1, b: 1, a: 1} 62 | wiiLoadingScreenPeriod: 1000 63 | wiiLoadingScreenFileName: 64 | wiiLoadingScreenRect: 65 | serializedVersion: 2 66 | x: 0 67 | y: 0 68 | width: 0 69 | height: 0 70 | m_SupportedAspectRatios: 71 | 4:3: 1 72 | 5:4: 1 73 | 16:10: 1 74 | 16:9: 1 75 | Others: 1 76 | iPhoneBundleIdentifier: com.Company.ProductName 77 | metroEnableIndependentInputSource: 0 78 | metroEnableLowLatencyPresentationAPI: 0 79 | productGUID: 69805ba57ed0595458505f58073d55bd 80 | iPhoneBundleVersion: 1.0 81 | AndroidBundleVersionCode: 1 82 | AndroidMinSdkVersion: 9 83 | AndroidPreferredInstallLocation: 1 84 | aotOptions: 85 | apiCompatibilityLevel: 2 86 | iPhoneStrippingLevel: 0 87 | iPhoneScriptCallOptimization: 0 88 | ForceInternetPermission: 0 89 | ForceSDCardPermission: 0 90 | CreateWallpaper: 0 91 | APKExpansionFiles: 0 92 | StripUnusedMeshComponents: 0 93 | iPhoneSdkVersion: 988 94 | iPhoneTargetOSVersion: 10 95 | uIPrerenderedIcon: 0 96 | uIRequiresPersistentWiFi: 0 97 | uIStatusBarHidden: 1 98 | uIExitOnSuspend: 0 99 | uIStatusBarStyle: 0 100 | iPhoneSplashScreen: {fileID: 0} 101 | iPhoneHighResSplashScreen: {fileID: 0} 102 | iPhoneTallHighResSplashScreen: {fileID: 0} 103 | iPadPortraitSplashScreen: {fileID: 0} 104 | iPadHighResPortraitSplashScreen: {fileID: 0} 105 | iPadLandscapeSplashScreen: {fileID: 0} 106 | iPadHighResLandscapeSplashScreen: {fileID: 0} 107 | AndroidTargetDevice: 0 108 | AndroidSplashScreenScale: 0 109 | AndroidKeystoreName: 110 | AndroidKeyaliasName: 111 | resolutionDialogBanner: {fileID: 0} 112 | m_BuildTargetIcons: [] 113 | m_BuildTargetBatching: [] 114 | webPlayerTemplate: APPLICATION:Default 115 | m_TemplateCustomTags: {} 116 | wiiRegion: 1 117 | wiiGameCode: RABA 118 | wiiGameVersion: 119 | wiiCompanyCode: ZZ 120 | wiiSupportsNunchuk: 0 121 | wiiSupportsClassicController: 0 122 | wiiSupportsBalanceBoard: 0 123 | wiiSupportsMotionPlus: 0 124 | wiiControllerCount: 1 125 | wiiFloatingPointExceptions: 0 126 | wiiScreenCrashDumps: 1 127 | XboxTitleId: 128 | XboxImageXexPath: 129 | XboxSpaPath: 130 | XboxGenerateSpa: 0 131 | XboxDeployKinectResources: 0 132 | XboxSplashScreen: {fileID: 0} 133 | xboxEnableSpeech: 0 134 | xboxAdditionalTitleMemorySize: 0 135 | xboxDeployKinectHeadOrientation: 0 136 | xboxDeployKinectHeadPosition: 0 137 | ps3TitleConfigPath: 138 | ps3DLCConfigPath: 139 | ps3ThumbnailPath: 140 | ps3BackgroundPath: 141 | ps3SoundPath: 142 | ps3TrophyCommId: 143 | ps3NpCommunicationPassphrase: 144 | ps3TrophyPackagePath: 145 | ps3BootCheckMaxSaveGameSizeKB: 128 146 | ps3TrophyCommSig: 147 | ps3SaveGameSlots: 1 148 | ps3TrialMode: 0 149 | flashStrippingLevel: 2 150 | spritePackerPolicy: 151 | scriptingDefineSymbols: {} 152 | metroPackageName: 153 | metroPackageLogo: 154 | metroPackageVersion: 155 | metroCertificatePath: 156 | metroCertificatePassword: 157 | metroCertificateSubject: 158 | metroCertificateIssuer: 159 | metroCertificateNotAfter: 0000000000000000 160 | metroApplicationDescription: 161 | metroTileLogo: 162 | metroTileWideLogo: 163 | metroTileSmallLogo: 164 | metroTileShortName: 165 | metroCommandLineArgsFile: 166 | metroTileShowName: 0 167 | metroTileForegroundText: 1 168 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 169 | metroSplashScreenImage: 170 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 171 | metroSplashScreenUseBackgroundColor: 0 172 | metroCapabilities: {} 173 | metroUnprocessedPlugins: [] 174 | metroCompilationOverrides: 1 175 | blackberryDeviceAddress: 176 | blackberryDevicePassword: 177 | blackberryTokenPath: 178 | blackberryTokenExires: 179 | blackberryTokenAuthor: 180 | blackberryTokenAuthorId: 181 | blackberryAuthorId: 182 | blackberryCskPassword: 183 | blackberrySaveLogPath: 184 | blackberryAuthorIdOveride: 0 185 | blackberrySharedPermissions: 0 186 | blackberryCameraPermissions: 0 187 | blackberryGPSPermissions: 0 188 | blackberryDeviceIDPermissions: 0 189 | blackberryMicrophonePermissions: 0 190 | blackberryGamepadSupport: 0 191 | blackberryBuildId: 0 192 | blackberryLandscapeSplashScreen: {fileID: 0} 193 | blackberryPortraitSplashScreen: {fileID: 0} 194 | blackberrySquareSplashScreen: {fileID: 0} 195 | tizenProductDescription: 196 | tizenProductURL: 197 | tizenCertificatePath: 198 | tizenCertificatePassword: 199 | tizenSaveLogPath: 200 | firstStreamedLevelWithResources: 0 201 | unityRebuildLibraryVersion: 9 202 | unityForwardCompatibleVersion: 39 203 | unityStandardAssetsVersion: 0 204 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | blendWeights: 1 18 | textureQuality: 1 19 | anisotropicTextures: 0 20 | antiAliasing: 0 21 | softParticles: 0 22 | softVegetation: 0 23 | vSyncCount: 0 24 | lodBias: .300000012 25 | maximumLODLevel: 0 26 | particleRaycastBudget: 4 27 | excludedTargetPlatforms: [] 28 | - serializedVersion: 2 29 | name: Fast 30 | pixelLightCount: 0 31 | shadows: 0 32 | shadowResolution: 0 33 | shadowProjection: 1 34 | shadowCascades: 1 35 | shadowDistance: 20 36 | blendWeights: 2 37 | textureQuality: 0 38 | anisotropicTextures: 0 39 | antiAliasing: 0 40 | softParticles: 0 41 | softVegetation: 0 42 | vSyncCount: 0 43 | lodBias: .400000006 44 | maximumLODLevel: 0 45 | particleRaycastBudget: 16 46 | excludedTargetPlatforms: [] 47 | - serializedVersion: 2 48 | name: Simple 49 | pixelLightCount: 1 50 | shadows: 1 51 | shadowResolution: 0 52 | shadowProjection: 1 53 | shadowCascades: 1 54 | shadowDistance: 20 55 | blendWeights: 2 56 | textureQuality: 0 57 | anisotropicTextures: 1 58 | antiAliasing: 0 59 | softParticles: 0 60 | softVegetation: 0 61 | vSyncCount: 0 62 | lodBias: .699999988 63 | maximumLODLevel: 0 64 | particleRaycastBudget: 64 65 | excludedTargetPlatforms: [] 66 | - serializedVersion: 2 67 | name: Good 68 | pixelLightCount: 2 69 | shadows: 2 70 | shadowResolution: 1 71 | shadowProjection: 1 72 | shadowCascades: 2 73 | shadowDistance: 40 74 | blendWeights: 2 75 | textureQuality: 0 76 | anisotropicTextures: 1 77 | antiAliasing: 0 78 | softParticles: 0 79 | softVegetation: 1 80 | vSyncCount: 1 81 | lodBias: 1 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 256 84 | excludedTargetPlatforms: [] 85 | - serializedVersion: 2 86 | name: Beautiful 87 | pixelLightCount: 3 88 | shadows: 2 89 | shadowResolution: 2 90 | shadowProjection: 1 91 | shadowCascades: 2 92 | shadowDistance: 70 93 | blendWeights: 4 94 | textureQuality: 0 95 | anisotropicTextures: 2 96 | antiAliasing: 2 97 | softParticles: 1 98 | softVegetation: 1 99 | vSyncCount: 1 100 | lodBias: 1.5 101 | maximumLODLevel: 0 102 | particleRaycastBudget: 1024 103 | excludedTargetPlatforms: [] 104 | - serializedVersion: 2 105 | name: Fantastic 106 | pixelLightCount: 4 107 | shadows: 2 108 | shadowResolution: 2 109 | shadowProjection: 1 110 | shadowCascades: 4 111 | shadowDistance: 150 112 | blendWeights: 4 113 | textureQuality: 0 114 | anisotropicTextures: 2 115 | antiAliasing: 2 116 | softParticles: 1 117 | softVegetation: 1 118 | vSyncCount: 1 119 | lodBias: 2 120 | maximumLODLevel: 0 121 | particleRaycastBudget: 4096 122 | excludedTargetPlatforms: [] 123 | m_PerPlatformDefaultQuality: 124 | Android: 2 125 | FlashPlayer: 3 126 | GLES Emulation: 3 127 | PS3: 3 128 | Standalone: 3 129 | Web: 3 130 | Wii: 3 131 | XBOX360: 3 132 | iPhone: 2 133 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | tags: 6 | - 7 | Builtin Layer 0: Default 8 | Builtin Layer 1: TransparentFX 9 | Builtin Layer 2: Ignore Raycast 10 | Builtin Layer 3: 11 | Builtin Layer 4: Water 12 | Builtin Layer 5: 13 | Builtin Layer 6: 14 | Builtin Layer 7: 15 | User Layer 8: 16 | User Layer 9: 17 | User Layer 10: 18 | User Layer 11: 19 | User Layer 12: 20 | User Layer 13: 21 | User Layer 14: 22 | User Layer 15: 23 | User Layer 16: 24 | User Layer 17: 25 | User Layer 18: 26 | User Layer 19: 27 | User Layer 20: 28 | User Layer 21: 29 | User Layer 22: 30 | User Layer 23: 31 | User Layer 24: 32 | User Layer 25: 33 | User Layer 26: 34 | User Layer 27: 35 | User Layer 28: 36 | User Layer 29: 37 | User Layer 30: 38 | User Layer 31: 39 | m_SortingLayers: 40 | - name: Default 41 | userID: 0 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /samples/benchmark/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /samples/main/.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | Temp/ 5 | Library/ 6 | 7 | # ===================================== # 8 | # Visual Studio / MonoDevelop generated # 9 | # ===================================== # 10 | ExportedObj/ 11 | obj/ 12 | *.svd 13 | *.userprefs 14 | /*.csproj 15 | *.pidb 16 | *.suo 17 | /*.sln 18 | *.user 19 | *.unityproj 20 | *.booproj 21 | 22 | # ============ # 23 | # OS generated # 24 | # ============ # 25 | .DS_Store 26 | .DS_Store? 27 | ._* 28 | .Spotlight-V100 29 | .Trashes 30 | ehthumbs.db 31 | Thumbs.db 32 | -------------------------------------------------------------------------------- /samples/main/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 872e07da8628bd540857172d96000c70 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/main/Assets/Scenes/main.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | SceneSettings: 5 | m_ObjectHideFlags: 0 6 | m_PVSData: 7 | m_PVSObjectsArray: [] 8 | m_PVSPortalsArray: [] 9 | m_OcclusionBakeSettings: 10 | smallestOccluder: 5 11 | smallestHole: .25 12 | backfaceThreshold: 100 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_Fog: 0 16 | m_FogColor: {r: .5, g: .5, b: .5, a: 1} 17 | m_FogMode: 3 18 | m_FogDensity: .00999999978 19 | m_LinearFogStart: 0 20 | m_LinearFogEnd: 300 21 | m_AmbientLight: {r: .200000003, g: .200000003, b: .200000003, a: 1} 22 | m_SkyboxMaterial: {fileID: 0} 23 | m_HaloStrength: .5 24 | m_FlareStrength: 1 25 | m_FlareFadeSpeed: 3 26 | m_HaloTexture: {fileID: 0} 27 | m_SpotCookie: {fileID: 0} 28 | m_ObjectHideFlags: 0 29 | --- !u!127 &3 30 | LevelGameManager: 31 | m_ObjectHideFlags: 0 32 | --- !u!157 &4 33 | LightmapSettings: 34 | m_ObjectHideFlags: 0 35 | m_LightProbes: {fileID: 0} 36 | m_Lightmaps: [] 37 | m_LightmapsMode: 1 38 | m_BakedColorSpace: 0 39 | m_UseDualLightmapsInForward: 0 40 | m_LightmapEditorSettings: 41 | m_Resolution: 50 42 | m_LastUsedResolution: 0 43 | m_TextureWidth: 1024 44 | m_TextureHeight: 1024 45 | m_BounceBoost: 1 46 | m_BounceIntensity: 1 47 | m_SkyLightColor: {r: .860000014, g: .930000007, b: 1, a: 1} 48 | m_SkyLightIntensity: 0 49 | m_Quality: 0 50 | m_Bounces: 1 51 | m_FinalGatherRays: 1000 52 | m_FinalGatherContrastThreshold: .0500000007 53 | m_FinalGatherGradientThreshold: 0 54 | m_FinalGatherInterpolationPoints: 15 55 | m_AOAmount: 0 56 | m_AOMaxDistance: .100000001 57 | m_AOContrast: 1 58 | m_LODSurfaceMappingDistance: 1 59 | m_Padding: 0 60 | m_TextureCompression: 0 61 | m_LockAtlas: 0 62 | --- !u!196 &5 63 | NavMeshSettings: 64 | m_ObjectHideFlags: 0 65 | m_BuildSettings: 66 | agentRadius: .5 67 | agentHeight: 2 68 | agentSlope: 45 69 | agentClimb: .400000006 70 | ledgeDropHeight: 0 71 | maxJumpAcrossDistance: 0 72 | accuratePlacement: 0 73 | minRegionArea: 2 74 | widthInaccuracy: 16.666666 75 | heightInaccuracy: 10 76 | m_NavMesh: {fileID: 0} 77 | --- !u!1 &374197903 78 | GameObject: 79 | m_ObjectHideFlags: 0 80 | m_PrefabParentObject: {fileID: 0} 81 | m_PrefabInternal: {fileID: 0} 82 | serializedVersion: 4 83 | m_Component: 84 | - 4: {fileID: 374197904} 85 | - 114: {fileID: 374197905} 86 | m_Layer: 0 87 | m_Name: SceneScripts 88 | m_TagString: Untagged 89 | m_Icon: {fileID: 0} 90 | m_NavMeshLayer: 0 91 | m_StaticEditorFlags: 0 92 | m_IsActive: 1 93 | --- !u!4 &374197904 94 | Transform: 95 | m_ObjectHideFlags: 0 96 | m_PrefabParentObject: {fileID: 0} 97 | m_PrefabInternal: {fileID: 0} 98 | m_GameObject: {fileID: 374197903} 99 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 100 | m_LocalPosition: {x: 0, y: 0, z: 0} 101 | m_LocalScale: {x: 1, y: 1, z: 1} 102 | m_Children: [] 103 | m_Father: {fileID: 0} 104 | --- !u!114 &374197905 105 | MonoBehaviour: 106 | m_ObjectHideFlags: 0 107 | m_PrefabParentObject: {fileID: 0} 108 | m_PrefabInternal: {fileID: 0} 109 | m_GameObject: {fileID: 374197903} 110 | m_Enabled: 1 111 | m_EditorHideFlags: 0 112 | m_Script: {fileID: 11500000, guid: 348e8d6c5de7b3e49b220abd82a8985d, type: 3} 113 | m_Name: 114 | m_EditorClassIdentifier: 115 | --- !u!1 &527473442 116 | GameObject: 117 | m_ObjectHideFlags: 0 118 | m_PrefabParentObject: {fileID: 0} 119 | m_PrefabInternal: {fileID: 0} 120 | serializedVersion: 4 121 | m_Component: 122 | - 4: {fileID: 527473447} 123 | - 20: {fileID: 527473446} 124 | - 92: {fileID: 527473445} 125 | - 124: {fileID: 527473444} 126 | - 81: {fileID: 527473443} 127 | m_Layer: 0 128 | m_Name: Main Camera 129 | m_TagString: MainCamera 130 | m_Icon: {fileID: 0} 131 | m_NavMeshLayer: 0 132 | m_StaticEditorFlags: 0 133 | m_IsActive: 1 134 | --- !u!81 &527473443 135 | AudioListener: 136 | m_ObjectHideFlags: 0 137 | m_PrefabParentObject: {fileID: 0} 138 | m_PrefabInternal: {fileID: 0} 139 | m_GameObject: {fileID: 527473442} 140 | m_Enabled: 1 141 | --- !u!124 &527473444 142 | Behaviour: 143 | m_ObjectHideFlags: 0 144 | m_PrefabParentObject: {fileID: 0} 145 | m_PrefabInternal: {fileID: 0} 146 | m_GameObject: {fileID: 527473442} 147 | m_Enabled: 1 148 | --- !u!92 &527473445 149 | Behaviour: 150 | m_ObjectHideFlags: 0 151 | m_PrefabParentObject: {fileID: 0} 152 | m_PrefabInternal: {fileID: 0} 153 | m_GameObject: {fileID: 527473442} 154 | m_Enabled: 1 155 | --- !u!20 &527473446 156 | Camera: 157 | m_ObjectHideFlags: 0 158 | m_PrefabParentObject: {fileID: 0} 159 | m_PrefabInternal: {fileID: 0} 160 | m_GameObject: {fileID: 527473442} 161 | m_Enabled: 1 162 | serializedVersion: 2 163 | m_ClearFlags: 1 164 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 165 | m_NormalizedViewPortRect: 166 | serializedVersion: 2 167 | x: 0 168 | y: 0 169 | width: 1 170 | height: 1 171 | near clip plane: .300000012 172 | far clip plane: 1000 173 | field of view: 60 174 | orthographic: 0 175 | orthographic size: 100 176 | m_Depth: -1 177 | m_CullingMask: 178 | serializedVersion: 2 179 | m_Bits: 4294967295 180 | m_RenderingPath: -1 181 | m_TargetTexture: {fileID: 0} 182 | m_HDR: 0 183 | m_OcclusionCulling: 1 184 | --- !u!4 &527473447 185 | Transform: 186 | m_ObjectHideFlags: 0 187 | m_PrefabParentObject: {fileID: 0} 188 | m_PrefabInternal: {fileID: 0} 189 | m_GameObject: {fileID: 527473442} 190 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 191 | m_LocalPosition: {x: 0, y: 0, z: -100} 192 | m_LocalScale: {x: 1, y: 1, z: 1} 193 | m_Children: [] 194 | m_Father: {fileID: 0} 195 | --- !u!1 &1287256859 196 | GameObject: 197 | m_ObjectHideFlags: 0 198 | m_PrefabParentObject: {fileID: 0} 199 | m_PrefabInternal: {fileID: 0} 200 | serializedVersion: 4 201 | m_Component: 202 | - 4: {fileID: 1287256861} 203 | - 132: {fileID: 1287256860} 204 | m_Layer: 0 205 | m_Name: GUI Text 206 | m_TagString: Untagged 207 | m_Icon: {fileID: 0} 208 | m_NavMeshLayer: 0 209 | m_StaticEditorFlags: 0 210 | m_IsActive: 1 211 | --- !u!132 &1287256860 212 | GUIText: 213 | m_ObjectHideFlags: 0 214 | m_PrefabParentObject: {fileID: 0} 215 | m_PrefabInternal: {fileID: 0} 216 | m_GameObject: {fileID: 1287256859} 217 | m_Enabled: 1 218 | serializedVersion: 3 219 | m_Text: Press A, B, C, D, E or F to test different forms of audio generation; check 220 | console for description 221 | m_Anchor: 4 222 | m_Alignment: 0 223 | m_PixelOffset: {x: 0, y: 0} 224 | m_LineSpacing: 1 225 | m_TabSize: 4 226 | m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} 227 | m_Material: {fileID: 0} 228 | m_FontSize: 0 229 | m_FontStyle: 0 230 | m_Color: 231 | serializedVersion: 2 232 | rgba: 4294967295 233 | m_PixelCorrect: 1 234 | m_RichText: 1 235 | --- !u!4 &1287256861 236 | Transform: 237 | m_ObjectHideFlags: 0 238 | m_PrefabParentObject: {fileID: 0} 239 | m_PrefabInternal: {fileID: 0} 240 | m_GameObject: {fileID: 1287256859} 241 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 242 | m_LocalPosition: {x: .5, y: .5, z: 0} 243 | m_LocalScale: {x: 1, y: 1, z: 1} 244 | m_Children: [] 245 | m_Father: {fileID: 0} 246 | -------------------------------------------------------------------------------- /samples/main/Assets/Scenes/main.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a51e66c428802654db710c4dfbc31f55 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f32d7cd5870b13d4982f0ca2efc9c26f 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/Main.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Main : MonoBehaviour { 5 | 6 | private SfxrSynth synthA; 7 | private SfxrSynth synthB; 8 | private SfxrSynth synthC; 9 | private SfxrSynth synthD; 10 | private SfxrSynth synthE; 11 | 12 | void Start () { 13 | Debug.Log("Initialized"); 14 | } 15 | 16 | void Update () { 17 | if (Input.GetKeyDown("a")) { 18 | Debug.Log("Key: A (Coin with synchronous cache)"); 19 | 20 | if (synthA == null) { 21 | // Coin 22 | synthA = new SfxrSynth(); 23 | synthA.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); 24 | synthA.CacheSound(); 25 | } 26 | 27 | synthA.Play(); 28 | } 29 | if (Input.GetKeyDown("b")) { 30 | Debug.Log("Key: B (Coin without caching, generating asynchronously)"); 31 | 32 | if (synthB == null) { 33 | // Coin 34 | synthB = new SfxrSynth(); 35 | synthB.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); 36 | } 37 | 38 | synthB.Play(); 39 | } 40 | if (Input.GetKeyDown("c")) { 41 | Debug.Log("Key: C (Laser with mutations cached synchronously)"); 42 | 43 | if (synthC == null) { 44 | // Laser 45 | synthC = new SfxrSynth(); 46 | synthC.parameters.SetSettingsString("0,,0.1783,,0.3898,0.7523,0.2,-0.2617,,,,,,0.261,0.0356,,,,1,,,0.2466,,0.5"); 47 | synthC.SetParentTransform(Camera.main.transform); 48 | 49 | float ti = Time.realtimeSinceStartup; 50 | synthC.CacheMutations(15, 0.05f); 51 | Debug.Log("Took " + (Time.realtimeSinceStartup - ti) + "s to cache mutations."); 52 | 53 | // Hit 54 | //synthC.paramss.setSettingsString("2,,0.1702,,0.1689,0.7793,0.0224,-0.4882,,,,,,0.271,0.1608,,,,1,,,,,0.5"); 55 | } 56 | 57 | synthC.PlayMutated(); 58 | } 59 | if (Input.GetKeyDown("d")) { 60 | Debug.Log("Key: D (Long death with asynchronous caching and callback)"); 61 | 62 | if (synthD == null) { 63 | synthD = new SfxrSynth(); 64 | synthD.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); 65 | synthD.CacheSound(() => synthD.Play()); 66 | } else { 67 | synthD.Play(); 68 | } 69 | } 70 | if (Input.GetKeyDown("e")) { 71 | Debug.Log("Key: E (Long death with parallel caching of mutations and callback)"); 72 | 73 | if (synthE == null) { 74 | // Coin 75 | synthE = new SfxrSynth(); 76 | synthE.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); 77 | synthE.CacheMutations(15, 0.05f, () => synthE.PlayMutated()); 78 | } else { 79 | synthE.PlayMutated(); 80 | } 81 | } 82 | if (Input.GetKeyDown("f")) { 83 | Debug.Log("Key: F (Random coin/pickup sound, automatically generated)"); 84 | SfxrSynth synthF = new SfxrSynth(); 85 | synthF.parameters.GeneratePickupCoin(); 86 | synthF.Play(); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/Main.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 348e8d6c5de7b3e49b220abd82a8985d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 684b14e9baa6dcc40965f37b1ea52e04 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01861723f9311e04294de55915397c62 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/Editor/SfxrGenerator.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // SfxrEditor implements a Unity window to generate sounds with usfxr 4 | // using a more friendly GUI. 5 | // 6 | // 7 | // Copyright 2013 Tiaan Geldenhuys, 2014 Zeh Fernando 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | //----------------------------------------------------------------------- 22 | using System; 23 | using System.IO; 24 | using UnityEditor; 25 | using UnityEngine; 26 | 27 | /// 28 | /// Implements a Unity window to generate sounds and their parameters with usfxr. 29 | /// 30 | /// 31 | /// Open the generator from the Window menu. You can then create a sound and 32 | /// when you are ready, copy the equivalent parameters to the clipboard to be 33 | /// used inside your game. 34 | /// 35 | public class SfxrGenerator : EditorWindow { 36 | 37 | /// 38 | /// Open the usfxr's sound-effects generator window. 39 | /// 40 | 41 | // Enums 42 | public enum WaveType : uint { 43 | Square = 0, 44 | Sawtooth = 1, 45 | Sine = 2, 46 | Noise = 3, 47 | Triangle = 4, 48 | PinkNoise = 5, 49 | Tan = 6, 50 | Whistle = 7, 51 | Breaker = 8 52 | } 53 | 54 | // Properties 55 | private Vector2 scrollPosition; // Position of the scroll window 56 | private Vector2 scrollPositionRoot; 57 | private SfxrParams soundParameters; 58 | 59 | private string suggestedName; 60 | 61 | private SfxrSynth synth; 62 | 63 | // ================================================================================================================ 64 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 65 | 66 | [MenuItem("Window/Generate usfxr Sound Effects")] 67 | public static void Initialize() { 68 | var window = ScriptableObject.CreateInstance(); 69 | window.title = window.name = "Sound Effects"; 70 | window.Show(); 71 | } 72 | 73 | protected virtual void OnGUI() { 74 | // Initializations 75 | if (soundParameters == null) { 76 | soundParameters = new SfxrParams(); 77 | soundParameters.Randomize(); 78 | } 79 | 80 | if (synth == null) { 81 | synth = new SfxrSynth(); 82 | } 83 | 84 | bool soundChanged = false; 85 | 86 | // Begin UI 87 | scrollPositionRoot = GUILayout.BeginScrollView(scrollPositionRoot); 88 | GUILayout.BeginHorizontal(); 89 | 90 | // Left column (generator buttons, copy & paste) 91 | soundChanged = RenderLeftColumn(soundParameters) || soundChanged; 92 | 93 | // Main settings column 94 | soundChanged = RenderSettingsColumn(soundParameters) || soundChanged; 95 | 96 | // Ends the UI 97 | GUILayout.EndHorizontal(); 98 | GUILayout.EndScrollView(); 99 | 100 | // Play sound if necessary 101 | if (soundChanged) { 102 | synth.parameters.SetSettingsString(soundParameters.GetSettingsString()); 103 | PlaySound(); 104 | CreateWavePreview(); 105 | } 106 | 107 | } 108 | 109 | public void PlaySound() { 110 | // Just play the current sound 111 | synth.Play(); 112 | } 113 | 114 | public void CreateWavePreview() { 115 | // Creates an image with a preview of the wave 116 | 117 | /* 118 | // Create the texture and set its colour. 119 | Texture2D blackTexture = new Texture2D(1,1); 120 | blackTexture.SetPixel(0,0,Color.black); 121 | blackTexture.Apply(); 122 | ... 123 | // Use the texture. 124 | GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), blackTexture); 125 | 126 | // Anti alias line: http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm 127 | */ 128 | 129 | } 130 | 131 | public bool RenderLeftColumn(SfxrParams parameters) { 132 | bool soundChanged = false; 133 | 134 | // Begin generator column 135 | GUILayout.BeginVertical("box", GUILayout.Width(110)); 136 | GUILayout.Label("GENERATOR", EditorStyles.boldLabel); 137 | GUILayout.Space(8); 138 | 139 | if (GUILayout.Button("PICKUP/COIN")) { 140 | suggestedName = "PickupCoin"; 141 | parameters.GeneratePickupCoin(); 142 | soundChanged = true; 143 | } 144 | if (GUILayout.Button("LASER/SHOOT")) { 145 | suggestedName = "LaserShoot"; 146 | parameters.GenerateLaserShoot(); 147 | soundChanged = true; 148 | } 149 | if (GUILayout.Button("EXPLOSION")) { 150 | suggestedName = "Explosion"; 151 | parameters.GenerateExplosion(); 152 | soundChanged = true; 153 | } 154 | if (GUILayout.Button("POWERUP")) { 155 | suggestedName = "Powerup"; 156 | parameters.GeneratePowerup(); 157 | soundChanged = true; 158 | } 159 | if (GUILayout.Button("HIT/HURT")) { 160 | suggestedName = "HitHurt"; 161 | parameters.GenerateHitHurt(); 162 | soundChanged = true; 163 | } 164 | if (GUILayout.Button("JUMP")) { 165 | suggestedName = "Jump"; 166 | parameters.GenerateJump(); 167 | soundChanged = true; 168 | } 169 | if (GUILayout.Button("BLIP/SELECT")) { 170 | suggestedName = "BlipSelect"; 171 | parameters.GenerateBlipSelect(); 172 | soundChanged = true; 173 | } 174 | 175 | GUILayout.Space(30); 176 | 177 | if (GUILayout.Button("MUTATE")) { 178 | parameters.Mutate(); 179 | soundChanged = true; 180 | } 181 | if (GUILayout.Button("RANDOMIZE")) { 182 | suggestedName = "Random"; 183 | parameters.Randomize(); 184 | soundChanged = true; 185 | } 186 | 187 | GUILayout.Space(30); 188 | 189 | if (GUILayout.Button("COPY (OLD)")) { 190 | EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); 191 | } 192 | if (GUILayout.Button("COPY")) { 193 | EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); 194 | } 195 | if (GUILayout.Button("PASTE")) { 196 | suggestedName = null; 197 | parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); 198 | soundChanged = true; 199 | } 200 | 201 | GUILayout.Space(30); 202 | 203 | if (GUILayout.Button("PLAY SOUND")) { 204 | PlaySound(); 205 | } 206 | 207 | GUILayout.Space(30); 208 | 209 | if (GUILayout.Button("EXPORT WAV")) { 210 | var path = EditorUtility.SaveFilePanel("Export as WAV", "", getSuggestedName() + ".wav", "wav"); 211 | if (path.Length != 0) { 212 | SfxrSynth synth = new SfxrSynth(); 213 | synth.parameters.SetSettingsString(parameters.GetSettingsString()); 214 | File.WriteAllBytes(path, synth.GetWavFile()); 215 | } 216 | } 217 | 218 | // End generator column 219 | GUILayout.FlexibleSpace(); 220 | GUILayout.EndVertical(); 221 | 222 | return soundChanged; 223 | } 224 | 225 | public bool RenderSettingsColumn(SfxrParams parameters) { 226 | bool soundChanged = false; 227 | 228 | // Begin manual settings column 229 | GUILayout.BeginVertical("box"); 230 | GUILayout.Label("MANUAL SETTINGS", EditorStyles.boldLabel); 231 | GUILayout.Space(8); 232 | 233 | scrollPosition = GUILayout.BeginScrollView(scrollPosition); 234 | soundChanged = RenderParameters(soundParameters) || soundChanged; 235 | GUILayout.EndScrollView(); 236 | 237 | // End manual settings column 238 | GUILayout.FlexibleSpace(); 239 | GUILayout.EndVertical(); 240 | 241 | return soundChanged; 242 | } 243 | 244 | /// 245 | /// Renders the specified SFXR parameters in the editor. 246 | /// 247 | /// The current parameters to be rendered. 248 | /// 249 | /// This method is called automatically for the standalone editor window 250 | /// when a game-object with parameters is selected. However, this public 251 | /// method can also be called by CustomEditor implementations for specific 252 | /// game-components to render the editor in the Inspector window 253 | /// (see UnityEditor.Editor for details). Also, this method can be used 254 | /// from PropertyDrawer implementations; future releases of the code may 255 | /// include such a default drawer (once SfxrSynth and SfxrParams supports 256 | /// native serialization for Unity). 257 | /// 258 | public bool RenderParameters(SfxrParams parameters) { 259 | bool soundChanged = false; 260 | 261 | GUIStyle waveTypeStyle = EditorStyles.popup; 262 | waveTypeStyle.fontSize = 12; 263 | waveTypeStyle.fixedHeight = 22; 264 | 265 | EditorGUI.BeginChangeCheck(); 266 | try { 267 | WaveType waveTypeAsEnum = (WaveType)parameters.waveType; 268 | waveTypeAsEnum = (WaveType)EditorGUILayout.EnumPopup(new GUIContent("Wave Type", "Shape of the wave"), waveTypeAsEnum, waveTypeStyle); 269 | parameters.waveType = (uint)waveTypeAsEnum; 270 | GUILayout.Space(12); 271 | 272 | //RenderPopup(waveTypeOptions, ((int)(parameters.waveType)), (value => parameters.waveType = ((uint)(value))), new GUIContent("Wave Type", "Shape of the wave")); 273 | bool isSquareWaveType = (parameters.waveType == 0); 274 | RenderSlider(+0, +1, parameters.masterVolume, (value => parameters.masterVolume = value), new GUIContent("Volume", "Overall volume of the sound (0 to 1)")); 275 | 276 | RenderHeading("Wave Envelope"); 277 | RenderSlider(+0, +1, parameters.attackTime, (value => parameters.attackTime = value), new GUIContent("Attack Time", "Length of the volume envelope attack (0 to 1)")); 278 | RenderSlider(+0, +1, parameters.sustainTime, (value => parameters.sustainTime = value), new GUIContent("Sustain Time", "Length of the volume envelope sustain (0 to 1)")); 279 | RenderSlider(+0, +1, parameters.sustainPunch, (value => parameters.sustainPunch = value), new GUIContent("Sustain Punch", "Tilts the sustain envelope for more 'pop' (0 to 1)")); 280 | RenderSlider(+0, +1, parameters.decayTime, (value => parameters.decayTime = value), new GUIContent("Decay Time", "Length of the volume envelope decay (yes, I know it's called release) (0 to 1)")); 281 | 282 | // BFXR 283 | RenderSlider(+0, +1, parameters.compressionAmount, (value => parameters.compressionAmount = value), new GUIContent("Compression", "Pushes amplitudes together into a narrower range to make them stand out more. Very good for sound effects, where you want them to stick out against background music (0 to 1)")); 284 | 285 | RenderHeading("Frequency"); 286 | RenderSlider(+0, +1, parameters.startFrequency, (value => parameters.startFrequency = value), new GUIContent("Start Frequency", "Base note of the sound (0 to 1)")); 287 | RenderSlider(+0, +1, parameters.minFrequency, (value => parameters.minFrequency = value), new GUIContent("Minimum Frequency", "If sliding, the sound will stop at this frequency, to prevent really low notes (0 to 1)")); 288 | RenderSlider(-1, +1, parameters.slide, (value => parameters.slide = value), new GUIContent("Slide", "Slides the note up or down (-1 to 1)")); 289 | RenderSlider(-1, +1, parameters.deltaSlide, (value => parameters.deltaSlide = value), new GUIContent("Delta Slide", "Accelerates the slide (-1 to 1)")); 290 | RenderSlider(+0, +1, parameters.vibratoDepth, (value => parameters.vibratoDepth = value), new GUIContent("Vibrato Depth", "Strength of the vibrato effect (0 to 1)")); 291 | RenderSlider(+0, +1, parameters.vibratoSpeed, (value => parameters.vibratoSpeed = value), new GUIContent("Vibrato Speed", "Speed of the vibrato effect (i.e. frequency) (0 to 1)")); 292 | 293 | // BFXR 294 | RenderSlider(+0, +1, parameters.overtones, (value => parameters.overtones = value), new GUIContent("Harmonics", "Overlays copies of the waveform with copies and multiples of its frequency. Good for bulking out or otherwise enriching the texture of the sounds (warning: this is the number 1 cause of usfxr slowdown!) (0 to 1)")); 295 | RenderSlider(+0, +1, parameters.overtoneFalloff, (value => parameters.overtoneFalloff = value), new GUIContent("Harmonics falloff", "The rate at which higher overtones should decay (0 to 1)")); 296 | 297 | RenderHeading("Tone Change/Pitch Jump"); 298 | // BFXR 299 | RenderSlider(+0, +1, parameters.changeRepeat, (value => parameters.changeRepeat = value), new GUIContent("Change Repeat Speed", "Larger Values means more pitch jumps, which can be useful for arpeggiation (0 to 1)")); 300 | 301 | RenderSlider(-1, +1, parameters.changeAmount, (value => parameters.changeAmount = value), new GUIContent("Change Amount 1", "Shift in note, either up or down (-1 to 1)")); 302 | RenderSlider(+0, +1, parameters.changeSpeed, (value => parameters.changeSpeed = value), new GUIContent("Change Speed 1", "How fast the note shift happens (only happens once) (0 to 1)")); 303 | 304 | // BFXR 305 | RenderSlider(-1, +1, parameters.changeAmount2, (value => parameters.changeAmount2 = value), new GUIContent("Change Amount 2", "Shift in note, either up or down (-1 to 1)")); 306 | RenderSlider(+0, +1, parameters.changeSpeed2, (value => parameters.changeSpeed2 = value), new GUIContent("Change Speed 2", "How fast the note shift happens (only happens once) (0 to 1)")); 307 | 308 | RenderHeading("Square Waves"); 309 | RenderSlider(+0, +1, parameters.squareDuty, (value => parameters.squareDuty = value), new GUIContent("Square Duty", "Controls the ratio between the up and down states of the square wave, changing the tibre (0 to 1)"), isSquareWaveType); 310 | RenderSlider(-1, +1, parameters.dutySweep, (value => parameters.dutySweep = value), new GUIContent("Duty Sweep", "Sweeps the duty up or down (-1 to 1)"), isSquareWaveType); 311 | 312 | RenderHeading("Repeats"); 313 | RenderSlider(+0, +1, parameters.repeatSpeed, (value => parameters.repeatSpeed = value), new GUIContent("Repeat Speed", "Speed of the note repeating - certain variables are reset each time (0 to 1)")); 314 | 315 | RenderHeading("Phaser"); 316 | RenderSlider(-1, +1, parameters.phaserOffset, (value => parameters.phaserOffset = value), new GUIContent("Phaser Offset", "Offsets a second copy of the wave by a small phase, changing the tibre (-1 to 1)")); 317 | RenderSlider(-1, +1, parameters.phaserSweep, (value => parameters.phaserSweep = value), new GUIContent("Phaser Sweep", "Sweeps the phase up or down (-1 to 1)")); 318 | 319 | RenderHeading("Filters"); 320 | RenderSlider(+0, +1, parameters.lpFilterCutoff, (value => parameters.lpFilterCutoff = value), new GUIContent("Low-Pass Cutoff", "Frequency at which the low-pass filter starts attenuating higher frequencies (0 to 1)")); 321 | RenderSlider(-1, +1, parameters.lpFilterCutoffSweep, (value => parameters.lpFilterCutoffSweep = value), new GUIContent("Low-Pass Cutoff Sweep", "Sweeps the low-pass cutoff up or down (-1 to 1)")); 322 | RenderSlider(+0, +1, parameters.lpFilterResonance, (value => parameters.lpFilterResonance = value), new GUIContent("Low-Pass Resonance", "Changes the attenuation rate for the low-pass filter, changing the timbre (0 to 1)")); 323 | RenderSlider(+0, +1, parameters.hpFilterCutoff, (value => parameters.hpFilterCutoff = value), new GUIContent("High-Pass Cutoff", "Frequency at which the high-pass filter starts attenuating lower frequencies (0 to 1)")); 324 | RenderSlider(-1, +1, parameters.hpFilterCutoffSweep, (value => parameters.hpFilterCutoffSweep = value), new GUIContent("High-Pass Cutoff Sweep", "Sweeps the high-pass cutoff up or down (-1 to 1)")); 325 | 326 | RenderHeading("Bit Crushing"); 327 | 328 | // BFXR 329 | RenderSlider(+0, +1, parameters.bitCrush, (value => parameters.bitCrush = value), new GUIContent("Bit Crush", "Resamples the audio at a lower frequency (0 to 1)")); 330 | RenderSlider(-1, +1, parameters.bitCrushSweep, (value => parameters.bitCrushSweep = value), new GUIContent("Bit Crush Sweep", "Sweeps the Bit Crush filter up or down (-1 to 1)")); 331 | } finally { 332 | if (EditorGUI.EndChangeCheck()) { 333 | parameters.paramsDirty = true; 334 | soundChanged = true; 335 | } 336 | } 337 | 338 | return soundChanged; 339 | } 340 | 341 | protected static void RenderHeading(string heading) { 342 | EditorGUILayout.LabelField(heading, EditorStyles.boldLabel); 343 | } 344 | 345 | protected static bool RenderButton( 346 | GUIContent content = null, 347 | Action valueChangeAction = null, 348 | bool? isEnabled = null, 349 | params GUILayoutOption[] options) 350 | { 351 | if (content == null) 352 | { 353 | content = GUIContent.none; 354 | } 355 | 356 | bool isClicked = false; 357 | return RenderGenericEditor( 358 | ref isClicked, 359 | () => GUILayout.Button(content, options), 360 | valueChangeAction, 361 | isEnabled); 362 | } 363 | 364 | protected static bool RenderButton( 365 | string text, 366 | Action valueChangeAction = null, 367 | bool? isEnabled = null, 368 | params GUILayoutOption[] options) 369 | { 370 | return RenderButton( 371 | new GUIContent(text), valueChangeAction, isEnabled, options); 372 | } 373 | 374 | protected static bool RenderPopup( 375 | GUIContent[] selectionOptions, 376 | int value, 377 | Action valueChangeAction = null, 378 | GUIContent label = null, 379 | bool? isEnabled = null) 380 | { 381 | if (label == null) 382 | { 383 | label = GUIContent.none; 384 | } 385 | 386 | return RenderGenericEditor( 387 | ref value, 388 | () => EditorGUILayout.Popup(label, value, selectionOptions), 389 | valueChangeAction, 390 | isEnabled); 391 | } 392 | 393 | protected static bool RenderSlider( 394 | float minValue, 395 | float maxValue, 396 | float value, 397 | Action valueChangeAction = null, 398 | GUIContent label = null, 399 | bool? isEnabled = null) 400 | { 401 | if (label == null) 402 | { 403 | label = GUIContent.none; 404 | } 405 | 406 | return RenderGenericEditor( 407 | ref value, 408 | () => EditorGUILayout.Slider(label, value, minValue, maxValue), 409 | valueChangeAction, 410 | isEnabled); 411 | } 412 | 413 | private static bool RenderGenericEditor( 414 | ref T value, 415 | Func valueEditFunction, 416 | Action valueChangeAction = null, 417 | bool? isEnabled = null) 418 | { 419 | bool isChanged; 420 | if (valueEditFunction == null) 421 | { 422 | isChanged = false; 423 | } 424 | else 425 | { 426 | bool? wasEnabled; 427 | if (isEnabled.HasValue) 428 | { 429 | wasEnabled = GUI.enabled; 430 | GUI.enabled = isEnabled.Value; 431 | } 432 | else 433 | { 434 | wasEnabled = null; 435 | } 436 | 437 | try 438 | { 439 | EditorGUI.BeginChangeCheck(); 440 | try 441 | { 442 | value = valueEditFunction(); 443 | } 444 | finally 445 | { 446 | isChanged = EditorGUI.EndChangeCheck(); 447 | } 448 | 449 | if (isChanged 450 | && (valueChangeAction != null)) 451 | { 452 | valueChangeAction(value); 453 | } 454 | } 455 | finally 456 | { 457 | if (wasEnabled.HasValue) 458 | { 459 | GUI.enabled = wasEnabled.Value; 460 | } 461 | } 462 | } 463 | 464 | return isChanged; 465 | } 466 | 467 | private static bool RenderGenericEditor( 468 | ref T value, 469 | Func valueEditFunction, 470 | Action valueChangeAction, 471 | bool? isEnabled = null) 472 | { 473 | Action valueChangeActionWrapped = null; 474 | if (valueChangeAction != null) 475 | { 476 | valueChangeActionWrapped = (dummyValue) => valueChangeAction(); 477 | } 478 | 479 | return RenderGenericEditor( 480 | ref value, valueEditFunction, valueChangeActionWrapped, isEnabled); 481 | } 482 | 483 | private string getSuggestedName() { 484 | return suggestedName != null && suggestedName.Length > 0 ? suggestedName : "Audio"; 485 | } 486 | } 487 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/Editor/SfxrGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cee7a406ae1fd88408be598ffbd47292 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/SfxrAudioPlayer.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | #endif 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | [ExecuteInEditMode] 8 | #endif 9 | public class SfxrAudioPlayer : MonoBehaviour { 10 | 11 | /** 12 | * usfxr 13 | * 14 | * Copyright 2013 Zeh Fernando 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | */ 29 | 30 | /** 31 | * SfxrAudioPlayer 32 | * This is the (internal) behavior script responsible for streaming audio to the engine 33 | * 34 | * @author Zeh Fernando 35 | */ 36 | 37 | 38 | // Properties 39 | private bool isDestroyed = false; // If true, this instance has been destroyed and shouldn't do anything yes 40 | private bool needsToDestroy = false; // If true, it has been scheduled for destruction (from outside the main thread) 41 | private bool runningInEditMode = false; // If true, it is running from the editor and NOT playing 42 | 43 | // Instances 44 | private SfxrSynth sfxrSynth; // SfxrSynth instance that will generate the audio samples used by this 45 | 46 | 47 | // ================================================================================================================ 48 | // INTERNAL INTERFACE --------------------------------------------------------------------------------------------- 49 | 50 | void Start() { 51 | // Creates an empty audio source so this GameObject can receive audio events 52 | AudioSource soundSource = gameObject.AddComponent(); 53 | soundSource.clip = new AudioClip(); 54 | soundSource.volume = 1f; 55 | soundSource.pitch = 1f; 56 | soundSource.priority = 128; 57 | soundSource.Play(); 58 | } 59 | 60 | void Update() { 61 | // Destroys self in case it has been queued for deletion 62 | if (sfxrSynth == null) { 63 | // Rogue object (leftover) 64 | // When switching between play and edit mode while the sound is playing, the object is restarted 65 | // So, queues for destruction 66 | needsToDestroy = true; 67 | } 68 | 69 | if (needsToDestroy) { 70 | needsToDestroy = false; 71 | Destroy(); 72 | } 73 | } 74 | 75 | void OnAudioFilterRead(float[] __data, int __channels) { 76 | // Requests the generation of the needed audio data from SfxrSynth 77 | 78 | if (!isDestroyed && !needsToDestroy && sfxrSynth != null) { 79 | bool hasMoreSamples = sfxrSynth.GenerateAudioFilterData(__data, __channels); 80 | 81 | // If no more samples are needed, there's no more need for this GameObject so schedule a destruction (cannot do this in this thread) 82 | if (!hasMoreSamples) { 83 | needsToDestroy = true; 84 | if (runningInEditMode) { 85 | // When running in edit mode, Update() is not called on every frame 86 | // We can't call Destroy() directly either, since Destroy() must be ran from the main thread 87 | // So we just attach our Update() to the editor's update event 88 | #if UNITY_EDITOR 89 | EditorApplication.update += Update; 90 | #endif 91 | } 92 | } 93 | } 94 | } 95 | 96 | 97 | // ================================================================================================================ 98 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 99 | 100 | public void SetSfxrSynth(SfxrSynth __sfxrSynth) { 101 | // Sets the SfxrSynth instance that will generate the audio samples used by this 102 | sfxrSynth = __sfxrSynth; 103 | } 104 | 105 | public void SetRunningInEditMode(bool __runningInEditMode) { 106 | // Sets the SfxrSynth instance that will generate the audio samples used by this 107 | runningInEditMode = __runningInEditMode; 108 | } 109 | 110 | public void Destroy() { 111 | // Stops audio immediately and destroys self 112 | if (!isDestroyed) { 113 | isDestroyed = true; 114 | sfxrSynth = null; 115 | if (runningInEditMode || !Application.isPlaying) { 116 | // Since we're running in the editor, we need to remove the update event, AND destroy immediately 117 | #if UNITY_EDITOR 118 | EditorApplication.update -= Update; 119 | #endif 120 | UnityEngine.Object.DestroyImmediate(gameObject); 121 | } else { 122 | UnityEngine.Object.Destroy(gameObject); 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/SfxrAudioPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f59cf3184c1e4347833fde7507e8bfc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/SfxrCacheSurrogate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | public class SfxrCacheSurrogate : MonoBehaviour { 6 | 7 | /** 8 | * usfxr 9 | * 10 | * Copyright 2013 Zeh Fernando 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | */ 25 | 26 | /** 27 | * SfxrCacheSurrogate 28 | * This is the (internal) behavior script responsible for calling Coroutines for asynchronous audio generation 29 | * 30 | * @author Zeh Fernando 31 | */ 32 | 33 | // ================================================================================================================ 34 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 35 | 36 | public void CacheSound(SfxrSynth __synth, Action __callback) { 37 | StartCoroutine(CacheSoundAsynchronously(__synth, __callback)); 38 | } 39 | 40 | private IEnumerator CacheSoundAsynchronously(SfxrSynth __synth, Action __callback) { 41 | yield return null; 42 | __synth.CacheSound(null, true); 43 | __callback(); 44 | UnityEngine.Object.Destroy(gameObject); 45 | } 46 | 47 | public void CacheMutations(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 48 | StartCoroutine(CacheMutationsAsynchronously(__synth, __mutationsNum, __mutationAmount, __callback)); 49 | } 50 | 51 | private IEnumerator CacheMutationsAsynchronously(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 52 | yield return null; 53 | __synth.CacheMutations(__mutationsNum, __mutationAmount, null, true); 54 | __callback(); 55 | UnityEngine.Object.Destroy(gameObject); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/SfxrCacheSurrogate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0216fe69f722f8141874a04a7bbb44ea 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/SfxrParams.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 847b3b03630aa1445af7a648d1df86dd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/main/Assets/Scripts/usfxr/SfxrSynth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2aaf75046af8d6d4598b2ecc6808c6ff 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | m_SpeedOfSound: 347 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_DSPBufferSize: 0 12 | m_DisableAudio: 0 13 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepVelocity: .150000006 10 | m_SleepAngularVelocity: .140000001 11 | m_MaxAngularVelocity: 7 12 | m_MinPenetrationForPenalty: .00999999978 13 | m_SolverIterationCount: 6 14 | m_RaycastsHitTriggers: 1 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 0 13 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | m_AlwaysIncludedShaders: 7 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 8 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | m_Axes: 7 | - serializedVersion: 3 8 | m_Name: Horizontal 9 | descriptiveName: 10 | descriptiveNegativeName: 11 | negativeButton: left 12 | positiveButton: right 13 | altNegativeButton: a 14 | altPositiveButton: d 15 | gravity: 3 16 | dead: .00100000005 17 | sensitivity: 3 18 | snap: 1 19 | invert: 0 20 | type: 0 21 | axis: 0 22 | joyNum: 0 23 | - serializedVersion: 3 24 | m_Name: Vertical 25 | descriptiveName: 26 | descriptiveNegativeName: 27 | negativeButton: down 28 | positiveButton: up 29 | altNegativeButton: s 30 | altPositiveButton: w 31 | gravity: 3 32 | dead: .00100000005 33 | sensitivity: 3 34 | snap: 1 35 | invert: 0 36 | type: 0 37 | axis: 0 38 | joyNum: 0 39 | - serializedVersion: 3 40 | m_Name: Fire1 41 | descriptiveName: 42 | descriptiveNegativeName: 43 | negativeButton: 44 | positiveButton: left ctrl 45 | altNegativeButton: 46 | altPositiveButton: mouse 0 47 | gravity: 1000 48 | dead: .00100000005 49 | sensitivity: 1000 50 | snap: 0 51 | invert: 0 52 | type: 0 53 | axis: 0 54 | joyNum: 0 55 | - serializedVersion: 3 56 | m_Name: Fire2 57 | descriptiveName: 58 | descriptiveNegativeName: 59 | negativeButton: 60 | positiveButton: left alt 61 | altNegativeButton: 62 | altPositiveButton: mouse 1 63 | gravity: 1000 64 | dead: .00100000005 65 | sensitivity: 1000 66 | snap: 0 67 | invert: 0 68 | type: 0 69 | axis: 0 70 | joyNum: 0 71 | - serializedVersion: 3 72 | m_Name: Fire3 73 | descriptiveName: 74 | descriptiveNegativeName: 75 | negativeButton: 76 | positiveButton: left cmd 77 | altNegativeButton: 78 | altPositiveButton: mouse 2 79 | gravity: 1000 80 | dead: .00100000005 81 | sensitivity: 1000 82 | snap: 0 83 | invert: 0 84 | type: 0 85 | axis: 0 86 | joyNum: 0 87 | - serializedVersion: 3 88 | m_Name: Jump 89 | descriptiveName: 90 | descriptiveNegativeName: 91 | negativeButton: 92 | positiveButton: space 93 | altNegativeButton: 94 | altPositiveButton: 95 | gravity: 1000 96 | dead: .00100000005 97 | sensitivity: 1000 98 | snap: 0 99 | invert: 0 100 | type: 0 101 | axis: 0 102 | joyNum: 0 103 | - serializedVersion: 3 104 | m_Name: Mouse X 105 | descriptiveName: 106 | descriptiveNegativeName: 107 | negativeButton: 108 | positiveButton: 109 | altNegativeButton: 110 | altPositiveButton: 111 | gravity: 0 112 | dead: 0 113 | sensitivity: .100000001 114 | snap: 0 115 | invert: 0 116 | type: 1 117 | axis: 0 118 | joyNum: 0 119 | - serializedVersion: 3 120 | m_Name: Mouse Y 121 | descriptiveName: 122 | descriptiveNegativeName: 123 | negativeButton: 124 | positiveButton: 125 | altNegativeButton: 126 | altPositiveButton: 127 | gravity: 0 128 | dead: 0 129 | sensitivity: .100000001 130 | snap: 0 131 | invert: 0 132 | type: 1 133 | axis: 1 134 | joyNum: 0 135 | - serializedVersion: 3 136 | m_Name: Mouse ScrollWheel 137 | descriptiveName: 138 | descriptiveNegativeName: 139 | negativeButton: 140 | positiveButton: 141 | altNegativeButton: 142 | altPositiveButton: 143 | gravity: 0 144 | dead: 0 145 | sensitivity: .100000001 146 | snap: 0 147 | invert: 0 148 | type: 1 149 | axis: 2 150 | joyNum: 0 151 | - serializedVersion: 3 152 | m_Name: Horizontal 153 | descriptiveName: 154 | descriptiveNegativeName: 155 | negativeButton: 156 | positiveButton: 157 | altNegativeButton: 158 | altPositiveButton: 159 | gravity: 0 160 | dead: .189999998 161 | sensitivity: 1 162 | snap: 0 163 | invert: 0 164 | type: 2 165 | axis: 0 166 | joyNum: 0 167 | - serializedVersion: 3 168 | m_Name: Vertical 169 | descriptiveName: 170 | descriptiveNegativeName: 171 | negativeButton: 172 | positiveButton: 173 | altNegativeButton: 174 | altPositiveButton: 175 | gravity: 0 176 | dead: .189999998 177 | sensitivity: 1 178 | snap: 0 179 | invert: 1 180 | type: 2 181 | axis: 1 182 | joyNum: 0 183 | - serializedVersion: 3 184 | m_Name: Fire1 185 | descriptiveName: 186 | descriptiveNegativeName: 187 | negativeButton: 188 | positiveButton: joystick button 0 189 | altNegativeButton: 190 | altPositiveButton: 191 | gravity: 1000 192 | dead: .00100000005 193 | sensitivity: 1000 194 | snap: 0 195 | invert: 0 196 | type: 0 197 | axis: 0 198 | joyNum: 0 199 | - serializedVersion: 3 200 | m_Name: Fire2 201 | descriptiveName: 202 | descriptiveNegativeName: 203 | negativeButton: 204 | positiveButton: joystick button 1 205 | altNegativeButton: 206 | altPositiveButton: 207 | gravity: 1000 208 | dead: .00100000005 209 | sensitivity: 1000 210 | snap: 0 211 | invert: 0 212 | type: 0 213 | axis: 0 214 | joyNum: 0 215 | - serializedVersion: 3 216 | m_Name: Fire3 217 | descriptiveName: 218 | descriptiveNegativeName: 219 | negativeButton: 220 | positiveButton: joystick button 2 221 | altNegativeButton: 222 | altPositiveButton: 223 | gravity: 1000 224 | dead: .00100000005 225 | sensitivity: 1000 226 | snap: 0 227 | invert: 0 228 | type: 0 229 | axis: 0 230 | joyNum: 0 231 | - serializedVersion: 3 232 | m_Name: Jump 233 | descriptiveName: 234 | descriptiveNegativeName: 235 | negativeButton: 236 | positiveButton: joystick button 3 237 | altNegativeButton: 238 | altPositiveButton: 239 | gravity: 1000 240 | dead: .00100000005 241 | sensitivity: 1000 242 | snap: 0 243 | invert: 0 244 | type: 0 245 | axis: 0 246 | joyNum: 0 247 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_RaycastsHitTriggers: 1 11 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 12 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | AndroidProfiler: 0 8 | defaultScreenOrientation: 0 9 | targetDevice: 2 10 | targetGlesGraphics: 1 11 | targetResolution: 0 12 | accelerometerFrequency: 60 13 | companyName: DefaultCompany 14 | productName: main 15 | defaultCursor: {fileID: 0} 16 | cursorHotspot: {x: 0, y: 0} 17 | defaultScreenWidth: 1024 18 | defaultScreenHeight: 768 19 | defaultScreenWidthWeb: 960 20 | defaultScreenHeightWeb: 600 21 | m_RenderingPath: 1 22 | m_MobileRenderingPath: 1 23 | m_ActiveColorSpace: 0 24 | m_MTRendering: 1 25 | m_MobileMTRendering: 0 26 | m_UseDX11: 0 27 | iosShowActivityIndicatorOnLoading: -1 28 | androidShowActivityIndicatorOnLoading: -1 29 | displayResolutionDialog: 1 30 | allowedAutorotateToPortrait: 1 31 | allowedAutorotateToPortraitUpsideDown: 1 32 | allowedAutorotateToLandscapeRight: 1 33 | allowedAutorotateToLandscapeLeft: 1 34 | useOSAutorotation: 1 35 | use32BitDisplayBuffer: 1 36 | use24BitDepthBuffer: 0 37 | defaultIsFullScreen: 0 38 | defaultIsNativeResolution: 1 39 | runInBackground: 0 40 | captureSingleScreen: 0 41 | Override IPod Music: 0 42 | Prepare IOS For Recording: 0 43 | enableHWStatistics: 1 44 | usePlayerLog: 1 45 | stripPhysics: 0 46 | forceSingleInstance: 0 47 | resizableWindow: 0 48 | useMacAppStoreValidation: 0 49 | gpuSkinning: 0 50 | xboxPIXTextureCapture: 0 51 | xboxEnableAvatar: 0 52 | xboxEnableKinect: 0 53 | xboxEnableKinectAutoTracking: 0 54 | xboxEnableFitness: 0 55 | macFullscreenMode: 2 56 | xboxSpeechDB: 0 57 | xboxEnableHeadOrientation: 0 58 | xboxEnableGuest: 0 59 | wiiHio2Usage: -1 60 | wiiLoadingScreenRectPlacement: 0 61 | wiiLoadingScreenBackground: {r: 1, g: 1, b: 1, a: 1} 62 | wiiLoadingScreenPeriod: 1000 63 | wiiLoadingScreenFileName: 64 | wiiLoadingScreenRect: 65 | serializedVersion: 2 66 | x: 0 67 | y: 0 68 | width: 0 69 | height: 0 70 | m_SupportedAspectRatios: 71 | 4:3: 1 72 | 5:4: 1 73 | 16:10: 1 74 | 16:9: 1 75 | Others: 1 76 | iPhoneBundleIdentifier: com.Company.ProductName 77 | metroEnableIndependentInputSource: 0 78 | metroEnableLowLatencyPresentationAPI: 0 79 | productGUID: b83f1fa2fd2e4914ab9176906ec122be 80 | iPhoneBundleVersion: 1.0 81 | AndroidBundleVersionCode: 1 82 | AndroidMinSdkVersion: 9 83 | AndroidPreferredInstallLocation: 1 84 | aotOptions: 85 | apiCompatibilityLevel: 2 86 | iPhoneStrippingLevel: 0 87 | iPhoneScriptCallOptimization: 0 88 | ForceInternetPermission: 0 89 | ForceSDCardPermission: 0 90 | CreateWallpaper: 0 91 | APKExpansionFiles: 0 92 | StripUnusedMeshComponents: 0 93 | iPhoneSdkVersion: 988 94 | iPhoneTargetOSVersion: 10 95 | uIPrerenderedIcon: 0 96 | uIRequiresPersistentWiFi: 0 97 | uIStatusBarHidden: 1 98 | uIExitOnSuspend: 0 99 | uIStatusBarStyle: 0 100 | iPhoneSplashScreen: {fileID: 0} 101 | iPhoneHighResSplashScreen: {fileID: 0} 102 | iPhoneTallHighResSplashScreen: {fileID: 0} 103 | iPadPortraitSplashScreen: {fileID: 0} 104 | iPadHighResPortraitSplashScreen: {fileID: 0} 105 | iPadLandscapeSplashScreen: {fileID: 0} 106 | iPadHighResLandscapeSplashScreen: {fileID: 0} 107 | AndroidTargetDevice: 0 108 | AndroidSplashScreenScale: 0 109 | AndroidKeystoreName: 110 | AndroidKeyaliasName: 111 | resolutionDialogBanner: {fileID: 0} 112 | m_BuildTargetIcons: [] 113 | m_BuildTargetBatching: [] 114 | webPlayerTemplate: APPLICATION:Default 115 | m_TemplateCustomTags: {} 116 | wiiRegion: 1 117 | wiiGameCode: RABA 118 | wiiGameVersion: 119 | wiiCompanyCode: ZZ 120 | wiiSupportsNunchuk: 0 121 | wiiSupportsClassicController: 0 122 | wiiSupportsBalanceBoard: 0 123 | wiiSupportsMotionPlus: 0 124 | wiiControllerCount: 1 125 | wiiFloatingPointExceptions: 0 126 | wiiScreenCrashDumps: 1 127 | XboxTitleId: 128 | XboxImageXexPath: 129 | XboxSpaPath: 130 | XboxGenerateSpa: 0 131 | XboxDeployKinectResources: 0 132 | XboxSplashScreen: {fileID: 0} 133 | xboxEnableSpeech: 0 134 | xboxAdditionalTitleMemorySize: 0 135 | xboxDeployKinectHeadOrientation: 0 136 | xboxDeployKinectHeadPosition: 0 137 | ps3TitleConfigPath: 138 | ps3DLCConfigPath: 139 | ps3ThumbnailPath: 140 | ps3BackgroundPath: 141 | ps3SoundPath: 142 | ps3TrophyCommId: 143 | ps3NpCommunicationPassphrase: 144 | ps3TrophyPackagePath: 145 | ps3BootCheckMaxSaveGameSizeKB: 128 146 | ps3TrophyCommSig: 147 | ps3SaveGameSlots: 1 148 | ps3TrialMode: 0 149 | flashStrippingLevel: 2 150 | spritePackerPolicy: 151 | scriptingDefineSymbols: {} 152 | metroPackageName: 153 | metroPackageLogo: 154 | metroPackageVersion: 155 | metroCertificatePath: 156 | metroCertificatePassword: 157 | metroCertificateSubject: 158 | metroCertificateIssuer: 159 | metroCertificateNotAfter: 0000000000000000 160 | metroApplicationDescription: 161 | metroTileLogo: 162 | metroTileWideLogo: 163 | metroTileSmallLogo: 164 | metroTileShortName: 165 | metroCommandLineArgsFile: 166 | metroTileShowName: 0 167 | metroTileForegroundText: 1 168 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 169 | metroSplashScreenImage: 170 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 171 | metroSplashScreenUseBackgroundColor: 0 172 | metroCapabilities: {} 173 | metroUnprocessedPlugins: [] 174 | metroCompilationOverrides: 1 175 | blackberryDeviceAddress: 176 | blackberryDevicePassword: 177 | blackberryTokenPath: 178 | blackberryTokenExires: 179 | blackberryTokenAuthor: 180 | blackberryTokenAuthorId: 181 | blackberryAuthorId: 182 | blackberryCskPassword: 183 | blackberrySaveLogPath: 184 | blackberryAuthorIdOveride: 0 185 | blackberrySharedPermissions: 0 186 | blackberryCameraPermissions: 0 187 | blackberryGPSPermissions: 0 188 | blackberryDeviceIDPermissions: 0 189 | blackberryMicrophonePermissions: 0 190 | blackberryGamepadSupport: 0 191 | blackberryBuildId: 0 192 | blackberryLandscapeSplashScreen: {fileID: 0} 193 | blackberryPortraitSplashScreen: {fileID: 0} 194 | blackberrySquareSplashScreen: {fileID: 0} 195 | tizenProductDescription: 196 | tizenProductURL: 197 | tizenCertificatePath: 198 | tizenCertificatePassword: 199 | tizenSaveLogPath: 200 | firstStreamedLevelWithResources: 0 201 | unityRebuildLibraryVersion: 9 202 | unityForwardCompatibleVersion: 39 203 | unityStandardAssetsVersion: 0 204 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | blendWeights: 1 18 | textureQuality: 1 19 | anisotropicTextures: 0 20 | antiAliasing: 0 21 | softParticles: 0 22 | softVegetation: 0 23 | vSyncCount: 0 24 | lodBias: .300000012 25 | maximumLODLevel: 0 26 | particleRaycastBudget: 4 27 | excludedTargetPlatforms: [] 28 | - serializedVersion: 2 29 | name: Fast 30 | pixelLightCount: 0 31 | shadows: 0 32 | shadowResolution: 0 33 | shadowProjection: 1 34 | shadowCascades: 1 35 | shadowDistance: 20 36 | blendWeights: 2 37 | textureQuality: 0 38 | anisotropicTextures: 0 39 | antiAliasing: 0 40 | softParticles: 0 41 | softVegetation: 0 42 | vSyncCount: 0 43 | lodBias: .400000006 44 | maximumLODLevel: 0 45 | particleRaycastBudget: 16 46 | excludedTargetPlatforms: [] 47 | - serializedVersion: 2 48 | name: Simple 49 | pixelLightCount: 1 50 | shadows: 1 51 | shadowResolution: 0 52 | shadowProjection: 1 53 | shadowCascades: 1 54 | shadowDistance: 20 55 | blendWeights: 2 56 | textureQuality: 0 57 | anisotropicTextures: 1 58 | antiAliasing: 0 59 | softParticles: 0 60 | softVegetation: 0 61 | vSyncCount: 0 62 | lodBias: .699999988 63 | maximumLODLevel: 0 64 | particleRaycastBudget: 64 65 | excludedTargetPlatforms: [] 66 | - serializedVersion: 2 67 | name: Good 68 | pixelLightCount: 2 69 | shadows: 2 70 | shadowResolution: 1 71 | shadowProjection: 1 72 | shadowCascades: 2 73 | shadowDistance: 40 74 | blendWeights: 2 75 | textureQuality: 0 76 | anisotropicTextures: 1 77 | antiAliasing: 0 78 | softParticles: 0 79 | softVegetation: 1 80 | vSyncCount: 1 81 | lodBias: 1 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 256 84 | excludedTargetPlatforms: [] 85 | - serializedVersion: 2 86 | name: Beautiful 87 | pixelLightCount: 3 88 | shadows: 2 89 | shadowResolution: 2 90 | shadowProjection: 1 91 | shadowCascades: 2 92 | shadowDistance: 70 93 | blendWeights: 4 94 | textureQuality: 0 95 | anisotropicTextures: 2 96 | antiAliasing: 2 97 | softParticles: 1 98 | softVegetation: 1 99 | vSyncCount: 1 100 | lodBias: 1.5 101 | maximumLODLevel: 0 102 | particleRaycastBudget: 1024 103 | excludedTargetPlatforms: [] 104 | - serializedVersion: 2 105 | name: Fantastic 106 | pixelLightCount: 4 107 | shadows: 2 108 | shadowResolution: 2 109 | shadowProjection: 1 110 | shadowCascades: 4 111 | shadowDistance: 150 112 | blendWeights: 4 113 | textureQuality: 0 114 | anisotropicTextures: 2 115 | antiAliasing: 2 116 | softParticles: 1 117 | softVegetation: 1 118 | vSyncCount: 1 119 | lodBias: 2 120 | maximumLODLevel: 0 121 | particleRaycastBudget: 4096 122 | excludedTargetPlatforms: [] 123 | m_PerPlatformDefaultQuality: {} 124 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | tags: 6 | - 7 | Builtin Layer 0: Default 8 | Builtin Layer 1: TransparentFX 9 | Builtin Layer 2: Ignore Raycast 10 | Builtin Layer 3: 11 | Builtin Layer 4: Water 12 | Builtin Layer 5: 13 | Builtin Layer 6: 14 | Builtin Layer 7: 15 | User Layer 8: 16 | User Layer 9: 17 | User Layer 10: 18 | User Layer 11: 19 | User Layer 12: 20 | User Layer 13: 21 | User Layer 14: 22 | User Layer 15: 23 | User Layer 16: 24 | User Layer 17: 25 | User Layer 18: 26 | User Layer 19: 27 | User Layer 20: 28 | User Layer 21: 29 | User Layer 22: 30 | User Layer 23: 31 | User Layer 24: 32 | User Layer 25: 33 | User Layer 26: 34 | User Layer 27: 35 | User Layer 28: 36 | User Layer 29: 37 | User Layer 30: 38 | User Layer 31: 39 | m_SortingLayers: 40 | - name: Default 41 | userID: 0 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /samples/main/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /source/Editor/SfxrSoundEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | [CustomPropertyDrawer(typeof(SfxrSound))] 6 | public class SfxrSoundEditor : PropertyDrawer { 7 | 8 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { 9 | if (property.isExpanded) 10 | return EditorGUIUtility.singleLineHeight * 5; 11 | else 12 | return EditorGUIUtility.singleLineHeight; 13 | } 14 | 15 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { 16 | if (property.isExpanded) 17 | DrawUnfolded(position, property, label); 18 | else 19 | DrawFolded(position, property, label); 20 | } 21 | 22 | private void DrawFolded(Rect position, SerializedProperty property, GUIContent label) { 23 | property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, property.name); 24 | } 25 | 26 | private void DrawUnfolded(Rect position, SerializedProperty property, GUIContent label) { 27 | Rect labelRect = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); 28 | Rect dropdownRect = new Rect(position.xMin, labelRect.yMax, position.width, EditorGUIUtility.singleLineHeight); 29 | Rect cachedRect = new Rect(position.xMin, dropdownRect.yMax, position.width, EditorGUIUtility.singleLineHeight); 30 | Rect mutationsRect = new Rect(position.xMin, cachedRect.yMax, position.width, EditorGUIUtility.singleLineHeight); 31 | Rect factorRect = new Rect(position.xMin, mutationsRect.yMax, position.width, EditorGUIUtility.singleLineHeight); 32 | 33 | var soundProperty = property.FindPropertyRelative("sound"); 34 | var cachedProperty = property.FindPropertyRelative("cached"); 35 | var mutationsProperty = property.FindPropertyRelative("mutations"); 36 | var factorProperty = property.FindPropertyRelative("mutationFactor"); 37 | 38 | var soundContainer = SfxrSoundContainer.Create(); 39 | 40 | property.isExpanded = EditorGUI.Foldout(labelRect, property.isExpanded, property.name); 41 | 42 | if (soundContainer.IsEmpty) { 43 | EditorGUI.Popup(dropdownRect, "Sound", 0, new string[] { "[No sounds saved]" }); 44 | } else { 45 | string sound = soundProperty.stringValue; 46 | List titles = new List(soundContainer.GetTitles()); 47 | int newIdx = 0; 48 | if (!string.IsNullOrEmpty(sound) && titles.Contains(sound)) { 49 | int idx = titles.IndexOf(sound); 50 | newIdx = EditorGUI.Popup(dropdownRect, "Sound", idx, titles.ToArray()); 51 | } else { 52 | newIdx = EditorGUI.Popup(dropdownRect, "Sound", 0, titles.ToArray()); 53 | } 54 | 55 | soundProperty.stringValue = titles[newIdx]; 56 | } 57 | 58 | EditorGUI.BeginChangeCheck(); 59 | bool newCached = EditorGUI.Toggle(cachedRect, "Cached", cachedProperty.boolValue); 60 | if (EditorGUI.EndChangeCheck()) 61 | cachedProperty.boolValue = newCached; 62 | 63 | EditorGUI.BeginChangeCheck(); 64 | int newMutations = EditorGUI.IntField(mutationsRect, "Mutations", mutationsProperty.intValue); 65 | if (EditorGUI.EndChangeCheck()) 66 | mutationsProperty.intValue = Mathf.Clamp(newMutations, 0, 100); 67 | 68 | EditorGUI.BeginChangeCheck(); 69 | float newFactor = EditorGUI.FloatField(factorRect, "Mutation factor", factorProperty.floatValue); 70 | if (EditorGUI.EndChangeCheck()) 71 | factorProperty.floatValue = newFactor; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /source/SfxrAudioPlayer.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | #endif 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | [ExecuteInEditMode] 8 | #endif 9 | public class SfxrAudioPlayer : MonoBehaviour { 10 | 11 | /** 12 | * usfxr 13 | * 14 | * Copyright 2013 Zeh Fernando 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | */ 29 | 30 | /** 31 | * SfxrAudioPlayer 32 | * This is the (internal) behavior script responsible for streaming audio to the engine 33 | * 34 | * @author Zeh Fernando 35 | */ 36 | 37 | 38 | // Properties 39 | private bool runAsAudioClip = false; // If true, will use a pre-generated AudioClip for the audio instead 40 | private bool isDestroyed = false; // If true, this instance has been destroyed and shouldn't do anything yes 41 | private bool needsToDestroy = false; // If true, it has been scheduled for destruction (from outside the main thread) 42 | private bool runningInEditMode = false; // If true, it is running from the editor and NOT playing 43 | 44 | private static bool hasWarnedAboutWebGL = false; 45 | 46 | // Instances 47 | private SfxrSynth sfxrSynth; // SfxrSynth instance that will generate the audio samples used by this 48 | 49 | 50 | // ================================================================================================================ 51 | // INTERNAL INTERFACE --------------------------------------------------------------------------------------------- 52 | 53 | void Start() { 54 | #if UNITY_WEBGL 55 | // WebGL doesn't allow OnAudioFilterRead, or any other parallel generation really. So we generate it completely once the sound starts (will still be cached). 56 | runAsAudioClip = true; 57 | #endif 58 | 59 | // Creates an empty audio source so this GameObject can receive audio events 60 | AudioSource soundSource = gameObject.AddComponent(); 61 | if (runAsAudioClip) { 62 | // Pre-generate everything 63 | soundSource.clip = AudioClip.Create("AudioClip Effect", (int)sfxrSynth.getNumSamples(), 2, 44100, false, OnAudioRead); 64 | } else { 65 | // Will generate audio later, during playback, so use an empty AudioClip 66 | soundSource.clip = null; 67 | } 68 | soundSource.volume = 1f; 69 | soundSource.pitch = 1f; 70 | soundSource.priority = 128; 71 | soundSource.Play(); 72 | } 73 | 74 | void Update() { 75 | // Destroys self in case it has been queued for deletion 76 | if (sfxrSynth == null) { 77 | // Rogue object (leftover) 78 | // When switching between play and edit mode while the sound is playing, the object is restarted 79 | // So, queues for destruction 80 | needsToDestroy = true; 81 | } 82 | 83 | if (needsToDestroy) { 84 | needsToDestroy = false; 85 | Destroy(); 86 | } 87 | } 88 | 89 | void OnAudioRead(float[] __data) { 90 | // Requests the generation of the needed audio data from SfxrSynth, AudioClip version 91 | if (!SfxrAudioPlayer.hasWarnedAboutWebGL) { 92 | Debug.LogWarning("Warning: the audio data is being generated in a UI blocking thread. This is probably because it is running in WebGL. It will still be cached. An alternate solution, using separate threads, will hopefully be available in the future."); 93 | SfxrAudioPlayer.hasWarnedAboutWebGL = true; 94 | } 95 | sfxrSynth.GenerateAudioFilterData(__data, 2); 96 | } 97 | 98 | void OnAudioFilterRead(float[] __data, int __channels) { 99 | // Requests the generation of the needed audio data from SfxrSynth, parallel version 100 | 101 | if (!runAsAudioClip && !isDestroyed && !needsToDestroy && sfxrSynth != null) { 102 | bool hasMoreSamples = sfxrSynth.GenerateAudioFilterData(__data, __channels); 103 | 104 | // If no more samples are needed, there's no more need for this GameObject so schedule a destruction (cannot do this in this thread) 105 | if (!hasMoreSamples) { 106 | needsToDestroy = true; 107 | if (runningInEditMode) { 108 | // When running in edit mode, Update() is not called on every frame 109 | // We can't call Destroy() directly either, since Destroy() must be ran from the main thread 110 | // So we just attach our Update() to the editor's update event 111 | #if UNITY_EDITOR 112 | EditorApplication.update += Update; 113 | #endif 114 | } 115 | } 116 | } 117 | } 118 | 119 | 120 | // ================================================================================================================ 121 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 122 | 123 | public void SetSfxrSynth(SfxrSynth __sfxrSynth) { 124 | // Sets the SfxrSynth instance that will generate the audio samples used by this 125 | sfxrSynth = __sfxrSynth; 126 | } 127 | 128 | public void SetRunningInEditMode(bool __runningInEditMode) { 129 | // Sets the SfxrSynth instance that will generate the audio samples used by this 130 | runningInEditMode = __runningInEditMode; 131 | } 132 | 133 | public void Destroy() { 134 | // Stops audio immediately and destroys self 135 | if (!isDestroyed) { 136 | isDestroyed = true; 137 | sfxrSynth = null; 138 | if (runningInEditMode || !Application.isPlaying) { 139 | // Since we're running in the editor, we need to remove the update event, AND destroy immediately 140 | #if UNITY_EDITOR 141 | EditorApplication.update -= Update; 142 | #endif 143 | UnityEngine.Object.DestroyImmediate(gameObject); 144 | } else { 145 | UnityEngine.Object.Destroy(gameObject); 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /source/SfxrCacheSurrogate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | public class SfxrCacheSurrogate : MonoBehaviour { 6 | 7 | /** 8 | * usfxr 9 | * 10 | * Copyright 2013 Zeh Fernando 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | */ 25 | 26 | /** 27 | * SfxrCacheSurrogate 28 | * This is the (internal) behavior script responsible for calling Coroutines for asynchronous audio generation 29 | * 30 | * @author Zeh Fernando 31 | */ 32 | 33 | // ================================================================================================================ 34 | // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- 35 | 36 | public void CacheSound(SfxrSynth __synth, Action __callback) { 37 | StartCoroutine(CacheSoundAsynchronously(__synth, __callback)); 38 | } 39 | 40 | private IEnumerator CacheSoundAsynchronously(SfxrSynth __synth, Action __callback) { 41 | yield return null; 42 | __synth.CacheSound(null, true); 43 | __callback(); 44 | UnityEngine.Object.Destroy(gameObject); 45 | } 46 | 47 | public void CacheMutations(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 48 | StartCoroutine(CacheMutationsAsynchronously(__synth, __mutationsNum, __mutationAmount, __callback)); 49 | } 50 | 51 | private IEnumerator CacheMutationsAsynchronously(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { 52 | yield return null; 53 | __synth.CacheMutations(__mutationsNum, __mutationAmount, null, true); 54 | __callback(); 55 | UnityEngine.Object.Destroy(gameObject); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /source/SfxrSound.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | [System.Serializable] 4 | public class SfxrSound { 5 | private SfxrSynth synthesizer = new SfxrSynth(); 6 | 7 | [SerializeField] 8 | private string sound = null; 9 | 10 | [SerializeField] 11 | private bool cached = true; 12 | 13 | [SerializeField] 14 | [Range(0, 100)] 15 | private int mutations = 0; 16 | private bool HasMutations { get { return mutations > 0; } } 17 | 18 | [SerializeField] 19 | [Range(0f, 1f)] 20 | private float mutationFactor = .05f; 21 | 22 | [System.NonSerialized] 23 | private bool initialized = false; 24 | 25 | public void Play() { 26 | if (!initialized) 27 | Initialize(); 28 | 29 | if (HasMutations) 30 | synthesizer.PlayMutated(mutationFactor, (uint)mutations); 31 | else 32 | synthesizer.Play(); 33 | } 34 | 35 | private void Initialize() { 36 | string parameters = SfxrSoundContainer.Create().GetSound(sound); 37 | synthesizer.parameters.SetSettingsString(parameters); 38 | if (cached) 39 | Cache(); 40 | 41 | initialized = true; 42 | } 43 | 44 | private void Cache() { 45 | if (HasMutations) 46 | synthesizer.CacheMutations((uint)mutations, mutationFactor, () => synthesizer.PlayMutated(mutationFactor, (uint)mutations)); 47 | else 48 | synthesizer.CacheSound(() => synthesizer.Play()); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /source/SfxrSoundContainer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | public class SfxrSoundContainer { 5 | private static SfxrSoundContainer container = null; 6 | 7 | public static SfxrSoundContainer Create() { 8 | #if !UNITY_EDITOR 9 | if (SfxrSoundContainer.container != null) 10 | return SfxrSoundContainer.container; 11 | #endif 12 | 13 | string paramsList = ReadSoundsFile(); 14 | Dictionary configurations = new Dictionary(); 15 | 16 | string[] pairs = paramsList.Split(new string[] { "\n", "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries); 17 | for (int i = 0; i < pairs.Length; ++i) { 18 | string[] vals = pairs[i].Split(':'); 19 | string title = vals[0]; 20 | string parameters = vals[1]; 21 | 22 | configurations.Add(title, parameters); 23 | } 24 | 25 | SfxrSoundContainer.container = new SfxrSoundContainer(configurations); 26 | return SfxrSoundContainer.container; 27 | } 28 | 29 | private static string ReadSoundsFile() { 30 | TextAsset textFile = Resources.Load("usfxr_sounds"); 31 | return !textFile ? string.Empty : textFile.text; 32 | } 33 | 34 | private Dictionary configs = new Dictionary(); 35 | 36 | private SfxrSoundContainer(Dictionary entries) { 37 | foreach (var kvp in entries) 38 | configs.Add(kvp.Key.ToLowerInvariant(), kvp.Value); 39 | } 40 | 41 | public bool IsEmpty { get { return configs.Count == 0; } } 42 | 43 | public bool Contains(string title) { 44 | string actualTitle = title.ToLowerInvariant(); 45 | return configs.ContainsKey(actualTitle); 46 | } 47 | 48 | public string[] GetTitles() { 49 | string[] titles = new string[configs.Count]; 50 | 51 | int i = 0; 52 | foreach (var title in configs.Keys) { 53 | titles[i] = title; 54 | ++i; 55 | } 56 | 57 | return titles; 58 | } 59 | 60 | public string GetSound(string title) { 61 | string actualTitle = title.ToLowerInvariant(); 62 | if (configs.ContainsKey(actualTitle)) 63 | return configs[actualTitle]; 64 | 65 | Debug.LogError("No sound with title '" + title + "' found. Create it or verify it has not been removed."); 66 | return ",,,,,,,,,,,,,,,,,,,,,,,"; 67 | } 68 | 69 | #if UNITY_EDITOR 70 | public void AddSound(string title, string parameters) { 71 | string actualTitle = title.ToLowerInvariant(); 72 | configs.Add(actualTitle, parameters); 73 | SaveToFile(); 74 | } 75 | 76 | public void ReplaceSound(string title, string parameters) { 77 | string actualTitle = title.ToLowerInvariant(); 78 | configs[actualTitle] = parameters; 79 | SaveToFile(); 80 | } 81 | 82 | public void DeleteSound(string title) { 83 | string actualTitle = title.ToLowerInvariant(); 84 | configs.Remove(actualTitle); 85 | SaveToFile(); 86 | } 87 | 88 | private void SaveToFile() { 89 | string contents = ToString(); 90 | string filePath = Application.dataPath + "/Resources/usfxr_sounds.txt"; 91 | System.IO.FileInfo file = new System.IO.FileInfo(filePath); 92 | if (!file.Directory.Exists) 93 | this.CreateDirectory(file.Directory); 94 | 95 | System.IO.File.WriteAllText(filePath, contents); 96 | UnityEditor.AssetDatabase.Refresh(); 97 | } 98 | 99 | public override string ToString() { 100 | System.Text.StringBuilder strBuilder = new System.Text.StringBuilder(); 101 | var titles = new List(configs.Keys); 102 | titles.Sort(); 103 | foreach (var title in titles) 104 | strBuilder.Append(title + ":" + configs[title] + System.Environment.NewLine); 105 | 106 | return strBuilder.ToString(); 107 | } 108 | 109 | private void CreateDirectory(System.IO.DirectoryInfo dir) { 110 | if (!dir.Parent.Exists) 111 | this.CreateDirectory(dir.Parent); 112 | 113 | dir.Create(); 114 | } 115 | #endif 116 | } 117 | --------------------------------------------------------------------------------