x


Read Texture from unity3d file? BuildAssetBundle made the unity3d file?

using UnityEngine; using System.Collections; using UnityEditor; //(1)

public class BuildAssetBundles{

[MenuItem ("Assets/Auto Build Image File")] 
public static void buildImage(){

    BuildPipeline.PushAssetDependencies();
    BuildAssetBundleOptions  options = BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets;        
    Object[] asset = new Object[1];
    asset[0] = AssetDatabase.LoadMainAssetAtPath("Assets/Resources/pic1.png");                

    BuildPipeline.BuildAssetBundle(null, asset, "Textures.unity3d", options);   

    BuildPipeline.PopAssetDependencies();     }

}

the code build a Textures.unity3d.but read the texture is wrong ?

WWW www = new WWW ("file:///"+Application.dataPath+"/Resources/Textures.unity3d"); yield return www; if(www.isDone) { Texture t=Instantiate(www.assetBundle.Load("pic1"))as Texture; //Instantiating a non-readable 'Bucket2' texture is not allowed! Please mark the texture readable in the inspector or don't instantiate it. }

How to read the texture?

more ▼

asked Feb 10 '11 at 07:35 AM

noflyzone 3 gravatar image

noflyzone 3
41 10 11 13

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2193
x15

asked: Feb 10 '11 at 07:35 AM

Seen: 1433 times

Last Updated: Feb 10 '11 at 07:35 AM