Search Unity

Problem withLoadAssetAtPath

Discussion in 'Editor & General Support' started by AliAzin, Dec 18, 2009.

  1. AliAzin

    AliAzin

    Joined:
    Jun 25, 2009
    Posts:
    51
    Hi there,

    I'm trying to use Resources.LoadAssetAtPath and AssetDatabase.LoadAssetAtPath in an editor static function to use in batch mode. But it seems no one works.
    My code is this :
    Code (csharp):
    1. static function Export(){
    2. var go : AudioClip[];
    3. go[0] = Resources.LoadAssetAtPath("/assets/sounds/1.mp3",AudioClip);
    4. Debug.Log(go[0]);
    5. .
    6. .
    7. .
    8. }
    It works when I put it for example in Start function.

    Is it a bug? and what can I do?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Can you clarify exactly what goes wrong? Do you get a null object from the LoadAssetAtPath call, error message... ?
     
  3. AliAzin

    AliAzin

    Joined:
    Jun 25, 2009
    Posts:
    51
    Yes, it's a null object error. But when unity is in play mode, everything works;
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    guess this is an iphone project then?

    Because on the desktop it would just fail due to the fact that mp3 is not supported at all for playback. Audio is converted to ogg for compressed and otherwise is wav.
     
  5. AliAzin

    AliAzin

    Joined:
    Jun 25, 2009
    Posts:
    51
    No, it's desktop. It takes the path to original asset, but uses the converted one.