Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unity 2023.1.0a22 C# reference source code
- Loading branch information
Unity Technologies
committed
Dec 7, 2022
1 parent
9cd83fb
commit 016297e
Showing
304 changed files
with
9,535 additions
and
6,141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsElement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Unity C# reference source | ||
// Copyright (c) Unity Technologies. For terms of use, see | ||
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License | ||
|
||
using UnityEditor.Experimental; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace UnityEditor | ||
{ | ||
internal abstract class GraphicsSettingsElement : VisualElement | ||
{ | ||
protected SerializedObject m_SerializedObject; | ||
protected SettingsWindow m_SettingsWindow; | ||
|
||
protected Color HighlightSelectionColor = EditorResources.GetStyle("sb-settings-panel-client-area").GetColor("-unity-search-highlight-selection-color"); | ||
protected Color HighlightColor = EditorResources.GetStyle("sb-settings-panel-client-area").GetColor("-unity-search-highlight-color"); | ||
|
||
//We rely on SupportedOn attribute for the cases when we need to show element for SRP. | ||
//Here is a way to specify when we want to have element visible for BuiltinOnly. | ||
//Important notice: we check first for SupportedOn first, then for this backup field. | ||
public virtual bool BuiltinOnly => false; | ||
|
||
internal void Initialize(SerializedObject serializedObject) | ||
{ | ||
m_SerializedObject = serializedObject; | ||
|
||
m_SettingsWindow = EditorWindow.GetWindow<SettingsWindow>(); | ||
|
||
Initialize(); | ||
} | ||
|
||
protected abstract void Initialize(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorAlwaysIncludedShader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Unity C# reference source | ||
// Copyright (c) Unity Technologies. For terms of use, see | ||
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License | ||
|
||
using UnityEngine.UIElements; | ||
|
||
namespace UnityEditor | ||
{ | ||
internal class GraphicsSettingsInspectorAlwaysIncludedShader : GraphicsSettingsElement | ||
{ | ||
public new class UxmlFactory : UxmlFactory<GraphicsSettingsInspectorAlwaysIncludedShader, UxmlTraits> { } | ||
|
||
SerializedProperty m_AlwaysIncludedShaders; | ||
|
||
protected override void Initialize() | ||
{ | ||
m_AlwaysIncludedShaders = m_SerializedObject.FindProperty("m_AlwaysIncludedShaders"); | ||
m_AlwaysIncludedShaders.isExpanded = true; | ||
|
||
Add(new IMGUIContainer(Draw)); | ||
} | ||
|
||
void Draw() | ||
{ | ||
using var highlightScope = new EditorGUI.LabelHighlightScope(m_SettingsWindow.GetSearchText(), HighlightSelectionColor, HighlightColor); | ||
using var check = new EditorGUI.ChangeCheckScope(); | ||
EditorGUILayout.PropertyField(m_AlwaysIncludedShaders, true); | ||
if (check.changed) | ||
m_SerializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorBuiltinShaderLabel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Unity C# reference source | ||
// Copyright (c) Unity Technologies. For terms of use, see | ||
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License | ||
|
||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace UnityEditor; | ||
|
||
internal class GraphicsSettingsInspectorBuiltinShaderLabel : GraphicsSettingsElement | ||
{ | ||
public new class UxmlFactory : UxmlFactory<GraphicsSettingsInspectorBuiltinShaderLabel, UxmlTraits> { } | ||
|
||
internal class Styles | ||
{ | ||
public static readonly GUIContent builtinSettings = EditorGUIUtility.TrTextContent("Built-in Shader Settings"); | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Add(new Label(Styles.builtinSettings.text)); | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorBuiltinShaders.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Unity C# reference source | ||
// Copyright (c) Unity Technologies. For terms of use, see | ||
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License | ||
|
||
using UnityEngine; | ||
using UnityEngine.Rendering; | ||
using UnityEngine.UIElements; | ||
|
||
namespace UnityEditor | ||
{ | ||
internal class GraphicsSettingsInspectorBuiltinShaders : GraphicsSettingsElement | ||
{ | ||
public new class UxmlFactory : UxmlFactory<GraphicsSettingsInspectorBuiltinShaders, UxmlTraits> { } | ||
internal class Styles | ||
{ | ||
public static readonly GUIContent deferredString = EditorGUIUtility.TrTextContent("Deferred", "Shader used for Deferred Shading."); | ||
public static readonly GUIContent deferredReflString = EditorGUIUtility.TrTextContent("Deferred Reflections", "Shader used for Deferred reflection probes."); | ||
public static readonly GUIContent screenShadowsString = EditorGUIUtility.TrTextContent("Screen Space Shadows", "Shader used for screen-space cascaded shadows."); | ||
public static readonly GUIContent depthNormalsString = EditorGUIUtility.TrTextContent("Depth Normals", "Shader used for depth and normals texture when enabled on a Camera."); | ||
|
||
public static readonly GUIContent motionVectorsString = | ||
EditorGUIUtility.TrTextContent("Motion Vectors", "Shader for generation of Motion Vectors when the rendering camera has renderMotionVectors set to true."); | ||
|
||
public static readonly GUIContent lightHaloString = EditorGUIUtility.TrTextContent("Light Halo", "Default Shader used for light halos."); | ||
public static readonly GUIContent lensFlareString = EditorGUIUtility.TrTextContent("Lens Flare", "Default Shader used for lens flares."); | ||
} | ||
|
||
public override bool BuiltinOnly => true; | ||
|
||
BuiltinShaderSettings m_Deferred; | ||
BuiltinShaderSettings m_DeferredReflections; | ||
BuiltinShaderSettings m_ScreenSpaceShadows; | ||
BuiltinShaderSettings m_DepthNormals; | ||
BuiltinShaderSettings m_MotionVectors; | ||
BuiltinShaderSettings m_LightHalo; | ||
BuiltinShaderSettings m_LensFlare; | ||
|
||
protected override void Initialize() | ||
{ | ||
m_Deferred = new BuiltinShaderSettings(Styles.deferredString, "m_Deferred", m_SerializedObject); | ||
m_DeferredReflections = new BuiltinShaderSettings(Styles.deferredReflString, "m_DeferredReflections", m_SerializedObject); | ||
m_ScreenSpaceShadows = new BuiltinShaderSettings(Styles.screenShadowsString, "m_ScreenSpaceShadows", m_SerializedObject); | ||
m_DepthNormals = new BuiltinShaderSettings(Styles.depthNormalsString, "m_DepthNormals", m_SerializedObject); | ||
m_MotionVectors = new BuiltinShaderSettings(Styles.motionVectorsString, "m_MotionVectors", m_SerializedObject); | ||
m_LightHalo = new BuiltinShaderSettings(Styles.lightHaloString, "m_LightHalo", m_SerializedObject); | ||
m_LensFlare = new BuiltinShaderSettings(Styles.lensFlareString, "m_LensFlare", m_SerializedObject); | ||
|
||
Add(new IMGUIContainer(Draw)); | ||
} | ||
|
||
void Draw() | ||
{ | ||
using var highlightScope = new EditorGUI.LabelHighlightScope(m_SettingsWindow.GetSearchText(), HighlightSelectionColor, HighlightColor); | ||
using var check = new EditorGUI.ChangeCheckScope(); | ||
m_Deferred.DoGUI(); | ||
|
||
// deferred reflections being off affects forward vs deferred style probe rendering; | ||
// need to reload shaders for new platform macro to live update | ||
using (var internalCheck = new EditorGUI.ChangeCheckScope()) | ||
{ | ||
m_DeferredReflections.DoGUI(); | ||
if (internalCheck.changed) | ||
ShaderUtil.ReloadAllShaders(); | ||
} | ||
|
||
m_ScreenSpaceShadows.DoGUI(); | ||
m_DepthNormals.DoGUI(); | ||
m_MotionVectors.DoGUI(); | ||
m_LightHalo.DoGUI(); | ||
m_LensFlare.DoGUI(); | ||
|
||
if (check.changed) | ||
m_SerializedObject.ApplyModifiedProperties(); | ||
} | ||
|
||
internal readonly struct BuiltinShaderSettings | ||
{ | ||
internal enum BuiltinShaderMode | ||
{ | ||
None = 0, | ||
Builtin, | ||
Custom | ||
} | ||
|
||
readonly SerializedProperty m_Mode; | ||
readonly SerializedProperty m_Shader; | ||
readonly GUIContent m_Label; | ||
|
||
internal BuiltinShaderSettings(GUIContent label, string name, SerializedObject serializedObject) | ||
{ | ||
m_Mode = serializedObject.FindProperty(name + ".m_Mode"); | ||
m_Shader = serializedObject.FindProperty(name + ".m_Shader"); | ||
m_Label = label; | ||
} | ||
|
||
internal void DoGUI() | ||
{ | ||
EditorGUILayout.PropertyField(m_Mode, m_Label); | ||
if (m_Mode.intValue == (int)BuiltinShaderMode.Custom) | ||
EditorGUILayout.PropertyField(m_Shader); | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorCameraSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Unity C# reference source | ||
// Copyright (c) Unity Technologies. For terms of use, see | ||
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License | ||
|
||
using UnityEngine; | ||
using UnityEngine.Rendering; | ||
using UnityEngine.UIElements; | ||
|
||
namespace UnityEditor | ||
{ | ||
internal class GraphicsSettingsInspectorCameraSettings : GraphicsSettingsElement | ||
{ | ||
public new class UxmlFactory : UxmlFactory<GraphicsSettingsInspectorCameraSettings, UxmlTraits> { } | ||
|
||
internal class Styles | ||
{ | ||
public static readonly GUIContent cameraSettings = EditorGUIUtility.TrTextContent("Camera Settings"); | ||
} | ||
|
||
public override bool BuiltinOnly => true; | ||
|
||
SerializedProperty m_TransparencySortMode; | ||
SerializedProperty m_TransparencySortAxis; | ||
|
||
protected override void Initialize() | ||
{ | ||
m_TransparencySortMode = m_SerializedObject.FindProperty("m_TransparencySortMode"); | ||
m_TransparencySortAxis = m_SerializedObject.FindProperty("m_TransparencySortAxis"); | ||
|
||
Add(new IMGUIContainer(Draw)); | ||
} | ||
|
||
void Draw() | ||
{ | ||
using var highlightScope = new EditorGUI.LabelHighlightScope(m_SettingsWindow.GetSearchText(), HighlightSelectionColor, HighlightColor); | ||
GUILayout.Label(Styles.cameraSettings, EditorStyles.boldLabel); | ||
|
||
using var changeScope = new EditorGUI.ChangeCheckScope(); | ||
EditorGUILayout.PropertyField(m_TransparencySortMode); | ||
if ((TransparencySortMode)m_TransparencySortMode.intValue == TransparencySortMode.CustomAxis) | ||
EditorGUILayout.PropertyField(m_TransparencySortAxis); | ||
if (changeScope.changed) | ||
m_SerializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorCullingSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Unity C# reference source | ||
// Copyright (c) Unity Technologies. For terms of use, see | ||
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License | ||
|
||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace UnityEditor | ||
{ | ||
internal class GraphicsSettingsInspectorCullingSettings : GraphicsSettingsElement | ||
{ | ||
public new class UxmlFactory : UxmlFactory<GraphicsSettingsInspectorCullingSettings, UxmlTraits> | ||
{ | ||
} | ||
|
||
internal class Styles | ||
{ | ||
public static readonly GUIContent cullingSettings = EditorGUIUtility.TrTextContent("Culling Settings"); | ||
public static readonly GUIContent cameraRelativeSettings = EditorGUIUtility.TrTextContent("Camera-Relative Culling"); | ||
|
||
public static readonly GUIContent cameraRelativeLightCulling = EditorGUIUtility.TrTextContent("Lights", | ||
"When enabled, Unity uses the camera position as the reference point for culling lights instead of the world space origin."); | ||
|
||
public static readonly GUIContent cameraRelativeShadowCulling = EditorGUIUtility.TrTextContent("Shadows", | ||
"When enabled, Unity uses the camera position as the reference point for culling shadows instead of the world space origin."); | ||
|
||
} | ||
|
||
SerializedProperty m_CameraRelativeLightCulling; | ||
SerializedProperty m_CameraRelativeShadowCulling; | ||
|
||
protected override void Initialize() | ||
{ | ||
m_CameraRelativeLightCulling = m_SerializedObject.FindProperty("m_CameraRelativeLightCulling"); | ||
m_CameraRelativeShadowCulling = m_SerializedObject.FindProperty("m_CameraRelativeShadowCulling"); | ||
|
||
Add(new IMGUIContainer(Draw)); | ||
} | ||
|
||
void Draw() | ||
{ | ||
using var highlightScope = new EditorGUI.LabelHighlightScope(m_SettingsWindow.GetSearchText(), HighlightSelectionColor, HighlightColor); | ||
using var check = new EditorGUI.ChangeCheckScope(); | ||
GUILayout.Label(Styles.cullingSettings, EditorStyles.boldLabel); | ||
EditorGUILayout.LabelField(Styles.cameraRelativeSettings, EditorStyles.label); | ||
EditorGUI.indentLevel++; | ||
EditorGUILayout.PropertyField(m_CameraRelativeLightCulling, Styles.cameraRelativeLightCulling); | ||
EditorGUILayout.PropertyField(m_CameraRelativeShadowCulling, Styles.cameraRelativeShadowCulling); | ||
EditorGUI.indentLevel--; | ||
if (check.changed) | ||
m_SerializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
Oops, something went wrong.