Beispiel #1
0
        public static void CompileAllCsPrograms(bool forceCompile = false, bool editorBuild = true)
        {
            UdonSharpProgramAsset[] programs = GetAllUdonSharpPrograms();

            if (!forceCompile)
            {
                UdonSharpEditorCache cache = UdonSharpEditorCache.Instance;
                bool needsCompile          = false;
                foreach (UdonSharpProgramAsset programAsset in programs)
                {
                    if (cache.IsSourceFileDirty(programAsset))
                    {
                        needsCompile = true;
                        break;
                    }
                }

                if (!needsCompile)
                {
                    return;
                }
            }

            UdonSharpCompiler compiler = new UdonSharpCompiler(programs, editorBuild);

            compiler.Compile();
        }
Beispiel #2
0
        private static UdonSharpEditorCache GetInstance()
        {
            lock (instanceLock)
            {
                if (_instance != null)
                {
                    return(_instance);
                }

                _instance = new UdonSharpEditorCache();

                if (File.Exists(CACHE_FILE_PATH))
                {
                    SourceHashLookupStorage storage = SerializationUtility.DeserializeValue <SourceHashLookupStorage>(File.ReadAllBytes(CACHE_FILE_PATH), DataFormat.Binary);
                    _instance.sourceFileHashLookup = storage.sourceFileHashLookup;
                    _instance.LastBuildType        = storage.lastScriptBuildType;
                }

                return(_instance);
            }
        }
        private static UdonSharpEditorCache GetInstance()
        {
            lock (_instanceLock)
            {
                if (_instance != null)
                {
                    return(_instance);
                }

                _instance = new UdonSharpEditorCache();
                _instance._info.version             = CURR_CACHE_VER;
                _instance._info.projectNeedsUpgrade = true;

                if (!File.Exists(CACHE_FILE_PATH))
                {
                    return(_instance);
                }

                UdonSharpCacheStorage storage = SerializationUtility.DeserializeValue <UdonSharpCacheStorage>(File.ReadAllBytes(CACHE_FILE_PATH), DataFormat.Binary);
                _instance._sourceFileHashLookup = storage.sourceFileHashLookup;
                _instance.LastBuildType         = storage.lastScriptBuildType;
                _instance._info        = storage.info;
                _instance._diagnostics = storage.diagnostics ?? Array.Empty <CompileDiagnostic>();

                // For now we just use this to see if we need to check for project serialization upgrade, may be extended later on. At the moment only used to avoid wasting time on extra validation when possible.
                // Hey now we use this to nuke out old data too
                if (_instance._info.version < CURR_CACHE_VER)
                {
                    _instance._info.version             = CURR_CACHE_VER;
                    _instance._sourceFileHashLookup     = new Dictionary <string, string>();
                    _instance._info.projectNeedsUpgrade = true;
                }

                return(_instance);
            }
        }
        public bool OnBuildRequested(VRCSDKRequestedBuildType requestedBuildType)
        {
            if (requestedBuildType == VRCSDKRequestedBuildType.Avatar)
            {
                return(true);
            }

            if (UdonSharpSettings.GetSettings()?.disableUploadCompile ?? false)
            {
                return(true);
            }

            UdonSharpProgramAsset.CompileAllCsPrograms(true, false);
            UdonSharpEditorCache.SaveAllCache();

            if (UdonSharpProgramAsset.AnyUdonSharpScriptHasError())
            {
                Debug.LogError("[<color=#FF00FF>UdonSharp</color>] Failed to compile UdonSharp scripts for build, check error log for details.");
                UdonSharpUtils.ShowEditorNotification("Failed to compile UdonSharp scripts for build, check error log for details.");
                return(false);
            }

            return(true);
        }
Beispiel #5
0
 internal static void ResetInstance()
 {
     _instance = null;
 }