Listener

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: == JavaScript - Listener.js == <javascript>@script RequireComponent(AudioListener) var volume : float = 1; // determines whether "RefreshVolume" will run in Update(), // or must be calle...)
 
(JavaScript - Listener.js)
Line 18: Line 18:
 
function Update ()
 
function Update ()
 
{if (performanceMode == false)
 
{if (performanceMode == false)
    RefreshVolume ();}
+
    RefreshVolume ();}</javascript>

Revision as of 18:12, 23 April 2009

JavaScript - Listener.js

<javascript>@script RequireComponent(AudioListener)

var volume : float = 1;

// determines whether "RefreshVolume" will run in Update(), // or must be called manually var performanceMode = false;

private var loudnessExponent = Mathf.Log(Mathf.Sqrt(10), 2);

function RefreshVolume () {audioListener.volume = Mathf.Pow(volume, loudnessExponent);}

function Start () {RefreshVolume ();}

function Update () {if (performanceMode == false) RefreshVolume ();}</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox