Search Unity

about load asset by code.

Discussion in 'Scripting' started by roger-wang, Dec 17, 2014.

  1. roger-wang

    roger-wang

    Joined:
    Jun 8, 2013
    Posts:
    11
    hello, everybody.

    i'm comfuse about the asset load API.

    i want generate *.prefab file when import the *.fbx file.
    • step 1: load *.fbx file
    • step 2: Create *.prefab file
    • step 3: load *.prefab file and Instantiate it.


    i try the code such below, but return null: [Windows]
    Code (CSharp):
    1.  
    2.               var prefab = AssetDatabase.LoadMainAssetAtPath("");
    3.                 Debug.Log(prefab);
    4.                 // This instantiates the prefab into the Hierarchy.
    5.                 var instance = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
    6.  
     
  2. roger-wang

    roger-wang

    Joined:
    Jun 8, 2013
    Posts:
    11
    i try it, but fail again.

    so, I think this is bug of Unity 4.6 version.