Beispiel #1
0
        public ScriptableObjectInfo(string path, T scriptableObject)
        {
            Path             = path;
            ScriptableObject = scriptableObject;

            string fullPath = ProjectFileUtils.GetFullPathFromProjectRelativePath(path);

            CreationTime = File.GetCreationTime(fullPath);
            ModifiedTime = File.GetLastWriteTime(fullPath);
        }
Beispiel #2
0
        /// <summary>
        /// Generates/Updates a Path for a ScriptableObject relative to the project directory.
        /// </summary>
        private static string GenerateSavePath <T>(string path = null)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = typeof(T).HasAttribute <DefaultAssetPath>() ? typeof(T).GetAttribute <DefaultAssetPath>().Path : "Assets";
            }

            if (string.IsNullOrEmpty(Path.GetExtension(path)))
            {
                path = path + "/" + typeof(T).Name + ".asset";
            }

            // Make sure the parent directories exist.
            Directory.GetParent(ProjectFileUtils.GetFullPathFromProjectRelativePath(path)).Create();
            AssetDatabase.Refresh();

            return(AssetDatabase.GenerateUniqueAssetPath(path));
        }