// Animancer // Copyright 2020 Kybernetik //
#if UNITY_EDITOR
using UnityEditor;
namespace Animancer.Editor
{
/// [Editor-Only] [Internal] Automatically selects the on startup.
/// This script is in the Examples folder so that it gets deleted along with them.
[InitializeOnLoad]
internal static class ShowReadMeOnStartup
{
/************************************************************************************************************************/
static ShowReadMeOnStartup()
{
const string SessionStateKey = "Animancer.HasShownReadMe";
if (SessionState.GetBool(SessionStateKey, false))
return;
EditorApplication.delayCall += () =>
{
var asset = FindReadMe();
if (asset == null ||
asset.DontShowOnStartup)
return;
SessionState.SetBool(SessionStateKey, true);
EditorApplication.delayCall += () =>
Selection.activeObject = asset;
};
}
/************************************************************************************************************************/
private static ReadMe FindReadMe()
{
var guids = AssetDatabase.FindAssets("t:ReadMe");
for (int i = 0; i < guids.Length; i++)
{
var assetPath = AssetDatabase.GUIDToAssetPath(guids[i]);
var asset = AssetDatabase.LoadAssetAtPath(assetPath);
if (asset != null)
return asset;
}
return null;
}
/************************************************************************************************************************/
}
}
#endif