com.soviby.unity.ui.ugui-to.../Assets/Editor/Windows/EditWindow.cs
2024-12-09 19:18:10 +08:00

99 lines
2.6 KiB
C#

#if UNITY_EDITOR
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using System;
using UnityEngine;
namespace UguiToolkit.Editor.Windows
{
public class EditWindow : BaseWindow<EditWindow>
{
/// <summary>
/// 当是否显示预览实例发生改变时
/// </summary>
public event Action<bool> showHierarchyOfEntityChanged;
/// <summary>
/// 背景显示发生改变
/// </summary>
public event Action<bool> showBackgroundChanged;
/// <summary>
/// 创建所有TextEntity
/// </summary>
public event Action createAllTextEntity;
[SerializeField, HideInInspector]
private bool m_showHierarchyOfEntityChange = false;
[SerializeField, HideInInspector]
private bool m_showBackground = true;
[LabelText("Hierarchy是否显示"), ShowInInspector]
private bool ShowHierarchyOfEntity
{
get => m_showHierarchyOfEntityChange;
set
{
m_showHierarchyOfEntityChange = value;
showHierarchyOfEntityChanged?.Invoke(m_showHierarchyOfEntityChange);
}
}
[LabelText("背景是否显示"), ShowInInspector]
private bool ShowBackground
{
get => m_showBackground;
set
{
m_showBackground = value;
showBackgroundChanged?.Invoke(m_showBackground);
}
}
[Button("创建所有Text")]
private void CreateAllTextEntity()
{
createAllTextEntity?.Invoke();
}
[Title("工具")]
[LabelText("上次变换的对象"), SerializeField]
private IEntity m_lastApplyEntity;
[LabelText("需要应用变换的对象"), SerializeField]
private Transform m_targetTransform;
[Button("应用上次变换")]
private void EffectLastApplyTransform()
{
if (m_targetTransform)
{
var m_lastApplyTransform = m_lastApplyEntity.gameObject.transform;
var parent = m_lastApplyTransform.parent;
m_lastApplyTransform.parent = null;
m_lastApplyEntity.ApplyTransformByParent(m_targetTransform);
m_lastApplyTransform.parent = parent;
}
}
public void SetLastApplyEntity(IEntity lastApplyTransform)
{
this.m_lastApplyEntity = lastApplyTransform;
}
public override string GettitleContent()
{
return "助手编辑界面";
}
public override void Init(WindowArgs args = null)
{
}
}
}
#endif