GQ_Communicate/GQ_URP/GQ/Assets/ScriptabLeObject/BaseConf.cs

68 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEditor;
/// <summary>
/// 管理类(配置文件)
/// </summary>
public class BaseConf : ScriptableObject
{
public Conf1 conf1 = new Conf1();
/// <summary>
/// Assets界面右键添加配置文件
/// </summary>
#if UNITY_EDITOR
[MenuItem("Assets/Create/Baseconf", false, 0)]
private static void Show()
{
Object o = Selection.activeObject;
if (o)
{
string path = AssetDatabase.GetAssetPath(o); //获取路径
if (!Directory.Exists(path))//判断是否有 AssetDatabase路径
{
Directory.CreateDirectory(path);//没有就 创建AssetDatabase路径
}
ScriptableObject a = CreateInstance<BaseConf>();//创建一个自身类型的对象
if (a)//判断创建的对象是否存在
{
string str = Unitil.TryGetName<BaseConf>(path);//类名打点调用获取文件名,并传参路径
AssetDatabase.CreateAsset(a, str);//根据对象(自身类) 及 路径创建
AssetDatabase.SaveAssets();//保存
}
else//否则创建失败
{
Debug.LogError(typeof(BaseConf) + " is null");//输出错误语句
}
}
}
#endif
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
[System.Serializable]
public class Conf1
{
public bool isUse;
public bool isPicture;
public string base64;
public string LensID;
public string LensName;
}
}