Firstborn/Library/PackageCache/com.unity.shadergraph@12.1.8/Editor/Importers/ShaderGraphMetadata.cs
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

69 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.ShaderGraph.Internal;
using UnityEngine;
using Object = UnityEngine.Object;
namespace UnityEditor.ShaderGraph
{
[Serializable]
struct GraphInputData
{
public string referenceName;
public bool isKeyword;
public PropertyType propertyType;
public KeywordType keywordType;
public bool isCompoundProperty;
public List<SubPropertyData> subProperties;
}
[Serializable]
struct SubPropertyData
{
public string referenceName;
public PropertyType propertyType;
}
[Serializable]
class MinimalCategoryData
{
// ShaderLab doesn't understand virtual texture inputs, they need to be processed to replace the virtual texture input with the layers that compose it instead
public static GraphInputData ProcessVirtualTextureProperty(VirtualTextureShaderProperty virtualTextureShaderProperty)
{
var layerReferenceNames = new List<string>();
virtualTextureShaderProperty.GetPropertyReferenceNames(layerReferenceNames);
var virtualTextureLayerDataList = new List<SubPropertyData>();
// Skip the first entry in this list as that's the Virtual Texture reference name itself, which won't exist in ShaderLab
foreach (var referenceName in layerReferenceNames.Skip(1))
{
var layerPropertyData = new SubPropertyData() { referenceName = referenceName, propertyType = PropertyType.Texture2D };
virtualTextureLayerDataList.Add(layerPropertyData);
}
var virtualTexturePropertyData = new GraphInputData() { referenceName = virtualTextureShaderProperty.displayName, propertyType = PropertyType.VirtualTexture, isKeyword = false };
virtualTexturePropertyData.isCompoundProperty = true;
virtualTexturePropertyData.subProperties = virtualTextureLayerDataList;
return virtualTexturePropertyData;
}
public string categoryName;
public List<GraphInputData> propertyDatas;
[NonSerialized]
public bool expanded = true;
}
class ShaderGraphMetadata : ScriptableObject
{
public string outputNodeTypeName;
// these asset dependencies are stored here as a way for "Export Package..." to discover them
// and automatically pull them in to the .unitypackage
public List<Object> assetDependencies;
public List<MinimalCategoryData> categoryDatas;
}
}