CodeSmile AssetDatabase 1.10
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches

◆ LoadOrCreate< T >()

static T LoadOrCreate< T > ( [NotNull] Path path,
[NotNull] Func< T > getInstance )
static

Loads an asset at path or creates the asset if needed.

  • If the file does not exist, creates the asset using the object returned from getInstance parameter.
  • If the asset isn't in the database, imports and loads the asset.
Parameters
pathPath to an asset file.
getInstanceMethod that returns an object instance. Invoked only if the asset needs to be created.
Template Parameters
TUnityEngine.Object derived type.
Returns
The loaded or created asset.
See also
  • CodeSmileEditor.Asset.File.Load<T>(CodeSmileEditor.Asset.Path)
Type Constraints
T :Object 

Definition at line 393 of file Asset.File.cs.

393 : Object
394 {
395 if (path.ExistsInFileSystem == false)
396 return Create(getInstance.Invoke(), path) as T;
397
398 return ImportAndLoad<T>(path);
399 }

References Create(), and ImportAndLoad< T >().

+ Here is the call graph for this function: