You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.5 KiB
80 lines
2.5 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.IO;
|
|
using uc;
|
|
using UnityEngine.SceneManagement;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
using UnityEditor.SceneManagement;
|
|
#endif
|
|
[System.Serializable]
|
|
public class DShowClip : ScriptableObject
|
|
{
|
|
public enum FileLocation
|
|
{
|
|
AbsolutePathOrURL,
|
|
RelativeToProjectFolder,
|
|
RelativeToStreamingAssetsFolder,
|
|
RelativeToDataFolder,
|
|
RelativeToPeristentDataFolder,
|
|
// TODO: Resource?
|
|
}
|
|
|
|
|
|
public FileLocation m_VideoLocation = FileLocation.RelativeToProjectFolder;
|
|
public string m_VideoPath;
|
|
public string fullPath { get { return GetFilePath(m_VideoPath, m_VideoLocation); } }
|
|
|
|
|
|
public static string GetPath(FileLocation location)
|
|
{
|
|
string result = string.Empty;
|
|
switch (location)
|
|
{
|
|
case FileLocation.AbsolutePathOrURL:
|
|
break;
|
|
case FileLocation.RelativeToDataFolder:
|
|
result = Application.dataPath;
|
|
break;
|
|
case FileLocation.RelativeToPeristentDataFolder:
|
|
result = Application.persistentDataPath;
|
|
break;
|
|
case FileLocation.RelativeToProjectFolder:
|
|
#if !UNITY_WINRT_8_1
|
|
string path = "..";
|
|
#if UNITY_STANDALONE_OSX && !UNITY_EDITOR_OSX
|
|
path += "/..";
|
|
#endif
|
|
result = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, path));
|
|
result = result.Replace('\\', '/');
|
|
#endif
|
|
break;
|
|
case FileLocation.RelativeToStreamingAssetsFolder:
|
|
result = Application.streamingAssetsPath;
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static string GetFilePath(string path, FileLocation location)
|
|
{
|
|
string result = string.Empty;
|
|
if (!string.IsNullOrEmpty(path))
|
|
{
|
|
switch (location)
|
|
{
|
|
case FileLocation.AbsolutePathOrURL:
|
|
result = path;
|
|
break;
|
|
case FileLocation.RelativeToDataFolder:
|
|
case FileLocation.RelativeToPeristentDataFolder:
|
|
case FileLocation.RelativeToProjectFolder:
|
|
case FileLocation.RelativeToStreamingAssetsFolder:
|
|
result = System.IO.Path.Combine(GetPath(location), path).Replace("\\","/");
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|