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.
302 lines
12 KiB
302 lines
12 KiB
8 months ago
|
using UnityEngine;
|
||
|
using UnityEditor;
|
||
|
using Newtonsoft.Json;
|
||
|
public enum FireDesignMode
|
||
|
{
|
||
|
避难层,防火分区,防火门,防火卷帘
|
||
|
}
|
||
|
public enum WaterMode { 室内消火栓,消防泵}
|
||
|
public enum EvacuationMode { 安全出口,疏散楼梯,消防电梯}
|
||
|
namespace AX.PlaneTools
|
||
|
{
|
||
|
using HighlightPlus;
|
||
|
using System;
|
||
|
using System.IO;
|
||
|
using UnityEditor.Animations;
|
||
|
|
||
|
public class PlanToolsEditor : Editor
|
||
|
{
|
||
|
//设置单位输出名称
|
||
|
public static bool isPlayerSetting = true;//是否显示UI;
|
||
|
public static string _productName;//单位名称
|
||
|
//存储设置
|
||
|
public static bool isShowStroe = true;
|
||
|
//模型初始角度
|
||
|
public static bool isInitAngele = true;
|
||
|
public static float InitAngele;
|
||
|
//设置摄像机初始位置;
|
||
|
public static bool isSetCamera = true;//是否显示UI;
|
||
|
public static GameObject MainCamera;//摄影机
|
||
|
public static Vector3 CamPostion;
|
||
|
public static Vector3 CamRotation;
|
||
|
public static float CamDistance;
|
||
|
public static Vector2 CamXY;
|
||
|
public static Vector3 TargetPosition;
|
||
|
//常用名称
|
||
|
public static bool isCommonNames = true;
|
||
|
|
||
|
//消控室
|
||
|
public static bool isFireControlRoom=true;
|
||
|
public static GameObject XKSLocation;
|
||
|
public static int XKSFloorNumber=1;
|
||
|
//防火设计
|
||
|
public static bool isFireDesign = true;
|
||
|
public static FireDesignMode fireDesignMode;
|
||
|
public static Color FireDoorDefaultColor = new Color(0.5f, 0, 0, 1);
|
||
|
public static Color FireDoorActiveColor = new Color(0, 0, 1, 1);
|
||
|
public static Color FireShutterDefaultColor = new Color(0.5f, 0, 0, 1);
|
||
|
public static Color FireShutterActiveColor = new Color(0, 0, 1, 1);
|
||
|
//供水系统
|
||
|
public static bool isWaterSupply=true;
|
||
|
public static WaterMode waterMode;
|
||
|
public static GameObject BFLocation;
|
||
|
public static int BFFloorNumber = -1;
|
||
|
public static int SXFloorNumber = 12;
|
||
|
public static AnimatorController HydrantController;
|
||
|
public static float SBJHQDistanceY = 0.75f;
|
||
|
public static float SWXHSDistanceY = 0.8f;
|
||
|
public static string SWXHSIconName = "DSXHSIcon";
|
||
|
|
||
|
public static Color PumpDefaultColor = new Color(1, 1, 1, 1);
|
||
|
public static Color PumpActiveColor = new Color(0, 1, 0, 1);
|
||
|
//疏散系统
|
||
|
public static bool isEvacuation = true;
|
||
|
public static EvacuationMode evacuationMode;
|
||
|
|
||
|
#region 模型初始角度
|
||
|
public static void GetInitAngele()
|
||
|
{
|
||
|
var url = $"{Application.streamingAssetsPath}/Data/InitialAngle.json";
|
||
|
GetInfo<InitialAngele>(url, data =>
|
||
|
{
|
||
|
InitAngele = data.Angle;
|
||
|
});
|
||
|
|
||
|
}
|
||
|
public static void SetInitAngele()
|
||
|
{
|
||
|
var url = $"{Application.streamingAssetsPath}/Data/InitialAngle.json";
|
||
|
var data = new InitialAngele
|
||
|
{
|
||
|
Angle = InitAngele
|
||
|
};
|
||
|
PostInfo(url, data);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
#region 摄影机设置
|
||
|
public static void GetCameraParameter()
|
||
|
{
|
||
|
CamPostion = MainCamera.transform.position;
|
||
|
CamRotation = MainCamera.transform.eulerAngles;
|
||
|
|
||
|
CamDistance = MainCamera.GetComponent<CameraOrbit>().distance;
|
||
|
CamXY = new Vector2(MainCamera.GetComponent<CameraOrbit>().x, MainCamera.GetComponent<CameraOrbit>().y);
|
||
|
TargetPosition = MainCamera.GetComponent<CameraOrbit>().target.position;
|
||
|
}
|
||
|
|
||
|
//初始角度
|
||
|
public static void SetInitializationCamera()
|
||
|
{
|
||
|
MainCamera.transform.position = CamPostion;
|
||
|
MainCamera.transform.eulerAngles = CamRotation;
|
||
|
MainCamera.GetComponent<CameraOrbit>().distance = CamDistance;
|
||
|
MainCamera.GetComponent<CameraOrbit>().x = CamXY.x;
|
||
|
MainCamera.GetComponent<CameraOrbit>().y = CamXY.y;
|
||
|
MainCamera.GetComponent<CameraOrbit>().target.position = TargetPosition;
|
||
|
}
|
||
|
//高度
|
||
|
public static void SetHeightCamera()
|
||
|
{
|
||
|
var Data = new CameraLocationDataReactive();
|
||
|
string fullpath = Application.streamingAssetsPath + "/Data/HeightLocation.json";
|
||
|
|
||
|
CameraLocationData tempData = new CameraLocationData
|
||
|
{
|
||
|
Position = CamPostion,
|
||
|
Rotation = CamRotation,
|
||
|
Distance = CamDistance,
|
||
|
Xy = CamXY,
|
||
|
Pivot = TargetPosition,
|
||
|
};
|
||
|
Data.SetData(tempData);
|
||
|
PostInfo(fullpath, tempData);
|
||
|
}
|
||
|
//毗邻
|
||
|
public static void SetAdjacentCamera()
|
||
|
{
|
||
|
var Data = new CameraLocationDataReactive();
|
||
|
string fullpath = Application.streamingAssetsPath + "/Data/AdjacentLocation.json";
|
||
|
|
||
|
CameraLocationData tempData = new CameraLocationData
|
||
|
{
|
||
|
Position = CamPostion,
|
||
|
Rotation = CamRotation,
|
||
|
Distance = CamDistance,
|
||
|
Xy = CamXY,
|
||
|
Pivot = TargetPosition,
|
||
|
};
|
||
|
Data.SetData(tempData);
|
||
|
PostInfo(fullpath, tempData);
|
||
|
}
|
||
|
#endregion
|
||
|
#region 常用名称
|
||
|
public static void CommonNames(string name)
|
||
|
{
|
||
|
foreach(GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
go.name = name;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
#region 防火设计
|
||
|
//避难层
|
||
|
public static void SetRefugeFloor()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
go.GetComponent<MeshRenderer>().enabled = false;
|
||
|
go.AddComponent<RefugeFloorListening>();
|
||
|
}
|
||
|
}
|
||
|
//防火分区
|
||
|
public static void SetFireZones()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
go.GetComponent<MeshRenderer>().enabled = false;
|
||
|
}
|
||
|
}
|
||
|
//防火门
|
||
|
public static void SetFireDoors()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<Lumos>() == null) { go.AddComponent<Lumos>(); }
|
||
|
go.GetComponent<Lumos>().NormalColor = FireDoorDefaultColor;
|
||
|
go.GetComponent<Lumos>().TargetColor = FireDoorActiveColor;
|
||
|
go.GetComponent<Lumos>().enabled = false;
|
||
|
}
|
||
|
}
|
||
|
//防火卷帘
|
||
|
public static void SetFireShutters()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<Lumos>() == null) { go.AddComponent<Lumos>(); }
|
||
|
go.GetComponent<Lumos>().NormalColor = FireShutterDefaultColor;
|
||
|
go.GetComponent<Lumos>().TargetColor = FireShutterActiveColor;
|
||
|
go.GetComponent<Lumos>().enabled = false;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
#region 供水系统
|
||
|
|
||
|
public static void OnIndoorHydrants()
|
||
|
{
|
||
|
foreach(GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<MeshRenderer>())
|
||
|
{
|
||
|
go.AddComponent<Animator>();
|
||
|
go.GetComponent<Animator>().runtimeAnimatorController = HydrantController;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public static void OnFirePump()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<BoxCollider>() == null) { go.AddComponent<BoxCollider>(); }
|
||
|
if (go.GetComponent<HighlightEffect>() == null) { go.AddComponent<HighlightEffect>(); }
|
||
|
if (go.GetComponent<EquipmentController>() == null) { go.AddComponent<EquipmentController>(); }
|
||
|
if (go.GetComponent<Lumos>() == null) { go.AddComponent<Lumos>(); }
|
||
|
if (go.GetComponent<EquipmentDataListening>() == null) { go.AddComponent<EquipmentDataListening>(); }
|
||
|
go.GetComponent<EquipmentController>().equipmentType = EquipmentType.Pump;
|
||
|
go.GetComponent<Lumos>().NormalColor = PumpDefaultColor;
|
||
|
go.GetComponent<Lumos>().TargetColor = PumpActiveColor;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
#region 疏散系统
|
||
|
public static void OnFireEscape()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<BoxCollider>() == null) { go.AddComponent<BoxCollider>(); }
|
||
|
if (go.GetComponent<Lumos>() == null) { go.AddComponent<Lumos>(); }
|
||
|
if (go.GetComponent<UIFollowTarget>() == null) { go.AddComponent<UIFollowTarget>(); }
|
||
|
if (go.GetComponent<EquipmentController>() == null) { go.AddComponent<EquipmentController>(); }
|
||
|
if (go.GetComponent<HighlightEffect>() == null) { go.AddComponent<HighlightEffect>(); }
|
||
|
if (go.GetComponent<EquipmentDataListening>() == null) { go.AddComponent<EquipmentDataListening>(); }
|
||
|
|
||
|
go.GetComponent<Lumos>().NormalColor = new Color(0f, 0.6f, 0f, 1f);
|
||
|
go.GetComponent<Lumos>().TargetColor = new Color(0.6f, 0f, 0f, 1f);
|
||
|
go.GetComponent<Lumos>().enabled = false;
|
||
|
|
||
|
go.GetComponent<UIFollowTarget>().IconName = "FireEscapeIcon";
|
||
|
go.GetComponent<UIFollowTarget>().DistanceY = 0.1f;
|
||
|
go.GetComponent<UIFollowTarget>().ZoomIn = true;
|
||
|
go.GetComponent<UIFollowTarget>().Distance = 5f;
|
||
|
|
||
|
go.GetComponent<EquipmentController>().equipmentType = EquipmentType.FireEscape;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
//疏散楼梯
|
||
|
public static void OnEscapeStair()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<BoxCollider>() == null) { go.AddComponent<BoxCollider>(); }
|
||
|
if (go.GetComponent<Lumos>() == null) { go.AddComponent<Lumos>(); }
|
||
|
if (go.GetComponent<EquipmentController>() == null) { go.AddComponent<EquipmentController>(); }
|
||
|
if (go.GetComponent<HighlightEffect>() == null) { go.AddComponent<HighlightEffect>(); }
|
||
|
if (go.GetComponent<EquipmentDataListening>() == null) { go.AddComponent<EquipmentDataListening>(); }
|
||
|
|
||
|
go.GetComponent<Lumos>().NormalColor = new Color(0f, 0.5f, 1f, 1f);
|
||
|
go.GetComponent<Lumos>().TargetColor = new Color(0, 0.6f, 0, 1);
|
||
|
go.GetComponent<Lumos>().enabled = false;
|
||
|
|
||
|
go.GetComponent<EquipmentController>().equipmentType = EquipmentType.EscapeStair;
|
||
|
}
|
||
|
}
|
||
|
//消防电梯
|
||
|
public static void OnFireElevator()
|
||
|
{
|
||
|
foreach (GameObject go in Selection.gameObjects)
|
||
|
{
|
||
|
if (go.GetComponent<BoxCollider>() == null) { go.AddComponent<BoxCollider>(); }
|
||
|
if (go.GetComponent<Lumos>() == null) { go.AddComponent<Lumos>(); }
|
||
|
if (go.GetComponent<EquipmentController>() == null) { go.AddComponent<EquipmentController>(); }
|
||
|
if (go.GetComponent<HighlightEffect>() == null) { go.AddComponent<HighlightEffect>(); }
|
||
|
if (go.GetComponent<EquipmentDataListening>() == null) { go.AddComponent<EquipmentDataListening>(); }
|
||
|
|
||
|
go.GetComponent<Lumos>().NormalColor = new Color(0.6f, 0f, 0f, 1f);
|
||
|
go.GetComponent<Lumos>().TargetColor = new Color(0, 0.6f, 0, 1);
|
||
|
go.GetComponent<Lumos>().enabled = false;
|
||
|
|
||
|
go.GetComponent<EquipmentController>().equipmentType = EquipmentType.FireElevator;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
public static void PostInfo<T>(string url, T obj)
|
||
|
{
|
||
|
var jsonParam = JsonConvert.SerializeObject(obj, Formatting.Indented);
|
||
|
File.WriteAllText(url, jsonParam);
|
||
|
Debug.Log("数据信息上传完成");
|
||
|
}
|
||
|
|
||
|
public static void GetInfo<T>(string url, Action<T> action)
|
||
|
{
|
||
|
string json = File.ReadAllText(url);
|
||
|
T obj = JsonConvert.DeserializeObject<T>(json);
|
||
|
action?.Invoke(obj);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|