Tanoda
AssetFolder.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System;
10using UnityEngine;
11using UnityObject = UnityEngine.Object;
12#if UNITY_EDITOR
13using UnityEditor;
14#endif
15
16namespace Leap.Unity {
17
25 [Serializable]
26 public class AssetFolder {
27
28 [SerializeField]
30
31 public AssetFolder() { }
32
33 public AssetFolder(string path) {
34 Path = path;
35 }
36
43 public virtual string Path {
44 get {
45#if UNITY_EDITOR
46 if (_assetFolder != null) {
47 return AssetDatabase.GetAssetPath(_assetFolder);
48 } else {
49 return null;
50 }
51#else
52 throw new InvalidOperationException("Cannot access the Path of an Asset Folder in a build.");
53#endif
54 }
55 set {
56#if UNITY_EDITOR
57 _assetFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(value);
58#else
59 throw new InvalidOperationException("Cannot set the Path of an Asset Folder in a build.");
60#endif
61 }
62 }
63 }
64}
UnityEngine.Object UnityObject
A convenient serializable representation of an asset folder. Only useful for editor scripts since ass...
Definition: AssetFolder.cs:26
UnityObject _assetFolder
Definition: AssetFolder.cs:29
AssetFolder(string path)
Definition: AssetFolder.cs:33
virtual string Path
Gets or sets the folder path. This path will always be a path relative to the asset folder,...
Definition: AssetFolder.cs:43
UnityEngine.Object UnityObject
Definition: EditorUtils.cs:19