testss
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[GenerationAPI]
|
||||
internal class TargetActiveBlockContext
|
||||
{
|
||||
public List<BlockFieldDescriptor> activeBlocks { get; private set; }
|
||||
public List<BlockFieldDescriptor> currentBlocks { get; private set; }
|
||||
public PassDescriptor? pass { get; private set; }
|
||||
|
||||
public TargetActiveBlockContext(List<BlockFieldDescriptor> currentBlocks, PassDescriptor? pass)
|
||||
{
|
||||
activeBlocks = new List<BlockFieldDescriptor>();
|
||||
this.currentBlocks = currentBlocks;
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
public void AddBlock(BlockFieldDescriptor block, bool conditional = true)
|
||||
{
|
||||
if (conditional == true)
|
||||
{
|
||||
activeBlocks.Add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[GenerationAPI]
|
||||
internal class TargetFieldContext
|
||||
{
|
||||
public List<ConditionalField> conditionalFields { get; private set; }
|
||||
public PassDescriptor pass { get; private set; }
|
||||
public List<(BlockFieldDescriptor descriptor, bool isDefaultValue)> blocks { get; private set; }
|
||||
public List<BlockFieldDescriptor> connectedBlocks { get; private set; }
|
||||
public bool hasDotsProperties { get; private set; }
|
||||
|
||||
// NOTE: active blocks (and connectedBlocks) do not include temporarily added default blocks
|
||||
public TargetFieldContext(PassDescriptor pass, List<(BlockFieldDescriptor descriptor, bool isDefaultValue)> activeBlocks, List<BlockFieldDescriptor> connectedBlocks, bool hasDotsProperties)
|
||||
{
|
||||
conditionalFields = new List<ConditionalField>();
|
||||
this.pass = pass;
|
||||
this.blocks = activeBlocks;
|
||||
this.connectedBlocks = connectedBlocks;
|
||||
this.hasDotsProperties = hasDotsProperties;
|
||||
}
|
||||
|
||||
public void AddField(FieldDescriptor field, bool conditional = true)
|
||||
{
|
||||
conditionalFields.Add(new ConditionalField(field, conditional));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.Graphing.Util;
|
||||
using UnityEditor.ShaderGraph.Drawing;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[GenerationAPI]
|
||||
internal class TargetPropertyGUIContext : VisualElement
|
||||
{
|
||||
const int kIndentWidthInPixel = 15;
|
||||
|
||||
public int globalIndentLevel {get; set;} = 0;
|
||||
|
||||
public TargetPropertyGUIContext()
|
||||
{
|
||||
}
|
||||
|
||||
public void AddProperty<T>(string label, BaseField<T> field, bool condition, EventCallback<ChangeEvent<T>> evt)
|
||||
{
|
||||
if (condition == true)
|
||||
{
|
||||
AddProperty<T>(label, field, evt);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProperty<T>(string label, int indentLevel, BaseField<T> field, bool condition, EventCallback<ChangeEvent<T>> evt)
|
||||
{
|
||||
if (condition == true)
|
||||
{
|
||||
AddProperty<T>(label, indentLevel, field, evt);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProperty<T>(string label, BaseField<T> field, EventCallback<ChangeEvent<T>> evt)
|
||||
{
|
||||
AddProperty<T>(label, 0, field, evt);
|
||||
}
|
||||
|
||||
public void AddProperty<T>(string label, int indentLevel, BaseField<T> field, EventCallback<ChangeEvent<T>> evt)
|
||||
{
|
||||
if (field is INotifyValueChanged<T> notifyValueChanged)
|
||||
{
|
||||
notifyValueChanged.RegisterValueChangedCallback(evt);
|
||||
}
|
||||
|
||||
var propertyRow = new PropertyRow(new Label(label));
|
||||
ApplyPadding(propertyRow, indentLevel);
|
||||
propertyRow.Add(field);
|
||||
this.hierarchy.Add(propertyRow);
|
||||
}
|
||||
|
||||
public void AddLabel(string label, int indentLevel)
|
||||
{
|
||||
var propertyRow = new PropertyRow(new Label(label));
|
||||
ApplyPadding(propertyRow, indentLevel);
|
||||
this.hierarchy.Add(propertyRow);
|
||||
}
|
||||
|
||||
public void AddHelpBox(MessageType messageType, string messageText)
|
||||
{
|
||||
var helpBox = new HelpBoxRow(messageType);
|
||||
helpBox.Add(new Label(messageText));
|
||||
this.hierarchy.Add(helpBox);
|
||||
}
|
||||
|
||||
void ApplyPadding(PropertyRow row, int indentLevel)
|
||||
{
|
||||
row.Q(className: "unity-label").style.marginLeft = (globalIndentLevel + indentLevel) * kIndentWidthInPixel;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[GenerationAPI]
|
||||
internal class TargetSetupContext
|
||||
{
|
||||
public List<SubShaderDescriptor> subShaders { get; private set; }
|
||||
public List<(string shaderGUI, string renderPipelineAssetType)> customEditorForRenderPipelines { get; private set; }
|
||||
public AssetCollection assetCollection { get; private set; }
|
||||
public string defaultShaderGUI { get; private set; }
|
||||
|
||||
// pass a HashSet to the constructor to have it gather asset dependency GUIDs
|
||||
public TargetSetupContext(AssetCollection assetCollection = null)
|
||||
{
|
||||
subShaders = new List<SubShaderDescriptor>();
|
||||
this.customEditorForRenderPipelines = new List<(string shaderGUI, string renderPipelineAssetType)>();
|
||||
this.assetCollection = assetCollection;
|
||||
}
|
||||
|
||||
public void AddSubShader(SubShaderDescriptor subShader)
|
||||
{
|
||||
subShaders.Add(subShader);
|
||||
}
|
||||
|
||||
public void AddAssetDependency(GUID guid, AssetCollection.Flags flags)
|
||||
{
|
||||
assetCollection?.AddAssetDependency(guid, flags);
|
||||
}
|
||||
|
||||
public void SetDefaultShaderGUI(string defaultShaderGUI)
|
||||
{
|
||||
this.defaultShaderGUI = defaultShaderGUI;
|
||||
}
|
||||
|
||||
public void AddCustomEditorForRenderPipeline(string shaderGUI, Type renderPipelineAssetType)
|
||||
{
|
||||
this.customEditorForRenderPipelines.Add((shaderGUI, renderPipelineAssetType.FullName));
|
||||
}
|
||||
|
||||
public bool HasCustomEditorForRenderPipeline(Type renderPipelineAssetType)
|
||||
=> this.customEditorForRenderPipelines.Any(c => c.renderPipelineAssetType == renderPipelineAssetType.FullName);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user