// Create a populated 'BuildUsageTagGlobal' instance.  Can set fields directly for 2019.4+ as internals are available but have to use reflection for 2018.4
        static BuildUsageTagGlobal CreateBuildUsageTagGlobal(uint lightmapModesUsed, uint legacyLightmapModesUsed, uint dynamicLightmapsUsed, uint fogModesUsed, bool forceInstancingStrip, bool forceInstancingKeep, bool shadowMasksUsed, bool subtractiveUsed, bool hybridRendererPackageUsed)
        {
            BuildUsageTagGlobal buildUsageTagGlobal = new BuildUsageTagGlobal();

#if UNITY_2019_4_OR_NEWER
            buildUsageTagGlobal.m_LightmapModesUsed       = lightmapModesUsed;
            buildUsageTagGlobal.m_LegacyLightmapModesUsed = legacyLightmapModesUsed;
            buildUsageTagGlobal.m_DynamicLightmapsUsed    = dynamicLightmapsUsed;
            buildUsageTagGlobal.m_FogModesUsed            = fogModesUsed;
            buildUsageTagGlobal.m_ForceInstancingStrip    = forceInstancingStrip;
            buildUsageTagGlobal.m_ForceInstancingKeep     = forceInstancingKeep;
            buildUsageTagGlobal.m_ShadowMasksUsed         = shadowMasksUsed;
            buildUsageTagGlobal.m_SubtractiveUsed         = subtractiveUsed;
#if UNITY_2020_1_OR_NEWER
            buildUsageTagGlobal.m_HybridRendererPackageUsed = hybridRendererPackageUsed;
#endif
#else
            SetFieldValue(buildUsageTagGlobal, "m_LightmapModesUsed", lightmapModesUsed);
            SetFieldValue(buildUsageTagGlobal, "m_LegacyLightmapModesUsed", legacyLightmapModesUsed);
            SetFieldValue(buildUsageTagGlobal, "m_DynamicLightmapsUsed", dynamicLightmapsUsed);
            SetFieldValue(buildUsageTagGlobal, "m_FogModesUsed", fogModesUsed);
            SetFieldValue(buildUsageTagGlobal, "m_ForceInstancingStrip", forceInstancingStrip);
            SetFieldValue(buildUsageTagGlobal, "m_ForceInstancingKeep", forceInstancingKeep);
            SetFieldValue(buildUsageTagGlobal, "m_ShadowMasksUsed", shadowMasksUsed);
            SetFieldValue(buildUsageTagGlobal, "m_SubtractiveUsed", subtractiveUsed);
#endif

            return(buildUsageTagGlobal);
        }
 private static void GetFogModeUsageFromCurrentScene(ref BuildUsageTagGlobal inoutUsage)
 {
     if (RenderSettings.fog)
     {
         inoutUsage.m_FogModesUsed |= (1 << (int)RenderSettings.fogMode);
     }
 }
示例#3
0
        /// <inheritdoc />
        public ReturnCode Run()
        {
            m_CustomAssets = new CustomAssets();
            m_GlobalUsage  = m_DependencyData.GlobalUsage;
            foreach (SceneDependencyInfo sceneInfo in m_DependencyData.SceneInfo.Values)
            {
                m_GlobalUsage |= sceneInfo.globalUsage;
            }

            foreach (CustomContent info in m_Content.CustomAssets)
            {
                if (!m_Tracker.UpdateInfoUnchecked(info.Asset.ToString()))
                {
                    return(ReturnCode.Canceled);
                }

                using (m_Log.ScopedStep(LogLevel.Verbose, "CustomAssetDependency", info.Asset.ToString()))
                    info.Processor(info.Asset, this);
            }

            // Add all the additional global usage for custom assets back into the dependency data result
            // for use in the write serialized file build task
            m_DependencyData.GlobalUsage |= m_CustomUsage;
            return(ReturnCode.Success);
        }
 public TestDependencyData(Dictionary <GUID, AssetLoadInfo> assetInfo)
 {
     m_AssetInfo   = assetInfo;
     m_GlobalUsage = new BuildUsageTagGlobal();
     m_SceneInfo   = new Dictionary <GUID, SceneDependencyInfo>();
     m_AssetUsage  = new Dictionary <GUID, BuildUsageTagSet>();
 }
        static SceneDependencyInfo CreateSyntheticSceneDependencyInfo(System.Random rnd)
        {
            BuildUsageTagGlobal buildUsageTagGlobal = CreateBuildUsageTagGlobal((uint)rnd.Next(100), (uint)rnd.Next(100), (uint)rnd.Next(100), (uint)rnd.Next(100), ((rnd.Next() & 1) != 0), ((rnd.Next() & 1) != 0), ((rnd.Next() & 1) != 0), ((rnd.Next() & 1) != 0), ((rnd.Next() & 1) != 0));

            return(CreateSceneDependencyInfo("SceneName", new ObjectIdentifier[2] {
                CreateObjectIdentifier(rnd), CreateObjectIdentifier(rnd)
            }, buildUsageTagGlobal, new Type[] { typeof(MonoBehaviour), typeof(ScriptableObject) }));
        }
        static unsafe BuildUsageTagGlobal ForceKeepInstancingVariants(BuildUsageTagGlobal globalUsage)
        {
            BlobGlobalUsage blob = *(BlobGlobalUsage *)&globalUsage;

            blob.m_ForceInstancingStrip = false;
            blob.m_ForceInstancingKeep  = true;
            return(*(BuildUsageTagGlobal *)&blob);
        }
示例#7
0
#pragma warning restore 649

        CacheEntry GetCacheEntry(IWriteOperation operation, BuildSettings settings, BuildUsageTagGlobal globalUsage)
        {
            var entry = new CacheEntry();

            entry.Type = CacheEntry.EntryType.Data;
            entry.Guid = HashingMethods.Calculate("WriteSerializedFiles", operation.Command.internalName).ToGUID();
            entry.Hash = HashingMethods.Calculate(Version, operation.GetHash128(), settings.GetHash128(), globalUsage).ToHash128();
            return(entry);
        }
#pragma warning restore 649

        CacheEntry GetCacheEntry(IWriteOperation operation, BuildSettings settings, BuildUsageTagGlobal globalUsage, bool onlySaveFirstSerializedObject)
        {
            var entry = new CacheEntry();

            entry.Type    = CacheEntry.EntryType.Data;
            entry.Guid    = HashingMethods.Calculate("WriteSerializedFiles").ToGUID();
            entry.Hash    = HashingMethods.Calculate(Version, operation.GetHash128(), settings.GetHash128(), globalUsage, onlySaveFirstSerializedObject).ToHash128();
            entry.Version = Version;
            return(entry);
        }
示例#9
0
        CacheEntry GetCacheEntry(string path, BuildUsageTagGlobal additionalGlobalUsage)
        {
            var entry = new CacheEntry();

            entry.Type    = CacheEntry.EntryType.Data;
            entry.Guid    = HashingMethods.Calculate("CalculateCustomDependencyData", path).ToGUID();
            entry.Hash    = HashingMethods.Calculate(HashingMethods.CalculateFile(path), additionalGlobalUsage).ToHash128();
            entry.Version = Version;
            return(entry);
        }
示例#10
0
        internal void SetupTaskContext()
        {
            m_GlobalUsage = m_DependencyData.GlobalUsage;
            foreach (var sceneInfo in m_DependencyData.SceneInfo)
            {
                m_GlobalUsage |= sceneInfo.Value.globalUsage;
            }

            m_BuildSettings = m_Parameters.GetContentBuildSettings();
            m_UseCache      = m_Parameters.UseCache ? m_Cache : null;
        }
示例#11
0
 CacheEntry GetCacheEntry(IWriteOperation operation, BuildSettings settings, BuildUsageTagGlobal globalUsage, bool onlySaveFirstSerializedObject)
 {
     using (m_Log.ScopedStep(LogLevel.Verbose, "GetCacheEntry", operation.Command.fileName))
     {
         var entry = new CacheEntry();
         entry.Type    = CacheEntry.EntryType.Data;
         entry.Guid    = HashingMethods.Calculate("WriteSerializedFiles", operation.Command.fileName).ToGUID();
         entry.Hash    = HashingMethods.Calculate(Version, operation.GetHash128(m_Log), settings.GetHash128(), globalUsage, onlySaveFirstSerializedObject, GetPlayerSettingsHash128(settings.target)).ToHash128();
         entry.Version = Version;
         return(entry);
     }
 }
示例#12
0
        /// <inheritdoc />
        public WriteResult Write(string outputFolder, BuildSettings settings, BuildUsageTagGlobal globalUsage)
        {
#if UNITY_2019_3_OR_NEWER
            return(ContentBuildInterface.WriteSerializedFile(outputFolder, new WriteParameters
            {
                writeCommand = Command,
                settings = settings,
                globalUsage = globalUsage,
                usageSet = UsageSet,
                referenceMap = ReferenceMap
            }));
#else
            return(ContentBuildInterface.WriteSerializedFile(outputFolder, Command, settings, globalUsage, UsageSet, ReferenceMap));
#endif
        }
        public ReturnCode Run()
        {
            m_GlobalUsage = m_DependencyData.GlobalUsage;
            foreach (SceneDependencyInfo sceneInfo in m_DependencyData.SceneInfo.Values)
            {
                m_GlobalUsage |= sceneInfo.globalUsage;
            }

            for (int i = 0; i < m_Content.CustomAssets.Count; i++)
            {
                CustomContent info = m_Content.CustomAssets[i];
                info.Processor(info.Asset, this);
            }
            return(ReturnCode.Success);
        }
        /// <inheritdoc />
        public WriteResult Write(string outputFolder, BuildSettings settings, BuildUsageTagGlobal globalUsage)
        {
#if UNITY_2019_3_OR_NEWER
            return(ContentBuildInterface.WriteSceneSerializedFile(outputFolder, new WriteSceneParameters
            {
                scenePath = Scene,
                writeCommand = Command,
                settings = settings,
                globalUsage = globalUsage,
                usageSet = UsageSet,
                referenceMap = ReferenceMap,
                preloadInfo = PreloadInfo
            }));
#else
            return(ContentBuildInterface.WriteSceneSerializedFile(outputFolder, Scene, ProcessedScene, Command, settings, globalUsage, UsageSet, ReferenceMap, PreloadInfo));
#endif
        }
示例#15
0
        /// <summary>
        /// Returns the Object Identifiers and Types in a raw Unity Serialized File. The resulting arrays will be empty if a non-serialized file path was used.
        /// </summary>
        /// <param name="path">Path to the Unity Serialized File</param>
        /// <param name="objectIdentifiers">Object Identifiers for all the objects in the serialized file</param>
        /// <param name="types">Types for all the objects in the serialized file</param>
        /// <param name="additionalGlobalUsage">Additional global lighting usage information to include with this custom asset</param>
        public void GetObjectIdentifiersAndTypesForSerializedFile(string path, out ObjectIdentifier[] objectIdentifiers, out Type[] types, BuildUsageTagGlobal additionalGlobalUsage)
        {
            // Additional global usage is local to the custom asset, so we are using a local copy of this additional data to avoid influencing the calcualtion
            // of other custom assets. Additionally we store all the addtional global usage for later copying back into the dependency data result for the final write build task.
            var globalUsage = m_GlobalUsage | additionalGlobalUsage;

            m_CustomUsage = m_CustomUsage | additionalGlobalUsage;
            if (!LoadCachedData(path, out var assetInfo, out var buildUsage, globalUsage))
            {
                GatherAssetData(path, out assetInfo, out buildUsage, globalUsage);
            }

            // Local cache to reuse data from this function in the next function
            m_AssetInfo[path]  = assetInfo;
            m_BuildUsage[path] = buildUsage;

            objectIdentifiers = assetInfo.includedObjects.ToArray();
            types             = BuildCacheUtility.GetSortedUniqueTypesForObjects(objectIdentifiers);
        }
示例#16
0
        /// <inheritdoc />
        public ReturnCode Run()
        {
            m_CustomAssets = new CustomAssets();
            m_GlobalUsage  = m_DependencyData.GlobalUsage;
            foreach (SceneDependencyInfo sceneInfo in m_DependencyData.SceneInfo.Values)
            {
                m_GlobalUsage |= sceneInfo.globalUsage;
            }

            foreach (CustomContent info in m_Content.CustomAssets)
            {
                if (!m_Tracker.UpdateInfoUnchecked(info.Asset.ToString()))
                {
                    return(ReturnCode.Canceled);
                }

                info.Processor(info.Asset, this);
            }
            return(ReturnCode.Success);
        }
示例#17
0
 /// <inheritdoc />
 public WriteResult Write(string outputFolder, BuildSettings settings, BuildUsageTagGlobal globalUsage)
 {
     return(ContentBuildInterface.WriteSerializedFile(outputFolder, Command, settings, globalUsage, UsageSet, ReferenceMap));
 }
示例#18
0
        /// <inheritdoc />
        public ReturnCode Run()
        {
            BuildUsageTagGlobal globalUsage = m_DependencyData.GlobalUsage;

            foreach (var sceneInfo in m_DependencyData.SceneInfo)
            {
                globalUsage |= sceneInfo.Value.globalUsage;
            }

            IList <CacheEntry> entries      = m_WriteData.WriteOperations.Select(x => GetCacheEntry(x, m_Parameters.GetContentBuildSettings(), globalUsage)).ToList();
            IList <CachedInfo> cachedInfo   = null;
            IList <CachedInfo> uncachedInfo = null;

            if (m_Parameters.UseCache && m_Cache != null)
            {
                m_Cache.LoadCachedData(entries, out cachedInfo);

                uncachedInfo = new List <CachedInfo>();
            }

            for (int i = 0; i < m_WriteData.WriteOperations.Count; i++)
            {
                IWriteOperation op = m_WriteData.WriteOperations[i];

                WriteResult result;
                if (cachedInfo != null && cachedInfo[i] != null)
                {
                    if (!m_Tracker.UpdateInfoUnchecked(string.Format("{0} (Cached)", op.Command.internalName)))
                    {
                        return(ReturnCode.Canceled);
                    }

                    result = (WriteResult)cachedInfo[i].Data[0];
                }
                else
                {
                    if (!m_Tracker.UpdateInfoUnchecked(op.Command.internalName))
                    {
                        return(ReturnCode.Canceled);
                    }

                    var outputFolder = m_Parameters.TempOutputFolder;
                    if (m_Parameters.UseCache && m_Cache != null)
                    {
                        outputFolder = m_Cache.GetCachedArtifactsDirectory(entries[i]);
                    }
                    Directory.CreateDirectory(outputFolder);

                    result = op.Write(outputFolder, m_Parameters.GetContentBuildSettings(), globalUsage);

                    if (uncachedInfo != null)
                    {
                        uncachedInfo.Add(GetCachedInfo(entries[i], op, result));
                    }
                }

                SetOutputInformation(op.Command.internalName, result);
            }

            if (m_Parameters.UseCache && m_Cache != null)
            {
                m_Cache.SaveCachedData(uncachedInfo);
            }

            return(ReturnCode.Success);
        }
        private static BuildUsageTagGlobal GetSceneBuildUsageTag(UScene varScene)
        {
            var tempSetting                      = new SerializedObject(GetGraphicsSettings());
            var m_LightmapStripping              = tempSetting.FindProperty("m_LightmapStripping").intValue;
            var m_LightmapKeepPlain              = tempSetting.FindProperty("m_LightmapKeepPlain").boolValue;
            var m_LightmapKeepDirCombined        = tempSetting.FindProperty("m_LightmapKeepDirCombined").boolValue;
            var m_LightmapKeepDynamicPlain       = tempSetting.FindProperty("m_LightmapKeepDynamicPlain").boolValue;
            var m_LightmapKeepDynamicDirCombined = tempSetting.FindProperty("m_LightmapKeepDynamicDirCombined").boolValue;
            var m_LightmapKeepShadowMask         = tempSetting.FindProperty("m_LightmapKeepShadowMask").boolValue;
            var m_LightmapKeepSubtractive        = tempSetting.FindProperty("m_LightmapKeepSubtractive").boolValue;
            var m_FogStripping                   = tempSetting.FindProperty("m_FogStripping").intValue;
            var m_FogKeepLinear                  = tempSetting.FindProperty("m_FogKeepLinear").boolValue;
            var m_FogKeepExp                     = tempSetting.FindProperty("m_FogKeepExp").boolValue;
            var m_FogKeepExp2                    = tempSetting.FindProperty("m_FogKeepExp2").boolValue;
            var m_InstancingStripping            = tempSetting.FindProperty("m_InstancingStripping").intValue;

            var tempTag = new BuildUsageTagGlobal();

            if (m_LightmapStripping == (int)ShaderStrippingMode.kShaderStrippingAutomatic)
            {
                AddLightmapModeUsageFromCurrentSceneToBuildUsage(ref tempTag);
            }
            else
            {
                if (m_LightmapKeepPlain)
                {
                    tempTag.m_LegacyLightmapModesUsed |= (1 << (int)LightmapsModeLegacy.kSingleLightmapsMode);
                }
                if (m_LightmapKeepDirCombined)
                {
                    tempTag.m_LegacyLightmapModesUsed |= (1 << (int)LightmapsModeLegacy.kDirectionalLightmapsMode);
                }

                if (m_LightmapKeepPlain)
                {
                    tempTag.m_LightmapModesUsed |= (1 << (int)LightmapsMode.kNonDirectionalLightmapsMode);
                }
                if (m_LightmapKeepDirCombined)
                {
                    tempTag.m_LightmapModesUsed |= (1 << (int)LightmapsMode.kCombinedDirectionalLightmapsMode);
                }

                if (m_LightmapKeepDynamicPlain)
                {
                    tempTag.m_DynamicLightmapsUsed |= (1 << (int)LightmapsMode.kNonDirectionalLightmapsMode);
                }
                if (m_LightmapKeepDynamicDirCombined)
                {
                    tempTag.m_DynamicLightmapsUsed |= (1 << (int)LightmapsMode.kCombinedDirectionalLightmapsMode);
                }

                if (m_LightmapKeepShadowMask)
                {
                    tempTag.m_ShadowMasksUsed = true;
                }
                if (m_LightmapKeepSubtractive)
                {
                    tempTag.m_SubtractiveUsed = true;
                }
            }

            if (m_FogStripping == (int)ShaderStrippingMode.kShaderStrippingAutomatic)
            {
                GetFogModeUsageFromCurrentScene(ref tempTag);
            }
            else
            {
                if (m_FogKeepLinear)
                {
                    tempTag.m_FogModesUsed |= (1 << (int)FogMode.kFogLinear);
                }
                if (m_FogKeepExp)
                {
                    tempTag.m_FogModesUsed |= (1 << (int)FogMode.kFogExp);
                }
                if (m_FogKeepExp2)
                {
                    tempTag.m_FogModesUsed |= (1 << (int)FogMode.kFogExp2);
                }
            }

            tempTag.m_ForceInstancingStrip = (m_InstancingStripping == (int)InstancingStrippingMode.kInstancingStrippingStripAll);
            tempTag.m_ForceInstancingKeep  = (m_InstancingStripping == (int)InstancingStrippingMode.kInstancingStrippingKeepAll);

            return(tempTag);
        }
        private static void AddLightmapModeUsageFromCurrentSceneToBuildUsage(ref BuildUsageTagGlobal inoutUsage)
        {
            var HasLightmapTextures = LightmapSettings.lightmaps.Length > 0;

            if (HasLightmapTextures)
            {
                if (Lightmapping.giWorkflowMode != Lightmapping.GIWorkflowMode.Legacy)
                {
                    inoutUsage.m_LightmapModesUsed |= (1 << (int)LightmapSettings.lightmapsMode);

                    var HasShadowMaskTextures = false;
                    var tempLightMaps         = LightmapSettings.lightmaps;
                    var tempCount             = tempLightMaps.Length;
                    for (int iL = 0; iL < tempCount; iL++)
                    {
                        var tempData = tempLightMaps[iL];
                        if (tempData.shadowMask != null)
                        {
                            HasShadowMaskTextures = true;
                            break;
                        }
                    }

                    if (HasShadowMaskTextures)
                    {
                        inoutUsage.m_ShadowMasksUsed |= true;
                    }
                    else
                    {
                        inoutUsage.m_SubtractiveUsed |= LightmapEditorSettings.mixedBakeMode == MixedLightingMode.Subtractive;
                    }
                }
                else
                {
                    inoutUsage.m_LegacyLightmapModesUsed |= (1 << (int)LightmapsModeLegacy.kSingleLightmapsMode);
                }
            }

            var DynamicGILightmapTextures    = GetRealtimeGITextures();
            var HasDynamicGILightmapTextures = DynamicGILightmapTextures != null && DynamicGILightmapTextures.Length != 0;

            if (HasDynamicGILightmapTextures)
            {
                inoutUsage.m_DynamicLightmapsUsed |= (1 << (int)LightmapSettings.lightmapsMode);
            }

            var tempTargetPlatform = EditorUserBuildSettings.activeBuildTarget;
            var tempAPIs           = PlayerSettings.GetGraphicsAPIs(tempTargetPlatform);

            foreach (var renderer in tempAPIs)
            {
                if ((renderer == GraphicsDeviceType.OpenGLES2) || (renderer == GraphicsDeviceType.Direct3D11 && tempTargetPlatform == BuildTarget.WSAPlayer))
                {
                    if (HasLightmapTextures)
                    {
                        inoutUsage.m_LightmapModesUsed       |= (1 << (int)LightmapsMode.kNonDirectionalLightmapsMode);
                        inoutUsage.m_LegacyLightmapModesUsed |= (1 << (int)LightmapsModeLegacy.kSingleLightmapsMode);
                    }

                    if (HasDynamicGILightmapTextures)
                    {
                        inoutUsage.m_DynamicLightmapsUsed |= (1 << (int)LightmapsMode.kNonDirectionalLightmapsMode);
                    }
                }
            }
        }
示例#21
0
        void GatherAssetData(string path, out AssetLoadInfo assetInfo, out BuildUsageTagSet buildUsage, BuildUsageTagGlobal globalUsage)
        {
            assetInfo  = new AssetLoadInfo();
            buildUsage = new BuildUsageTagSet();

            var includedObjects   = ContentBuildInterface.GetPlayerObjectIdentifiersInSerializedFile(path, m_Parameters.Target);
            var referencedObjects = ContentBuildInterface.GetPlayerDependenciesForObjects(includedObjects, m_Parameters.Target, m_Parameters.ScriptInfo);

            assetInfo.includedObjects   = new List <ObjectIdentifier>(includedObjects);
            assetInfo.referencedObjects = new List <ObjectIdentifier>(referencedObjects);

            ContentBuildInterface.CalculateBuildUsageTags(referencedObjects, includedObjects, globalUsage, buildUsage, m_DependencyData.DependencyUsageCache);
        }
 private static extern void CalculateBuildUsageTags_Injected(ObjectIdentifier[] objectIDs, ObjectIdentifier[] dependentObjectIDs, ref BuildUsageTagGlobal globalUsage, BuildUsageTagSet usageSet);
 public virtual WriteResult Write(string outputFolder, List <WriteCommand> dependencies, BuildSettings settings, BuildUsageTagGlobal globalUsage, BuildUsageTagSet buildUsage)
 {
     return(BundleBuildInterface.WriteSerializedFile(outputFolder, command, dependencies, settings, globalUsage, buildUsage));
 }
 public override WriteResult Write(string outputFolder, List <WriteCommand> dependencies, BuildSettings settings, BuildUsageTagGlobal globalUsage, BuildUsageTagSet buildUsage)
 {
     buildUsage.UnionWith(usageTags);
     return(BundleBuildInterface.WriteSceneSerializedFile(outputFolder, scene, processedScene, command, dependencies, settings, globalUsage, buildUsage, preloadInfo, info));
 }
 public static void CalculateBuildUsageTags(ObjectIdentifier[] objectIDs, ObjectIdentifier[] dependentObjectIDs, BuildUsageTagGlobal globalUsage, BuildUsageTagSet usageSet)
 {
     BundleBuildInterface.CalculateBuildUsageTags_Injected(objectIDs, dependentObjectIDs, ref globalUsage, usageSet);
 }
 extern public static void CalculateBuildUsageTags(ObjectIdentifier[] objectIDs, ObjectIdentifier[] dependentObjectIDs, BuildUsageTagGlobal globalUsage, BuildUsageTagSet usageSet);
示例#27
0
        internal static BuildUsageTagGlobal GetGlobalUsage()
        {
            OnEnable();

            if (m_LightmapStripping.intValue != 0)
            {
                if (m_LightmapKeepPlain.boolValue)
                {
                    m_LegacyLightmapModesUsed_Value |= (1 << 0);
                }
                if (m_LightmapKeepDirCombined.boolValue)
                {
                    m_LegacyLightmapModesUsed_Value |= (1 << 2);
                }

                if (m_LightmapKeepPlain.boolValue)
                {
                    m_LightmapModesUsed_Value |= (1 << 0);
                }
                if (m_LightmapKeepDirCombined.boolValue)
                {
                    m_LightmapModesUsed_Value |= (1 << 1);
                }

                if (m_LightmapKeepDynamicPlain.boolValue)
                {
                    m_DynamicLightmapsUsed_Value |= (1 << 0);
                }
                if (m_LightmapKeepDynamicDirCombined.boolValue)
                {
                    m_DynamicLightmapsUsed_Value |= (1 << 1);
                }

                if (m_LightmapKeepShadowMask.boolValue)
                {
                    m_ShadowMasksUsed_Value = true;
                }
                if (m_LightmapKeepSubtractive.boolValue)
                {
                    m_SubtractiveUsed_Value = true;
                }
            }

            if (m_FogStripping.intValue != 0)
            {
                if (m_FogKeepLinear.boolValue)
                {
                    m_FogModesUsed_Value |= (1 << 1);
                }
                if (m_FogKeepExp.boolValue)
                {
                    m_FogModesUsed_Value |= (1 << 2);
                }
                if (m_FogKeepExp2.boolValue)
                {
                    m_FogModesUsed_Value |= (1 << 3);
                }
            }

            m_ForceInstancingStrip_Value = (m_InstancingStripping.intValue == 1);
            m_ForceInstancingKeep_Value  = (m_InstancingStripping.intValue == 2);

            BuildUsageTagGlobal globalUsage = new BuildUsageTagGlobal();
            var boxedUsage = (object)globalUsage;

            m_LightmapModesUsed.SetValue(boxedUsage, m_LightmapModesUsed_Value);
            m_LegacyLightmapModesUsed.SetValue(boxedUsage, m_LegacyLightmapModesUsed_Value);
            m_DynamicLightmapsUsed.SetValue(boxedUsage, m_DynamicLightmapsUsed_Value);
            m_FogModesUsed.SetValue(boxedUsage, m_FogModesUsed_Value);
            m_ForceInstancingStrip.SetValue(boxedUsage, m_ForceInstancingStrip_Value);
            m_ForceInstancingKeep.SetValue(boxedUsage, m_ForceInstancingKeep_Value);
            m_ShadowMasksUsed.SetValue(boxedUsage, m_ShadowMasksUsed_Value);
            m_SubtractiveUsed.SetValue(boxedUsage, m_SubtractiveUsed_Value);
            globalUsage = (BuildUsageTagGlobal)boxedUsage;
            return(globalUsage);
        }
示例#28
0
        bool LoadCachedData(string path, out AssetLoadInfo assetInfo, out BuildUsageTagSet buildUsage, BuildUsageTagGlobal globalUsage)
        {
            assetInfo  = default;
            buildUsage = default;

            if (!m_Parameters.UseCache || m_Cache == null)
            {
                return(false);
            }

            CacheEntry entry = GetCacheEntry(path, globalUsage);

            m_Cache.LoadCachedData(new List <CacheEntry> {
                entry
            }, out IList <CachedInfo> cachedInfos);
            var cachedInfo = cachedInfos[0];

            if (cachedInfo != null)
            {
                assetInfo  = (AssetLoadInfo)cachedInfo.Data[0];
                buildUsage = (BuildUsageTagSet)cachedInfo.Data[1];
                var objectTypes = (List <KeyValuePair <ObjectIdentifier, Type[]> >)cachedInfo.Data[2];
                BuildCacheUtility.SetTypeForObjects(objectTypes);
            }
            else
            {
                GatherAssetData(path, out assetInfo, out buildUsage, globalUsage);
                cachedInfo = GetCachedInfo(entry, assetInfo, buildUsage);
                m_Cache.SaveCachedData(new List <CachedInfo> {
                    cachedInfo
                });
            }
            return(true);
        }
        // Create a populated 'SceneDependencyInfo' instance.  Can set fields directly for 2019.4+ as internals are available but have to use reflection for 2018.4
        static SceneDependencyInfo CreateSceneDependencyInfo(string scene, ObjectIdentifier[] objectIdentifiers, BuildUsageTagGlobal globalUsage, Type[] includedTypes)
        {
            SceneDependencyInfo sceneDependencyInfo = new SceneDependencyInfo();

#if UNITY_2019_4_OR_NEWER
            sceneDependencyInfo.m_Scene             = scene;
            sceneDependencyInfo.m_ReferencedObjects = objectIdentifiers;
            sceneDependencyInfo.m_GlobalUsage       = globalUsage;

#if UNITY_2020_1_OR_NEWER
            sceneDependencyInfo.m_IncludedTypes = includedTypes;
#endif
#else
            sceneDependencyInfo.SetScene(scene);
            sceneDependencyInfo.SetReferencedObjects(objectIdentifiers);
            SetFieldValue(sceneDependencyInfo, "m_GlobalUsage", globalUsage);
#endif

            return(sceneDependencyInfo);
        }