コード例 #1
0
    public void CreateAsset(string assetFile, FmodEvent asset)
    {
#if UNITY_EDITOR
        AssetDatabase.AddObjectToAsset(this, asset);
//		AssetDatabase.ImportAsset(assetFile, ImportAssetOptions.ImportRecursive); // force a save
#endif
    }
コード例 #2
0
 public void SetSourceEvent(FmodEvent srcEvent)
 {
     if (m_source == srcEvent)
     {
         return;
     }
     CleanRuntimeEvent();
     m_source = srcEvent;
     if (m_source != null)
     {
         UpdateRestorationData();
         m_type = m_source.getSourceType();
         setMaxRange(m_source.m_maxRange);
         setMinRange(m_source.m_minRange);
         if (m_parameters != null)
         {
             CleanAndRemoveParameters();
         }
         else
         {
             m_parameters = new List <FmodRuntimeEventParameter>();
         }
         foreach (FmodEventParameter p in m_source.getParameters())
         {
             FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent <FmodRuntimeEventParameter>();
             runtimeParam.Initialize(p);
             m_parameters.Add(runtimeParam);
         }
     }
     else
     {
         CleanAndRemoveParameters();
     }
 }
コード例 #3
0
    /**
     * This method returns the event in an updated .fev asset file that matches an event from the previous
     * version of that .fev asset file.
     * The matching is based on the GUID first, then the path through event groups and the name of the event.
     * Returns the event or null if no match could be found.
     */
    public FmodEvent getMatchingEvent(FmodEvent oldEvent)
    {
        string guidString = oldEvent.getGUIDString();

        if (guidString != "" && guidString != FmodEvent.EMPTY_GUIDSTRING)
        {
            foreach (FmodEvent e in m_events)
            {
                if (e.WasLoaded() && e.getGUIDString() != "" && e.getGUIDString() != FmodEvent.EMPTY_GUIDSTRING)
                {
                    if (e.getGUIDString() == guidString)
                    {
                        return(e);
                    }
                }
            }
        }
        string fullName = oldEvent.getFullName();

        foreach (FmodEvent e in m_events)
        {
            string tmp = e.getFullName();

            if (e.WasLoaded() && tmp == fullName)
            {
                return(e);
            }
        }
        return(null);
    }
コード例 #4
0
    protected void CreateEventInstance(FmodEvent srcEvent, Vector3 worldPos, RaycastHit hitInfo)
    {
        FmodEventAudioSource audioSource = null;

        if (Event.current.alt)           // if alt is on, we add the audio source as a component
        {
            GameObject dest = hitInfo.collider.gameObject;

            audioSource = dest.GetComponent <FmodEventAudioSource>();
            if (audioSource == null || audioSource.eventClip != null)
            {
                audioSource = dest.AddComponent(typeof(FmodEventAudioSource)) as FmodEventAudioSource;
            }
        }
        else             // else we create a GameObject to act as source
        {
            GameObject obj = GameObject.Instantiate(Resources.Load("FmodEventAudioSource"), worldPos, Quaternion.identity) as GameObject;
            audioSource = obj.GetComponent <FmodEventAudioSource>();
            if (audioSource == null)
            {
                Debug.LogError("Prefab for FmodEventAudioSource should have component FmodEventAudioSource !");
            }
            else
            {
                obj.name = "FmodEventSource (" + srcEvent.name + ")";
            }
        }
        audioSource.SetSourceEvent(srcEvent);
    }
コード例 #5
0
ファイル: Boudoir.cs プロジェクト: Bourinours/Projet_Son
 public bool CheckValue()
 {
     if (source != null && source.CurrentStatus == FmodEventAudioSource.Status.Stopped)
     {
         source.Play();
     }
     if (source != null && source.GetParameterValue("param01") == wantedValue)
     {
         if (eventDialog != null)
         {
             if (this.charactere == null)
             {
                 return(true);
             }
             GameManager tmp = this.charactere.GetComponent <GameManager>();
             if (tmp == null)
             {
                 return(true);
             }
             tmp.SetDialog(eventDialog, true);
             eventDialog = null;
         }
         return(true);
     }
     return(false);
 }
コード例 #6
0
 public void CreateAsset(string assetFile, FmodEvent asset)
 {
     #if UNITY_EDITOR
     AssetDatabase.AddObjectToAsset(this, asset);
     //		AssetDatabase.ImportAsset(assetFile, ImportAssetOptions.ImportRecursive); // force a save
     #endif
 }
コード例 #7
0
 public void Play()
 {
     if (!FmodEvent.IsPlaying(musicInstance))
     {
         musicInstance = FmodEvent.Play(music, gameObject.transform, null);
     }
 }
コード例 #8
0
    public void RestoreAsset()
    {
        if (m_source == null && m_pathToAssetFile != null)
        {
#if UNITY_EDITOR
            FmodEventAsset asset = AssetDatabase.LoadMainAssetAtPath(m_pathToAssetFile) as FmodEventAsset;

            if (asset == null)
            {
                Debug.LogWarning("FmodEventAudioSource (" + name + "): Error while restoring source: could not find asset at path '" + m_pathToAssetFile + "'.");
            }
            else
            {
                FmodEvent evt = null;

                if (m_sourceEventGUID != null && m_sourceEventGUID != "" && m_sourceEventGUID != FmodEvent.EMPTY_GUIDSTRING)
                {
                    evt = asset.getEventWithGUID(m_sourceEventGUID);
                }
                if (evt == null && m_sourceEventFullName != null && m_sourceEventFullName != "")
                {
                    evt = asset.getEventWithFullName(m_sourceEventFullName);
                }
                if (evt == null)
                {
                    Debug.LogWarning("FmodEventAudioSource (" + name + "): Error while restoring source: could not find event with GUID '" + m_sourceEventFullName + "' or at '" + m_sourceEventFullName + "'");
                }
                else
                {
                    SetSourceEvent(evt);
                }
            }
#endif
        }
    }
コード例 #9
0
    public void InitializeFromUpdatedEvent(FmodEvent src, FmodEvent oldEvent)
    {
#if UNITY_EDITOR
        List <FmodEventParameter> newParams = new List <FmodEventParameter>();
        List <FmodEventParameter> oldParams = oldEvent.getParameters();


        EditorUtility.CopySerialized(src, this);
        hideFlags = HideFlags.HideInHierarchy;
        foreach (FmodEventParameter p in m_parameters)
        {
            FmodEventParameter newP = ScriptableObject.CreateInstance("FmodEventParameter") as FmodEventParameter;
            newP.Initialize(p, this);
            foreach (FmodEventParameter oldP in oldParams)
            {
                if (p.name == oldP.name)
                {
                    newP.SetValue(oldP.getValue());
                    oldParams.Remove(oldP);
                    break;
                }
            }
            newParams.Add(newP);
        }
        m_parameters = newParams;
        m_minRange   = oldEvent.m_minRange;
        m_maxRange   = oldEvent.m_maxRange;
#endif
    }
コード例 #10
0
    public void Initialize(FmodEventParameter src, FmodEvent evt)
    {
#if UNITY_EDITOR
        hideFlags = HideFlags.HideInHierarchy;
        EditorUtility.CopySerialized(src, this);
        m_event = evt;
#endif
    }
コード例 #11
0
    private void OnDisable()
    {
        FmodEvent.Stop(_instance, FMOD.Studio.STOP_MODE.ALLOWFADEOUT);

        if (positionClamperRoutine != null)
        {
            StopCoroutine(positionClamperRoutine);
        }
    }
コード例 #12
0
    public void SteppedOnWalkableTile(Collider tile, PlayerMovement actor)
    {
        Renderer renderer = tile.GetComponent <Renderer>();

        renderer.material.EnableKeyword("_EMISSION");

        FmodEvent.PlayOneShot(unlockTiles, transform, null);
        tilesActivated++;
    }
コード例 #13
0
 public FmodEventPool getEventPool(FmodEvent evt)
 {
     if (m_pools.ContainsKey(evt)) {
         return (m_pools[evt]);
     }
     FmodEventPool newPool = new FmodEventPool(evt);
     m_pools[evt] = newPool;
     return (newPool);
 }
コード例 #14
0
    public void OnSceneGUI(SceneView sceneView)
    {
        if (m_ongoingDrag && Event.current.type != EventType.MouseMove)
        {
            if (Event.current.type == EventType.MouseUp || Event.current.type == EventType.MouseDown)
            {
                _clearDragAndDrop();
            }
            if (Event.current.type == EventType.DragUpdated)
            {
                DragAndDrop.AcceptDrag();
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                Vector2    mousePos = Event.current.mousePosition;
                Ray        ray      = HandleUtility.GUIPointToWorldRay(mousePos);
                RaycastHit hitInfo  = new RaycastHit();

                if (Physics.Raycast(ray, out hitInfo))
                {
                    EditorGUIUtility.PingObject(hitInfo.collider.gameObject);
                }
                // todo: preview of object creation ?
                Event.current.Use();
            }
            else if (Event.current.type == EventType.DragPerform)
            {
                Vector2    mousePos = Event.current.mousePosition;
                Vector3    worldPos = new Vector3();
                Ray        ray      = HandleUtility.GUIPointToWorldRay(mousePos);
                RaycastHit hitInfo  = new RaycastHit();

                if (Physics.Raycast(ray, out hitInfo))
                {
                    worldPos = hitInfo.point;
                }
                else
                {
                    worldPos = ray.origin + ray.direction.normalized * 10;
                }

                FmodEvent  srcEvent  = DragAndDrop.objectReferences[0] as FmodEvent;
                FmodReverb srcReverb = DragAndDrop.objectReferences[0] as FmodReverb;

                if (srcEvent != null)
                {
                    CreateEventInstance(srcEvent, worldPos, hitInfo);
                }
                else if (srcReverb)
                {
                    CreateReverbZone(srcReverb, worldPos, hitInfo);
                }

                _clearDragAndDrop();
                Event.current.Use();
            }
        }
    }
コード例 #15
0
    public void GameOver()
    {
        currentGamestate = GameState.WINSCREEN;
        if (gameOverEvent != null)
        {
            gameOverEvent();
        }

        FmodEvent.PlayOneShot(wonGame, transform, null);
    }
コード例 #16
0
    public FmodEventPool getEventPool(FmodEvent evt)
    {
        if (m_pools.ContainsKey(evt))
        {
            return(m_pools[evt]);
        }
        FmodEventPool newPool = new FmodEventPool(evt);

        m_pools[evt] = newPool;
        return(newPool);
    }
コード例 #17
0
    public void OnEnable()
    {
        if (m_oldEventPath == null)
        {
            return;
        }

        m_fmodEVent    = (FmodEvent)target;
        m_oldEventPath = m_fmodEVent.EventPath;
        InitVariable();
    }
コード例 #18
0
 public int getNumberRunningInstances(FmodEvent evt)
 {
     if (evt == null)
     {
         return(0);
     }
     if (m_eventPoolManager.eventPoolExists(evt) == false)
     {
         return(0);
     }
     return(m_eventPoolManager.getEventPool(evt).getNumberRunningInstances());
 }
コード例 #19
0
    public void Initialize(FMOD.EventGroup eventgroup, FmodEventGroup parentGroup, FmodEventAsset asset)
    {
        FMOD.EventGroup childEventgroup   = null;
        FMOD.RESULT     result            = FMOD.RESULT.OK;
        FmodEventGroup  child             = null;
        int             numChildrenGroups = 0;
        int             numEvents         = 0;

        FMOD.Event e     = null;
        FmodEvent  toAdd = null;

        hideFlags     = HideFlags.HideInHierarchy;
        m_projectName = asset.getProjectName();
        m_parent      = parentGroup;
        _getName(eventgroup);
        result = eventgroup.loadEventData();
        ERRCHECK(result);
        result = eventgroup.getNumEvents(ref numEvents);
        ERRCHECK(result);
        for (int j = 0; j < numEvents; j++)
        {
            e      = null;
            result = eventgroup.getEventByIndex(j, FMOD.EVENT_MODE.DEFAULT | FMOD.EVENT_MODE.ERROR_ON_DISKACCESS, ref e);
            ERRCHECK(result);
            if (result != FMOD.RESULT.OK)
            {
                result = FMOD.RESULT.OK;
            }
            toAdd = FmodEvent.CreateInstance("FmodEvent") as FmodEvent;
            if (e != null)
            {
                toAdd.Initialize(e, this, j, asset);
                e.release();
            }
            else
            {
                toAdd.Initialize(this, j, asset);
            }
            m_events.Add(toAdd);
        }
        result = eventgroup.freeEventData(false);
        ERRCHECK(result);
        result = eventgroup.getNumGroups(ref numChildrenGroups);
        for (int k = 0; k < numChildrenGroups; k++)
        {
            result = eventgroup.getGroupByIndex(k, false, ref childEventgroup);
            ERRCHECK(result);
            child = FmodEventGroup.CreateInstance("FmodEventGroup") as FmodEventGroup;
            child.Initialize(childEventgroup, this, asset);
            m_children.Add(child);
        }
        name = getFullName();
    }
コード例 #20
0
 public bool SetDialog(FmodEvent eventDialog, bool stop = false)
 {
     if (dialogue == false || stop)
     {
         source.Stop();
         source.SetSourceEvent(eventDialog);
         source.Play();
         dialogue = true;
         return(true);
     }
     return(false);
 }
コード例 #21
0
ファイル: GameManager.cs プロジェクト: Bourinours/Projet_Son
 public bool SetDialog(FmodEvent eventDialog, bool stop = false)
 {
     if (dialogue == false || stop)
     {
         source.Stop();
         source.SetSourceEvent(eventDialog);
         source.Play();
         dialogue = true;
         return true;
     }
     return false;
 }
コード例 #22
0
    public void DisableEmission()
    {
        foreach (var tile in m_levelScript.walkableTiles)
        {
            Renderer renderer = tile.GetComponent <Renderer>();

            renderer.material.DisableKeyword("_EMISSION");

            Debug.Log("Lighted Down");
        }

        FmodEvent.PlayOneShot(hidetiles, transform, null);
    }
コード例 #23
0
ファイル: Interaction.cs プロジェクト: Bourinours/Projet_Son
 protected virtual void ActiveDialog(FmodEvent eventDialogue, bool stop = true)
 {
     if (this.charactere == null)
         return;
     GameManager tmp = this.charactere.GetComponent<GameManager>();
     if (tmp == null)
         return;
     if (impact != null)
         impact.Stop();
     if (eventDialog == null)
         return;
     tmp.SetDialog(eventDialogue, stop);
 }
コード例 #24
0
    public void releaseRunningInstance(FmodEventAudioSource runningSource)
    {
        if (runningSource != null && runningSource.getSource() != null)
        {
            FmodEvent evt = runningSource.getSource();

            if (m_eventPoolManager.eventPoolExists(evt) == false)
            {
                Debug.LogError("CRITICAL ERROR: No pool was created for event " + evt.getName());
            }
            else
            {
                m_eventPoolManager.getEventPool(evt).releaseRunningInstance(runningSource);
            }
        }
    }
コード例 #25
0
    public void Initialize(FmodEvent src)
    {
#if UNITY_EDITOR
        List <FmodEventParameter> newParams = new List <FmodEventParameter>();

        EditorUtility.CopySerialized(src, this);
        hideFlags = HideFlags.HideInHierarchy;
        foreach (FmodEventParameter p in m_parameters)
        {
            FmodEventParameter newP = ScriptableObject.CreateInstance("FmodEventParameter") as FmodEventParameter;
            newP.Initialize(p, this);
            newParams.Add(newP);
        }
        m_parameters = newParams;
#endif
    }
コード例 #26
0
    public void UpdateExistingEvent(FmodEvent newEvent)
    {
#if UNITY_EDITOR
        List <FmodRuntimeEventParameter> oldParams = getParameters();
        List <FmodRuntimeEventParameter> toRemove  = new List <FmodRuntimeEventParameter>();

        //checking for existing params
        foreach (FmodRuntimeEventParameter oldParam in oldParams)
        {
            FmodEventParameter matchingParam = newEvent.getParameter(oldParam.getName());

            if (matchingParam == null)
            {
                toRemove.Add(oldParam);
            }
            else
            {
                oldParam.UpdateExistingParam(matchingParam);
            }
        }
        //removing previously existing params that have been deleted
        foreach (FmodRuntimeEventParameter toDelete in toRemove)
        {
            m_parameters.Remove(toDelete);
            DestroyImmediate(toDelete, true);
        }
        PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject);

        // checking for newly created params
        if (prefabType != PrefabType.PrefabInstance &&
            prefabType != PrefabType.ModelPrefabInstance)
        {
            foreach (FmodEventParameter newParam in newEvent.getParameters())
            {
                if (ParameterExists(newParam.getName()) == false)
                {
                    FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent <FmodRuntimeEventParameter>();
                    runtimeParam.Initialize(newParam);
                    m_parameters.Add(runtimeParam);
                }
            }
        }
        m_source = newEvent;
#endif
    }
コード例 #27
0
    private FMOD.RESULT _loadEvent(FmodEvent evt, ref FMOD.Event fmodEvent)
    {
        string guidString = evt.getGUIDString();

        FMOD.RESULT result = FMOD.RESULT.OK;

        if (guidString != FmodEvent.EMPTY_GUIDSTRING)
        {
            result = getEventSystem().getEventByGUIDString(guidString, FMOD.EVENT_MODE.DEFAULT | FMOD.EVENT_MODE.ERROR_ON_DISKACCESS, ref fmodEvent);
        }
        else
        {
            string fullName = evt.getFullName();

            result = getEventSystem().getEvent(fullName, FMOD.EVENT_MODE.DEFAULT | FMOD.EVENT_MODE.ERROR_ON_DISKACCESS, ref fmodEvent);
        }
        return(result);
    }
コード例 #28
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);


        m_musicInstance = RuntimeManager.CreateInstance(musicEvent);

        m_gameStateParameter = FmodEvent.GetParameterId(musicEvent, "MusicStates");
    }
コード例 #29
0
    private void freeEventData()
    {
        FmodEvent evt = getSource();

        if (evt != null && m_runtimeEvent != null)
        {
            FmodEventGroup evtGroup = evt.getEventGroup();

            if (m_eventSystemHandle != null &&
                m_eventSystemHandle.getEventSystem() != null &&
                m_eventSystemHandle.getEventSystem().wasCleaned() == false)
            {
                if (m_eventSystemHandle.getEventSystem().getNumberRunningInstancesInGroup(evtGroup) == 0)
                {
                    evtGroup.freeWholeGroup();
                }
            }
        }
    }
コード例 #30
0
    private void _SetupDragAndDrop(FmodEventAsset asset)
    {
        Event e = Event.current;

        if (e.type == EventType.MouseUp || e.type == EventType.MouseDown)
        {
            _clearDragAndDrop();
        }
        if (e.type == EventType.MouseDrag)
        {
            FmodEvent  fmodEvent = _getHoveredEvent();
            FmodReverb reverb    = _getHoveredReverb();

            if (fmodEvent != null)
            {
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.paths            = new string[0];
                DragAndDrop.objectReferences = new Object[1] {
                    fmodEvent
                };
                DragAndDrop.SetGenericData(ONGOING_DRAG_KEY, true);
                DragAndDrop.SetGenericData(SOURCE_ASSET_KEY, asset);
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                DragAndDrop.StartDrag("Creating sound from event '" + fmodEvent.getName() + "'");
                m_ongoingDrag = true;
                e.Use();
            }
            else if (reverb != null)
            {
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.paths            = new string[0];
                DragAndDrop.objectReferences = new Object[1] {
                    reverb
                };
                DragAndDrop.SetGenericData(ONGOING_DRAG_KEY, true);
                DragAndDrop.SetGenericData(SOURCE_ASSET_KEY, asset);
                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                DragAndDrop.StartDrag("Creating reverb zone from reverb '" + reverb.getName() + "'");
                m_ongoingDrag = true;
                e.Use();
            }
        }
    }
コード例 #31
0
    static void UpdateEventAsset(FmodEventAsset oldAsset, FmodEventAsset newAsset)
    {
        FmodEventAudioSource[] allSources     = Resources.FindObjectsOfTypeAll(typeof(FmodEventAudioSource)) as FmodEventAudioSource[];
        FmodReverbZone[]       allReverbZones = Resources.FindObjectsOfTypeAll(typeof(FmodReverbZone)) as FmodReverbZone[];

        foreach (FmodEventAudioSource source in allSources)
        {
            source.CheckForOldFormat();
            if (source.getSource() != null)
            {
                FmodEvent oldEvent = source.getSource();
                FmodEvent newEvent = newAsset.getMatchingEvent(oldEvent);

                if (newEvent == null)
                {
                    source.SetSourceEvent(null);
                }
                else
                {
                    source.UpdateExistingEvent(newEvent);
                }
            }
        }
        foreach (FmodReverbZone zone in allReverbZones)
        {
            if (zone.GetReverb() != null)
            {
                FmodReverb oldReverb = zone.GetReverb();
                FmodReverb newReverb = newAsset.getMatchingReverb(oldReverb);

                if (newReverb == null)
                {
                    zone.ResetReverb();
                }
                else
                {
                    zone.ResetReverb();
                    zone.SetReverb(newReverb);
                }
            }
        }
    }
コード例 #32
0
    private void OnEnable()
    {
        listenerGameObject = FindObjectOfType <StudioListener>();


        if (listenerGameObject != null)
        {
            m_targetTransform = listenerGameObject.transform;
        }
        else
        {
            Debug.LogError(this + ": No GameObject with 'Studio Listener' Component found! Aborting.");
            enabled = false;
        }

        _instance = FmodEvent.Play(eventToPlay, m_eventEmitter.transform, null);

        positionClamperRoutine = ClampEmitterPosition();
        StartCoroutine(positionClamperRoutine);
    }
コード例 #33
0
    public FMOD.RESULT loadEventFromFile(FmodEventAudioSource src)
    {
        FmodEvent      evt   = src.getSource();
        FmodEventAsset asset = evt.getAsset();

        FMOD.RESULT         result    = FMOD.RESULT.OK;
        FMOD.EVENT_LOADINFO loadInfo  = new FMOD.EVENT_LOADINFO();
        FMOD.EventProject   project   = null;
        FMOD.Event          fmodEvent = null;

        _loadFile(asset.getMediaPath(), asset.getName(), ref loadInfo, ref project);
        _loadEventGroup(evt);
        result = _loadEvent(evt, ref fmodEvent);
        ERRCHECK(result);
        if (result == FMOD.RESULT.OK)
        {
            src.SetEvent(fmodEvent);
        }
        return(result);
    }
コード例 #34
0
ファイル: Boudoir.cs プロジェクト: Bourinours/Projet_Son
 public bool CheckValue()
 {
     if (source != null && source.CurrentStatus == FmodEventAudioSource.Status.Stopped)
         source.Play();
     if (source != null && source.GetParameterValue("param01") == wantedValue)
     {
         if (eventDialog != null)
         {
             if (this.charactere == null)
                 return true;
             GameManager tmp = this.charactere.GetComponent<GameManager>();
             if (tmp == null)
                 return true;
             tmp.SetDialog(eventDialog, true);
             eventDialog = null;
         }
         return true;
     }
     return false;
 }
コード例 #35
0
    /// <summary>
    /// Gets an event based on the full path from the root of the asset. A starting slash is not required.
    /// Double slashes, i.e. "Group1//Group2/Event" are ignored.
    /// </summary>
    /// <returns>
    /// The event, or null if not found.
    /// </returns>
    /// <param name='fullName'>
    /// Full name of an event, meaning path from the root of the asset, e.g. "FeatureDemonstration/Basics/BasicSoundWithLooping"
    /// </param>
    public FmodEvent getEventWithFullName(string fullName)
    {
        List <FmodEventGroup> curChildrenGroups;
        List <FmodEvent>      curChildrenEvents;

        string[] explodedPath;

        explodedPath = fullName.Split(new char[1] {
            '/'
        });
        curChildrenGroups = m_eventGroups;
        curChildrenEvents = m_events;

        for (int i = 0; i < explodedPath.Length - 1; i++)
        {
            string pathElement = explodedPath[i];

            if (pathElement != "")               // we skip null paths in things such as "elem1/elem2//elem3". Also, enables not caring about a starting /
            {
                FmodEventGroup grp = _getChildGroupWithName(curChildrenGroups, pathElement);

                if (grp == null)
                {
                    Debug.LogWarning("FmodEventAsset (" + getName() + "): getEventWithFullName: Could not find event group with name '" + pathElement + "'");
                    return(null);
                }
                curChildrenGroups = grp.getChildrenGroups();
                curChildrenEvents = grp.getEvents();
            }
        }
        string    eventName = explodedPath[explodedPath.Length - 1];
        FmodEvent ret       = _getEventFromListWithName(curChildrenEvents, eventName);

        if (ret != null)
        {
            return(ret);
        }
        Debug.LogWarning("FmodEventAsset (" + getName() + "): getEventWithFullName: Could not find event with name '" + eventName + "'");
        return(null);
    }
コード例 #36
0
    /**
     * This method returns the event in an updated .fev asset file that matches an event from the previous
     * version of that .fev asset file.
     * The matching is based on the GUID first, then the path through event groups and the name of the event.
     * Returns the event or null if no match could be found.
     */
    public FmodEvent getMatchingEvent(FmodEvent oldEvent)
    {
        string guidString = oldEvent.getGUIDString();

        if (guidString != "" && guidString != FmodEvent.EMPTY_GUIDSTRING) {
            foreach (FmodEvent e in m_events) {
                if (e.WasLoaded() && e.getGUIDString() != "" && e.getGUIDString() != FmodEvent.EMPTY_GUIDSTRING) {
                    if (e.getGUIDString() == guidString) {
                        return (e);
                    }
                }
            }
        }
        string fullName = oldEvent.getFullName();

        foreach (FmodEvent e in m_events) {
            string tmp = e.getFullName();

            if (e.WasLoaded() && tmp == fullName) {
                return (e);
            }
        }
        return (null);
    }
コード例 #37
0
 public bool eventPoolExists(FmodEvent evt)
 {
     return (m_pools.ContainsKey(evt));
 }
コード例 #38
0
    public void UpdateExistingEvent(FmodEvent newEvent)
    {
        #if UNITY_EDITOR
        List<FmodRuntimeEventParameter> oldParams = getParameters();
        List<FmodRuntimeEventParameter> toRemove = new List<FmodRuntimeEventParameter>();

        //checking for existing params
        foreach (FmodRuntimeEventParameter oldParam in oldParams) {
            FmodEventParameter matchingParam = newEvent.getParameter(oldParam.getName());

            if (matchingParam == null) {
                toRemove.Add(oldParam);
            } else {
                oldParam.UpdateExistingParam(matchingParam);
            }
        }
        //removing previously existing params that have been deleted
        foreach (FmodRuntimeEventParameter toDelete in toRemove) {
            m_parameters.Remove(toDelete);
            DestroyImmediate(toDelete, true);
        }
        PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject);

        // checking for newly created params
        if (prefabType != PrefabType.PrefabInstance &&
            prefabType != PrefabType.ModelPrefabInstance) {
            foreach (FmodEventParameter newParam in newEvent.getParameters()) {
                if (ParameterExists(newParam.getName()) == false) {
                        FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent<FmodRuntimeEventParameter>();
                        runtimeParam.Initialize(newParam);
                        m_parameters.Add(runtimeParam);
                }
            }
        }
        m_source = newEvent;
        #endif
    }
コード例 #39
0
 public void SetSourceEvent(FmodEvent srcEvent)
 {
     if (m_source == srcEvent) {
         return ;
     }
     CleanRuntimeEvent();
     m_source = srcEvent;
     if (m_source != null) {
         UpdateRestorationData();
         m_type = m_source.getSourceType();
         setMaxRange(m_source.m_maxRange);
         setMinRange(m_source.m_minRange);
         if (m_parameters != null) {
             CleanAndRemoveParameters();
         } else {
             m_parameters = new List<FmodRuntimeEventParameter>();
         }
         foreach (FmodEventParameter p in m_source.getParameters()) {
             FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent<FmodRuntimeEventParameter>();
             runtimeParam.Initialize(p);
             m_parameters.Add(runtimeParam);
         }
     } else {
         CleanAndRemoveParameters();
     }
 }
コード例 #40
0
 public void Initialize(FmodEvent sourceEvent)
 {
     m_source = sourceEvent;
     name = m_source.name;
 }
コード例 #41
0
 public void CheckForOldFormat()
 {
     if (m_source == null && m_eventClip != null) {
         m_source = m_eventClip.getSource();
     }
 }
コード例 #42
0
ファイル: FmodEvent.cs プロジェクト: Bourinours/Projet_Son
    public void InitializeFromUpdatedEvent(FmodEvent src, FmodEvent oldEvent)
    {
        #if UNITY_EDITOR
        List<FmodEventParameter> newParams = new List<FmodEventParameter>();
        List<FmodEventParameter> oldParams = oldEvent.getParameters();

        EditorUtility.CopySerialized(src, this);
        hideFlags = HideFlags.HideInHierarchy;
        foreach (FmodEventParameter p in m_parameters) {
            FmodEventParameter newP = ScriptableObject.CreateInstance("FmodEventParameter") as FmodEventParameter;
            newP.Initialize(p, this);
            foreach (FmodEventParameter oldP in oldParams) {
                if (p.name == oldP.name) {
                    newP.SetValue(oldP.getValue());
                    oldParams.Remove(oldP);
                    break;
                }
            }
            newParams.Add(newP);
        }
        m_parameters = newParams;
        m_minRange = oldEvent.m_minRange;
        m_maxRange = oldEvent.m_maxRange;
        #endif
    }
コード例 #43
0
    public void _loadEventGroup(FmodEvent evt)
    {
        if (evt.getEventGroup() == null || evt.getEventGroup().isInit()) {
            return ;
        }
        FMOD.RESULT result = FMOD.RESULT.OK;
        FMOD.EventGroup eventGroup = null;
        string groupName = evt.getEventGroup().getFullName();

        result = getEventSystem().getGroup(groupName, true, ref eventGroup);
        ERRCHECK(result);
        if (eventGroup != null) {
            result = eventGroup.loadEventData();
            ERRCHECK(result);
            if (result == FMOD.RESULT.OK) {
                evt.getEventGroup().setEventGroup(eventGroup);
            }
        }
    }
コード例 #44
0
ファイル: FmodEvent.cs プロジェクト: Bourinours/Projet_Son
    public void Initialize(FmodEvent src)
    {
        #if UNITY_EDITOR
        List<FmodEventParameter> newParams = new List<FmodEventParameter>();

        EditorUtility.CopySerialized(src, this);
        hideFlags = HideFlags.HideInHierarchy;
        foreach (FmodEventParameter p in m_parameters) {
            FmodEventParameter newP = ScriptableObject.CreateInstance("FmodEventParameter") as FmodEventParameter;
            newP.Initialize(p, this);
            newParams.Add(newP);
        }
        m_parameters = newParams;
        #endif
    }
コード例 #45
0
 public int getNumberRunningInstances(FmodEvent evt)
 {
     if (evt == null) {
         return (0);
     }
     if (m_eventPoolManager.eventPoolExists(evt) == false) {
         return (0);
     }
     return (m_eventPoolManager.getEventPool(evt).getNumberRunningInstances());
 }
コード例 #46
0
 public void Initialize(FmodEventParameter src, FmodEvent evt)
 {
     #if UNITY_EDITOR
     hideFlags = HideFlags.HideInHierarchy;
     EditorUtility.CopySerialized(src, this);
     m_event = evt;
     #endif
 }
コード例 #47
0
    private FMOD.RESULT _loadEvent(FmodEvent evt, ref FMOD.Event fmodEvent)
    {
        string guidString = evt.getGUIDString();
        FMOD.RESULT result = FMOD.RESULT.OK;

        if (guidString != FmodEvent.EMPTY_GUIDSTRING) {
            result = getEventSystem().getEventByGUIDString(guidString, FMOD.EVENT_MODE.DEFAULT | FMOD.EVENT_MODE.ERROR_ON_DISKACCESS, ref fmodEvent);
        } else {
            string fullName = evt.getFullName();

            result = getEventSystem().getEvent(fullName, FMOD.EVENT_MODE.DEFAULT | FMOD.EVENT_MODE.ERROR_ON_DISKACCESS, ref fmodEvent);
        }
        return (result);
    }
コード例 #48
0
    protected void CreateEventInstance(FmodEvent srcEvent, Vector3 worldPos, RaycastHit hitInfo)
    {
        FmodEventAudioSource audioSource = null;
        if (Event.current.alt) { // if alt is on, we add the audio source as a component
            GameObject dest = hitInfo.collider.gameObject;

            audioSource = dest.GetComponent<FmodEventAudioSource>();
            if (audioSource == null || audioSource.eventClip != null) {
                audioSource = dest.AddComponent(typeof(FmodEventAudioSource)) as FmodEventAudioSource;
            }
        } else { // else we create a GameObject to act as source
            GameObject obj = GameObject.Instantiate(Resources.Load("FmodEventAudioSource"), worldPos, Quaternion.identity) as GameObject;
            audioSource = obj.GetComponent<FmodEventAudioSource>();
            if (audioSource == null) {
                Debug.LogError("Prefab for FmodEventAudioSource should have component FmodEventAudioSource !");
            } else {
                obj.name = "FmodEventSource (" + srcEvent.name + ")";
            }
        }
        audioSource.SetSourceEvent(srcEvent);
    }
コード例 #49
0
    public void Initialize(FMOD.EventParameter param, FmodEvent evt)
    {
        IntPtr paramName = new IntPtr(0);
        int index = 0;
        FMOD.RESULT result = FMOD.RESULT.OK;

        hideFlags = HideFlags.HideInHierarchy;
        result = param.getInfo(ref index, ref paramName);
        ERRCHECK(result);
        m_name = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(paramName);
        this.name = m_name;
        result = param.getRange(ref m_minRange, ref m_maxRange);
        ERRCHECK(result);
        result = param.getValue(ref m_value);
        ERRCHECK(result);
        result = param.getVelocity(ref m_velocity);
        ERRCHECK(result);
        result = param.getSeekSpeed(ref m_seekSpeed);
        ERRCHECK(result);
        m_event = evt;
    }
コード例 #50
0
 public FmodEventPool(FmodEvent source)
 {
     m_event = source;
 }