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.
639 lines
30 KiB
639 lines
30 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEditor; |
|
using UnityEngine.AI; |
|
using System.IO; |
|
using System.Text; |
|
using System; |
|
|
|
public class SceneToolFloor |
|
{ |
|
[MenuItem("SceneTool/SetFloorMessage")]//添加FloorMessage脚本绑定楼层信息 |
|
public static void SetFloorMessage() |
|
{ |
|
Transform neiParent = GameObject.Find("shinei").transform.GetChild(0); |
|
for (int i = 0; i < neiParent.childCount; i++) |
|
{ |
|
//Debug.Log(neiParent.GetChild(i).name); |
|
if (!neiParent.GetChild(i).GetComponent<FloorMessage>()) |
|
{ |
|
neiParent.GetChild(i).gameObject.AddComponent<FloorMessage>(); |
|
} |
|
FloorMessage msg = neiParent.GetChild(i).GetComponent<FloorMessage>(); |
|
msg.targetTrans = GetTarget(neiParent.GetChild(i)); |
|
msg.buildNum = neiParent.name; |
|
if (!neiParent.GetChild(i).name.ToLower().Contains("m")) |
|
{ |
|
string floornum = neiParent.GetChild(i).name.Substring |
|
(neiParent.GetChild(i).name.ToLower().IndexOf("nei") + 3/*, neiParent.GetChild(i).name.Length - 4*/); |
|
|
|
msg.floorNum = int.Parse(floornum); |
|
msg.interlayerNum = 0; |
|
} |
|
else |
|
{ |
|
string floornum = neiParent.GetChild(i).name.Substring(4); |
|
msg.floorNum = int.Parse(floornum); |
|
msg.interlayerNum = 1; |
|
} |
|
} |
|
Transform waiParent = GameObject.Find("shiwai").transform.GetChild(0); |
|
for (int i = 0; i < waiParent.childCount; i++) |
|
{ |
|
//Debug.Log(waiParent.GetChild(i).name); |
|
if (!waiParent.GetChild(i).GetComponent<FloorMessage>()) |
|
{ |
|
waiParent.GetChild(i).gameObject.AddComponent<FloorMessage>(); |
|
} |
|
FloorMessage msg = waiParent.GetChild(i).GetComponent<FloorMessage>(); |
|
msg.buildNum = waiParent.name; |
|
if (!waiParent.GetChild(i).name.ToLower().Contains("m")) |
|
{ |
|
string floornum = waiParent.GetChild(i).name.Substring |
|
(waiParent.GetChild(i).name.ToLower().IndexOf("wai") + 3/*, waiParent.GetChild(i).name.Length - 4*/); |
|
msg.floorNum = int.Parse(floornum); |
|
msg.interlayerNum = 0; |
|
} |
|
else |
|
{ |
|
string floornum = waiParent.GetChild(i).name.Substring(4); |
|
msg.floorNum = int.Parse(floornum); |
|
msg.interlayerNum = 1; |
|
} |
|
} |
|
} |
|
static Transform GetTarget(Transform parent) |
|
{ |
|
for (int i = 0; i < parent.childCount; i++) |
|
{ |
|
if (parent.GetChild(i).name.ToLower().Contains("_floor") |
|
|| parent.GetChild(i).name.ToLower().Contains("-floor") |
|
) |
|
{ |
|
return parent.GetChild(i); |
|
} |
|
} |
|
|
|
return parent; |
|
} |
|
[MenuItem("SceneTool/SetNavLayershinei")]//添加寻路层(选中shinei对象设置,注:扶梯情况特殊没有包含) |
|
public static void SetNavLayer() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
CloneableEnums shineienums = GameObject.Find("CloneAbleEnumsParent").transform.Find("ShiNeiFloor").GetComponent<CloneableEnums>(); |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].name.ToLower().Contains("_floor") ||//地面 |
|
obj[i].name.ToLower().Contains("_floor") ||//地面 |
|
obj[i].name.ToLower().Contains("-floor")) |
|
{ |
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<PathFindingClick>()) |
|
{ |
|
obj[i].gameObject.AddComponent<PathFindingClick>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
//obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
} |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = shineienums.CloneableTypes; |
|
|
|
if (obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Contains(CloneObjType.FirefightingRobot)) |
|
{ |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Remove(CloneObjType.FirefightingRobot); |
|
} |
|
// CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
// GameObject CarRoad = GameObject.Find("FloorNei"); |
|
// var CloneableEnums = CarRoad.GetComponent<CloneableEnums>(); |
|
// enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
if (obj[i].parent.GetComponent<FloorMessage>()) |
|
{ |
|
FloorMessage fmg = obj[i].parent.GetComponent<FloorMessage>(); |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
} |
|
if (obj[i].parent.parent.GetComponent<FloorMessage>()) |
|
{ |
|
FloorMessage fmg = obj[i].parent.parent.GetComponent<FloorMessage>(); |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
} |
|
} |
|
//if (obj[i].name.ToLower().Contains("_wall") ||//墙面 |
|
// obj[i].name.ToLower().Contains("_wall")) |
|
//{ |
|
// obj[i].gameObject.layer = LayerMask.NameToLayer("Wall"); |
|
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
// // if (!obj[i].gameObject.GetComponent<NavMeshModifier>()) |
|
// // { |
|
// // obj[i].gameObject.AddComponent<NavMeshModifier>(); |
|
// // } |
|
// // NavMeshModifier mod = obj[i].gameObject.GetComponent<NavMeshModifier>(); |
|
// // mod.overrideArea = true; |
|
// // mod.area = 1; |
|
// // if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
// // { |
|
// // obj[i].gameObject.AddComponent<MeshCollider>(); |
|
// // } |
|
//} |
|
//if (obj[i].name.ToLower().Contains("lt")&& !obj[i].name.ToLower().Contains("name"))//楼梯 |
|
//{ |
|
// obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
// if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
// { |
|
// obj[i].gameObject.AddComponent<MeshCollider>(); |
|
// } |
|
// if (!obj[i].gameObject.GetComponent<PathFindingClick>()) |
|
// { |
|
// obj[i].gameObject.AddComponent<PathFindingClick>(); |
|
// } |
|
// if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
// { |
|
// obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
// } |
|
// if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
// { |
|
// obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
// //obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
// } |
|
// if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
// { |
|
// obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
// obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = shineienums.CloneableTypes; |
|
|
|
// } |
|
// if (obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Contains(CloneObjType.FirefightingRobot)) |
|
// { |
|
// obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Remove(CloneObjType.FirefightingRobot); |
|
// } |
|
// // CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
// // GameObject CarRoad = GameObject.Find("FloorNei"); |
|
// // var CloneableEnums = CarRoad.GetComponent<CloneableEnums>(); |
|
// // enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
// if (obj[i].parent.GetComponent<FloorMessage>()) |
|
// { |
|
// FloorMessage fmg = obj[i].parent.GetComponent<FloorMessage>(); |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
// } |
|
// if (obj[i].parent.parent.GetComponent<FloorMessage>()) |
|
// { |
|
// FloorMessage fmg = obj[i].parent.parent.GetComponent<FloorMessage>(); |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
// } |
|
//} |
|
} |
|
} |
|
[MenuItem("SceneTool/SetNavLTLayer")]//添加寻路层(选中shinei对象设置,注:扶梯情况特殊没有包含) |
|
public static void SetNavLTLayer() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
CloneableEnums shineienums = GameObject.Find("CloneAbleEnumsParent").transform.Find("ShiNeiFloor").GetComponent<CloneableEnums>(); |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].name.ToUpper().Contains("LT")) |
|
|
|
{ |
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<PathFindingClick>()) |
|
{ |
|
obj[i].gameObject.AddComponent<PathFindingClick>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
//obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
} |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = shineienums.CloneableTypes; |
|
if (obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Contains(CloneObjType.FirefightingRobot)) |
|
{ |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Remove(CloneObjType.FirefightingRobot); |
|
} |
|
// CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
// GameObject CarRoad = GameObject.Find("FloorNei"); |
|
// var CloneableEnums = CarRoad.GetComponent<CloneableEnums>(); |
|
// enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
if (obj[i].parent.GetComponent<FloorMessage>()) |
|
{ |
|
FloorMessage fmg = obj[i].parent.GetComponent<FloorMessage>(); |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
} |
|
if (obj[i].parent.parent.GetComponent<FloorMessage>()) |
|
{ |
|
FloorMessage fmg = obj[i].parent.parent.GetComponent<FloorMessage>(); |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
} |
|
} |
|
|
|
} |
|
} |
|
|
|
[MenuItem("SceneTool/GetNavLayerCarRoad")] |
|
public static void GetNavLayerCarRoad() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
{ |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].gameObject.layer == LayerMask.NameToLayer("CarRoad")) |
|
{ |
|
// if (!obj[i].gameObject.GetComponent<NavMeshModifier>()) |
|
{ |
|
Debug.Log(obj[i].name); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
[MenuItem("SceneTool/SetNavLayerCarRoad")]//高层设置车辆寻路层,添加脚本及设置脚本属性 |
|
public static void SetNavLayerCarRoad() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
CloneableEnums carenums = GameObject.Find("CloneAbleEnumsParent").transform.Find("CarLode").GetComponent<CloneableEnums>(); |
|
{ |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].gameObject.layer == LayerMask.NameToLayer("CarRoad")&& |
|
!obj[i].gameObject.GetComponent<NavMeshModifier>()) |
|
{ |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<PathFindingClick>()) |
|
{ |
|
obj[i].gameObject.AddComponent<PathFindingClick>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
} |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = carenums.CloneableTypes; |
|
} |
|
} |
|
} |
|
} |
|
[MenuItem("SceneTool/SetNavLayerShiwaiHumanRoad")] |
|
public static void SetNavLayershiwaiHumanRoad() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
CloneableEnums shiwaienums = GameObject.Find("CloneAbleEnumsParent").transform.Find("ShiWaiFloor").GetComponent<CloneableEnums>(); |
|
{ |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].gameObject.layer == LayerMask.NameToLayer("SoldierRoad") |
|
&& !obj[i].gameObject.GetComponent<NavMeshModifier>()) |
|
{ |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<PathFindingClick>()) |
|
{ |
|
obj[i].gameObject.AddComponent<PathFindingClick>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
} |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = shiwaienums.CloneableTypes; |
|
} |
|
} |
|
} |
|
} |
|
[MenuItem("SceneTool/ReadCloneTypes")] |
|
static void ReadCloneTypes() |
|
{ |
|
string path = Application.dataPath + "/Floors.txt"; |
|
string str = File.ReadAllText(path, Encoding.UTF8); |
|
string[] EnumStrList = str.Split(','); |
|
//List<CloneObjType> EnmuList = new List<CloneObjType>(); |
|
//foreach (var item in EnumStrList) |
|
//{ |
|
// if (!string.IsNullOrEmpty(item)) |
|
// { |
|
// CloneObjType type = (CloneObjType)Enum.Parse(typeof(CloneObjType), item); |
|
// EnmuList.Add(type); |
|
// } |
|
//} |
|
//GameObject CarRoad = GameObject.Find("FloorNei"); |
|
//if (!CarRoad.GetComponent<CloneableEnums>()) |
|
//{ |
|
// CarRoad.AddComponent<CloneableEnums>(); |
|
//} |
|
//var CloneableEnums = CarRoad.GetComponent<CloneableEnums>(); |
|
//CloneableEnums.CloneableTypes = EnmuList; |
|
} |
|
[MenuItem("SceneTool/AddColider")] |
|
static void AddColider() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Unfiltered); |
|
{ |
|
Debug.Log(obj[0].name); |
|
} |
|
} |
|
[MenuItem("SceneTool/SetShiNeiXHS")] |
|
public static void SetShiNeiXHS() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
CloneableEnums SNXHS = GameObject.Find("CloneAbleEnumsParent").transform.Find("SNXHS").GetComponent<CloneableEnums>(); |
|
{ |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
FloorMessage floormessage = obj[i].GetComponentInParent<FloorMessage>(); |
|
if (obj[i].gameObject.name.ToUpper().Contains("XHS")/*&& obj[i].gameObject.GetComponent<Animator>()*/) |
|
{ |
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
{ |
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
} |
|
|
|
if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<WaterSource>()) |
|
{ |
|
obj[i].gameObject.AddComponent<WaterSource>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<WATER_SOURCE_INFO_SYNC>()) |
|
{ |
|
obj[i].gameObject.AddComponent<WATER_SOURCE_INFO_SYNC>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<XFSS>()) |
|
{ |
|
obj[i].gameObject.AddComponent<XFSS>(); |
|
} |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = floormessage.buildNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = floormessage.floorNum; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = floormessage.interlayerNum; |
|
obj[i].gameObject.GetComponent<XFSS>().type = XFSSType.室内消火栓; |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = SNXHS.CloneableTypes; |
|
obj[i].gameObject.GetComponent<WaterSource>().water = true; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
} |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 作战部署消火栓等图标显示Quad添加,需要先在需要的物体上添加XFSS脚本 |
|
/// </summary> |
|
[MenuItem("SceneTool/AddQuad")] |
|
public static void AddQuad() |
|
{ |
|
QuadMat quadMat = GameObject.Find("QuadMat").GetComponent<QuadMat>(); |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].GetComponent<XFSS>()) |
|
{ |
|
if (!obj[i].transform.Find("Quad")&& obj[i].name!="Quad") |
|
{ |
|
GameObject quad = GameObject.Instantiate(quadMat.Quad); |
|
quad.name = "Quad"; |
|
quad.transform.parent = obj[i].transform; |
|
quad.transform.localPosition = Vector3.up * 10; |
|
switch (obj[i].GetComponent<XFSS>().type) |
|
{ |
|
case XFSSType.地上消火栓: |
|
quad.GetComponent<Renderer>().material = quadMat.mats[0]; |
|
break; |
|
case XFSSType.泡沫栓: |
|
quad.GetComponent<Renderer>().material = quadMat.mats[1]; |
|
break; |
|
case XFSSType.水泵接合器: |
|
quad.GetComponent<Renderer>().material = quadMat.mats[2]; |
|
break; |
|
case XFSSType.水炮: |
|
quad.GetComponent<Renderer>().material = quadMat.mats[3]; |
|
break; |
|
case XFSSType.室内消火栓: |
|
quad.GetComponent<Renderer>().material = quadMat.mats[0]; |
|
break; |
|
default: |
|
break; |
|
} |
|
quad.layer = LayerMask.NameToLayer("FightDeploy"); |
|
obj[i].transform.Find("Quad").localScale = new Vector3(3, 3, 3); |
|
quad.gameObject.SetActive(false); |
|
} |
|
else |
|
{ |
|
obj[i].transform.Find("Quad").gameObject.layer = LayerMask.NameToLayer("FightDeploy"); |
|
obj[i].transform.Find("Quad").localScale = new Vector3(3, 3, 3); |
|
obj[i].transform.Find("Quad").gameObject.SetActive(false); |
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
[MenuItem("SceneTool/ClearMissSprite")] |
|
public static void ClearMissSprite() |
|
{ |
|
|
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
var gameObject = obj[i].gameObject; |
|
object p = GameObjectUtility.RemoveMonoBehavioursWithMissingScript(gameObject); |
|
} |
|
} |
|
} |
|
|
|
[MenuItem("SceneTool/SetOilNormal")] |
|
public static void SetOilNormal() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
GameObject NornalPre = GameObject.Find("NormalPre"); |
|
if (!obj[0].GetComponent<Mesh>()) |
|
{ |
|
//obj[0].gameObject.AddComponent<MeshFilter>(); |
|
//obj[0].gameObject.GetComponent<MeshFilter>().mesh = NornalPre.GetComponent<MeshFilter>().mesh; |
|
|
|
// obj[0].gameObject.AddComponent<MeshRenderer>(); |
|
obj[0].gameObject.GetComponent<MeshRenderer>().material = NornalPre.GetComponent<MeshRenderer>().material; |
|
|
|
//obj[0].gameObject.AddComponent<MeshCollider>(); |
|
//obj[0].gameObject.GetComponent<MeshCollider>().sharedMesh = NornalPre.GetComponent<MeshCollider>().sharedMesh; |
|
|
|
obj[0].gameObject.AddComponent<CreateStaticObjID>(); |
|
|
|
obj[0].gameObject.AddComponent<OilTankBase>(); |
|
|
|
obj[0].gameObject.AddComponent<OilTankMessage>(); |
|
|
|
obj[0].gameObject.AddComponent<HideOilLevel>(); |
|
|
|
obj[0].gameObject.AddComponent<OIL_TANK_INFO_SYNC>(); |
|
|
|
obj[0].gameObject.AddComponent<OilTankDisasterRecord>(); |
|
|
|
obj[0].gameObject.AddComponent<CloneableEnums>(); |
|
obj[0].gameObject.GetComponent<CloneableEnums>().CloneableTypes = NornalPre.GetComponent<CloneableEnums>().CloneableTypes; |
|
obj[0].gameObject.name = "Normal"; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 替换场景中的水炮,适用于没有拆分但是需要出水的水炮 |
|
/// </summary> |
|
[MenuItem("SceneTool/ChangeShuiPao")] |
|
public static void ChangeShuiPao() |
|
{ |
|
GameObject shuipaopre = Resources.Load<GameObject>("ShuiPao"); |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].GetComponent<Collider>()) |
|
{ |
|
GameObject csp = GameObject.Instantiate(shuipaopre); |
|
csp.transform.parent = obj[i].parent; |
|
csp.transform.localPosition = obj[i].localPosition; |
|
// csp.transform.localRotation = obj[i].localRotation; |
|
csp.name = "shuipao" + i; |
|
obj[i].gameObject.SetActive(false); |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 须先添加MeshCollider使用,选中消火栓父物体设置 |
|
/// </summary> |
|
[MenuItem("SceneTool/SetShiWaiXHS")] |
|
public static void SetShiWaiXHS() |
|
{ |
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
CloneableEnums SNXHS = GameObject.Find("CloneAbleEnumsParent").transform.Find("SNXHS").GetComponent<CloneableEnums>(); |
|
{ |
|
for (int i = 0; i < obj.Length; i++) |
|
{ |
|
if (obj[i].gameObject.GetComponent<MeshCollider>()&& obj[i].name != "Quad") |
|
{ |
|
if (!obj[i].gameObject.GetComponent<CreateStaticObjID>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CreateStaticObjID>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
{ |
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<WaterSource>()) |
|
{ |
|
obj[i].gameObject.AddComponent<WaterSource>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<WATER_SOURCE_INFO_SYNC>()) |
|
{ |
|
obj[i].gameObject.AddComponent<WATER_SOURCE_INFO_SYNC>(); |
|
} |
|
if (!obj[i].gameObject.GetComponent<XFSS>()) |
|
{ |
|
obj[i].gameObject.AddComponent<XFSS>(); |
|
} |
|
|
|
obj[i].gameObject.GetComponent<XFSS>().type = XFSSType.地上消火栓; |
|
obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes = SNXHS.CloneableTypes; |
|
obj[i].gameObject.GetComponent<WaterSource>().water = true; |
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.staticGameObject; |
|
if (obj[i].GetComponent<XFSS>()) |
|
{ |
|
if (obj[i].GetComponent<XFSS>().type==XFSSType.泡沫栓) |
|
{ |
|
obj[i].gameObject.GetComponent<WaterSource>().foam = true; |
|
} |
|
} |
|
} |
|
} |
|
|
|
} |
|
} |
|
|
|
} |