BITKit/Packages/Runtime/UX/Core/UXMeshRenderer.cs

58 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BITKit;
using BITKit.SubSystems;
using UnityEngine.UIElements;
using Cysharp.Threading.Tasks;
using System.Threading.Tasks;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.UIElements;
#endif
namespace BITKit.UX
{
public class UXMeshRenderer : UXElement<VisualElement>
{
[Header(Constant.Header.Settings)]
public Transform model;
public override void OnStart()
{
base.OnStart();
CreateTexture();
}
public async void CreateTexture()
{
//visualElement.style.backgroundImage = new(Background.FromTexture2D(texture));
visualElement.style.backgroundImage = new(await MeshRendering.Create(model));
}
}
#if UNITY_EDITOR
//[CustomEditor(typeof(UXMeshRenderer))]
public class UXMeshRendererInspector : BITInspector<UXMeshRenderer>
{
public override VisualElement CreateInspectorGUI()
{
CreateSubTitle(Constant.Header.Gameobjects);
var document = root.Create<PropertyField>();
CreateSubTitle(Constant.Header.Settings);
var model = root.Create<PropertyField>();
var button = root.Create<Button>();
model.BindProperty(serializedObject.FindProperty(nameof(UXMeshRenderer.model)));
button.text = "Create";
button.clicked += () =>
{
if (EditorApplication.isPlaying)
{
agent.CreateTexture();
}
};
return root;
}
}
#endif
}