summaryrefslogtreecommitdiff
path: root/VRCSDK3Worlds/Assets/Udon/Editor/UdonImportPostProcessor.cs
blob: 8d2f2dbe9d53c60e6d94062d223b36b3e9e3ff73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.IO;
using UnityEditor;
using UnityEngine;

namespace VRC.Udon.Editor
{
    public class UdonImportPostProcessor : AssetPostprocessor
    {
        private const string PREFABS_INITIALIZED = "PrefabsInitialized";
        
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            // Get key unique to this project, exit early if we've run the function already
            string key = Path.Combine(Application.dataPath, PREFABS_INITIALIZED);
            if (EditorPrefs.HasKey(key))
                return;
            
            // Function never run for this project - compile and link all prefab programs
            foreach(string importedAsset in importedAssets)
            {
                UdonEditorManager.PopulateAssetDependenciesPrefabSerializedProgramAssetReferences(importedAsset);
            }

            UdonEditorManager.RecompileAllProgramSources();

            EditorPrefs.SetBool(key, true);
        }
    }
}