195 lines
4.0 KiB
C#
195 lines
4.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
|
|
|
|
/// <summary>
|
|
/// 管理类(配置文件)
|
|
/// </summary>
|
|
public class BaseConf : ScriptableObject
|
|
{
|
|
[Header("摄像机的")]
|
|
public Conf1 conf1 = new Conf1();
|
|
|
|
[Header("可插拔组件的")]
|
|
public Conf2 conf2 = new Conf2();
|
|
|
|
|
|
|
|
/// <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;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class Conf2
|
|
{
|
|
public bool isUse;
|
|
//模型类型
|
|
public ModuleType module_type;
|
|
//板卡类型
|
|
public Type_Card type_card;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public enum ModuleType
|
|
{
|
|
板卡,
|
|
风扇,
|
|
开关,
|
|
}
|
|
|
|
[System.Serializable]
|
|
public enum Type_Card
|
|
{
|
|
板卡1,
|
|
板卡2,
|
|
板卡3,
|
|
板卡4,
|
|
板卡5,
|
|
板卡6,
|
|
板卡7,
|
|
板卡8,
|
|
板卡9,
|
|
板卡10,
|
|
板卡11,
|
|
板卡12,
|
|
板卡13,
|
|
板卡14,
|
|
板卡15,
|
|
板卡16,
|
|
板卡17,
|
|
板卡18,
|
|
板卡19,
|
|
板卡20,
|
|
板卡21,
|
|
板卡22,
|
|
板卡23,
|
|
板卡24,
|
|
板卡25,
|
|
板卡26,
|
|
板卡27,
|
|
板卡28,
|
|
板卡29,
|
|
板卡30,
|
|
板卡31,
|
|
板卡32,
|
|
板卡33,
|
|
板卡34,
|
|
板卡35,
|
|
板卡36,
|
|
板卡37,
|
|
板卡38,
|
|
板卡39,
|
|
板卡40,
|
|
板卡41,
|
|
板卡42,
|
|
板卡43,
|
|
板卡44,
|
|
板卡45,
|
|
板卡46,
|
|
板卡47,
|
|
板卡48,
|
|
板卡49,
|
|
板卡50,
|
|
板卡51,
|
|
板卡52,
|
|
板卡53,
|
|
板卡54,
|
|
板卡55,
|
|
板卡56,
|
|
板卡57,
|
|
板卡58,
|
|
板卡59,
|
|
板卡60,
|
|
板卡61,
|
|
板卡62,
|
|
板卡63,
|
|
板卡64,
|
|
板卡65,
|
|
板卡66,
|
|
板卡67,
|
|
板卡68,
|
|
板卡69,
|
|
板卡70,
|
|
板卡71,
|
|
板卡72,
|
|
板卡73,
|
|
板卡74,
|
|
板卡75,
|
|
板卡76,
|
|
板卡77,
|
|
板卡78,
|
|
板卡79,
|
|
板卡80,
|
|
板卡81,
|
|
板卡82,
|
|
板卡83,
|
|
板卡84,
|
|
板卡85,
|
|
板卡86,
|
|
板卡87,
|
|
板卡88,
|
|
板卡89,
|
|
板卡90,
|
|
板卡91,
|
|
板卡92,
|
|
板卡93,
|
|
板卡94,
|
|
板卡95,
|
|
板卡96,
|
|
板卡97,
|
|
板卡98,
|
|
板卡99,
|
|
板卡100,
|
|
}
|
|
}
|