Tanoda
StreamingAssetPropertyDrawer.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.IO;
10using UnityEditor;
11
12namespace Leap.Unity {
13
14 [CustomPropertyDrawer(typeof(StreamingFolder), useForChildren: true)]
16
17 protected override string PromptUserForPath(string currentPath) {
18 return EditorUtility.OpenFilePanel("Select File", currentPath, "");
19 }
20
21 protected override bool ValidatePath(string fullPath, string relativePath, out string errorMessage) {
22 if (!File.Exists(fullPath)) {
23 errorMessage = "The specified file does not exist!";
24 return false;
25 }
26
27 if ((File.GetAttributes(fullPath) & FileAttributes.Directory) == FileAttributes.Directory) {
28 errorMessage = "You must specify a file and not a directory!";
29 return false;
30 }
31
32 bool isValid = base.ValidatePath(fullPath, relativePath, out errorMessage);
33 if (!isValid) {
34 errorMessage = "The specified file is not a streaming asset. Streaming assets must be inside project's Assets/StreamingAssets directory.";
35 }
36 return isValid;
37 }
38 }
39}
override string PromptUserForPath(string currentPath)
override bool ValidatePath(string fullPath, string relativePath, out string errorMessage)