Ejemplo n.º 1
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
    }
Ejemplo n.º 2
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
    }
Ejemplo n.º 3
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
    }