createInstance() public method

public createInstance ( EventInstance &instance ) : RESULT
instance EventInstance
return RESULT
Esempio n. 1
0
 private void SetEventInstance()
 {
     eventDescription.getInstanceList(out FMOD.Studio.EventInstance[] instanceList);
     if (instanceList.Length == 0)
     {
         eventDescription.createInstance(out eventInstance);
         eventInstance.start();
     }
     else
     {
         eventInstance = instanceList[0];
     }
     return;
 }
Esempio n. 2
0
 private void OnObjectAddReceive(List <ObjectInput> objects)
 {
     if (numberOfActiveObjects == 0)
     {
         eventDescription.createInstance(out eventInstance);
         eventInstance.start();
     }
     foreach (ObjectInput tableObject in objects)
     {
         prevTrackVolumes[tableObject.tagValue] = 0f;
         UpdateTrackValue(tableObject.tagValue, tableObject);
         UpdateAudioEffects(tableObject.tagValue, tableObject);
         numberOfActiveObjects += 1;
     }
 }
Esempio n. 3
0
    public FMOD.Studio.EventInstance GetEvent(string path)
    {
        FMOD.Studio.EventInstance instance = null;

        if (string.IsNullOrEmpty(path))
        {
            FMOD.Studio.UnityUtil.LogError("Empty event path!");
            return(null);
        }

        if (eventDescriptions.ContainsKey(path))
        {
            ERRCHECK(eventDescriptions[path].createInstance(out instance));
        }
        else
        {
            FMOD.GUID id = new FMOD.GUID();

            if (path.StartsWith("{"))
            {
                ERRCHECK(FMOD.Studio.Util.ParseID(path, out id));
            }
            else if (path.StartsWith("event:"))
            {
                ERRCHECK(system.lookupID(path, out id));
            }
            else
            {
                FMOD.Studio.UnityUtil.LogError("Expected event path to start with 'event:/'");
            }

            FMOD.Studio.EventDescription desc = null;
            ERRCHECK(system.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc));

            if (desc != null && desc.isValid())
            {
                eventDescriptions.Add(path, desc);
                ERRCHECK(desc.createInstance(out instance));
            }
        }

        if (instance == null)
        {
            FMOD.Studio.UnityUtil.Log("GetEvent FAILED: \"path\"");
        }

        return(instance);
    }
Esempio n. 4
0
    public FMOD.Studio.EventInstance GetEvent(string path)
    {
        FMOD.Studio.EventInstance instance = null;

        if (string.IsNullOrEmpty(path))
        {
            FMOD.Studio.UnityUtil.LogError("Empty event path!");
            return(null);
        }

        if (eventDescriptions.ContainsKey(path) && eventDescriptions[path].isValid())
        {
            ERRCHECK(eventDescriptions[path].createInstance(out instance));
        }
        else
        {
            Guid id = new Guid();

            if (path.StartsWith("{"))
            {
                ERRCHECK(FMOD.Studio.Util.ParseID(path, out id));
            }
            else if (path.StartsWith("event:") || path.StartsWith("snapshot:"))
            {
                ERRCHECK(system.lookupID(path, out id));
            }
            else
            {
                FMOD.Studio.UnityUtil.LogError("Expected event path to start with 'event:/' or 'snapshot:/'");
            }

            FMOD.Studio.EventDescription desc = null;
            ERRCHECK(system.getEventByID(id, out desc));

            if (desc != null && desc.isValid())
            {
                eventDescriptions[path] = desc;
                ERRCHECK(desc.createInstance(out instance));
            }
        }

        if (instance == null)
        {
            FMOD.Studio.UnityUtil.Log("GetEvent FAILED: \"" + path + "\"");
        }

        return(instance);
    }
Esempio n. 5
0
    public void PlayMusic()
    {
        EventDescription = RuntimeManager.GetEventDescription(Event);                       //this assigns the EventDescription from the Event string variable that we set in the editor
        EventDescription.createInstance(out EventInstance);                                 //this creates an EventInstance from the EventDescription
        EventInstance.start();                                                              //this starts the event

        FMOD.Studio.EVENT_CALLBACK callback;                                                //special type of variable defined by FMOD.studio called EVENT_CALLBACK
        callback = new FMOD.Studio.EVENT_CALLBACK(BeatEventCallBack);                       //pointer to the function that we're going to callback which is MusicEventCallBack

        EventInstance.setCallback(callback, FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT); // sets a callback on the event that is created with the flag to call this on every Timeline beat

        FMOD.Studio.PARAMETER_DESCRIPTION distanceToClue_fmodParam;
        EventDescription.getParameter("DistanceToClue", out distanceToClue_fmodParam);
        maxClueDistance = distanceToClue_fmodParam.maximum; // sets maxClueDistance to the maximum value of the game parameter in the fmod parameter (30)
        print("Max Distance to Clue = " + maxClueDistance);
    }
Esempio n. 6
0
    private void StartInstance()
    {
        secondEventDescription.getInstanceList(out FMOD.Studio.EventInstance[] instanceList);
        eventDescription.createInstance(out eventInstance);
        if (instanceList.Length > 0)
        {
            instanceList[0].getTimelinePosition(out int pos);
            Debug.Log(pos % 2000);
            eventInstance.setTimelinePosition(1000);
            eventInstance.getTimelinePosition(out int b);
            Debug.Log(b);
        }


        eventInstance.setTimelinePosition(500);
        eventInstance.start();
        eventInstance.getTimelinePosition(out int a);
        Debug.Log(a);
    }
Esempio n. 7
0
        public static FMOD.Studio.EventInstance CreateInstance(Guid guid)
        {
            FMOD.Studio.EventDescription eventDesc = GetEventDescription(guid);
            FMOD.Studio.EventInstance    newInstance;
            eventDesc.createInstance(out newInstance);

            #if UNITY_EDITOR
            bool is3D = false;
            eventDesc.is3D(out is3D);
            if (is3D)
            {
                // Set position to 1e+18F, set3DAttributes should be called by the dev after this.
                newInstance.set3DAttributes(RuntimeUtils.To3DAttributes(new Vector3(1e+18F, 1e+18F, 1e+18F)));
                instance.eventPositionWarnings.Add(newInstance);
            }
            #endif

            return(newInstance);
        }
Esempio n. 8
0
    public FMOD.Studio.EventInstance getEvent(string path)
    {
        FMOD.Studio.EventInstance instance = null;

        if (string.IsNullOrEmpty(path))
        {
            Debug.LogError("Empty event path!");
            return(null);
        }

        if (eventDescriptions.ContainsKey(path))
        {
            ERRCHECK(eventDescriptions[path].createInstance(out instance));
        }
        else
        {
            FMOD.GUID id = new FMOD.GUID();

            if (path.StartsWith("{"))
            {
                ERRCHECK(FMOD.Studio.Util.ParseID(path, out id));
            }
            else if (path.StartsWith("/"))
            {
                ERRCHECK(system.lookupEventID(path, out id));
            }
            else
            {
                Debug.LogError("Expected event path to start with '/'");
            }

            FMOD.Studio.EventDescription desc = null;
            ERRCHECK(system.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc));

            eventDescriptions.Add(path, desc);
            ERRCHECK(desc.createInstance(out instance));
        }

//		Debug.Log("get event: " + (instance != null ? "suceeded!!" : "failed!!")); //PAS

        return(instance);
    }
 public EventInstance CreateInstance()
 {
     FMOD.Studio.EventInstance instance;
     _fmodEventDescription.createInstance(out instance).Check();
     return(EventInstance.FromFmod(instance));
 }
Esempio n. 10
0
    public void Play()
    {
        if (_HasTriggered && _TriggerOnce)
        {
            return;
        }

        if (string.IsNullOrEmpty(_EventMusic))
        {
            return;
        }

        if (_EventDescription == null)
        {
            GetEvent();
        }

        bool isOneshot = false;

        if (!_EventMusic.StartsWith("snapshot", System.StringComparison.CurrentCultureIgnoreCase))
        {
            _EventDescription.isOneshot(out isOneshot);
        }

        bool is3D;

        _EventDescription.is3D(out is3D);

        if (_EventInstance != null && !_EventInstance.isValid())
        {
            _EventInstance = null;
        }

        // Let previous oneshot instances play out
        if (isOneshot && _EventInstance != null)
        {
            _EventInstance.release();
            _EventInstance = null;
        }


        if (_EventInstance == null)
        {
            _EventDescription.createInstance(out _EventInstance);

            if (is3D)
            {
                var rigidBody   = GetComponent <Rigidbody>();
                var rigidBody2D = GetComponent <Rigidbody2D>();
                var transform   = GetComponent <Transform>();
                if (rigidBody)
                {
                    _EventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, rigidBody));
                    FMODUnity.RuntimeManager.AttachInstanceToGameObject(_EventInstance, transform, rigidBody);
                }
                else
                {
                    _EventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, rigidBody2D));
                    FMODUnity.RuntimeManager.AttachInstanceToGameObject(_EventInstance, transform, rigidBody2D);
                }
            }
        }

        foreach (var param in Params)
        {
            _EventInstance.setParameterValue(param.Name, param.Value);
        }

        if (is3D && _OverrideAttenuation)
        {
            _EventInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, _OverrideMinDistance);
            _EventInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, _OverrideMaxDistance);
        }


        /*_EventCallback = new FMOD.Studio.EVENT_CALLBACK(StudioEventCallback);
         * _EventInstance.setCallback(_EventCallback, FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT);*/
        _EventInstance.start();

        //add 3d attributes here when converting to a more base script

        _HasTriggered = true;
    }