public override void OnInspectorGUI()
    {
        EditorGUILayout.LabelField("Path:", currentAsset.path);
        //EditorGUILayout.LabelField("GUID:", currentAsset.id);
        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Play", new GUILayoutOption[0]))
        {
            FMODEditorExtension.AuditionEvent(currentAsset);
        }
        if (GUILayout.Button("Stop", new GUILayoutOption[0]))
        {
            FMODEditorExtension.StopEvent();
        }
        GUILayout.EndHorizontal();



        // Display Parameters
        if (parameters.Count > 0)
        {
            EditorGUILayout.Space();
        }
        foreach (Param param in parameters)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(param.description.name);
            param.value = GUILayout.HorizontalSlider(param.value, param.description.minimum, param.description.maximum, new GUILayoutOption[0]);
            //FMODEditorExtension.SetEventParameterValue(i, param.value);
            GUILayout.EndHorizontal();
        }
    }
    private void Awake()
    {
        currentAsset = (FMODAsset)target;
        FMODEditorExtension.StopEvent();

        // Seting up parameters
        FMOD.Studio.EventDescription eventDescription = FMODEditorExtension.GetEventDescription(currentAsset.id);

        if (eventDescription == null)
        {
            return;
        }

        int count;

        eventDescription.GetParameterCount(out count);

        // Fetch parameters
        parameters.Clear();
        for (int i = 0; i < count; ++i)
        {
            Param parameter = new Param();
            eventDescription.GetParameterByIndex(i, out parameter.description);
            parameter.value = parameter.description.minimum;
        }
    }
    public override void OnInspectorGUI()
    {
        //GUILayout.Label("Event: " + currentAsset.name);
        GUILayout.Label("Path: " + currentAsset.path);
        GUILayout.Label("GUID: " + currentAsset.id);

        GUILayout.Label(is3D ? "3D" : "2D");
        if (is3D)
        {
            GUILayout.Label("Distance: (" + minDistance + " - " + maxDistance + ")");
        }

        GUILayout.BeginHorizontal();
        if (!isPlaying && GUILayout.Button("Play", new GUILayoutOption[0]))
        {
            FMODEditorExtension.AuditionEvent(currentAsset);
            isPlaying = true;
        }
        if (isPlaying && GUILayout.Button("Stop", new GUILayoutOption[0]))
        {
            FMODEditorExtension.StopEvent();
            isPlaying = false;
        }
        GUILayout.EndHorizontal();

        for (int i = 0; i < parameters.Length; ++i)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(parameters[i].desc.name);
            parameters[i].val = GUILayout.HorizontalSlider(parameters[i].val, parameters[i].desc.minimum, parameters[i].desc.maximum, new GUILayoutOption[0]);
            FMODEditorExtension.SetEventParameterValue(i, parameters[i].val);
            GUILayout.EndHorizontal();
        }
    }
    void OnDrawGizmosSelected()

    {
        if (asset != null && enabled)

        {
            FMOD.Studio.EventDescription desc = null;

            desc = FMODEditorExtension.GetEventDescription(asset.id);



            if (desc != null)

            {
                float max, min;

                desc.getMaximumDistance(out max);

                desc.getMinimumDistance(out min);



                Gizmos.color = Color.blue;

                Gizmos.DrawWireSphere(transform.position, min);

                Gizmos.DrawWireSphere(transform.position, max);
            }
        }
    }
    void Awake()
    {
        currentAsset = (FMODAsset)target;
        FMODEditorExtension.StopEvent();
        isPlaying = false;

        // set up parameters
        FMOD.Studio.EventDescription desc = FMODEditorExtension.GetEventDescription(currentAsset.id);
        int count;

        if (desc == null)
        {
            return;
        }

        desc.is3D(out is3D);
        desc.getMinimumDistance(out minDistance);
        desc.getMaximumDistance(out maxDistance);

        desc.getParameterCount(out count);
        parameters = new Param[count];

        for (int i = 0; i < count; ++i)
        {
            desc.getParameterByIndex(i, out parameters[i].desc);
            parameters[i].val = parameters[i].desc.minimum;
        }
    }
    void Awake()
    {
        emitter = (FMOD_StudioEventEmitter)target;

        is3D = false;

        FMOD.Studio.EventDescription desc = FMODEditorExtension.GetEventDescription(emitter.asset.id);

        if (desc != null)
        {
            desc.is3D(out is3D);
            desc.getMinimumDistance(out minDistance);
            desc.getMaximumDistance(out maxDistance);
        }
    }
    void Awake()
    {
        currentAsset = (FMODAsset)target;
        FMODEditorExtension.StopEvent();
        isPlaying = false;

        // set up parameters
        FMOD.Studio.EventDescription desc = FMODEditorExtension.GetEventDescription(currentAsset.id);
        int count;

        desc.getParameterCount(out count);
        parameters = new Param[count];

        for (int i = 0; i < count; ++i)
        {
            desc.getParameterByIndex(i, out parameters[i].desc);
            parameters[i].val = parameters[i].desc.minimum;
        }
    }
    void OnDrawGizmosSelected()
    {
        if (asset != null && enabled &&
            (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isPlaying))
        {
            FMOD.Studio.EventDescription desc = null;
            desc = FMODEditorExtension.GetEventDescription(asset.id);

            if (desc != null)
            {
                float max, min;
                desc.getMaximumDistance(out max);
                desc.getMinimumDistance(out min);

                Gizmos.color = Color.blue;
                Gizmos.DrawWireSphere(transform.position, min);
                Gizmos.DrawWireSphere(transform.position, max);
            }
        }
    }
예제 #9
0
    static void DrawGizmo(FMOD_StudioEventEmitter studioEmitter, GizmoType gizmoType)
    {
        if (studioEmitter.asset != null && studioEmitter.enabled &&
            (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isPlaying))
        {
            FMOD.Studio.EventDescription desc = null;
            desc = FMODEditorExtension.GetEventDescription(studioEmitter.asset.id);

            if (desc != null)
            {
                float max, min;
                desc.getMaximumDistance(out max);
                desc.getMinimumDistance(out min);

                Gizmos.color = Color.blue;
                Gizmos.DrawWireSphere(studioEmitter.transform.position, min);
                Gizmos.DrawWireSphere(studioEmitter.transform.position, max);
            }
        }
    }
예제 #10
0
    public static void UpdateParamsOnEmmitter(SerializedObject serializedObject, string id)
    {
        var param = serializedObject.FindProperty("Params");

        if (param == null)
        {
            return;
        }

        param.ClearArray();

        FMOD.Studio.EventDescription desc = FMODEditorExtension.GetEventDescription(id);
        if (desc == null)
        {
            serializedObject.ApplyModifiedProperties();
            return;
        }

        int count = 0;

        desc.getParameterCount(out count);
        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                FMOD.Studio.PARAMETER_DESCRIPTION parameter;
                desc.getParameterByIndex(i, out parameter);

                param.InsertArrayElementAtIndex(0);
                var parami = param.GetArrayElementAtIndex(0);
                parami.FindPropertyRelative("name").stringValue = parameter.name;
                parami.FindPropertyRelative("min").floatValue   = parameter.minimum;
                parami.FindPropertyRelative("max").floatValue   = parameter.maximum;
                parami.FindPropertyRelative("value").floatValue = 0;
            }
        }
    }
 private void OnDestroy()
 {
     FMODEditorExtension.StopEvent();
 }
예제 #12
0
    public override void OnInspectorGUI()
    {
        FMOD_StudioEventEmitter emitter = (FMOD_StudioEventEmitter)target;
        var ev = serializedObject.FindProperty("asset");

        EditorGUI.BeginChangeCheck();
        //emitter.asset = (FMODAsset)EditorGUILayout.ObjectField("Asset:", emitter.asset, typeof(FMODAsset), false);
        EditorGUILayout.PropertyField(ev, new GUIContent("Asset:"));
        if (EditorGUI.EndChangeCheck())
        {
            emitter.asset = (FMODAsset)ev.objectReferenceValue;
            // Note: set path to guid just in case the asset gets deleted
            emitter.path = (emitter.asset != null) ? emitter.asset.id : "";
            UpdateParamsOnEmmitter(serializedObject, emitter.path);
        }

        string id = "";
        string path = "";
        bool   is3D = false;
        float  minDistance = 0, maxDistance = 0;

        FMOD.Studio.EventDescription desc = null;
        if (emitter.asset != null)
        {
            id   = emitter.asset.id;
            path = emitter.asset.path;

            desc = FMODEditorExtension.GetEventDescription(id);
            if (desc != null)
            {
                desc.is3D(out is3D);
                desc.getMinimumDistance(out minDistance);
                desc.getMaximumDistance(out maxDistance);
            }
        }
        EditorGUILayout.LabelField("Path:", path, GUILayout.Height(14));
        EditorGUILayout.LabelField("GUID:", id, GUILayout.Height(14));

        GUILayout.Label(is3D ? "3D" : "2D");
        if (is3D)
        {
            GUILayout.Label("Distance: (" + minDistance + " - " + maxDistance + ")");
        }

        bool isDirty = false;

        {
            bool oldIsMusic = emitter.isMusic;
            emitter.isMusic = GUILayout.Toggle(oldIsMusic, "IsMusic");
            isDirty         = isDirty || (oldIsMusic != emitter.isMusic);

            bool oldState = emitter.startEventOnAwake;
            emitter.startEventOnAwake = GUILayout.Toggle(oldState, "Start Event on Awake");
            isDirty = isDirty || (oldState != emitter.startEventOnAwake);
        }

        if (isDirty)
        {
            EditorUtility.SetDirty(emitter);
        }

        showParameters = EditorGUILayout.Foldout(showParameters, "Parameters");
        var param = serializedObject.FindProperty("Params");

        if (showParameters && param.arraySize > 0 && desc != null)
        {
            for (int i = 0; i < param.arraySize; i++)
            {
                var parami        = param.GetArrayElementAtIndex(i);
                var nameProperty  = parami.FindPropertyRelative("name");
                var minProperty   = parami.FindPropertyRelative("min");
                var maxProperty   = parami.FindPropertyRelative("max");
                var valueProperty = parami.FindPropertyRelative("value");

                int  count = 0;
                bool isHas = false;
                desc.getParameterCount(out count);
                for (int j = 0; j < count; j++)
                {
                    FMOD.Studio.PARAMETER_DESCRIPTION parameter;
                    desc.getParameterByIndex(j, out parameter);
                    if (parameter.name == nameProperty.stringValue)
                    {
                        isHas = true;
                        break;
                    }
                }
                if (!isHas)
                {
                    param.DeleteArrayElementAtIndex(i);
                    i--;
                    continue;
                }
                EditorGUILayout.Slider(valueProperty, minProperty.floatValue, maxProperty.floatValue, "[" + nameProperty.stringValue + "]");
            }
        }
        serializedObject.ApplyModifiedProperties();
    }