public static void Create(bool activateAsset) { settings = null; updateGraphicsSettings = activateAsset; var path = $"Assets/{UniversalRenderPipelineGlobalSettings.defaultAssetName}.asset"; ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <UniversalGlobalSettingsCreator>(), path, CoreEditorStyles.globalSettingsIcon, null); }
static internal void UpdateGraphicsSettings(UniversalRenderPipelineGlobalSettings newSettings) { if (newSettings == null || newSettings == cachedInstance) { return; } GraphicsSettings.RegisterRenderPipelineSettings <UniversalRenderPipeline>(newSettings as RenderPipelineGlobalSettings); cachedInstance = newSettings; }
public static void Clone(UniversalRenderPipelineGlobalSettings src, bool activateAsset) { settings = src; updateGraphicsSettings = activateAsset; var path = AssetDatabase.GetAssetPath(src); var assetCreator = ScriptableObject.CreateInstance <UniversalGlobalSettingsCreator>(); ProjectWindowUtil.StartNameEditingIfProjectWindowExists(assetCreator.GetInstanceID(), assetCreator, path, CoreEditorStyles.globalSettingsIcon, null); }
public override void Action(int instanceId, string pathName, string resourceFile) { var newAsset = UniversalRenderPipelineGlobalSettings.Create(pathName, settings); if (updateGraphicsSettings) { UniversalRenderPipelineGlobalSettings.UpdateGraphicsSettings(newAsset); } ProjectWindowUtil.ShowCreatedAsset(newAsset); }
public static void Create(bool useProjectSettingsFolder, bool activateAsset) { settings = null; updateGraphicsSettings = activateAsset; var path = $"{UniversalRenderPipelineGlobalSettings.defaultAssetName}.asset"; if (useProjectSettingsFolder) { path = $"Assets/{path}"; CoreUtils.EnsureFolderTreeInAssetFilePath(path); } ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <UniversalGlobalSettingsCreator>(), path, CoreEditorStyles.globalSettingsIcon, null); }
//Making sure there is at least one UniversalRenderPipelineGlobalSettings instance in the project internal static UniversalRenderPipelineGlobalSettings Ensure(string folderPath = "", bool canCreateNewAsset = true) { if (UniversalRenderPipelineGlobalSettings.instance) { return(UniversalRenderPipelineGlobalSettings.instance); } UniversalRenderPipelineGlobalSettings assetCreated = null; string path = $"Assets/{folderPath}/{defaultAssetName}.asset"; assetCreated = AssetDatabase.LoadAssetAtPath <UniversalRenderPipelineGlobalSettings>(path); if (assetCreated == null) { var guidGlobalSettingsAssets = AssetDatabase.FindAssets("t:UniversalRenderPipelineGlobalSettings"); //If we could not find the asset at the default path, find the first one if (guidGlobalSettingsAssets.Length > 0) { var curGUID = guidGlobalSettingsAssets[0]; path = AssetDatabase.GUIDToAssetPath(curGUID); assetCreated = AssetDatabase.LoadAssetAtPath <UniversalRenderPipelineGlobalSettings>(path); } else if (canCreateNewAsset)// or create one altogether { if (!AssetDatabase.IsValidFolder("Assets/" + folderPath)) { AssetDatabase.CreateFolder("Assets", folderPath); } assetCreated = Create(path); // TODO: Reenable after next urp template is published //Debug.LogWarning("No URP Global Settings Asset is assigned. One will be created for you. If you want to modify it, go to Project Settings > Graphics > URP Settings."); } else { Debug.LogError("If you are building a Player, make sure to save an URP Global Settings asset by opening the project in the Editor first."); return(null); } } Debug.Assert(assetCreated, "Could not create URP's Global Settings - URP may not work correctly - Open Project Settings > Graphics > URP Settings for additional help."); UpdateGraphicsSettings(assetCreated); return(UniversalRenderPipelineGlobalSettings.instance); }
static void UpgradeAsset(int assetInstanceID) { UniversalRenderPipelineGlobalSettings asset = EditorUtility.InstanceIDToObject(assetInstanceID) as UniversalRenderPipelineGlobalSettings; if (asset.k_AssetVersion < 2) { #pragma warning disable 618 // Obsolete warning // Renamed supportRuntimeDebugDisplay => stripDebugVariants, which results in inverted logic asset.m_StripDebugVariants = !asset.supportRuntimeDebugDisplay; asset.k_AssetVersion = 2; #pragma warning restore 618 // Obsolete warning // For old test projects lets keep post processing stripping enabled, as huge chance they did not used runtime profile creating #if UNITY_INCLUDE_TESTS asset.m_StripUnusedPostProcessingVariants = true; #endif } EditorUtility.SetDirty(asset); }
internal static UniversalRenderPipelineGlobalSettings Create(string path, UniversalRenderPipelineGlobalSettings src = null) { UniversalRenderPipelineGlobalSettings assetCreated = null; // make sure the asset does not already exists assetCreated = AssetDatabase.LoadAssetAtPath <UniversalRenderPipelineGlobalSettings>(path); if (assetCreated == null) { assetCreated = ScriptableObject.CreateInstance <UniversalRenderPipelineGlobalSettings>(); if (assetCreated != null) { assetCreated.name = System.IO.Path.GetFileName(path); } AssetDatabase.CreateAsset(assetCreated, path); Debug.Assert(assetCreated); } if (assetCreated) { if (src != null) { assetCreated.lightLayerName0 = System.String.Copy(src.lightLayerName0); assetCreated.lightLayerName1 = System.String.Copy(src.lightLayerName1); assetCreated.lightLayerName2 = System.String.Copy(src.lightLayerName2); assetCreated.lightLayerName3 = System.String.Copy(src.lightLayerName3); assetCreated.lightLayerName4 = System.String.Copy(src.lightLayerName4); assetCreated.lightLayerName5 = System.String.Copy(src.lightLayerName5); assetCreated.lightLayerName6 = System.String.Copy(src.lightLayerName6); assetCreated.lightLayerName7 = System.String.Copy(src.lightLayerName7); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } return(assetCreated); }
static void UpgradeAsset(UniversalRenderPipelineGlobalSettings asset) { EditorUtility.SetDirty(asset); }