internal static HDRenderPipelineGlobalSettings Create(string path, HDRenderPipelineGlobalSettings dataSource = null)
        {
            HDRenderPipelineGlobalSettings assetCreated = null;

            //ensure folder tree exist
            CoreUtils.EnsureFolderTreeInAssetFilePath(path);

            //prevent any path conflict
            path = AssetDatabase.GenerateUniqueAssetPath(path);

            //asset creation
            assetCreated      = ScriptableObject.CreateInstance <HDRenderPipelineGlobalSettings>();
            assetCreated.name = Path.GetFileName(path);
            AssetDatabase.CreateAsset(assetCreated, path);
            Debug.Assert(assetCreated);

            // copy data from provided source
            if (dataSource != null)
            {
                EditorUtility.CopySerialized(dataSource, assetCreated);
            }

            // ensure resources are here
            assetCreated.EnsureEditorResources(forceReload: true);
            assetCreated.EnsureRuntimeResources(forceReload: true);
            assetCreated.EnsureRayTracingResources(forceReload: true);
            assetCreated.GetOrCreateDefaultVolumeProfile();
            assetCreated.GetOrAssignLookDevVolumeProfile();

            return(assetCreated);
        }
示例#2
0
        internal static HDRenderPipelineGlobalSettings Create(string path, HDRenderPipelineGlobalSettings src = null)
        {
            HDRenderPipelineGlobalSettings assetCreated = null;

            // make sure the asset does not already exists
            assetCreated = AssetDatabase.LoadAssetAtPath <HDRenderPipelineGlobalSettings>(path);
            if (assetCreated == null)
            {
                assetCreated = ScriptableObject.CreateInstance <HDRenderPipelineGlobalSettings>();
                AssetDatabase.CreateAsset(assetCreated, path);
                assetCreated.Init();
                if (assetCreated != null)
                {
                    assetCreated.name = Path.GetFileName(path);
                }
            }

            if (assetCreated)
            {
#if UNITY_EDITOR
                assetCreated.EnsureEditorResources(forceReload: true);
#endif
                if (src != null)
                {
                    assetCreated.renderPipelineResources           = src.renderPipelineResources;
                    assetCreated.renderPipelineRayTracingResources = src.renderPipelineRayTracingResources;

                    assetCreated.volumeProfile        = src.volumeProfile;
                    assetCreated.volumeProfileLookDev = src.volumeProfileLookDev;

                    assetCreated.m_RenderingPathDefaultCameraFrameSettings = src.m_RenderingPathDefaultCameraFrameSettings;
                    assetCreated.m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings = src.m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings;
                    assetCreated.m_RenderingPathDefaultRealtimeReflectionFrameSettings      = src.m_RenderingPathDefaultRealtimeReflectionFrameSettings;

                    assetCreated.beforeTransparentCustomPostProcesses.AddRange(src.beforeTransparentCustomPostProcesses);
                    assetCreated.beforePostProcessCustomPostProcesses.AddRange(src.beforePostProcessCustomPostProcesses);
                    assetCreated.afterPostProcessCustomPostProcesses.AddRange(src.afterPostProcessCustomPostProcesses);
                    assetCreated.beforeTAACustomPostProcesses.AddRange(src.beforeTAACustomPostProcesses);

                    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);

                    assetCreated.decalLayerName0 = System.String.Copy(src.decalLayerName0);
                    assetCreated.decalLayerName1 = System.String.Copy(src.decalLayerName1);
                    assetCreated.decalLayerName2 = System.String.Copy(src.decalLayerName2);
                    assetCreated.decalLayerName3 = System.String.Copy(src.decalLayerName3);
                    assetCreated.decalLayerName4 = System.String.Copy(src.decalLayerName4);
                    assetCreated.decalLayerName5 = System.String.Copy(src.decalLayerName5);
                    assetCreated.decalLayerName6 = System.String.Copy(src.decalLayerName6);
                    assetCreated.decalLayerName7 = System.String.Copy(src.decalLayerName7);

                    assetCreated.shaderVariantLogLevel = src.shaderVariantLogLevel;
                    assetCreated.lensAttenuationMode   = src.lensAttenuationMode;

                    System.Array.Resize(ref assetCreated.diffusionProfileSettingsList, src.diffusionProfileSettingsList.Length);
                    for (int i = 0; i < src.diffusionProfileSettingsList.Length; ++i)
                    {
                        assetCreated.diffusionProfileSettingsList[i] = src.diffusionProfileSettingsList[i];
                    }
                }
                else
                {
                    assetCreated.EnsureRuntimeResources(forceReload: false);
                    assetCreated.EnsureRayTracingResources(forceReload: false);
                    assetCreated.GetOrCreateDefaultVolumeProfile();
                    assetCreated.GetOrAssignLookDevVolumeProfile();
                }
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            return(assetCreated);
        }