Added EnumFlagsDrawer; Added custom keywordName option to KeywordTexturePropertySingleLine;
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEditor.Rendering;
|
|
using UnityEngine;
|
|
|
|
namespace Misaki.ShaderGUI.Packages
|
|
{
|
|
public abstract class MaterialUIBlock<TExpandableBit> : IMaterialUIScope where TExpandableBit : Enum, IConvertible
|
|
{
|
|
protected readonly MaterialPropertyContainer propertyContainer = new();
|
|
|
|
protected MaterialEditor editor;
|
|
protected IMaterialUIScopeContainer owner;
|
|
|
|
protected virtual bool ShowSection => true;
|
|
protected virtual bool IsSubHeader => false;
|
|
protected virtual bool SpaceAtEnd => true;
|
|
protected virtual string DocumentationURL => string.Empty;
|
|
|
|
protected abstract TExpandableBit ExpandableBit
|
|
{
|
|
get;
|
|
}
|
|
|
|
protected abstract GUIContent Header
|
|
{
|
|
get;
|
|
}
|
|
|
|
public MaterialEditor Editor => editor;
|
|
|
|
public abstract void LoadMaterialProperties(MaterialPropertyContainer propertyContainer);
|
|
|
|
protected abstract void DrawContent();
|
|
|
|
public void Initialize(MaterialEditor materialEditor, IEnumerable<MaterialProperty> properties, IMaterialUIScopeContainer container)
|
|
{
|
|
editor = materialEditor;
|
|
owner = container;
|
|
|
|
LoadMaterialProperties(propertyContainer);
|
|
UpdateMaterialProperties(properties);
|
|
}
|
|
|
|
public void UpdateMaterialProperties(IEnumerable<MaterialProperty> properties)
|
|
{
|
|
propertyContainer.ReloadProperties(properties);
|
|
}
|
|
|
|
public void Draw()
|
|
{
|
|
if (!ShowSection)
|
|
{
|
|
return;
|
|
}
|
|
|
|
using var scope = new MaterialHeaderScope(Header, Convert.ToUInt32(ExpandableBit), editor, spaceAtEnd: SpaceAtEnd, subHeader: IsSubHeader, documentationURL: DocumentationURL);
|
|
if (scope.expanded)
|
|
{
|
|
DrawContent();
|
|
}
|
|
}
|
|
}
|
|
} |