|
|
|
@ -2,668 +2,96 @@ using System.Collections;
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using UnityEngine; |
|
|
|
|
using UnityEditor; |
|
|
|
|
using UnityEngine.AI; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Text; |
|
|
|
|
using System; |
|
|
|
|
|
|
|
|
|
public class SceneTool |
|
|
|
|
public class SceneTool : Editor |
|
|
|
|
{ |
|
|
|
|
[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 - 3); |
|
|
|
|
msg.floorNum = int.Parse(floornum); |
|
|
|
|
msg.interlayerNum = 0; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
msg.floorNum = int.Parse(neiParent.GetChild(i).name.Substring |
|
|
|
|
(neiParent.GetChild(i).name.ToLower().IndexOf("nei") + 3, neiParent.GetChild(i).name.ToLower().IndexOf("m") |
|
|
|
|
- neiParent.GetChild(i).name.ToLower().IndexOf("nei") - 3)); |
|
|
|
|
msg.interlayerNum = int.Parse(neiParent.GetChild(i).name.Substring |
|
|
|
|
(neiParent.GetChild(i).name.ToLower().IndexOf("m") + 1, neiParent.GetChild(i).name.Length - |
|
|
|
|
neiParent.GetChild(i).name.ToLower().IndexOf("m") - 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 - 3); |
|
|
|
|
msg.floorNum = int.Parse(floornum); |
|
|
|
|
msg.interlayerNum = 0; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
msg.floorNum = int.Parse(waiParent.GetChild(i).name.Substring |
|
|
|
|
(waiParent.GetChild(i).name.ToLower().IndexOf("wai") + 3, waiParent.GetChild(i).name.ToLower().IndexOf("m") |
|
|
|
|
- waiParent.GetChild(i).name.ToLower().IndexOf("wai") - 3)); |
|
|
|
|
msg.interlayerNum = int.Parse(waiParent.GetChild(i).name.Substring |
|
|
|
|
(waiParent.GetChild(i).name.ToLower().IndexOf("m") + 1, waiParent.GetChild(i).name.Length - |
|
|
|
|
waiParent.GetChild(i).name.ToLower().IndexOf("m") - 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") |
|
|
|
|
|| parent.GetChild(i).name.ToLower().Contains("-floor") |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
if (parent.GetChild(i).GetComponent<MeshRenderer>()) |
|
|
|
|
return parent.GetChild(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return parent; |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetNavLayerShiNeiFloor")]//添加寻路层(选中shinei对象设置,注:扶梯情况特殊没有包含) |
|
|
|
|
public static void SetNavLayerShiNeiFloor() |
|
|
|
|
[MenuItem("SceneTool/AddNewScripts")]//优化增加新的脚本 |
|
|
|
|
public static void AddNewScripts() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
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].name.ToLower().Contains("chewei") || |
|
|
|
|
obj[i].name.ToLower().Contains("-floor") && |
|
|
|
|
obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("TheCarRoad").transform.Find("ShiNeiFloor"); |
|
|
|
|
var CloneableEnums = Template.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].name.ToLower().Contains("wall") || |
|
|
|
|
obj[i].name.ToLower().Contains("-wall") && |
|
|
|
|
obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
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("zhuzi") ||//柱子 |
|
|
|
|
obj[i].name.ToLower().Contains("_zhuzi") || |
|
|
|
|
obj[i].name.ToLower().Contains("-zhuzi") && |
|
|
|
|
obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
//Debug.Log(obj[i].name); |
|
|
|
|
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].GetComponent<MeshRenderer>() && |
|
|
|
|
!obj[i].name.ToLower().Contains("lt_name") && |
|
|
|
|
!obj[i].name.ToLower().Contains("_ltcs"))//楼梯 |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("TheCarRoad").transform.Find("ShiNeiFloor"); |
|
|
|
|
var CloneableEnums = Template.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("ft") && |
|
|
|
|
obj[i].GetComponent<MeshRenderer>() && |
|
|
|
|
!obj[i].name.ToLower().Contains("ft_name") && |
|
|
|
|
!obj[i].name.ToLower().Contains("bf"))//扶梯 |
|
|
|
|
if (obj[i].gameObject.activeInHierarchy && obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneEnumsHelp>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
|
|
|
obj[i].gameObject.AddComponent<CloneEnumsHelp>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
var count = obj[i].GetComponent<CloneableEnums>().CloneableTypes.Count; |
|
|
|
|
if (count == 81 || count == 80 || count == 82)// 室外车能走 |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.ShiWaiCar; |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("TheCarRoad").transform.Find("ShiNeiFloor"); |
|
|
|
|
var CloneableEnums = Template.GetComponent<CloneableEnums>(); |
|
|
|
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
|
|
|
if (obj[i].parent.GetComponent<FloorMessage>()) |
|
|
|
|
else if (count == 35 && hasParentByName(obj[i].gameObject, "shinei"))// 室内人能走 |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.ShiNeiMan; |
|
|
|
|
} |
|
|
|
|
if (obj[i].parent.parent.GetComponent<FloorMessage>()) |
|
|
|
|
else if (count == 35 && hasParentByName(obj[i].gameObject, "shiwai"))// 楼顶 |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.LouDing; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetNavLayerShiWaiCarRoad")]//添加寻路层车(前提是将车的寻路层添加layer CarRoad) |
|
|
|
|
public static void SetNavLayerShiWaiCarRoad() |
|
|
|
|
{ |
|
|
|
|
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>()) |
|
|
|
|
else if (count == 46 || count == 36 || count == 47)// 室外人能走 |
|
|
|
|
{ |
|
|
|
|
//Debug.Log(obj[i].name); |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
if (hasParentByName(obj[i].gameObject, "shinei")) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.ShiNeiMan; |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.ShiWaiMan; |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("TheCarRoad").transform; |
|
|
|
|
var CloneableEnums = Template.GetComponent<CloneableEnums>(); |
|
|
|
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetNavLayerShiWaiSoldierRoad")]//添加寻路层车(前提是将车的寻路层添加layer SoliderRoad) |
|
|
|
|
public static void SetNavLayerShiWaiSoliderRoad() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].gameObject.layer == LayerMask.NameToLayer("SoldierRoad")) |
|
|
|
|
{ |
|
|
|
|
if (!obj[i].gameObject.GetComponent<NavMeshModifier>()) |
|
|
|
|
{ |
|
|
|
|
//Debug.Log(obj[i].name); |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("TheCarRoad").transform.Find("ShiWaiSolider"); |
|
|
|
|
var CloneableEnums = Template.GetComponent<CloneableEnums>(); |
|
|
|
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/RemoveColider")]//移除碰撞器 |
|
|
|
|
public static void RemoveColider() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
UnityEngine.Object.DestroyImmediate(obj[i].GetComponent<MeshCollider>(), true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/AddColider")]//添加碰撞器 |
|
|
|
|
public static void AddColider() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
if (!obj[i].GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetGuanDing")] |
|
|
|
|
public static void SetGuanDing() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else if (obj[i].gameObject.GetComponent<InDoorHydrantMessage>())// 室内消火栓 |
|
|
|
|
{ |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<FireOnTank>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<FireOnTank>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
} |
|
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("Guanding").transform; |
|
|
|
|
var CloneableEnums = Template.GetComponent<CloneableEnums>(); |
|
|
|
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.ShiNeiXHS; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetGuanBi")] |
|
|
|
|
public static void SetGuanBi() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else if (count == 3)//罐顶 |
|
|
|
|
{ |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("GuanBi").transform; |
|
|
|
|
var CloneableEnums = Template.GetComponent<CloneableEnums>(); |
|
|
|
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.YouGuanDing; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetGuanDi")] |
|
|
|
|
public static void SetGuanDi() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else if (count == 1 && hasParentByName(obj[i].gameObject, "GuanQu"))//罐壁 |
|
|
|
|
{ |
|
|
|
|
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>(); |
|
|
|
|
} |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.YouGuanBi; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetTeamTargetItemName")] |
|
|
|
|
public static void SetTeamTargetItemName() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<TeamTargetItem>()) |
|
|
|
|
else if (count == 27)//罐区地面 |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.GetComponent<TeamTargetItem>().TankName = obj[i].gameObject.name; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.GuanQuDiMian; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetGuanLouTi")] |
|
|
|
|
public static void SetGuanLouTi() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else if (count == 1 && hasParentByName(obj[i].gameObject, "syk"))//试压口 |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<MeshCollider>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<PathFindable>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<PathFindable>(); |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
Transform Template = GameObject.Find("GuanLouTi").transform; |
|
|
|
|
var CloneableEnums = Template.GetComponent<CloneableEnums>(); |
|
|
|
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.ShiYaKou; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetDouBuZou")] |
|
|
|
|
public static void SetDouBuZou() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else if (count == 1 && hasParentByName(obj[i].gameObject, "CubeParent"))//半固定接口 |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.layer = LayerMask.NameToLayer("CarRoad"); |
|
|
|
|
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>(); |
|
|
|
|
} |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.SemiFixedInterface; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/ChangDingName")] |
|
|
|
|
public static void ChangDingName() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else if (count == 1 && hasParentByName(obj[i].gameObject, "Normal"))//半固定分水器 |
|
|
|
|
{ |
|
|
|
|
if (obj[i].gameObject.GetComponent<FireOnTank>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.name = "GuanDing"; |
|
|
|
|
} |
|
|
|
|
obj[i].gameObject.GetComponent<CloneEnumsHelp>().cloneOnFloorType = CloneOnFloorType.SemiFixedWaterSegregator; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/ChangBiName")] |
|
|
|
|
public static void ChangBiName() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (obj[i].gameObject.GetComponent<CloneableEnums>() && obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes.Count == 1) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].gameObject.GetComponent<CloneableEnums>().CloneableTypes[0] == CloneObjType.FireBreakThough) |
|
|
|
|
obj[i].gameObject.name = "GuanBi"; |
|
|
|
|
} |
|
|
|
|
Debug.Log("警告,有对象没有绑定上脚本" + obj[i].name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/ChangeMessage")]//添加碰撞器 |
|
|
|
|
public static void ChangeMessage() |
|
|
|
|
private static bool hasParentByName(GameObject gameObject, string parentName) |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
if (gameObject.transform.parent) |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
if (gameObject.transform.parent.name == parentName) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<CloneGameObjInfo>()) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<CloneGameObjInfo>().buildNum == "8XGYTC") |
|
|
|
|
{ |
|
|
|
|
obj[i].GetComponent<CloneGameObjInfo>().buildNum = "2XGYTC"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/RemoveAnimator")]//移除碰撞器 |
|
|
|
|
public static void RemoveAnimator() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<Animator>()) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<Animator>()) |
|
|
|
|
{ |
|
|
|
|
UnityEngine.Object.DestroyImmediate(obj[i].GetComponent<Animator>(), true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return hasParentByName(gameObject.transform.parent.gameObject, parentName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[MenuItem("SceneTool/SetshineiXHS")]//设置室内消火栓属性 |
|
|
|
|
public static void SetSNXHS() |
|
|
|
|
{ |
|
|
|
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
|
|
|
|
for (int i = 0; i < obj.Length; i++) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (obj[i].name.ToLower().Contains("xhs") && |
|
|
|
|
!obj[i].name.ToLower().Contains("xhs_name") && |
|
|
|
|
!obj[i].name.ToLower().Contains("xhs_wz") && |
|
|
|
|
!obj[i].name.ToLower().Contains("xhs-wz") && |
|
|
|
|
obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
if (!obj[i].gameObject.GetComponent<BoxCollider>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<BoxCollider>(); |
|
|
|
|
} |
|
|
|
|
if (obj[i].GetComponent<MeshRenderer>()) |
|
|
|
|
{ |
|
|
|
|
if (obj[i].GetComponent<MeshCollider>()) |
|
|
|
|
{ |
|
|
|
|
UnityEngine.Object.DestroyImmediate(obj[i].GetComponent<MeshCollider>(), true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
|
|
|
|
} |
|
|
|
|
if (obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjID == 0) |
|
|
|
|
{ |
|
|
|
|
long staticGameObjId = (long)GUID.NewGuid(1, 1); |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().SetGameObjID(staticGameObjId); |
|
|
|
|
} |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.IndoorFireHydrant; |
|
|
|
|
if (!obj[i].gameObject.GetComponent<InDoorHydrantMessage>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<InDoorHydrantMessage>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<WaterSource>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<WaterSource>(); |
|
|
|
|
} |
|
|
|
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
|
|
|
|
{ |
|
|
|
|
obj[i].gameObject.AddComponent<CloneableEnums>(); |
|
|
|
|
} |
|
|
|
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
|
|
|
|
|
|
|
|
|
List<CloneObjType> EnumsList = new List<CloneObjType>() { |
|
|
|
|
CloneObjType.FireHose |
|
|
|
|
}; |
|
|
|
|
enumParent.CloneableTypes = EnumsList; |
|
|
|
|
if (obj[i].parent.GetComponent<FloorMessage>()) |
|
|
|
|
{ |
|
|
|
|
FloorMessage fmg = obj[i].parent.GetComponent<FloorMessage>(); |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.IndoorFireHydrant; |
|
|
|
|
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.IndoorFireHydrant; |
|
|
|
|
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.parent.GetComponent<FloorMessage>()) |
|
|
|
|
{ |
|
|
|
|
FloorMessage fmg = obj[i].parent.parent.parent.GetComponent<FloorMessage>(); |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.IndoorFireHydrant; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
|
|
|
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|