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.
412 lines
19 KiB
412 lines
19 KiB
4 years ago
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEditor;
|
||
|
using UnityEngine.AI;
|
||
|
|
||
|
public class SceneToolNew
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 选中子建筑父物体设置,根据单位名字长度调整下面BuildName
|
||
|
/// </summary>
|
||
|
[MenuItem("SceneToolNew/ChangefloorName")]
|
||
|
public static void ChangefloorName()
|
||
|
{
|
||
|
string BuildName= Selection.activeTransform.name.Substring(0,1);
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].name.Contains("nei")||obj[i].name.Contains("wai"))
|
||
|
{
|
||
|
obj[i].name = BuildName + obj[i].name;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 需要在楼层上手动挂载FloorMessage脚本
|
||
|
/// </summary>
|
||
|
[MenuItem("SceneToolNew/SetFloorMessage")]
|
||
|
public static void SetfloorMessage()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].GetComponent<FloorMessage>())
|
||
|
{
|
||
|
string name = obj[i].name;
|
||
|
obj[i].GetComponent<FloorMessage>().buildNum = name.Substring(0,1);
|
||
|
|
||
|
if (name.ToLower().Contains("m"))
|
||
|
{
|
||
|
obj[i].GetComponent<FloorMessage>().floorNum = int.Parse(name.Substring(5, name.Length - 5));
|
||
|
obj[i].GetComponent<FloorMessage>().interlayerNum = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
obj[i].GetComponent<FloorMessage>().floorNum = int.Parse(name.Substring(4, name.Length - 4));
|
||
|
obj[i].GetComponent<FloorMessage>().interlayerNum = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[MenuItem("SceneToolNew/SetWallCanMove")]
|
||
|
public static void SetWallCanMove()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].gameObject.layer == LayerMask.NameToLayer("Wall"))
|
||
|
{
|
||
|
if(!obj[i].gameObject.GetComponent<NavMeshModifier>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<NavMeshModifier>();
|
||
|
}
|
||
|
obj[i].gameObject.GetComponent<NavMeshModifier>().overrideArea = true;
|
||
|
obj[i].gameObject.GetComponent<NavMeshModifier>().area = 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
[MenuItem("SceneToolNew/SetNavLayerShiWaiCarRoad")]
|
||
|
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("CarRode"))
|
||
|
{
|
||
|
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<PathFindingClick>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<PathFindingClick>();
|
||
|
}
|
||
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CloneableEnums>();
|
||
|
}
|
||
|
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;
|
||
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>();
|
||
|
Transform Template = GameObject.Find("CloneEnums").transform.Find("CarRoad");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
[MenuItem("SceneToolNew/SetNavLayerShiWaiSoldierRoad")]
|
||
|
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("ManRode"))
|
||
|
{
|
||
|
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<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>();
|
||
|
}
|
||
|
|
||
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CloneableEnums>();
|
||
|
}
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
|
||
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>();
|
||
|
Transform Template = GameObject.Find("CloneEnums").transform.Find("ShiWaiSoldier");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[MenuItem("SceneToolNew/SetShiNeiFloor")]
|
||
|
public static void SetShiNeiFloor()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].gameObject.name.ToLower().Contains("floor")&&
|
||
|
obj[i].gameObject.GetComponent<Renderer>())
|
||
|
{
|
||
|
if (!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<CreateStaticObjID>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CreateStaticObjID>();
|
||
|
}
|
||
|
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("CloneEnums").transform.Find("ShiNeiFloor");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
FloorMessage mess = obj[i].GetComponentInParent<FloorMessage>();
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = mess.buildNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = mess.interlayerNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = mess.floorNum;
|
||
|
obj[i].gameObject.layer = LayerMask.NameToLayer("ManRode");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
[MenuItem("SceneToolNew/SetShiNeiLT")]
|
||
|
public static void SetShiNeiLT()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].gameObject.name.ToLower().Contains("lt") &&
|
||
|
obj[i].gameObject.GetComponent<Renderer>())
|
||
|
{
|
||
|
if (!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<CreateStaticObjID>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CreateStaticObjID>();
|
||
|
}
|
||
|
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("CloneEnums").transform.Find("ShiNeiFloor");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
FloorMessage mess = obj[i].GetComponentInParent<FloorMessage>();
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = mess.buildNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = mess.interlayerNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = mess.floorNum;
|
||
|
obj[i].gameObject.layer = LayerMask.NameToLayer("ManRode");
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[MenuItem("SceneToolNew/SetShiNeiFT")]
|
||
|
public static void SetShiNeiFT()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].gameObject.name.ToLower().Contains("ft") &&
|
||
|
obj[i].gameObject.GetComponent<Renderer>())
|
||
|
{
|
||
|
if (!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<CreateStaticObjID>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CreateStaticObjID>();
|
||
|
}
|
||
|
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("CloneEnums").transform.Find("ShiNeiFloor");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
FloorMessage mess = obj[i].GetComponentInParent<FloorMessage>();
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = mess.buildNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = mess.interlayerNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = mess.floorNum;
|
||
|
obj[i].gameObject.layer = LayerMask.NameToLayer("ManRode");
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[MenuItem("SceneToolNew/SetShiNeiXHS")]
|
||
|
public static void SetShiNeiXHS()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if ((obj[i].gameObject.name.ToLower().Contains("xhs")|| obj[i].gameObject.name.ToLower().Contains("snxh")) &&
|
||
|
obj[i].gameObject.GetComponent<Renderer>())
|
||
|
{
|
||
|
if (!obj[i].gameObject.GetComponent<NavMeshModifier>())
|
||
|
{
|
||
|
if (!obj[i].gameObject.GetComponent<Collider>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<BoxCollider>();
|
||
|
}
|
||
|
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>();
|
||
|
}
|
||
|
|
||
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CloneableEnums>();
|
||
|
}
|
||
|
if (!obj[i].gameObject.GetComponent<WaterSupplier>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<WaterSupplier>();
|
||
|
obj[i].gameObject.GetComponent<WaterSupplier>().WaterReceiverType=WaterType.water;
|
||
|
}
|
||
|
|
||
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>();
|
||
|
Transform Template = GameObject.Find("CloneEnums").transform.Find("xhs");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
FloorMessage mess = obj[i].GetComponentInParent<FloorMessage>();
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.XHS;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = mess.buildNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = mess.interlayerNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = mess.floorNum;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
[MenuItem("SceneToolNew/SetShiWaiZhutiSoldierRoad")]
|
||
|
public static void SetShiWaiZhutiSoldierRoad()
|
||
|
{
|
||
|
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
|
||
|
for (int i = 0; i < obj.Length; i++)
|
||
|
{
|
||
|
if (obj[i].gameObject.layer == LayerMask.NameToLayer("ManRode"))
|
||
|
{
|
||
|
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<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>();
|
||
|
}
|
||
|
|
||
|
if (!obj[i].gameObject.GetComponent<CloneableEnums>())
|
||
|
{
|
||
|
obj[i].gameObject.AddComponent<CloneableEnums>();
|
||
|
}
|
||
|
|
||
|
CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>();
|
||
|
Transform Template = GameObject.Find("CloneEnums").transform.Find("ShiWaiSoldier");
|
||
|
var CloneableEnums = Template.GetComponent<CloneableEnums>();
|
||
|
enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
|
||
|
FloorMessage mess = obj[i].GetComponentInParent<FloorMessage>();
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = mess.buildNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = mess.interlayerNum;
|
||
|
obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = mess.floorNum;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
[MenuItem("SceneToolNew/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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|