x


How would I call upon an asset in the projects tab with an array?

I can't seem to figure it out on my own...

more ▼

asked Jun 14 '10 at 07:14 PM

medsouz gravatar image

medsouz
16 1 1 1

And I cant't figure out what you mean.. ;)

Jun 14 '10 at 08:16 PM StephanK

Next time, ask a more detailed question.

Jun 14 '10 at 08:35 PM qJake
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

You have two options.

Array Referencing and the Inspector

  • Create an array with code, say:
public Texture[] myTextures;
  • Attach this to a script (C#), and then attach the script to a game object.
  • Select the game object in the heirarchy, and look at the Inspector panel. The script should have an array list that you can fill in with whatever assets you want (just drag and drop).
  • To change the type of asset in the array, simply change the array type from Texture[] to whatever you want.

Using Resources.Load

This method is NOT recommended for all your game assets because it is much less efficient. However, any resources in the folder Resources/ will always be loaded, and can be called by name during scripting. For example, if you had a texture called "Wall" and it was in the Resources folder, you could do:

Texture myWall = Resources.Load("Wall") as Texture;

You could devise some way of loading multiple resources from the Resources folder into an array, though again, the method described above is preferred.

more ▼

answered Jun 14 '10 at 08:34 PM

qJake gravatar image

qJake
11.6k 43 78 161

(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x3461
x355
x280
x268

asked: Jun 14 '10 at 07:14 PM

Seen: 1044 times

Last Updated: Jun 14 '10 at 07:14 PM