Exemplo n.º 1
0
    void CreateClip(SoundBank bank)
    {
        new_clip_name     = EditorGUILayout.TextField("New SFXClip Name", new_clip_name);
        new_clip_codename = SoundBank.GetCodename(new_clip_name);
        EditorGUILayout.LabelField("Codename", new_clip_codename);

        EditorGUILayout.BeginHorizontal();

        clip = (AudioClip)EditorGUILayout.ObjectField(clip, typeof(AudioClip), false);

        EditorGUI.BeginDisabledGroup(clip == null || bank.HasSFXClip(new_clip_name) || new_clip_name == "");

        if (GUILayout.Button("Create New SFXClip"))
        {
            CreateAndAddToBank(serializedObject, clip, new_clip_name, new_clip_codename);
            clip              = null;
            new_clip_name     = "";
            new_clip_codename = "";
        }

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();

        if (bank.HasSFXClip(new_clip_codename))
        {
            EditorGUILayout.LabelField(new_clip_codename + " already exists in sound bank.", error_style);
        }
    }
Exemplo n.º 2
0
    void AddToBank(SerializedObject bank, SFXClip sfx_clip)
    {
        SerializedObject sfx_clip_object = new SerializedObject(sfx_clip);

        sfx_clip_object.FindProperty("_codename").stringValue = SoundBank.GetCodename(sfx_clip.name);
        sfx_clip_object.ApplyModifiedProperties();

        string new_path = "Assets/SFX/Resources/" + sfx_clip.name + ".asset";

        AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(sfx_clip), new_path);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        SerializedProperty property = bank.FindProperty("_sound_effect_list");

        property.InsertArrayElementAtIndex(property.arraySize);
        property.GetArrayElementAtIndex(property.arraySize - 1).objectReferenceValue = AssetDatabase.LoadAssetAtPath <SFXClip>(new_path);

        bank.ApplyModifiedProperties();
    }
Exemplo n.º 3
0
    void AddClip(SoundBank bank)
    {
        EditorGUILayout.BeginHorizontal();

        add_clip = (SFXClip)EditorGUILayout.ObjectField(add_clip, typeof(SFXClip), false);

        EditorGUI.BeginDisabledGroup(add_clip == null || bank.HasSFXClip(SoundBank.GetCodename(add_clip.name)));

        if (GUILayout.Button("Add SFXClip"))
        {
            AddToBank(serializedObject, add_clip);
            add_clip = null;
        }

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();

        if (add_clip != null && bank.HasSFXClip(SoundBank.GetCodename(add_clip.name)))
        {
            EditorGUILayout.LabelField(SoundBank.GetCodename(add_clip.name) + " already exists in sound bank.", error_style);
        }
    }