This commit is contained in:
2026-05-19 17:39:03 +07:00
parent bf0ebe447d
commit 5da832bb57
559 changed files with 69543 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
using Rive.Components;
using UnityEditor;
using UnityEngine.UIElements;
namespace Rive.EditorTools
{
[CustomEditor(typeof(RiveTextureRenderer), true)]
internal class TexturePanelRendererEditor : PanelRendererInspector
{
public override VisualElement CreateInspectorGUI()
{
var root = base.CreateInspectorGUI() ?? new VisualElement();
// For worldspace renderers, we display a button to convert materials on the current mesh renderer, if needed.
// Makes it easier for users to switch to Rive materials without having to know the right ones to pick.
var textureRenderer = (RiveTextureRenderer)target;
if (textureRenderer != null && textureRenderer.Renderer != null)
{
System.Action clickAction = () =>
{
// This will replace any non-Rive materials with Rive equivalents, even if the existing materials are not Unity defaults.
MaterialConversionUtility.ReplaceMaterialsWithRive(textureRenderer.Renderer);
};
var convertButton = new Button(() => clickAction())
{
text = "Replace Materials with Rive Materials"
};
convertButton.name = "RiveConvertMaterialsButton";
convertButton.userData = clickAction; // allow tests to invoke without event system/panel
convertButton.style.marginTop = 6;
root.Add(convertButton);
}
return root;
}
}
}