UnityEditor.AssetModificationProcessorInternal.OnWillCreateAsset C# (CSharp) Method

OnWillCreateAsset() private static method

private static OnWillCreateAsset ( string path ) : void
path string
return void
        private static void OnWillCreateAsset(string path)
        {
            foreach (Type type in AssetModificationProcessors)
            {
                MethodInfo method = type.GetMethod("OnWillCreateAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = new object[] { path };
                    if (CheckArguments(args, method))
                    {
                        method.Invoke(null, args);
                    }
                }
            }
        }

Usage Example

        internal static Object CreateScriptAssetWithContent(string pathName, string templateContent)
        {
            AssetModificationProcessorInternal.OnWillCreateAsset(pathName);

            templateContent = SetLineEndings(templateContent, EditorSettings.lineEndingsForNewScripts);

            string fullPath = Path.GetFullPath(pathName);

            File.WriteAllText(fullPath, templateContent);

            // Import the asset
            AssetDatabase.ImportAsset(pathName);

            return(AssetDatabase.LoadAssetAtPath(pathName, typeof(Object)));
        }