public void Clean()
 {
     if (m_runtimeParam != null)
     {
         m_runtimeParam = null;
     }
 }
 public void BombWickFmodSound(TimeSpan alarm, ref FMOD.Event evt, ref FMOD.EventParameter evntParam)
 {
     if (this.GameTimer.Time < alarm && !this.MecheBomb.Finished && this.GameTimer.Time > TimeSpan.FromSeconds(0.0) && this.Result == 0)
     {
         FmodFactory.Instance.start(ref evt);
         FmodFactory.Instance.update(this.GameTimer.Time.Seconds, ref evntParam);
     }
 }
    public void SetEvent(FMOD.Event evt)
    {
        FMOD.RESULT         result = FMOD.RESULT.OK;
        FMOD.EventParameter param  = null;

        hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
        if (m_parameter != null)
        {
            result = evt.getParameter(m_parameter.getName(), ref param);
            ERRCHECK(result);
            if (result == FMOD.RESULT.OK)
            {
                m_runtimeParam = param;
                result         = m_runtimeParam.setValue(m_value);
                ERRCHECK(result);
            }
        }
        else
        {
            Debug.Log("Error: This component should not exist now if its parameter is null");
        }
    }
Esempio n. 4
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;
    }
Esempio n. 5
0
    public void Initialize(FMOD.Event e, FmodEventGroup eventGroup, int indexInGroup, FmodEventAsset asset)
    {
#if UNITY_EDITOR
        FMOD.EVENT_INFO     info   = new FMOD.EVENT_INFO();
        FMOD.GUID           guid   = new FMOD.GUID();
        FMOD.EventParameter param  = null;
        FMOD.RESULT         result = FMOD.RESULT.OK;
        FmodEventParameter  toAdd  = null;
        IntPtr name          = new IntPtr(0);
        int    numParameters = 0;
        int    index         = 0;

        Initialize(eventGroup, indexInGroup, asset);
        int size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(FMOD.GUID));
        info.guid = System.Runtime.InteropServices.Marshal.AllocHGlobal(size);
        result    = e.getInfo(ref index, ref name, ref info);
        ERRCHECK(result);
        m_name       = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(name);
        this.name    = m_name;
        guid         = (FMOD.GUID)System.Runtime.InteropServices.Marshal.PtrToStructure(info.guid, typeof(FMOD.GUID));
        m_guidString = "{" + String.Format("{0:x8}-{1:x4}-{2:x4}-{3:x2}{4:x2}-{5:x2}{6:x2}{7:x2}{8:x2}{9:x2}{10:x2}",
                                           guid.Data1, guid.Data2, guid.Data3,
                                           guid.Data4[0], guid.Data4[1],
                                           guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]
                                           ) + "}";

        int    mode    = 0;
        IntPtr modePtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(int));
        e.getPropertyByIndex((int)FMOD.EVENTPROPERTY.MODE, modePtr, false);
        mode = System.Runtime.InteropServices.Marshal.ReadInt32(modePtr);
        System.Runtime.InteropServices.Marshal.FreeHGlobal(modePtr);
        m_sourceType = (SourceType)mode;

        if (m_sourceType == SourceType.SOURCE_3D)
        {
            IntPtr  range;
            float[] tmp    = new float[1];
            int[]   tmpInt = new int[1];

            range  = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(int));
            result = e.getPropertyByIndex((int)FMOD.EVENTPROPERTY._3D_ROLLOFF, range, false);
            ERRCHECK(result);
            System.Runtime.InteropServices.Marshal.Copy(range, tmpInt, 0, 1);
            if (tmpInt[0] == (int)FMOD.MODE._3D_CUSTOMROLLOFF)
            {
                m_rolloffType = RolloffType.CUSTOM;
            }
            else if (tmpInt[0] == (int)FMOD.MODE._3D_INVERSEROLLOFF)
            {
                m_rolloffType = RolloffType.INVERSE;
            }
            else if (tmpInt[0] == (int)FMOD.MODE._3D_LINEARROLLOFF)
            {
                m_rolloffType = RolloffType.LINEAR;
            }
            else if (tmpInt[0] == (int)FMOD.MODE._3D_LINEARSQUAREROLLOFF)
            {
                m_rolloffType = RolloffType.LINEARSQUARE;
            }
            else if (tmpInt[0] == (int)FMOD.MODE._3D_LOGROLLOFF)
            {
                m_rolloffType = RolloffType.LOGARITHMIC;
            }
            System.Runtime.InteropServices.Marshal.FreeHGlobal(range);

            range  = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float));
            result = e.getPropertyByIndex((int)FMOD.EVENTPROPERTY._3D_MINDISTANCE, range, false);
            ERRCHECK(result);
            System.Runtime.InteropServices.Marshal.Copy(range, tmp, 0, 1);
            m_minRange = tmp[0];
            System.Runtime.InteropServices.Marshal.FreeHGlobal(range);
            range  = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float));
            result = e.getPropertyByIndex((int)FMOD.EVENTPROPERTY._3D_MAXDISTANCE, range, false);
            ERRCHECK(result);
            System.Runtime.InteropServices.Marshal.Copy(range, tmp, 0, 1);
            m_maxRange = tmp[0];
            System.Runtime.InteropServices.Marshal.FreeHGlobal(range);
        }


        e.getNumParameters(ref numParameters);
        for (int k = 0; k < numParameters; k++)
        {
            e.getParameterByIndex(k, ref param);
            toAdd = FmodEventParameter.CreateInstance("FmodEventParameter") as FmodEventParameter;
            toAdd.Initialize(param, this);
            m_parameters.Add(toAdd);
        }
        m_wasLoaded = true;
#endif
    }