Пример #1
0
    public static AudioContainerList Create()
    {
        AudioContainerList asset = ScriptableObject.CreateInstance <AudioContainerList>();

        AssetDatabase.CreateAsset(asset, "Assets/AudioContainerList.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
 private void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         audioContainerList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(AudioContainerList)) as AudioContainerList;
     }
 }
 void CreateNewContainerList()
 {
     //No overwrite protection
     //This should probably get a string from the user to create a new name and pass it in
     viewIndex          = 1;
     audioContainerList = CreateAudioContainerList.Create();
     if (audioContainerList)
     {
         audioContainerList.audioContainers = new List <AudioContainer>();
         string relPath = AssetDatabase.GetAssetPath(audioContainerList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
    void OpenContainerList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Audio Container List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            audioContainerList = AssetDatabase.LoadAssetAtPath(relPath, typeof(AudioContainerList)) as AudioContainerList;
            if (audioContainerList.audioContainers == null)
            {
                audioContainerList.audioContainers = new List <AudioContainer>();
            }
            if (audioContainerList)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }