I'm working with Unity using Git and we have .gitignore setup so that we could create "_local" folder anywhere in Assets and it won't be commited. It makes for kind of a Debug/Backup folder, where I can put any of textures I want to check or any script I want to test in Unity, but keep it locally.


That unfortunately causes problems. After referencing many local files I decide to commit the project, so I make all the references pointing files that will be commited. Sometimes though I don't notice one wrong reference and I commit the project which causes errors on collaborators' devices.


I came up with an idea that I could write a script which goes through every reference and if any of them points to a local file it should generate a warning or error. All that would happen after saving the project.

But can it be done?

Is there a way to find all the references and call the script once the project is saved?


1 Answer 1


Yes, it can be done:



Example of usage:

using UnityEngine;
using UnityEditor;
using System.Collections;

public class FileModificationWarning : SaveAssetsProcessor
    static string[] OnWillSaveAssets(string[] paths)
        foreach (string path in paths)
        return paths;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .