上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

130 lines
4.4 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using Newtonsoft.Json;
/// <summary>
///
/// <summary>
public class EquipmentAttrubeConfig : EditorWindow
{
[MenuItem("Tools/设备属性配置")]
static void EquipmentConfigWindow()
{
var window = (EquipmentAttrubeConfig)EditorWindow.GetWindow(typeof(EquipmentAttrubeConfig), true, "属性配置");
window.Show();
}
private void OnGUI()
{
if (GUILayout.Button("Set"))
{
OnSet();
}
if (GUILayout.Button("Power"))
{
OnPowerSet();
}
}
private void OnPowerSet()
{
var list = new List<PowerAttributeConfig>();
foreach (var go in Selection.gameObjects)
{
var data = new PowerAttributeConfig();
data.id = go.name;
if (go.GetComponent<BoxCollider>())
{
data.isBoxcollider = true;
data.boxColliderCenter = go.GetComponent<BoxCollider>().center;
data.boxColliderSize = go.GetComponent<BoxCollider>().size;
}
if (go.GetComponent<MeshCollider>())
data.isMeshCollider = true;
data.createMode = go.GetComponent<PowerController>().PowerMode;
data.taskType = go.GetComponent<PowerController>().taskType;
if (go.GetComponent<FiremanController>())
data.isFiremanController = true;
if (go.GetComponent<ShuiGuanCheController>())
data.isShuiGuanCheController = true;
if (go.GetComponent<GaoPenCheController>())
data.isGaoPenCheController = true;
if (go.GetComponent<DengGaoPingTaiCheController>())
data.isDenGaoCheController = true;
if (go.GetComponent<YunTiCheController>())
data.isYunTiCheController = true;
if (go.GetComponent<AreaController>())
data.isAreaController = true;
if (go.GetComponent<Ladder6Controller>())
data.isLT6Controller = true;
if (go.GetComponent<Ladder15Controller>())
data.isLT15Controller = true;
if (go.GetComponent<WaterMonitorController>())
data.isWaterMonitorController = true;
if (go.GetComponent<ZhaoMingCheController>())
data.isZhaoMingCheController = true;
if (go.transform.Find("Info"))
data.isInfo = true;
list.Add(data);
}
Debug.Log(list.Count);
var json = JsonConvert.SerializeObject(list, Formatting.Indented);
var path = $"{Application.streamingAssetsPath}/Config/PowerAttributeConfig.json";
Debug.Log(json);
File.WriteAllText(path, json);
}
private void OnSet()
{
var list = new List<EquipmentAttributeConfig>();
foreach(var go in Selection.gameObjects)
{
var data = new EquipmentAttributeConfig();
data.Id = go.name;
if (go.GetComponent<BoxCollider>())
{
data.IsBoxCollider = true;
data.BoxColliderCenter = go.GetComponent<BoxCollider>().center;
data.BoxColliderSize = go.GetComponent<BoxCollider>().size;
}
else
{
data.IsBoxCollider = false;
}
if (go.GetComponent<MeshCollider>())
data.IsMeshCollider = true;
else
{
data.IsMeshCollider = false;
}
data.Type = go.GetComponent<EquipmentController>().equipmentType;
if (go.GetComponent<EquipmentDataListening>())
data.IsEquipmentDataListening = true;
data.ufIconName = go.GetComponent<UIFollowTarget>().IconName;
data.ufDistanceY = go.GetComponent<UIFollowTarget>().DistanceY;
data.ufChangeFloor = go.GetComponent<UIFollowTarget>().ChangeFloor;
data.ufFloorNumber = go.GetComponent<UIFollowTarget>().FloorNumber;
list.Add(data);
}
Debug.Log(list.Count);
var json = JsonConvert.SerializeObject(list, Formatting.Indented);
var path = $"{Application.streamingAssetsPath}/Config/EquipmentAttributeConfig.json";
Debug.Log(json);
File.WriteAllText(path,json);
}
}