メインコンテンツまでスキップ

Scripting API

このページは、シェーダーパッケージ作者が主に使う公開 C# API の概要です。すべて Editor 専用です。

名前空間​

名前空間用途
KIBA_.KIBAMaterialGUI.Editor.Coreモデル、コンテキスト、診断
KIBA_.KIBAMaterialGUI.Editor.Extensibility注入と contribution API
KIBA_.KIBAMaterialGUI.Editor.ShaderLabShaderLab drawer bridge
KIBA_.KIBAMaterialGUI.Editor.UI.Propertyプロパティレンダラーと値書き込み

Context​

MaterialGUIContext は拡張コールバックに渡される読み取り中心のコンテキストです。

メンバー説明
MaterialEditor現在の Unity MaterialEditor
Material代表マテリアル
Targets選択中の全マテリアル
Properties現在の MaterialProperty 一覧
CurrentLanguage現在の表示言語
Search現在の検索文字列
Modelグループ/プロパティモデル

Property Renderer​

public interface IMaterialGUIPropertyRenderer
{
float GetHeight(PropertyRendererArgs args);
Rect OnGUI(PropertyRendererArgs args);
}
[MaterialGUIPropertyRenderer(
Order = -100,
PropertyTypes = new[] { MaterialProperty.PropType.Float },
RequireShaderAttributes = new[] { "StepFloat" })]

値の書き込みには helper を使います。

args.SetFloatValue(value);
args.SetColorValue(color);
args.SetVectorValue(vector);
args.SetTextureValue(texture);
args.RegisterPropertyValueChange();

Editor Injection​

public interface IShaderEditor
{
void OnGUI(InjectionArgs args);
}
[ShaderEditorInjection(HookPoint.AfterToolbar, Order = 0)]
public sealed class MyInjection : IShaderEditor
{
public void OnGUI(InjectionArgs args)
{
EditorGUILayout.LabelField("Project helper");
}
}

Contribution API​

public interface IToolbarContributor { void Contribute(ToolbarModel model, InjectionArgs args); }
public interface IGroupMenuContributor { void Contribute(ContextMenuModel model, InjectionArgs args); }
public interface IMaterialGUIGroupActionContributor { void Contribute(GroupActionModel model, InjectionArgs args); }
public interface IMaterialGUIDiagnosticProvider { void Contribute(List<MaterialGUIDiagnostic> diagnostics, InjectionArgs args); }
public interface IMaterialGUIFilterProvider { void Contribute(ToolbarModel model, InjectionArgs args); }

詳しい例は カスタムレンダラー と エディター注入 を参照してください。