Merge pull request #1851 from ousttrue/fix/PathObject_if_UNITY_EDITOR

Editor向け機能の切り分け忘れ
This commit is contained in:
ousttrue 2022-10-07 13:51:31 +09:00 committed by GitHub
commit ba197f68f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,9 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace VRMShaders
{
@ -119,25 +121,6 @@ namespace VRMShaders
return UnityRoot.Child(src);
}
public static bool TryGetFromAsset(UnityEngine.Object src, out PathObject dst)
{
if (src == null)
{
dst = default;
return false;
}
var assetPath = AssetDatabase.GetAssetPath(src);
if (string.IsNullOrEmpty(assetPath))
{
dst = default;
return false;
}
dst = FromUnityAssetPath(assetPath);
return true;
}
public static bool TryGetFromEnvironmentVariable(string key, out PathObject dst)
{
var value = System.Environment.GetEnvironmentVariable(key);
@ -178,6 +161,26 @@ namespace VRMShaders
File.WriteAllBytes(FullPath, data);
}
#if UNITY_EDITOR
public static bool TryGetFromAsset(UnityEngine.Object src, out PathObject dst)
{
if (src == null)
{
dst = default;
return false;
}
var assetPath = AssetDatabase.GetAssetPath(src);
if (string.IsNullOrEmpty(assetPath))
{
dst = default;
return false;
}
dst = FromUnityAssetPath(assetPath);
return true;
}
public void ImportAsset()
{
AssetDatabase.ImportAsset(UnityAssetPath);
@ -198,5 +201,6 @@ namespace VRMShaders
dst = PathObject.FromFullPath(path);
return true;
}
#endif
}
}