mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-14 16:25:32 +01:00
max
c465ec6585
Animations can now be used by scriptable object reference. Bake saves book and animations. Checks to update instead of create+overwrite assets to keep references/configuration.
63 lines
1.2 KiB
C#
63 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
namespace TAO.VertexAnimation.Editor
|
|
{
|
|
public static class AssetDatabaseUtils
|
|
{
|
|
public static bool HasChildAsset(Object parent, Object child)
|
|
{
|
|
var assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(parent));
|
|
|
|
foreach (var a in assets)
|
|
{
|
|
if (a == child)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool TryAddChildAsset(Object parent, Object child)
|
|
{
|
|
if (!HasChildAsset(parent, child))
|
|
{
|
|
AssetDatabase.AddObjectToAsset(child, parent);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static void RemoveChildAssets(Object parent, Object[] filter = null)
|
|
{
|
|
var assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(parent));
|
|
|
|
foreach (var a in assets)
|
|
{
|
|
bool filterSkip = false;
|
|
|
|
foreach (var f in filter)
|
|
{
|
|
if (a == f)
|
|
{
|
|
filterSkip = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!filterSkip && a != parent)
|
|
{
|
|
AssetDatabase.RemoveObjectFromAsset(a);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static bool HasAsset(string path, System.Type type)
|
|
{
|
|
return (AssetDatabase.LoadAssetAtPath(path, type) ? true : false);
|
|
}
|
|
}
|
|
} |