9092858a58
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
using UnityEditor;
|
|
|
|
using Codice.Client.BaseCommands;
|
|
|
|
namespace Unity.PlasticSCM.Editor.AssetUtils
|
|
{
|
|
internal static class LoadAsset
|
|
{
|
|
internal static UnityEngine.Object FromChangeInfo(ChangeInfo changeInfo)
|
|
{
|
|
string changeFullPath = changeInfo.GetFullPath();
|
|
|
|
if (MetaPath.IsMetaPath(changeFullPath))
|
|
changeFullPath = MetaPath.GetPathFromMetaPath(changeFullPath);
|
|
|
|
return FromFullPath(changeFullPath);
|
|
}
|
|
|
|
static UnityEngine.Object FromFullPath(string fullPath)
|
|
{
|
|
if (!IsPathUnderProject(fullPath))
|
|
return null;
|
|
|
|
return AssetDatabase.LoadMainAssetAtPath(
|
|
AssetsPath.GetRelativePath(fullPath));
|
|
}
|
|
|
|
static bool IsPathUnderProject(string path)
|
|
{
|
|
if (string.IsNullOrEmpty(path))
|
|
return false;
|
|
|
|
var fullPath = Path.GetFullPath(path).Replace('\\', '/');
|
|
|
|
return fullPath.StartsWith(
|
|
mProjectRelativePath,
|
|
StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
static string mProjectRelativePath =
|
|
Directory.GetCurrentDirectory().Replace('\\', '/') + '/';
|
|
}
|
|
}
|