浏览代码
Merge pull request #161 from Unity-Technologies/Branch_SceneSettings
Merge pull request #161 from Unity-Technologies/Branch_SceneSettings
Added Scene Setting manager for better handling of scene settings for users./Branch_Batching2
GitHub
8 年前
当前提交
207a9a78
共有 44 个文件被更改,包括 378 次插入 和 312 次删除
-
2Assets/ScriptableRenderPipeline.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline.meta
-
16Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor.meta
-
106Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
-
7Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
-
14Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.asset
-
91Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Resources.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass.meta
-
24Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Material.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit.meta
-
33Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettings.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky.meta
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Editor/HDRISkyEditor.cs
-
6Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
-
26Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources.meta
-
38Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyRenderer.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs
-
64Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs
-
81Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs
-
12Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs.meta
-
15Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkySettings.cs
-
17Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs
-
45Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipeWindow.cs
-
15Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs
-
17Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParametersSingleton.cs
-
20Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset
-
9Assets/TestScenes/HDTest/CascadedShadowsTest/HDRISkyParameters_Cascaded.asset.meta
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs.meta
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkySettings.cs.meta
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs.meta
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkySettings.cs
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettingsSingleton.cs.meta
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs.meta
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkySettings.cs
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class SceneSettingsManagementWindow : EditorWindow |
|||
{ |
|||
[MenuItem("HDRenderPipeline/Scene Settings Management")] |
|||
static void SceneSettingsManagement() |
|||
{ |
|||
GetWindow<SceneSettingsManagementWindow>().Show(); |
|||
} |
|||
|
|||
static private string m_LastCreationPath = "Assets"; |
|||
|
|||
void CreateAsset<AssetType>(string assetName) where AssetType : ScriptableObject |
|||
{ |
|||
string assetPath = EditorUtility.SaveFilePanel("Create new Asset", m_LastCreationPath, assetName, "asset"); |
|||
if (!string.IsNullOrEmpty(assetPath)) |
|||
{ |
|||
assetPath = assetPath.Substring(assetPath.LastIndexOf("Assets")); |
|||
m_LastCreationPath = System.IO.Path.GetDirectoryName(assetPath); |
|||
var instance = CreateInstance<AssetType>(); |
|||
AssetDatabase.CreateAsset(instance, assetPath); |
|||
} |
|||
} |
|||
|
|||
void OnGUI() |
|||
{ |
|||
// Keep it there temporarily until it's back to an "engine" setting in the HDRenderPipeline asset.
|
|||
SubsurfaceScatteringSettings.overrideSettings = (SubsurfaceScatteringParameters)EditorGUILayout.ObjectField(new GUIContent("SSS Settings"), SubsurfaceScatteringSettings.overrideSettings, typeof(SubsurfaceScatteringParameters), false); |
|||
EditorGUILayout.Space(); |
|||
|
|||
if (GUILayout.Button("Create new Common Settings")) |
|||
{ |
|||
CreateAsset<CommonSettings>("NewCommonSettings"); |
|||
} |
|||
|
|||
if (GUILayout.Button("Create new HDRI sky params")) |
|||
{ |
|||
CreateAsset<HDRISkySettings>("NewHDRISkySettings"); |
|||
} |
|||
|
|||
if (GUILayout.Button("Create new Procedural sky params")) |
|||
{ |
|||
CreateAsset<ProceduralSkySettings>("NewProceduralSkyParameters"); |
|||
} |
|||
|
|||
if (GUILayout.Button("Create new SSS params")) |
|||
{ |
|||
CreateAsset<SubsurfaceScatteringParameters>("NewSssParameters"); |
|||
} |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
if (GUILayout.Button("Create Scene Settings")) |
|||
{ |
|||
var manager = new GameObject(); |
|||
manager.name = "Scene Settings"; |
|||
manager.AddComponent<SceneSettings>(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class SceneSettingsManager |
|||
{ |
|||
static private SceneSettingsManager s_Instance = null; |
|||
static public SceneSettingsManager instance |
|||
{ |
|||
get |
|||
{ |
|||
if(s_Instance == null) |
|||
s_Instance = new SceneSettingsManager(); |
|||
|
|||
return s_Instance; |
|||
} |
|||
} |
|||
|
|||
private List<SceneSettings> m_SceneSettingsList = new List<SceneSettings>(); |
|||
|
|||
void OnEnable() |
|||
{ |
|||
|
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public SceneSettings GetCurrentSceneSetting() |
|||
{ |
|||
if (m_SceneSettingsList.Count == 0) |
|||
return null; |
|||
else |
|||
return m_SceneSettingsList[m_SceneSettingsList.Count - 1]; |
|||
} |
|||
|
|||
// This can be needed in the editor in case the current setting is being changed. In this case we need to reapply it.
|
|||
public void UpdateCurrentSceneSetting() |
|||
{ |
|||
if (m_SceneSettingsList.Count != 0) |
|||
ApplySettings(GetCurrentSceneSetting()); |
|||
} |
|||
|
|||
public void AddSceneSettings(SceneSettings settings) |
|||
{ |
|||
m_SceneSettingsList.Add(settings); |
|||
ApplySettings(settings); |
|||
} |
|||
|
|||
public void RemoveSceneSettings(SceneSettings settings) |
|||
{ |
|||
m_SceneSettingsList.Remove(settings); |
|||
|
|||
// Always reapply the settings at the top of the list
|
|||
// (this way if the setting being removed was the active one we switch to the next one)
|
|||
ApplySettings(GetCurrentSceneSetting()); |
|||
} |
|||
|
|||
private void ApplySettings(SceneSettings settings) |
|||
{ |
|||
if(settings) |
|||
{ |
|||
if (settings.commonSettings != null) |
|||
CommonSettingsSingleton.overrideSettings = settings.commonSettings; |
|||
|
|||
if (settings.skySettings != null) |
|||
SkySettingsSingleton.overrideSettings = settings.skySettings; |
|||
} |
|||
else |
|||
{ |
|||
CommonSettingsSingleton.overrideSettings = null; |
|||
SkySettingsSingleton.overrideSettings = null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f31f023dee834de44993536e71ee27ac |
|||
timeCreated: 1487241314 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[DisallowMultipleComponent] |
|||
public class HDRISkySettings |
|||
: SkySettings |
|||
{ |
|||
public Cubemap skyHDRI; |
|||
|
|||
|
|||
public override SkyRenderer GetRenderer() |
|||
{ |
|||
return new HDRISkyRenderer(this); |
|||
} |
|||
} |
|||
} |
|
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class SkySettingsSingleton : Singleton<SkySettingsSingleton> |
|||
{ |
|||
private SkySettings settings { get; set; } |
|||
|
|||
public static SkySettings overrideSettings |
|||
{ |
|||
get { return instance.settings; } |
|||
set { instance.settings = value; } |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class HDRenderPipeWindow : EditorWindow |
|||
{ |
|||
[MenuItem("HDRenderPipeline/Configure Overrides")] |
|||
static void ConfigureOverrides() |
|||
{ |
|||
GetWindow<HDRenderPipeWindow>().Show(); |
|||
} |
|||
|
|||
void OnGUI() |
|||
{ |
|||
CommonSettingsSingleton.overrideSettings = (CommonSettings)EditorGUILayout.ObjectField(new GUIContent("Common Settings"), CommonSettingsSingleton.overrideSettings, typeof(CommonSettings), false); |
|||
SkyParametersSingleton.overrideSettings = (SkyParameters)EditorGUILayout.ObjectField(new GUIContent("Sky Settings"), SkyParametersSingleton.overrideSettings, typeof(SkyParameters), false); |
|||
SubsurfaceScatteringSettings.overrideSettings = (SubsurfaceScatteringParameters)EditorGUILayout.ObjectField(new GUIContent("Subsurface Scattering Settings"), SubsurfaceScatteringSettings.overrideSettings, typeof(SubsurfaceScatteringParameters), false); |
|||
|
|||
if (GUILayout.Button("Create new common settings")) |
|||
{ |
|||
var instance = CreateInstance<CommonSettings>(); |
|||
AssetDatabase.CreateAsset(instance, "Assets/NewCommonSettings.asset"); |
|||
} |
|||
|
|||
if (GUILayout.Button("Create new HDRI sky params")) |
|||
{ |
|||
var instance = CreateInstance<HDRISkyParameters>(); |
|||
AssetDatabase.CreateAsset(instance, "Assets/NewHDRISkyParameters.asset"); |
|||
} |
|||
|
|||
if (GUILayout.Button("Create new Procedural sky params")) |
|||
{ |
|||
var instance = CreateInstance<ProceduralSkyParameters>(); |
|||
AssetDatabase.CreateAsset(instance, "Assets/NewProceduralSkyParameters.asset"); |
|||
} |
|||
|
|||
if (GUILayout.Button("Create new SSS params")) |
|||
{ |
|||
var instance = CreateInstance<SubsurfaceScatteringParameters>(); |
|||
AssetDatabase.CreateAsset(instance, "Assets/NewSssParameters.asset"); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[DisallowMultipleComponent] |
|||
public class HDRISkyParameters |
|||
: SkyParameters |
|||
{ |
|||
public Cubemap skyHDRI; |
|||
|
|||
|
|||
public override SkyRenderer GetRenderer() |
|||
{ |
|||
return new HDRISkyRenderer(this); |
|||
} |
|||
} |
|||
} |
|
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class SkyParametersSingleton : Singleton<SkyParametersSingleton> |
|||
{ |
|||
private SkyParameters settings { get; set; } |
|||
|
|||
public static SkyParameters overrideSettings |
|||
{ |
|||
get { return instance.settings; } |
|||
set { instance.settings = value; } |
|||
} |
|||
} |
|||
} |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 59b6606ef2548734bb6d11b9d160bc7e, type: 3} |
|||
m_Name: HDRISkyParameters_Cascaded |
|||
m_EditorClassIdentifier: |
|||
rotation: 0 |
|||
exposure: 0 |
|||
multiplier: 1 |
|||
resolution: 256 |
|||
updateMode: 0 |
|||
updatePeriod: 0 |
|||
skyHDRI: {fileID: 8900000, guid: 9b513842339ef704ca63ef696691bc34, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: e87251404948e274ab006302af9b80f8 |
|||
timeCreated: 1486126252 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue