Search Feedback

6
votes

Adding automatic loading to ScriptableObject assets

Scripting

-

-

It would be fantastic if there was a way to add automatic loading capabilities to scriptable object assets. There are many use cases for this ranging from game-wide controllers and managers to allowing custom asset packages to automatically initialise without the need for any manual setup by user.

I feel that this would be best implemented as an "Auto Load" toggle on a per asset basis. This would effectively allow multiple instances of the same scriptable object class when needed. I feel that the best location for this new functionality would be within the ScriptableObject class itself.

With this added flexbility I also feel that there must be an easy way for users to locate and disable this functionality using an editor window. Since this is project-wide, the best location for these controls is probably "Edit | Project Settings | Script Execution". Here is a mockup of such an interface:

http://pbrd.co/16EGrRP

Comments (2)

  1. 4ff331252f29470ced7466bb5577f74b?d=mm

    numberkruncher

    Sep 22, 2013 17:35

    > 1) There already exists 'ScriptableObject'

    I am proposing that an "autoLoad" property is added to the 'ScriptableObject' base class allowing any scriptable object asset to acquire auto loading capabilities.

    > '[InitializeOnLoad]'

    This is an editor-only attribute class, not suitable for runtime:
    http://docs.unity3d.com/Documentation/Manual/RunningEditorCodeOnLaunch.html
    https://docs.unity3d.com/Documentation/ScriptReference/InitializeOnLoadAttribute.html

    > Too specific to be baked into Unity, but it is perfect for an AssetStore item. I'm working on just such an item, but there are Unity bugs that prevent me from completing it. Thoughts?

    You can enumerate asset paths using AssetDatabase.GetAllAssetPaths().

  2. 3b44b0782e1f2d93650cde15d819eaec?d=mm

    srivello

    Sep 22, 2013 12:02

    I understand your needs well. I have needs too. However, for two reasons I not agree with this being appropriate for a suggested feature. 1) There already exists 'ScriptableObject' as well as '[InitializeOnLoad]' and both work without any known issues (AFAIK). So you have the tools to create the feature you are suggesting. And equally important, 2) this is a very specific use-case you are talking about. Too specific to be baked into Unity, but it is perfect for an AssetStore item. I'm working on just such an item, but there are Unity bugs that prevent me from completing it. Thoughts?

    http://www.rivellomultimediaconsulting.com/unity-umom-dev-diary-1/

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(8464)

2D

(203)

Ads

(31)

AI & Navigation

(51)

Analytics

(81)

Animation

(278)

Asset Store

(195)

Assets

(477)

Audio

(146)

Cloud Build

(88)

Collaborate

(15)

Docs & Tutorials

(178)

Editor

(1966)

Everyplay

(13)

Game Performance Reporting

(10)

General

(760)

Graphics

(707)

GUI

(338)

Input

(139)

Licensing

(69)

Networking

(145)

Physics

(315)

Platforms

(394)

Profiling & Optimization

(64)

Runtime

(147)

Scripting

(954)

Terrain

(145)

WebGL

(125)