6
FMOD Studio Unity Integration Introduction The FMOD Studio Unity integration provides a streamlined workflow for Unity developers to create high quality game audio for their games. The integration is provided as a .unitypackage available from the FMOD downloads page . This document explains the various components of the integration. For more information visit the FMOD Studio Unity Integration forum . Supported platforms The current integration supports iOS, Android, PC and Mac. The Unity webplayer is not supported, as it does not provide the native plugin support that the integration requires. Licensing The integration itself is free, but you must have the appropriate FMOD License to release a title using FMOD Studio with Unity, as it is not covered by the Unity license alone. For more information about licensing FMOD see the FMOD sales page . The FMOD Studio integration is a native plugin which is available in the free iOS/Android Unity license but requires Pro for PC and Mac. Contents This section describes the contents of the integration package. Example Scripts found in Assets/Plugins/FMOD The integration package includes scripts which demonstrate usage of the FMOD Studio API. you can use these scripts and extend them, or write your own using the C# API directly. A brief description of each of the example scripts is listed below. FMOD_Listener Attach this to the camera in the scene. (there should only be one listener)

Unity Documentation

Embed Size (px)

DESCRIPTION

unity

Citation preview

  • FMOD Studio Unity IntegrationIntroduction

    TheFMODStudioUnityintegrationprovidesastreamlinedworkflowforUnitydeveloperstocreatehighqualitygameaudiofortheirgames.Theintegrationisprovidedasa.unitypackageavailablefromtheFMODdownloadspage.Thisdocumentexplainsthevariouscomponentsoftheintegration.FormoreinformationvisittheFMODStudioUnityIntegrationforum.

    Supported platformsThecurrentintegrationsupportsiOS,Android,PCandMac.TheUnitywebplayerisnotsupported,asitdoesnotprovidethenativepluginsupportthattheintegrationrequires.

    LicensingTheintegrationitselfisfree,butyoumusthavetheappropriateFMODLicensetoreleaseatitleusingFMODStudiowithUnity,asitisnotcoveredbytheUnitylicensealone.FormoreinformationaboutlicensingFMODseetheFMODsalespage.TheFMODStudiointegrationisanativepluginwhichisavailableinthefreeiOS/AndroidUnitylicensebutrequiresProforPCandMac.

    ContentsThissectiondescribesthecontentsoftheintegrationpackage.

    Example ScriptsfoundinAssets/Plugins/FMOD

    TheintegrationpackageincludesscriptswhichdemonstrateusageoftheFMODStudioAPI.youcanusethesescriptsandextendthem,orwriteyourownusingtheC#APIdirectly.Abriefdescriptionofeachoftheexamplescriptsislistedbelow.

    FMOD_ListenerAttachthistothecamerainthescene.(thereshouldonlybeonelistener)

  • FMOD_StudioEventEmitterControlstheplaybackofoneevent,usethistoattacheventstoobjectsinsideUnity.Thisismostsuitedtoendlesseventswhichplayforalongtime.ForshortoneshotstyleeventstheycanbefiredofffromscriptsusingtheFMOD_StudioSystem.

    FMOD_StudioSystemNote:Thisisinternal,don'tattachittoanyobjects

    Thisisthecentralsystemwhichcanbeusedtoloadbanksandretrieveevents.IthassomeconveniencefunctionsthatdemonstrateusageoftheFMODStudioAPI.Itisasingletonsothereisonlyeveroneofthese,itwillgetcreatedautomatically,youcanaccessitbycallingFMOD_StudioSystem.instance.

    FMOD Studio Runtime C# APIfoundinAssets/Plugins/FMOD/Wrapper

    ThisistheFMODStudioC#API.ThewrapperexposesthesamefunctionsavailableintheC++APIforuseinsideUnity.FormoreinformationpleaserefertotheprogrammerAPIdocumenationthatcomeswiththeFMODStudioAPIinstaller.

    FMODStudioAPIusage

    ThecontentcreatedinFMODStudioisexportedinto.bankfiles.Thesefilescontaintheencodedaudiodata,aswellasthemetadataforplayback.TheyareloadedasloosefilesusingtheAPI(System.loadBankFile).TheeventsareretrievedusingGUIDs(System.parseID)orpaths(System.lookupID).ThesefunctionsprovideanIDwhichcanbeusedtoretrievetheEventDescription,whichisthenusedtocreateEventInstances.EventplaybackiscontrolledusingtheEventInstance.

  • Setting up the integration1.Importtheintegrationunitypackage.

    2.AddtheFMOD_ListenerscripttotheMainCamera.

    Importing .bank files into Unity

    InsideFMODStudio:

    1.AssignyourEventstobanks.

    2.Buildallbanks.(File>Build...)

    3.ExportGUIDs.txt.(File>ExportGUIDs...)

    InsideUnity:

    4.FMOD>RefreshEventListselecttheGUIDs.txtgeneratedfromthepreviousstep(insidethe/BuildsfolderofyourFMODStudioproject)

    TheGUIDs.txtisatextfilewhichdescribesalloftheeventsintheFMODStudioproject.TheRefreshEventliststepwillcopythe.bankfilesfromtheFMODStudioprojecttotheUnityproject'sAssets/StreamingAssetsdirectory.ThenitwillcreatetheAssets/FMODAssetsdirectoryandpopulateitwitheventassetsforeacheventintheFMODStudioproject.

    Playing an event inside Unity1.AddFMOD_StudioEventEmitterscripttoanobjectinthescene.

    2.LocatetheeventyouwanttoplayinsideAssets/FMODAssetsandassignittotheFMOD_StudioEventEmitter.

  • ScriptingFMOD_StudioSystemcontainssomeconveniencefunctionswhichmakeiteasytocontroleventsfromyourUnityscripts.

    ThefollowingexamplesdemonstrateusingtheAPIwithC#butareapplicabletotheotherscriptinglanguagesavailableinUnity.PlayOneShotfireandforgetoneshotevents.Goodforshortsoundslikefootstepsandgunshots

    example:playagunshotsoundatthecurrentposition

    FMOD_StudioSystem.instance.PlayOneShot(/Weapons/SingleShot,transform.position)

    GetEventretrieveaneventthiscanbeusedwhenyouwantmorecontrol,suchasmodifyingthegameparameters.

    example:getanengineeventandupdatetheRPMparametereachframe

    FMOD.Studio.EventInstanceengineFMOD.Studio.ParameterInstanceengineRPM

    voidStart(){engine=FMOD_StudioSystem.instance.getEvent("/Vehicles/CarEngine")engine.start()engine.getParameter("RPM",outengineRPM)}

    voidUpdate(){//getaRPMvaluefromthegame'scarengineengineRPM.setValue(rpm)}

    voidOnDisable(){engine.stop()engine.release()}

    Note:Whencontrollingtheeventinstanceincode,youmustcallreleasewhenyouarefinishedwithitto

    ensuretheresourcesarecleanedup.

  • Loading Plugin Effects and Plugin InstrumentsNote:Importingbanksusingpluginsmightfailwithintegrationversion1.02.09orearlier.JustchangeFMOD.Studio.INITFLAGS.NORMALtoFMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINSinFMODEditorExtension.cs.

    TheFMODPluginEffectslikeDistanceFilterandGainarefree,thethirdpartyeffectsliketheML1LimiterandAudioWeatherhavetobelicensedseparately.ThereislicensinginformationavailableontheFMODsalespage.

    ToloadthepluginsusingUnityyouaddtheplugintotheFMOD_Listener'spluginlist.ThenjustcopythepluginfileintoappropriatesubdirectoryoftheAssets/Pluginsdirectory(insideyourUnityproject)fortheplatformyouaretargeting.ForWindows32bititwouldbe/Assets/Plugins/x86.Thedirectoryforeachplatformislistedhere.

    TogetthefreeFMODplugins,youcancopythefilesinsidethe/PluginsdirectorywhereFMODStudioisinstalled.

    Configuration OptionsNote:Onlyavailableinversion1.3ornewer

    Thereareoptionsfeatureswhichcanbeenabledwhichcanhelpduringdevelopment.Theseoptionsareusefulduringdevelopment.ToenabletheseaddthespecifiedkeywordtotheScriptingDefineSymbols,insideUnityPlayerSettings(Edit>ProjectSettings>Player)

    Connecting to the tool with Live UpdateOption:FMOD_LIVEUPDATE

    LiveUpdateallowsyoutomakechangesinsideFMODStudiohavehavethemmirroredonthegameside.Thisisparticularlyusefulformixingandtweakingattenuationcurves.

    1.AddFMOD_LIVEUPDATEtotheScriptingDefineSymbolsinyourUnityproject.

    ThiswillenableStudiotoconnecttoUnitywhilethegameisrunning.

    2.Startrunningthegame,eitherbybuildingandexecutingonthetargetdevice,orbyrunningthegameinsidetheUnityeditor.

    3.InsideFMODStudioopenuptheConnecttoGamedialog(File>ConnecttoGame)

  • 4.EntertheIPaddressofthetargetdevicewhichisrunninggame(ifitisrunningonthesamemachineasFMODStudioyoujustenterlocalhostor127.0.0.1)

    StudioshouldnowbeconnectedtothegameandmodificationsmadeinStudiowillbemirroredaslongasthegameisrunning.

    Note:WhenthegamestopsallofthechangesmadeviaLiveUpdatewillbelost,atthatpointitisadvisedtorebuildthebanksandimportthemintoUnitytokeepeverythinginsync.

    Additional Debug informationOption:FMOD_DEBUG

    ThiswillprintadditionalinformationtotheUnityconsoletohelpdiagnoseissuesifsomethinghasgonewrongwiththeintegration.