BITKit/Packages/Runtime~/Unity/Editor/BITEditorForUnity.cs

52 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.UIElements;
namespace BITKit
{
public class BITEditorForUnity : EditorWindow
{
private Slider _timeScaleSlider;
private Button _resetTimeScaleButton;
[MenuItem("Tools/Common Editor")]
private static void OpenEditor()
{
var window = GetWindow<BITEditorForUnity>();
window.titleContent = new GUIContent("BIT Editor");
window.Show();
}
private void OnEnable()
{
rootVisualElement.styleSheets.Add(BITEditorUtils.InspectorStyleSheet);
_timeScaleSlider = new Slider()
{
label = "TimeScale",
showInputField = true,
value = Time.timeScale
};
_timeScaleSlider.RegisterValueChangedCallback(x => { Time.timeScale = x.newValue; });
_resetTimeScaleButton = new Button()
{
text = "Reset TimeScale",
};
_resetTimeScaleButton.clicked += () =>
{
Time.timeScale = 1;
_timeScaleSlider.value = 1;
};
rootVisualElement.Add(_timeScaleSlider);
rootVisualElement.Add(_resetTimeScaleButton);
}
}
}