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.
261 lines
9.4 KiB
261 lines
9.4 KiB
2 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEditor;
|
||
|
|
||
|
public class EditorWindows : UnityEditor.EditorWindow
|
||
|
{
|
||
|
|
||
|
/// <summary>
|
||
|
/// 设置每层楼层Floor
|
||
|
/// <summary>
|
||
|
static int NUM = 1;
|
||
|
[MenuItem("SetSence/AllSet(目前仅仅限制于11场景,不要乱点)")]
|
||
|
static void AllSet()
|
||
|
{
|
||
|
SetFloor();
|
||
|
SetLT();
|
||
|
SetXHS();
|
||
|
//SetTrigger();
|
||
|
}
|
||
|
[MenuItem("SetSence/SetFloorWal(设置地板和墙)")]
|
||
|
static void SetFloor()
|
||
|
{
|
||
|
int N = 0;
|
||
|
GameObject GameFather = GameObject.Find("SceneAll/shinei").gameObject;
|
||
|
foreach (Transform childs in GameFather.transform)
|
||
|
{
|
||
|
if (childs.name.Contains("qian")|| childs.name.Contains("hou"))
|
||
|
{
|
||
|
foreach (Transform child in childs)
|
||
|
{
|
||
|
if (child.name.Contains("nei"))
|
||
|
{
|
||
|
if (child.gameObject.tag == "jaceng")
|
||
|
{
|
||
|
N++;
|
||
|
}
|
||
|
foreach (Transform childs_ in child.transform)
|
||
|
{
|
||
|
if (childs_.name.Contains("Floor"))
|
||
|
{
|
||
|
childs_.transform.SetAsFirstSibling();
|
||
|
RemoveSetFloor(childs_.gameObject);
|
||
|
childs_.gameObject.AddComponent<CengID>();
|
||
|
childs_.gameObject.AddComponent<CancelPitchOn>();
|
||
|
childs_.gameObject.AddComponent<MeshCollider>();
|
||
|
childs_.GetComponent<CengID>().CengIDBuildType = BuildType.TypeA;
|
||
|
childs_.gameObject.layer = 26;
|
||
|
SetFloorID(childs_.gameObject, N);
|
||
|
}
|
||
|
if (childs_.name.Contains("Wall"))
|
||
|
{
|
||
|
childs_.gameObject.layer = 12;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
static void SetFloorID(GameObject child, int n)
|
||
|
{
|
||
|
string floorStr = child.transform.parent.name.Substring(3);
|
||
|
child.GetComponent<CengID>().cengID = int.Parse(floorStr);
|
||
|
int Num = int.Parse(floorStr) - n;
|
||
|
if (child.transform.parent.tag == "jaceng")
|
||
|
{
|
||
|
child.GetComponent<CengID>().NEI = Num.ToString() + "M";
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
child.GetComponent<CengID>().NEI = Num.ToString();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
static void RemoveSetFloor(GameObject child)
|
||
|
{
|
||
|
if (child.GetComponent<CengID>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("CengID"));
|
||
|
}
|
||
|
if (child.GetComponent<CancelPitchOn>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("CancelPitchOn"));
|
||
|
}
|
||
|
if (child.GetComponent<MeshCollider>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("MeshCollider"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 设置每层楼层LT
|
||
|
/// <summary>
|
||
|
[MenuItem("SetSence/SetLT(设置楼梯属性)")]
|
||
|
static void SetLT()
|
||
|
{
|
||
|
GameObject GameFather = GameObject.Find("SceneAll/shinei").gameObject;
|
||
|
foreach (Transform childs in GameFather.transform)
|
||
|
{
|
||
|
if (childs.name.Contains("qian") || childs.name.Contains("hou"))
|
||
|
{
|
||
|
foreach (Transform child in childs.transform)
|
||
|
{
|
||
|
|
||
|
if (child.name.Contains("nei"))
|
||
|
{
|
||
|
foreach (Transform child_ in child.transform)
|
||
|
{
|
||
|
if (child_.name.Contains("LT"))
|
||
|
{
|
||
|
foreach (Transform obj in child_.transform)
|
||
|
{
|
||
|
RemoveSetLT(obj.gameObject);
|
||
|
obj.gameObject.AddComponent<CengID>();
|
||
|
obj.gameObject.AddComponent<CancelPitchOn>();
|
||
|
obj.gameObject.AddComponent<MeshCollider>();
|
||
|
obj.gameObject.layer = 26;
|
||
|
string floorStr = child.transform.name.Substring(3);
|
||
|
SetLTid(obj.gameObject, floorStr);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
static void SetLTid(GameObject child, string floorStr)
|
||
|
{
|
||
|
child.GetComponent<CengID>().cengID = int.Parse(floorStr);
|
||
|
child.GetComponent<CengID>().CengIDBuildType = BuildType.TypeA;
|
||
|
}
|
||
|
static void RemoveSetLT(GameObject child)
|
||
|
{
|
||
|
if (child.GetComponent<CengID>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("CengID"));
|
||
|
}
|
||
|
if (child.GetComponent<CancelPitchOn>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("CancelPitchOn"));
|
||
|
}
|
||
|
if (child.GetComponent<MeshCollider>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("MeshCollider"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 设置每层楼层XHS
|
||
|
/// <summary>
|
||
|
[MenuItem("SetSence/SetXHS(设置消火栓属性)")]
|
||
|
static void SetXHS()
|
||
|
{
|
||
|
GameObject GameFather = GameObject.Find("SceneAll/shinei").gameObject;
|
||
|
foreach (Transform childs in GameFather.transform)
|
||
|
{
|
||
|
if (childs.name.Contains("qian") || childs.name.Contains("hou"))
|
||
|
{
|
||
|
foreach (Transform child in childs.transform)
|
||
|
{
|
||
|
if (child.name.Contains("nei"))
|
||
|
{
|
||
|
foreach (Transform child_ in child.transform)
|
||
|
{
|
||
|
if (child_.name.Contains("XHS"))
|
||
|
{
|
||
|
foreach (Transform obj in child_.transform)
|
||
|
{
|
||
|
RemoveSetXHS(obj.gameObject);
|
||
|
obj.gameObject.AddComponent<CengID>();
|
||
|
obj.gameObject.AddComponent<BoxCollider>();
|
||
|
obj.gameObject.layer = 27;
|
||
|
string floorStr = child.transform.name.Substring(3);
|
||
|
SetXHSid(obj.gameObject, floorStr);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
static void SetXHSid(GameObject child, string floorStr)
|
||
|
{
|
||
|
if (child.GetComponent<CengID>())
|
||
|
{
|
||
|
child.GetComponent<CengID>().cengID = int.Parse(floorStr);
|
||
|
child.GetComponent<CengID>().CengIDBuildType = BuildType.TypeA;
|
||
|
}
|
||
|
}
|
||
|
static void RemoveSetXHS(GameObject child)
|
||
|
{
|
||
|
if (child.GetComponent<CengID>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("CengID"));
|
||
|
}
|
||
|
if (child.GetComponent<CancelPitchOn>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("CancelPitchOn"));
|
||
|
}
|
||
|
if (child.GetComponent<BoxCollider>())
|
||
|
{
|
||
|
DestroyImmediate(child.GetComponent("BoxCollider"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 设置每层楼层Trigger
|
||
|
/// <summary>
|
||
|
[MenuItem("SetSence/SetTrigger(设置消防电梯触发)")]
|
||
|
static void SetTrigger()
|
||
|
{
|
||
|
|
||
|
GameObject GameFather = GameObject.Find("SceneAll/shinei").gameObject;
|
||
|
foreach (Transform child in GameFather.transform)
|
||
|
{
|
||
|
if (child.name.Contains("qian") || child.name.Contains("hou"))
|
||
|
{
|
||
|
foreach (Transform childs in child.transform)
|
||
|
{
|
||
|
if (childs.name.Contains("nei"))
|
||
|
{
|
||
|
bool has = false;
|
||
|
float Z = 0f;
|
||
|
foreach (Transform childs_ in childs)
|
||
|
{
|
||
|
if (childs_.name.Contains("Floor"))
|
||
|
{
|
||
|
Z = childs_.transform.localPosition.z;
|
||
|
}
|
||
|
|
||
|
if (childs_.name.Equals("TriggerEvent"))
|
||
|
{
|
||
|
DestroyImmediate(childs_.gameObject);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (!has)
|
||
|
{
|
||
|
GameObject game = Instantiate(Resources.Load<GameObject>("ScenesPrefabs/TriggerEvent")) as GameObject;
|
||
|
game.transform.parent = childs.transform;
|
||
|
game.transform.localScale = new Vector3(1, 1, 1);
|
||
|
game.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||
|
game.transform.localPosition = new Vector3(1.3f, 13.80001f, Z);
|
||
|
game.name = "TriggerEvent";
|
||
|
foreach (Transform games in game.transform)
|
||
|
{
|
||
|
games.GetComponent<StairTrigger>().HasCengNum = 81;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|