x


Custom Asset Files

I've seen that the Terrain System was able to create its own Terrain Asset, it even has its own Icon, this asset can then be selected from an ObjectField in the inspector, and loaded. Any idea how this is done, and how I might replicate it?

I've been looking around the forums, and answers board for a while.. but I can't find any leads.

Hope someone can help, and thanks a lot if you do!

more ▼

asked Jul 09 '10 at 10:30 PM

N1nja gravatar image

N1nja
520 29 29 37

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

0 answers: sort voted first

I think what you're looking for is ScriptableObject. When you implement ScriptableObject you can create instances of those objects via editor scripts and use those objects e.g. for storing data.

I'm using this, for example, to store meta information about my levels persistently as objects in the project. Here's a script snippet I used to create those assets ("LevelData" is a ScriptableObject).

[MenuItem("LevelEditor/Create Level Data")]
public static void CreateLevelData() {
    LevelData asset = new LevelData();  //scriptable object
    AssetUtility.CreateAsset(asset, "LevelData New");
    AssetUtility.SaveAsset(asset);
    EditorUtility.FocusProjectWindow();
    Selection.activeObject = asset;
}
more ▼

answered Aug 05 '10 at 12:28 PM

jashan gravatar image

jashan
11.1k 25 46 122

thanks, this will do =]

Aug 24 '10 at 04:13 PM N1nja

What is AssetUtility? I've searched all over for it and I can't seem to find it anywhere. AssetDatabase seems to have the same functions, but it won't let you create an asset that isn't native to Unity. I'm trying to do the same thing here, except I'm trying to load a custom file type (.custom for example)

Aug 02 '11 at 05:02 PM Leolicos

That does not work anymore, anyone can give feedback on how to do this in Unity 3.5?

Jan 14 '12 at 05:18 PM zharramadar

Try AssetDatabase

Jun 12 '12 at 11:17 PM jeffpk
Jun 27 '12 at 11:42 AM Avaista
(comments are locked)
10|3000 characters needed characters left
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:

x603
x267

asked: Jul 09 '10 at 10:30 PM

Seen: 7462 times

Last Updated: May 14 '13 at 05:27 AM