Files
Test/Library/PackageCache/com.unity.shadergraph@8b7e693cdbfe/Editor/ProviderSystem/Model/ExternalMaterialSlot.cs
T
2026-11-01 23:39:55 +02:00

70 lines
2.2 KiB
C#

using System;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph.ProviderSystem
{
interface INeedsExplicitCompatibilityTest
{
bool HasExplicitCompatibility(MaterialSlot other);
static bool TestExplicitCompatibility(MaterialSlot a, MaterialSlot b)
{
return a is INeedsExplicitCompatibilityTest atester
&& b is INeedsExplicitCompatibilityTest btester
&& atester.HasExplicitCompatibility(b)
&& btester.HasExplicitCompatibility(a);
}
}
[Serializable]
internal class ExternalMaterialSlot : MaterialSlot, INeedsExplicitCompatibilityTest
{
public string TypeName => m_typeName;
[SerializeField]
string m_typeName;
[SerializeField]
string m_rawDefaultValueString;
public override bool isDefaultValue => throw new System.NotImplementedException();
public override SlotValueType valueType => SlotValueType.External;
public override ConcreteSlotValueType concreteValueType => ConcreteSlotValueType.External;
public ExternalMaterialSlot() : base()
{
}
public ExternalMaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
string typeName,
SlotType slotType,
string rawDefaultValue = null,
ShaderStageCapability stageCapability = ShaderStageCapability.All,
bool hidden = false)
: base(slotId, displayName, shaderOutputName, slotType, stageCapability, hidden)
{
m_typeName = typeName;
m_rawDefaultValueString = rawDefaultValue ?? "0";
}
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode) { }
public override void CopyValuesFrom(MaterialSlot foundSlot) { }
public override string GetDefaultValue(GenerationMode generationMode)
{
return $"({TypeName})({m_rawDefaultValueString})";
}
public bool HasExplicitCompatibility(MaterialSlot other)
=> other is ExternalMaterialSlot externalSlot && externalSlot.TypeName == this.TypeName;
}
}