Skip to content

Commit

Permalink
Unity 2023.1.0a22 C# reference source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Technologies committed Dec 7, 2022
1 parent 9cd83fb commit 016297e
Show file tree
Hide file tree
Showing 304 changed files with 9,535 additions and 6,141 deletions.
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>latest</LangVersion>
<NoWarn>1071</NoWarn>
<NoWarn>1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="Data.cs" />
Expand Down
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>latest</LangVersion>
<NoWarn>1071</NoWarn>
<NoWarn>1701</NoWarn>
<AssemblyName>PlayerBuildProgramLibrary.Data</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>latest</LangVersion>
<NoWarn>1071</NoWarn>
<NoWarn>1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="Data.cs" />
Expand Down
4 changes: 4 additions & 0 deletions Editor/Mono/EditorGUIUtility.bindings.cs
Expand Up @@ -151,6 +151,10 @@ public new static string systemCopyBuffer
internal static extern void RenderPlayModeViewCamerasInternal(RenderTexture target, int targetDisplay, Vector2 mousePosition, bool gizmos, bool renderIMGUI);
internal static extern void SetupWindowSpaceAndVSyncInternal(Rect screenRect);

internal static extern void PerformTonemappingForGameView();
internal static extern void DrawTextureHdrSupport(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder,
int rightBorder, int topBorder, int bottomBorder, Color color, Material mat, int pass, bool resetLinearToSrgbIfHdrActive);

private static extern Texture2D FindTextureByName(string name);
private static extern Texture2D FindTextureByType([NotNull] Type type);
internal static extern string GetObjectNameWithInfo(Object obj);
Expand Down
5 changes: 4 additions & 1 deletion Editor/Mono/GameView/GameView.cs
Expand Up @@ -1139,6 +1139,9 @@ private void OnGUI()
{
GUI.Box(m_ZoomArea.drawRect, GUIContent.none, Styles.gameViewBackgroundStyle);

// Tonemapping for HDR targets
EditorGUIUtility.PerformTonemappingForGameView();

Vector2 oldOffset = GUIUtility.s_EditorScreenPointOffset;
GUIUtility.s_EditorScreenPointOffset = Vector2.zero;
SavedGUIState oldState = SavedGUIState.Create();
Expand Down Expand Up @@ -1179,7 +1182,7 @@ private void OnGUI()
Rect drawRect = deviceFlippedTargetInView;
drawRect.x = Mathf.Round(drawRect.x);
drawRect.y = Mathf.Round(drawRect.y);
Graphics.DrawTexture(drawRect, m_RenderTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUI.blitMaterial);
EditorGUIUtility.DrawTextureHdrSupport(drawRect, m_RenderTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUI.blitMaterial, -1, true);
GUI.EndGroup();
}
}
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/Inspector/CameraOverlay.cs
Expand Up @@ -176,6 +176,7 @@ public override void OnGUI()
RenderTexture.active = rt;
}

previewCamera.cameraType = CameraType.Preview;
previewCamera.Render();

Graphics.DrawTexture(previewRect, previewTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, EditorGUIUtility.GUITextureBlit2SRGBMaterial);
Expand Down
328 changes: 144 additions & 184 deletions Editor/Mono/Inspector/GraphicsSettingsInspector.cs

Large diffs are not rendered by default.

@@ -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();
}
}
@@ -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();
}
}
}
@@ -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));
}
}
@@ -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);
}
}
}
}
@@ -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();
}
}
}
@@ -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();
}
}
}

0 comments on commit 016297e

Please sign in to comment.