59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using QFramework;
|
||
using System;
|
||
using System.IO;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
#if UNITY_EDITOR
|
||
public class FixedMainEditor
|
||
{
|
||
private const string FixedMainKey = "IsFixedMain";
|
||
public static bool isFixedMain
|
||
{
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(FixedMainKey, 0) == 1;
|
||
}
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(FixedMainKey, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
}
|
||
|
||
[MenuItem("Tools/强制Main场景启动 %#x", false, 10)]
|
||
private static void ToggleOption()
|
||
{
|
||
isFixedMain = !isFixedMain;
|
||
EditorUtility.DisplayDialog("Option Status", "Option is now " + (isFixedMain ? "enabled" : "disabled"), "OK");
|
||
}
|
||
|
||
[MenuItem("Tools/强制Main场景启动 %#x", true, 10)]
|
||
private static bool ValidateToggleOption()
|
||
{
|
||
Menu.SetChecked("Tools/强制Main场景启动", isFixedMain);
|
||
return true;
|
||
}
|
||
|
||
|
||
|
||
[MenuItem("Tools/创建时间锁")]
|
||
private static void TimerLock()
|
||
{
|
||
//创建数据资源文件
|
||
//泛型是继承自ScriptableObject的类
|
||
TimerLock asset = ScriptableObject.CreateInstance<TimerLock>();
|
||
//前一步创建的资源只是存在内存中,现在要把它保存到本地
|
||
//通过编辑器API,创建一个数据资源文件,第二个参数为资源文件在Assets目录下的路径
|
||
AssetDatabase.CreateAsset(asset, "Assets/TimerLock.asset");
|
||
//保存创建的资源
|
||
AssetDatabase.SaveAssets();
|
||
//刷新界面
|
||
AssetDatabase.Refresh();
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
#endif |